If you work within a large company that has thousands of test, running all the tests can take forever to run:
One way of making life easier to to only run tests on a certain file, which you can do like so:
jest -u src/package/
This is a better approach especially if you have only touched a very small area in the codebase. Sometimes I've been faced in a situation where the test fails locally but builds on the server. In a perfect world you would fix every test, sometimes you just need to get shit done.
In these situations, you can use the --testNamePattern or -t flag to only run the tests you want to update. This can be done like so:
This command will only run any tests that contain 'my-new-test' within the name, so this test would get triggered:
The other way to ensure that only a single test is run within a file is to use the only() function. When you write your tests you can also include: