Reputation: 1192
I have a folder structure as follow:
The package.json has the following configuration:
{
"scripts": {
"test": "mocha ./**/*-tests.js"
},
"devDependencies": {
"axios": "^0.19.2",
"mocha": "^7.1.1",
"should": "^13.2.3",
"should-sinon": "0.0.6",
"sinon": "^9.0.1"
}
}
Now from the command line I can execute "npm test" and all tests, integration and unit, will run.
I would like to be able to pass a parameter, something like "npm test --folder unit_tests", so only one set of tests under the same folder will run.
Upvotes: 1
Views: 960
Reputation: 24565
You could define separate test-scripts
for integration and unit tests in your package.json:
"scripts": {
"test:unit": "mocha path/to/unit-test-folder/*-tests.js",
"test:integration": "mocha path/to/integration-test-folder/*-tests.js"
}
You can then call them independently as:
npm run test:unit
npm run test:integration
Upvotes: 3