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

jest.mock() does not work with using backticks e.g. jest.mock(fs) #5368

Closed
maoberlehner opened this issue Jan 23, 2018 · 6 comments
Closed

Comments

@maoberlehner
Copy link

maoberlehner commented Jan 23, 2018

Do you want to request a feature or report a bug?
Bug

What is the current behavior?

// Works
jest.mock('fs');

// Doesn't work (backticks instead of single or double quotes)
jest.mock(`fs`);

If the current behavior is a bug, please provide the steps to reproduce and
either a repl.it demo through https://repl.it/languages/jest or a minimal
repository on GitHub that we can yarn install and yarn test.

It is not possible to reproduce this on repl.it, but it is pretty simple to test.

  1. Create a __mocks__ directory with a mock for fs
  2. Create a test which jest.mock(`fs`)s using backticks
  3. fs is not mocked

What is the expected behavior?

It should mock fs no matter if single or double quotes or backticks are used.

Please provide your exact Jest configuration and mention your Jest, node,
yarn/npm version and operating system.

Jest: 22.1.4
Node: v8.7.0
npm: 5.6.0

@SimenB
Copy link
Member

SimenB commented Jan 24, 2018

@maoberlehner
Copy link
Author

Thanks @SimenB for pointing me in the right direction – I'll look what I can do ;)

@rafaelramalho19
Copy link
Contributor

@maoberlehner and @SimenB I managed to find the solution. Will create a merge request as soon as the tests stop failing on the integration-tests/__tests__/timeouts.test.js file 🙃

@maoberlehner
Copy link
Author

@rafaelramalho19 cool, I couldn't figure it out, thx!

@SimenB
Copy link
Member

SimenB commented Feb 2, 2018

#5426

@SimenB SimenB closed this as completed Feb 2, 2018
@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 13, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants