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.