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

Fix mistake as test files when run coverage issue. #7506

Merged
merged 3 commits into from
Dec 24, 2018

Conversation

H1Gdev
Copy link
Contributor

@H1Gdev H1Gdev commented Dec 12, 2018

  • Check testPathIgnorePatterns.
  • Add tests.

Summary

Run coverage the following test environment.

package.json

{
  "jest": {
    "testPathIgnorePatterns": [
      "/node_modules/",
      "/src/"
    ],
  }
}

file tree

├── __tests__
│   └── component.spec.js
└── src
     ├── component.js
     └── spec.js

Expect:

  • src/spec.js file is not a test file.

Actual:

  • src/spec.js file is a test file.

Test plan

Above test result as expected.

--------------------|----------|----------|----------|----------|-------------------|
File                |  % Stmts | % Branch |  % Funcs |  % Lines | Uncovered Line #s |
--------------------|----------|----------|----------|----------|-------------------|
All files           |      100 |      100 |      100 |      100 |                   |
 src                |      100 |      100 |      100 |      100 |                   |
  component.js      |      100 |      100 |      100 |      100 |                   |
  spec.js           |      100 |      100 |      100 |      100 |                   |
--------------------|----------|----------|----------|----------|-------------------|

config.testRegex &&
config.testRegex.some(regex => new RegExp(regex).test(filename))
!config.testPathIgnorePatterns ||
!config.testPathIgnorePatterns.some(pattern => filename.match(pattern))
) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there's the same check a bit further down this file: https://github.com/facebook/jest/blob/f38b0c9d17f92f3e0f144087db6264d585bcbeed/packages/jest-runtime/src/should_instrument.js#L79-L84

maybe we can just move it up to this place?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@thymikee testPathIgnorePatterns vs coveragePathIgnorePatterns, no?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🙈

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@thymikee
@SimenB

Thank you for your review.

I think that it is determined by testRegex, testMatch and testPathIgnorePatterns whether file is test file or not.

@SimenB SimenB merged commit 6488fb7 into jestjs:master Dec 24, 2018
@H1Gdev H1Gdev deleted the coverage branch December 24, 2018 23:24
captain-yossarian pushed a commit to captain-yossarian/jest that referenced this pull request Jul 18, 2019
@github-actions
Copy link

This pull request 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 12, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants