I am working on the Build a Chat App lab from the Back End Development and APIs v9 curriculum:
https://www.freecodecamp.org/learn/back-end-development-and-apis-v9/lab-chat-app/lab-chat-app
Tests 1 and 2 pass, but tests 3–6 consistently fail.
The Console for test 3 reports:
ReferenceError: Cannot access 'WebSocket' before initialization
Full stack trace:
{
"stack": "ReferenceError: Cannot access 'WebSocket' before initialization\n at eval (eval at <anonymous> (file:///workspaces/back-end-development-and-apis/node_modules/@freecodecamp/freecodecamp-os/.freeCodeCamp/tooling/tests/test-worker.js:25:29), <anonymous>:4:21)\n at new Promise (<anonymous>)\n at eval (eval at <anonymous> (file:///workspaces/back-end-development-and-apis/node_modules/@freecodecamp/freecodecamp-os/.freeCodeCamp/tooling/tests/test-worker.js:25:29), <anonymous>:3:13)\n at eval (eval at <anonymous> (file:///workspaces/back-end-development-and-apis/node_modules/@freecodecamp/freecodecamp-os/.freeCodeCamp/tooling/tests/test-worker.js:25:29), <anonymous>:14:3)\n at MessagePort.<anonymous> (file:///workspaces/back-end-development-and-apis/node_modules/@freecodecamp/freecodecamp-os/.freeCodeCamp/tooling/tests/test-worker.js:25:29)\n at [nodejs.internal.kHybridDispatch] (node:internal/event_target:843:20)\n at MessagePort.<anonymous> (file:///workspaces/back-end-development-and-apis/node_modules/@freecodecamp/freecodecamp-os/.freeCodeCamp/tooling/tests/test-worker.js:25:29)\n at [nodejs.internal/per_context/messageport:23:28]",
"message": "Cannot access 'WebSocket' before initialization",
"type": "Error"
}
My environment:
Node: v24.18.0
npm: 11.16.0
@freecodecamp/freecodecamp-os: 3.5.4
ws: 8.20.0
The server itself is functioning. I independently tested the WebSocket functionality with two clients:
TEST 3: connection successful
TEST 4: PASS
TEST 5: PASS
TEST 6: PASS
The browser UI also successfully connects through the forwarded Codespaces URL and messages work correctly.
The freeCodeCamp test runner, however, produces connections such as:
CONNECTED: Observer
CONNECTED: Alice
CONNECTED: Bob
CONNECTED: Alice
CONNECTED: Bob
but the test 3 Console reports the WebSocket initialization error before the WebSocket test can execute normally.
I have also verified that the local project does not contain the test files; the tests are being dynamically evaluated by:
@freecodecamp/freecodecamp-os/.freeCodeCamp/tooling/tests/test-worker.js
Could someone confirm whether this is a known issue with the current Chat App lab/test runner, particularly with Node 24 / freecodecamp-os@3.5.4?
I need to complete this project for a college certificate deadline, so I would appreciate advice on the correct way to proceed if the test runner is malfunctioning.
I can provide screenshots, the project code, or any additional diagnostic output needed.


