Step 20 of Build a Web Server can reject the instructed command even when the server responds correctly.
Reproduction
-
Complete Step 19 so that the server calls response.end(request.url).
-
Restart the server with node server.js.
-
In another terminal, run:
curl http://localhost:3001/hello
-
Click Run Tests.
Actual behavior
The test requires the exact substring curl http://localhost:3001/hello in __helpers.getTemp(). getTemp() reads .logs/.temp.log, which records raw terminal input. Terminal control sequences can split the command, so the substring assertion fails even though the command was run and the server returns a response.
Expected behavior
The instructed command should pass regardless of terminal escape sequences.
Proposed fix
Use __helpers.getLastCommand() and __helpers.parseCli() to verify that the command is curl and that its arguments include http://localhost:3001/hello. Step 18 already uses this approach for a similar curl assertion.
This is a remaining instance of the raw-terminal-log failure reported in #12, which was closed by commit 27aae2a.
Affected source:
|
## 20 |
|
|
|
### --description-- |
|
|
|
Restart your server, and make a request to `http://localhost:3001/hello`. You no longer need to add a timeout to your `curl` command, because your sever is responding with something. |
|
|
|
### --tests-- |
|
|
|
You should restart the server, and make a request to it. |
|
|
|
```js |
|
const temp = await __helpers.getTemp(); |
|
assert.include(temp, "curl http://localhost:3001/hello"); |
|
``` |
Forum report: https://forum.freecodecamp.org/t/build-a-web-server-build-a-web-server/799172
Step 20 of Build a Web Server can reject the instructed command even when the server responds correctly.
Reproduction
Complete Step 19 so that the server calls
response.end(request.url).Restart the server with
node server.js.In another terminal, run:
Click Run Tests.
Actual behavior
The test requires the exact substring
curl http://localhost:3001/helloin__helpers.getTemp().getTemp()reads.logs/.temp.log, which records raw terminal input. Terminal control sequences can split the command, so the substring assertion fails even though the command was run and the server returns a response.Expected behavior
The instructed command should pass regardless of terminal escape sequences.
Proposed fix
Use
__helpers.getLastCommand()and__helpers.parseCli()to verify that the command iscurland that its arguments includehttp://localhost:3001/hello. Step 18 already uses this approach for a similar curl assertion.This is a remaining instance of the raw-terminal-log failure reported in #12, which was closed by commit 27aae2a.
Affected source:
back-end-development-and-apis/curriculum/locales/english/build-a-web-server.md
Lines 600 to 613 in 4a47aa0
Forum report: https://forum.freecodecamp.org/t/build-a-web-server-build-a-web-server/799172