Passing --onlyFailures
doesn't run failed tests only.
// __tests__/a.test.js
it('fails', () => {
expect(true).toBeFalsy();
});
// __tests__/b.test.js
it('passes', () => {
expect(true).toBeTruthy();
});
// package.json
{
"dependencies": {
"jest": "23.1.0"
}
}
./node_modules/jest/bin/jest.js
=> 1 passed, 1 failed as expected../node_modules/jest/bin/jest.js --onlyFailures
. Unexpectedly, all tests are run again.A single failed test is rerun.
https://repl.it/@sergey_simonchik/rerun-failed-tests
npx envinfo --preset jest
System:
OS: Linux 4.8 Linux Mint 18.1 (Sonya)
CPU: x64 Intel(R) Core(TM) i7-3632QM CPU @ 2.20GHz
Binaries:
Node: 10.4.0 - ~/.nvm/versions/node/v10.4.0/bin/node
npm: 6.1.0 - ~/.nvm/versions/node/v10.4.0/bin/npm
npmPackages:
jest: 23.1.0 => 23.1.0
The flag is intended for watch mode. I do agree it should probably work, though. And if _not_, we should throw when the flag is provided outside of watch mode.
@rickhanlonii @thymikee thoughts?
Sounds reasonable to make it work in regular runs too 馃憤
+1, nice feature to add
I agree, I think this flag should work in a single run mode as well
Agree that this would be very helpful in single-run mode to fit more workflows.
Any news on that?
I was surprised when this flag didn't work :(
searching for same issue,
found this thread.
maybe at least put a log using the flag, that warns users about watch mode.
Many 3rd parties introduce verbose output which sometimes we use with Jest, making this flag work will make the output of Jest much more clear and helpful to debug. This is a big thing.
I was looking for a way to run only the failed tests and ended up here 馃槃
馃憤
This is what we end up using so far:
npx jest --runInBand --ci --testNamePattern="$(python -c "from xml.dom import minidom;import re;print('|'.join([i.parentNode.attributes['name'].value.strip() for i in minidom.parse('junit.xml').getElementsByTagName('failure')]))")"
This requires jest-junit reports to be installed and configured, and python for parsing XML.
Is it time to consider removing this flag, if it hasn't worked in at least 26 months?
@SimenB May I give this a try?
Most helpful comment
I agree, I think this flag should work in a single run mode as well