Run server before test

nodejs

#1

I am new to circleCI and build a very simple “hello world” app to get myself familiar with circleCI.

In my app I have a mocha test that requests the “/” resource and checks the status code. In order for that test to work, the node app needs to be running.

Can this be done in circleCI or can this only be done by first building a docker container, running the container and afterwards executing the tests?

At the moment the test fails because he cannot connect to the server.

I even tried adding this to the circle.yml but still it fails although the server has been started…

test:
pre:
- node main &


#2

This can be done on CircleCI no problem. More of your circle.yml file and/or more explaination of what you’re doing will help.

Have you already seen our NodeJS doc?


#3

Do you mind explaining how? I’ve looked through the documentation and that’s where I found out I could execute pre test scripts. So that’s why I added
test:
pre:

  • node main &
    to the circle.yml (it’ the only thing in the file) and the logs shows the server was running but still my mocha test failed because it could not connect to localhost:3001

#4

Have you tried this? https://circleci.com/docs/1.0/background-process/


#5