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 incorrect duplicate mock warning. #8167

Merged

Conversation

scotthovestadt
Copy link
Contributor

Summary

This fixes a regression introduced by: #8153

I've fixed it by using the same logic already present for modules, which also check to be sure the file path isn't a match before warning.

Test plan

I added an e2e test that catches the behavior to ensure this regression will not happen again.

To reproduce manually:

  1. Run yarn jest packages/jest-haste-map/src/__tests__/index.test.js (or any other test)
  2. Make any change to a mock file, for example add a comment to packages/jest-config/src/__mocks__/fs.js
  3. Run Jest again, the warning jest-haste-map: duplicate manual mock found: fs incorrectly shows up

@codecov-io
Copy link

Codecov Report

Merging #8167 into master will decrease coverage by <.01%.
The diff coverage is 40%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #8167      +/-   ##
==========================================
- Coverage   62.29%   62.28%   -0.01%     
==========================================
  Files         265      265              
  Lines       10433    10434       +1     
  Branches     2533     2535       +2     
==========================================
  Hits         6499     6499              
  Misses       3352     3352              
- Partials      582      583       +1
Impacted Files Coverage Δ
packages/jest-haste-map/src/index.ts 81.5% <40%> (-0.24%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5bb9624...898b547. Read the comment docs.

@scotthovestadt scotthovestadt merged commit c5fd7aa into jestjs:master Mar 20, 2019
beforeEach(() => cleanup(DIR));
afterEach(() => cleanup(DIR));

test('should not warn when a mock file changes', async () => {
Copy link
Member

Choose a reason for hiding this comment

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

I like jest-haste-map tests as e2e tests. The tests in packages/jest-haste-map are really hard on testing internals - this way it's easier to test it behaves properly in a way observable from the outside

@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 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 this pull request may close these issues.

None yet

4 participants