I have several files in the test folder.
Test files
Each file has several test suites and test cases. npm test command runs all the files one after another. How do I run just one test file?
I tried npm test -- --grep "file name" command, but it didn’t work. This command only works with the name of the test suites or test cases.
>Solution :
Assuming you have a test script defined in your package.json file like this:
"scripts": {
"test":{command to run tests}
}
Modify the test script to include the path to the specific test file you want to run like following:
"scripts": {
"test":{command to run tests} test/myTestFile.js
}
Now try running npm test command. Hope this helps!!!