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

fix: replace root when resolving dependency #1310

Merged
merged 1 commit into from May 20, 2022

Conversation

nieyuyao
Copy link
Contributor

fix #1294.

the reason for this issue is that when we resolve all mocks, store them in mockMap. it looks like below,

{
    '/node_modules/@wdio/logger/build/node.js': '/__mocks__/@wdio/logger.ts'
}

but when we actually import, the incoming path is @wdio/logger, it becomes /@fs/${rootPath}/node_modules/@wdio/logger/build/node.js after resolveId function. so the mock fails.

@netlify
Copy link

netlify bot commented May 15, 2022

Deploy Preview for vitest-dev ready!

Name Link
🔨 Latest commit a0c0784
🔍 Latest deploy log https://app.netlify.com/sites/vitest-dev/deploys/62808a3178f2510008c8c713
😎 Deploy Preview https://deploy-preview-1310--vitest-dev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@@ -8,6 +8,10 @@ export function slash(str: string) {
return str.replace(/\\/g, '/')
}

export function mergeSlashes(str: string) {
Copy link
Member

Choose a reason for hiding this comment

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

we already have this function in utils/base.ts

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The existing function is under vitest package. Should we reference this function across packages?

Copy link
Member

Choose a reason for hiding this comment

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

Oh, I didn't notice. I guess no, we shouldn't. Maybe sometime we can create a utils package, but not in this issue, I think

@sheremet-va sheremet-va merged commit b802d5e into vitest-dev:main May 20, 2022
@nieyuyao nieyuyao deleted the fix/normalize-dep-path branch May 25, 2022 04:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Can't mock dynamically imported packages
2 participants