We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
29.7.0
foo
example.ts:
const {foo} = require('./path-to-func'); export const bar = () => { ... foo() }
example.ts
const example = require('path-to-example'); const funcs = require('./path-to-func') describe('example test', () => { it('should call mocked foo()', () => { jest.spyOn(funcs, foo') .mockImplementation(() => console.log('mock called!')); //call bar(): example.bar() }) } )
Mocked foo should be called.
it calls the original foo instead of using the mocked foo.
We can resolve this if we dont deference the require statement (in example.ts):
//example.ts const funcs = require('./path-to-func'); export const bar = () => { ... funcs.foo() }
System: OS: Linux 6.5 Ubuntu 22.04.3 LTS 22.04.3 LTS (Jammy Jellyfish) CPU: (20) x64 12th Gen Intel(R) Core(TM) i7-12800H Binaries: Node: 18.17.1 - ~/.nvm/versions/node/v18.17.1/bin/node npm: 9.6.7 - ~/.nvm/versions/node/v18.17.1/bin/npm
The text was updated successfully, but these errors were encountered:
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 30 days.
Sorry, something went wrong.
No branches or pull requests
Version
29.7.0
Steps to reproduce
foo
used inexample.ts:
example.ts
looks like the following:Expected behavior
Mocked
foo
should be called.Actual behavior
it calls the original
foo
instead of using the mockedfoo
.Additional context
We can resolve this if we dont deference the require statement (in
example.ts
):Environment
The text was updated successfully, but these errors were encountered: