Mark Kadlec Mark Kadlec - 24 days ago 13
React JSX Question

How to run npm tests from a single folder?

Currently I am testing a React node application, and have all my tests in the root/tests folder, with components in separate folders pertaining to their function.

I have 10+ folders and 100+ tests, and would like to 'watch' a single folder while I write a test for a new component.

Currently, I am using


npm run test:watch


Which is working brilliantly, however, not only is there a lot of overhead re-running the 100 other tests not related to my new component, it's also hard to weed through all the feedback to see the results of my current test.

Is there a nice command to only watch the directory of my new test, or even the test file?

Answer

You can pass mocha test directory to the npm command:

npm run test:watch -- root/tests/subfolder

However it might depend on how your test script test:watch is defined.

Comments