0

I have a script that sequentially executes 2 instructions as following:

node server.js
node tests.js
  • Server.js initializes a local Node.js + Express server
  • Tests.js executes some unit tests on that server

The problem is that the first instruction keeps listening for requests, so the second is never executed.

Is it possible to solve this behaviour?

1 Answer 1

1

I advise you to use the npm package start-server-and-test to be sure that your api server is ready to be tested

start-server-and-test 'node server.js' http://localhost:{API_PORT}/ 'node tests.js'
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.