I am trying to configure package.json to run test cases with similar names. In my case i have two different naming conventions,one for unit test and another for integration test. I need to run only unit test by giving a command which picks only unit test case files and same with the integration test files.
unit test case file naming convention
sample_unit.test.js
sample1_unit.test.js
integration test case file naming convention
sample_integration.test.js
sample1_integration.test.js
package.json(Attached only test configuration part)
"scripts": {
"test": "jest --config=./config/jest/jest_all.config.json --runInBand",
"unit-test": "jest --config=./config/jest/jest_unit.config.json",
"integration-test": "jest --config=./config/jest/jest_integration.config.json --runInBand",
"start": "node app.js",
"doc": "jsdoc -c config/jsdoc_config.json",
"sonar-scanner": "node_modules/sonar-scanner/bin/sonar-scanner"
}
I think this would work (as jest accepts a regex pattern):
"scripts": {
"test": "jest --config=./config/jest/jest_all.config.json --runInBand",
"unit-test": "jest --config=./config/jest/jest_unit.config.json '.+_unit.test.js'",
"integration-test": "jest --config=./config/jest/jest_integration.config.json --runInBand '.+_integration.test.js'",
"start": "node app.js",
"doc": "jsdoc -c config/jsdoc_config.json",
"sonar-scanner": "node_modules/sonar-scanner/bin/sonar-scanner"
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.