I am trying to run mocha tests on linux > @ test C:\Users\wd.ssh\tel\qa_test\mocha-api-tests
Error: No test files found: "test/" npm ERR! Test failed. See above for more details.
here is my package.json
{ "scripts": { "test": "mocha --reporter mocha-junit-reporter --timeout 60000 --exit", }, "dependencies": { "cassandra-driver": "3.5.0", "chai": "4.2.0", "chai-http": "4.2.0", "express": "4.16.4", "mocha-junit-reporter": "1.18.0", "request-promise": "4.2.2" } }
commands used: npm install --global mocha npm i and to run the tests I'm using npm test
Project structure:
Learn how to run only one test with Mocha To run a single test (as defined in it() ), you can simply call the only() method on it in the following way: it. only('...', function () { // only this test will run... });
Use Mocha's skip() function. It can be used to either statically to disable a test or entire suite, or dynamically skip it at runtime.
seeing your project structure, seems that you have one test.js
so mocha should target this file.
"scripts": { "test": "mocha test.js --reporter mocha-junit-reporter --timeout 60000 --exit", },
If you want to add more test files, it is better to put them inside test directory e.g. /test
and must change the target to test files inside the directory.
"scripts": { "test": "mocha 'test/**/*.js' --recursive --reporter mocha-junit-reporter --timeout 60000 --exit", },
Hope it helps
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With