'What is jest's equivalent of `mocha -g` (grep option)?
Per the Mocha documentation, I can run a group of tests with a particular pattern in their describe/suite
or it/test
block using mocha -g
. For example mocha -g 'filtering usernames'
only the tests with filtering usernames
in their names.
Test Filters
--fgrep, -f Only run tests containing this string [string]
--grep, -g Only run tests matching this string or regexp [string]
--invert, -i Inverts --grep and --fgrep matches [boolean]
I am now working on projects using jest
.
How can I run tests whose name matches a pattern in Jest?
Solution 1:[1]
Looking through the Jest docs I've found the answer to this one myself - keeping the question up as the answer may be useful for others:
From https://jestjs.io/docs/en/cli
Run tests that match this spec name (match against the name in describe or test, basically).
jest -t name-of-spec
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | mikemaccana |