Reputation: 2947
I am following step 1 of this tutorial
I have the following folder structure:
├── lib
│ ├── json
│ │ ├── messages.json
│ │ └── testMessages.json
│ └── model.js
├── test
│ └── model.test.js
└── package.json
My package.json
has the following to run the mocha tests
“test”: “mocha -r esm ./test/* —exit”,
But I get the following error
> [email protected] test /Users/lee33ya/Desktop/mern-app/backend
> mocha -r esm ./test/* --exit
Error: No test files found: "./test/*"
npm ERR! Test failed. See above for more details.
What am I doing wrong and what can I do to resolve my tests not running?
My github
Upvotes: 7
Views: 8527
Reputation: 180
while doing a mocha test these things you should follow
first npm init
this initializes the package.json file
Then add the following inside the package.json file
"script": {"test" : "mocha"}
(this should be inside the main { })
then install mocha as a dependency by doing npm install mocha -D
then make a test folder in the main file and put the .js file you want to test
then run npm test
if i didn't explain correctly i am sorry and this is my first answer so :)
here is a very good article on mocha if you want to see
https://blog.logrocket.com/a-quick-and-complete-guide-to-mocha-testing-d0e0ea09f09d/
Upvotes: 0
Reputation: 86
Found two issues
Upvotes: 5