Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
tdoran opened this issue Mar 28, 2018 · 3 comments
Open

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

tdoran opened this issue Mar 28, 2018 · 3 comments

Comments

@tdoran
Copy link
Contributor

tdoran commented Mar 28, 2018

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
Copy link
Contributor Author

tdoran commented Mar 28, 2018

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
Copy link

Good to know! 👍

@tspeed90
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants