-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
module mock will not work with yarn workspaces mode #578
Comments
Is this still happening? I just tried to reproduce it and it works fine. Was able to mock hoisted axios package. |
I have a repro: https://codesandbox.io/s/festive-goldstine-ysjbf?file=/packages/a/index.test.js I can mock an external package like Alternatively, you can fork the sandbox and open and file and hit |
@NMinhNguyen Thanks for repro, this makes more sense then not being able to mock You can use Will investigate if it is possible to resolve |
Thanks for the temporary workaround!
I've updated the repro to make use of |
I found the issue, will make a PR in a few hours. |
I tested #712 on your reproduction, and everything worked 🎆 |
Great, thank you for fixing this! |
Thanks! |
it was using "and" as title instead of "or"
@sheremet-va could you check please if this is somehow related to this issue #3426 |
Describe the bug
My project use yarn workspaces mode. So some node_modules will hoist to the project root node_modules directory.
However, when I use vi.mock to mock a module which hoisted to the root it didnot work as expected.
// in test.spec.ts
vi.mock('some-package');
// in index.ts
import { someFn } from 'some-package'; // someFn still not mocked
But when mocking a module not hoisted to the root node_modules it works as expected.
In this case to fix that, I have to use relateive path while mocking such module:
vi.mock('../some_path_to_root_dir/node_modules/some-package');
Which is pretty tricky. Hope that vi.mock can resolve the correct module path.
Thanks.
Reproduction
"workspaces": [ "packages/**" ],
vi.mock('axios')
under the dir root/packages/app1;System Info
Used Package Manager
yarn
Validations
The text was updated successfully, but these errors were encountered: