Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Passing --onlyFailures doesn't run failed tests only #6470

Closed
segrey opened this issue Jun 14, 2018 · 14 comments 路 Fixed by #10678
Closed

Passing --onlyFailures doesn't run failed tests only #6470

segrey opened this issue Jun 14, 2018 · 14 comments 路 Fixed by #10678

Comments

@segrey
Copy link

segrey commented Jun 14, 2018

馃悰 Bug Report

Passing --onlyFailures doesn't run failed tests only.

To Reproduce

// __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"
  }
}
  1. Run "npm install"
  2. Run all tests initially with ./node_modules/jest/bin/jest.js => 1 passed, 1 failed as expected.
  3. Rerun failed tests only with ./node_modules/jest/bin/jest.js --onlyFailures. Unexpectedly, all tests are run again.

Expected behavior

A single failed test is rerun.

Link to repl or repo (highly encouraged)

https://repl.it/@sergey_simonchik/rerun-failed-tests

Run 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 
@SimenB
Copy link
Member

SimenB commented Jun 15, 2018

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?

@thymikee
Copy link
Collaborator

Sounds reasonable to make it work in regular runs too 馃憤

@rickhanlonii
Copy link
Member

+1, nice feature to add

@peterdemartini
Copy link

I agree, I think this flag should work in a single run mode as well

@csvan
Copy link

csvan commented Feb 22, 2019

Agree that this would be very helpful in single-run mode to fit more workflows.

@liranpeleg
Copy link

Any news on that?

@jshearer
Copy link

I was surprised when this flag didn't work :(

@andreabisello
Copy link

searching for same issue,
found this thread.
maybe at least put a log using the flag, that warns users about watch mode.

@zohar-yzgiaev
Copy link

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.

@JoaoFGuiomar
Copy link

I was looking for a way to run only the failed tests and ended up here 馃槃
馃憤

@sadovnychyi
Copy link

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.

@prometheas
Copy link

Is it time to consider removing this flag, if it hasn't worked in at least 26 months?

@victorphoenix3
Copy link
Contributor

@SimenB May I give this a try?

@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 11, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.