Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to run only one test file using Selenium webdriver and mocha?

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.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>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!!!

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading