Is it possible to get a list of suites/specs without running the actual tests w/ Jest.
For example, I have a test that looks like this:
describe('when blah blah blah', function () {
it('returns foobar', function () { /* test code */ })
})
Ideally, I'd like to be able to just get a list of describe/it statements to quickly look at scenarios covered.
# stdout
when blah blah blah
returns foobar
I think this is possible with rspec, using a dry-run
flag. Is there any such option with Jest?
I took a look at the Jest CLI documentation and have done an issue search at the project's Github page, but could not find anything.
But we need to skip test 2 due to certain reasons. In jest, we can do this using the test. skip function. Using this function, we can skip specific test cases.
If you want to run files in sequence as well, run Jest with the --runInBand command line flag. ( -i does the same thing.) Doing this, the scheduler might still run them in a different order from run to run. To prevent this as well, you will need to define your own test sequencer.
It's in the Jest documentation. Another way is to run tests in watch mode, jest --watch , and then press P to filter the tests by typing the test file name or T to run a single test name.
To speed-up your tests, Jest can run them in parallel. By default, Jest will parallelise tests that are in different files. IMPORTANT: Paralellising tests mean using different threads to run test-cases simultaneously.
The switch --listTests
returns a JSON array of the test files and then exits (instead of running the tests).
It might not be exactly what you're looking for though since it doesn't parse the
describe
/it
functions, nor is the output very pretty.
https://facebook.github.io/jest/docs/en/cli.html#listtests
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With