Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mocha Error: No test files found: "test/" npm ERR! Test failed

Tags:

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:

project structure

like image 296
ranger Avatar asked Feb 21 '19 10:02

ranger


People also ask

How do I test a single file using mocha?

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... });

How do I disable mocha test?

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.


1 Answers

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

like image 106
deerawan Avatar answered Sep 23 '22 11:09

deerawan