-
Notifications
You must be signed in to change notification settings - Fork 284
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
[node:test] How to mocking function exported with named export #4326
Comments
I have the same problem, I looked at this issue and apparently the native node test does not have support for mocking modules #4298 |
Odd note, when I do: import fs from 'node:fs'
import * as blah from './blah';
test('my test', (t) => {
// this works
t.mock.method(fs, 'writeFileSync', () => /* */);
// this doesn't work
t.mock.method(blah, 'someExport', () => /* */);
}); I'm guessing this is either because I'm using a loader ( In any case, I would also like to be able to mock exports from local files |
It seems there has been no activity on this issue for a while, and it is being closed in 30 days. If you believe this issue should remain open, please leave a comment. |
It seems there has been no activity on this issue for a while, and it is being closed. If you believe this issue should remain open, please leave a comment. |
Details
I'm trying to mock a function that has been exported using named export, but I'm not able to do it successfully.
How can I mock it properly?
Any help would be greatly appreciated!
Expected Behavior
test passing
Actual Behavior
Node.js version
v20.0.0
Example code
Implementation Code
Test Code
Operating system
Ubuntu 22.04.3 LTS
Scope
test
Module and version
The text was updated successfully, but these errors were encountered: