fac-13 / research

This is where we document our learning
5 stars 0 forks source link

Running multiple tests in your package.json - useful for Travis #24

Open tdoran opened 6 years ago

tdoran commented 6 years ago

If you want to have two suites of tests running with independent commands in the terminal (e.g. npm run test-router and npm run test-logic), while also having them run together with npm test, you can use the structure below - note this also allows Travis to run both test suites whenever it's doing its CI.

"scripts": {
    "start": "node src/server.js",
    "test": "npm run test-router && npm run test-logic ",
    "test-router": "nyc tape ./test/router.test.js | tap-spec",
    "test-logic": "nyc tape ./test/logic.test.js | tap-spec",
    "dev": "nodemon src/server.js"
  },
tdoran commented 6 years ago

Update on the above - specifying your test script like this is neater, and will work the same, provided you are consistent with your file naming (it will run all files in the /test folder that end in .test.js):

"test": "nyc tape ./test/*.test.js",
helenzhou6 commented 6 years ago

Good to know! 👍

tspeed90 commented 6 years ago

Super helpful. I'm going to use it now! @tdoran