Node.js · Middle · Question 56 of 75

How do you test an Express app's endpoints without starting a real server on a fixed port?

Explanation

Port 0 lets the OS pick a free port, so tests can run in parallel. Export the app separately from the listen() call to make this easy.

Further reading

Problem with a question

Node.js · Middle · question 56

Test yourself

Take the Node.js · Middle quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz