Tutorials Build a Real-Time Chat Application with Node.js

Running the App & Testing in Two Tabs

Learn Running the App & Testing in Two Tabs in our free Build a Real-Time Chat Application with Node.js series. Step-by-step explanations, examples, and interview tips on Toolliyo Academy.

On this page
Running the App & Testing in Two Tabs
Lesson 7 of 10 · Part 3 — Run, Learn & Extend · Build a Real-Time Chat Application with Node.js
Course: Build a Real-Time Chat Application with Node.js · Lesson: 7/10 · Read time: ~15 min · Level: Beginner

Running the App & Testing in Two Tabs

You built all the pieces — now connect them. This lesson is hands-on: start the server, open two browser tabs, join the same room, and watch real-time magic happen.

Step 1 — Start the development server

In terminal, inside your chat-app folder:

npm run dev

Expected output:

Chat server running on http://localhost:3000
[nodemon] watching path(s): *.*
[nodemon] starting `node server.js`
💡 Tip: If port 3000 is busy, change const PORT = 3000 to 3001 in server.js and use http://localhost:3001.

Step 2 — Open the app in your browser

Navigate to:

http://localhost:3000

You should see the login screen — dark background, username and room inputs, Join button.

⚠️ Common Mistake: Opening public/index.html as a file (file:///...). Socket.IO requires HTTP — always use localhost through Express.

Step 3 — Two-tab test (the “wow” moment)

  1. Tab 1: Name = Alice, Room = general → Join Chat
  2. Tab 2: Name = Bob, Room = general → Join Chat
  3. In Tab 1, type “Hello from Alice!” and press Enter
  4. Tab 2 should show the message instantly without refresh
  5. Reply from Tab 2 — Tab 1 receives it immediately

What to verify

FeatureExpected behavior
Join messageBoth tabs show “Bob joined the room” (system text, centered)
Chat bubblesYour messages blue/right; others gray/left
TimestampsSmall time under each bubble (e.g. 2:45 PM)
Online usersHeader shows “Online (2) — Alice, Bob”
TypingStart typing in Tab 1 → Tab 2 shows “Alice is typing…”
DisconnectClose Tab 2 → Tab 1 shows “Bob left the room”

Step 4 — Test different rooms

Open Tab 3: join room random as Charlie. Messages in general should not appear in random. This proves Socket.IO rooms isolate conversations.

👨‍🏫 Teaching note: Make this a class activity: half the class joins #team-a, half joins #team-b. Shout “send hello” — only same-room students see it. Teaches rooms viscerally.

Debugging with browser DevTools

  1. Press F12Network tab
  2. Filter by WS (WebSocket)
  3. Click the socket.io connection → Messages
  4. Watch JSON frames fly when you send chat — great for demos

Server terminal logs

When tabs connect/disconnect, server prints:

A user connected: xK39f...
A user connected: pQ82a...
User disconnected: pQ82a...

If something does not work

  • Blank page → check Express static path and that files are in public/
  • Cannot connect → server running? Correct port?
  • Messages missing → compare event names in server.js and client.js character by character

Full troubleshooting table is in Lesson 10.

Celebrate 🎉

You built a working real-time chat application. Next we explain why it works — the Socket.IO deep dive.

Continue learning

Previous: Frontend JavaScript — Connect & Send Messages

Next: How Socket.IO Works — Deep Dive

Course home: All 10 lessons

Interview prep for this lesson

Practice these questions aloud after reading—each links to a full structured answer.

Mid Detailed
Compare two approaches to Testing—when would you choose each?
Short answer: Interviewers want a crisp definition, a practical example from your projects, and awareness of trade-offs—not textbook dumps. How to structure your answer (60–90 seconds) Define Testing in plain language fo…
Junior Detailed
Explain Design in the context of Build a Real-Time Chat Application with Node.js.
Short answer: Interviewers want a crisp definition, a practical example from your projects, and awareness of trade-offs—not textbook dumps. How to structure your answer (60–90 seconds) Define Design in plain language for…
Mid Detailed
What are common mistakes teams make with Implementation when using Build a Real-Time Chat Application with Node.js?
Short answer: Interviewers want a crisp definition, a practical example from your projects, and awareness of trade-offs—not textbook dumps. How to structure your answer (60–90 seconds) Define Implementation in plain lang…
Senior Detailed
How would you debug a production issue related to Trade-offs in a Build a Real-Time Chat Application with Node.js application?
Short answer: Interviewers want a crisp definition, a practical example from your projects, and awareness of trade-offs—not textbook dumps. How to structure your answer (60–90 seconds) Define Trade-offs in plain language…
Junior Detailed
Describe a real-world scenario where Demo mattered in a Build a Real-Time Chat Application with Node.js project.
Short answer: Interviewers want a crisp definition, a practical example from your projects, and awareness of trade-offs—not textbook dumps. How to structure your answer (60–90 seconds) Define Demo in plain language for B…
Questions on this lesson 0

Sign in to ask a question or upvote helpful answers.

No questions yet — be the first to ask!

Build a Real-Time Chat Application with Node.js
Course syllabus
Part 1 — Getting Started
Part 2 — Build the App
Part 3 — Run, Learn & Extend
Part 4 — Ship It
Toolliyo Assistant
Ask about tutorials, ebooks, training, pricing, mentor services, and support. I use public site content only—not admin or internal tools.

care@toolliyo.com

Need callback? Share your details