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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Duplicate test names #175

Open
Vanuan opened this issue Oct 5, 2017 · 6 comments
Open

Duplicate test names #175

Vanuan opened this issue Oct 5, 2017 · 6 comments

Comments

@Vanuan
Copy link

Vanuan commented Oct 5, 2017

I'm using jasmine-reporters with jest.

Unfortunately, it doesn't detect duplicate names. So when you have multiple identical describes, multiple test results will be written to the same file. E.g.:

// jest.setup.jasmine.js
jasmine.getEnv().addReporter(
  new jasmineReporters.JUnitXmlReporter({
    // Jest runs many instances of Jasmine in parallel. Force distinct file output
    // per test to avoid collisions.
    consolidateAll: false,
    savePath: "build-artifacts/",
    filePrefix: "test-results"
  })
);
// test1.js
describe('some test', () => {
  it('should pass', () => {
    fail('error')
  })
})
// test2.js
describe('some test', () => {
  it('should pass', () => {
    // pass
  })
})

So the build would be flaky: sometimes it will fail. Sometimes it will pass.
Apparently, there's no way to detect this in jasmine reporters level, since jest can run those in different workers (node processes). Any suggestions?

@Vanuan
Copy link
Author

Vanuan commented Oct 5, 2017

Can junit report filename be generated using full path to the test file?

@Vanuan
Copy link
Author

Vanuan commented Oct 5, 2017

I've looked at modifyReportFileName and it doesn't appear that suite contains a path to the suite file.

@Vanuan
Copy link
Author

Vanuan commented Oct 5, 2017

See also jestjs/jest#4607

@Vanuan
Copy link
Author

Vanuan commented Jan 25, 2018

Jest 22 has added testPath to test case: jestjs/jest#4594

Would you consider adding that to the topLevel suite in modifyReportFileName?

@jeff-knurek
Copy link

We just experienced this issue in which our CI let a failing test pass the build because the other test with the same name passed. It also lead to the realization that about 15 other test cases weren't being evaluated properly by the CI.

@putermancer
Copy link
Collaborator

I'm sorry you have experienced problems. Please consider creating a pull request with appropriate improvements and I'd be happy to include those and produce a new build.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants