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

Fixed the bug where mocking a file with the filename resolved as backticks would fail #5426

Merged
merged 7 commits into from
Feb 1, 2018

Conversation

rafaelramalho19
Copy link
Contributor

Summary

Related with issue #5368
This fixes a bug that needed the following conditions:

  1. Mock a package via the __mocks__ folder.
  2. call the mock function with backticks (``).

Test plan

Added tests to the babel-plugin-jest-hoist package. Also added a __mocks__ folder there to replicate this issue.

@facebook-github-bot
Copy link
Contributor

Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please sign up at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need the corporate CLA signed.

If you have received this in error or have any questions, please contact us at cla@fb.com. Thanks!

@facebook-github-bot
Copy link
Contributor

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks!

@codecov-io
Copy link

codecov-io commented Jan 30, 2018

Codecov Report

Merging #5426 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #5426   +/-   ##
=======================================
  Coverage   62.18%   62.18%           
=======================================
  Files         205      205           
  Lines        6928     6928           
  Branches        3        4    +1     
=======================================
  Hits         4308     4308           
  Misses       2619     2619           
  Partials        1        1

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 03bf2a9...932ae39. Read the comment docs.

Copy link
Member

@SimenB SimenB left a comment

Choose a reason for hiding this comment

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

Unless I misunderstand, the added test does not cover the original issue. See inline comment

CHANGELOG.md Outdated
@@ -7,6 +7,7 @@

### Fixes

* `[mock]` Add backticks support (\`\`) to `mock` a certain package via the `__mocks__` folder.
Copy link
Member

Choose a reason for hiding this comment

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

please include a link to this PR

@@ -44,6 +45,7 @@ jest.mock('../__test_modules__/e', () => {
},
};
});
jest.mock('../__test_modules__/jest-backticks');
Copy link
Member

Choose a reason for hiding this comment

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

should this use backticks?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You're absolutelly right, I was testing if the backticks were really working and forgot to update this. Thanks :)

Copy link
Member

@SimenB SimenB left a comment

Choose a reason for hiding this comment

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

Thanks!

CHANGELOG.md Outdated
@@ -7,6 +7,7 @@

### Fixes

* `[mock]` Add backticks support (\`\`) to `mock` a certain package via the `__mocks__` folder.([#5426](https://github.com/facebook/jest/pull/5426))
Copy link
Member

Choose a reason for hiding this comment

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

Should this be [jest-mock]?

Copy link
Member

@SimenB SimenB Feb 1, 2018

Choose a reason for hiding this comment

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

You're right. I meant to fix that - forgot, though. Thanks!

@cpojer cpojer merged commit c885f41 into jestjs:master Feb 1, 2018
jessecarfb pushed a commit to jessecarfb/jest that referenced this pull request Feb 2, 2018
…ticks would fail (jestjs#5426)

* Fixed the bug where mocking a file with the filename resolved as backticks would fail

* Updated changelog

* Added license info

* Fixed the unit test related to the backticks issue and updated the changelog with the PR link

* Update CHANGELOG.md

* Update CHANGELOG.md
@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.

None yet

6 participants