Table of contents
Open Table of contents
Watch Mode
Watch mode can really boost my productivity. Especially in big projects.
npx jest --watch
# or if you have an npm command for tests:
npm t -- --watch
Now that jest is looking for file updates, we can tell jest to only run some tests instead of re-running everything.
1. Filter by file/folder name
While jest is running in watch mode, press p and type the file/folder name (ie: “login”).
2. Filter by test name
You can also filter by test name. To do so, press t and type a pattern that matches your test describe clause.
Now, jest will automatically run tests, only the feature you are developing.
Don’t forget to run every test in the end.