Adv. Node & Exp. - Announce New Users: Wrong or Outdated test?

Hello campers,

Quick FYI: there is a discrepancy between what the lesson instructs students to do (use a username key), and what the tests apparently* check for.

Instructions read:

… change the event name to ‘user’, and pass an object along containing the fields username, currentUsers, and connected

And it even provides this code for users to use:

io.emit('user', {
  username: socket.request.user.username,
  currentUsers,
  connected: true
});

The fCC-provided solution ( Advanced Node and Express - #3 by Sky020 ) also reads:

io.emit('user', {
      username: socket.request.user.username,
      currentUsers,
      connected: true
    });
// ... some more code ...
      io.emit('user', {
        username: socket.request.user.username,
        currentUsers,
        connected: false
      });

However, the first test reads Event 'user' should be emitted with name, currentUsers, and connected.

In my case, I ran the tests several times and they didn’t pass until I replaced the username key with name.

*I say “what the tests apparently check for” because, once I passed the tests, I then reverted to using username for the key name, and it passed. It even passes if you use any random name for said key. However, this seems to only happen after having passed the test for the first time, using name . Before that, it wouldn’t pass. I don’t know how this particular test works, but I swear it only started working after I used name, and that afterwards they would pass no matter what random name I assing to the key.

Lesson link:

Hello there,

Thank you for pointing this out. You are correct in the issue about the test text not matching the instructions.

However, the test code is lenient and allows both:

name: socket.request.user.name
// and
username: socket.request.user.username

So, just the test text needs to be updated, as it was not here: fix(learn): advanced-node-and-express username field (#47349) · freeCodeCamp/freeCodeCamp@de02417 · GitHub


If you are interested in fixing this, then let me know? Otherwise, I can go ahead and quickly change this.

I have opened: