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: use node:path to resolve dist directory #1054

Merged
merged 2 commits into from
Jan 11, 2025
Merged

Conversation

scottbedard
Copy link
Contributor

@scottbedard scottbedard commented Jan 1, 2025

πŸ”— Linked issue

resolves #1038
resolves #1050

❓ Type of change

  • πŸ“– Documentation (updates to the documentation or readme)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • πŸ‘Œ Enhancement (improving an existing functionality)
  • ✨ New feature (a non-breaking change that adds functionality)
  • 🧹 Chore (updates to the build process or auxiliary tools and libraries)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

πŸ“š Description

It appears that 56122b7 caused a regression with 3.15 that can produce the following error. I suspect this is environment-specific. If it were widespread, I'd expect more people to be talking about it.

TypeError: The URL must be of scheme file
 ❯ ../node_modules/.pnpm/@[email protected]_@[email protected]_@[email protected][email protected]_magicast@_qhcyoib43mexeh3yv2rdveqtry/node_modules/@nuxt/test-utils/dirs.js:4:17

Making this change directly inside node_modules works for me, but @danielroe perhaps you can provide more context. If our goal is to simply resolve the dist directory, using node:path could be a safer way to do it.

@scottbedard scottbedard requested a review from danielroe as a code owner January 1, 2025 23:14
@Aietes
Copy link

Aietes commented Jan 10, 2025

I think quite a few people have this problem and downgraded test-utils because of it. I can confirm this fix works for me on a mac.

@danielroe
Copy link
Member

danielroe commented Jan 10, 2025

do you have a reproduction that this fixes? this seems to be a bug in your test runner or node.

I see the linked repro. I'll check it but this is a surprising result and probably needs to be reported elsewhere - maybe to vitest

@scottbedard
Copy link
Contributor Author

scottbedard commented Jan 10, 2025

Here is a minimal reproduction and my environment details

https://github.com/scottbedard/nuxt-test-utils-repro

npx envinfo --system --npmPackages vue --binaries --browsers

  System:
    OS: macOS 14.4.1
    CPU: (10) arm64 Apple M1 Pro
    Memory: 458.97 MB / 32.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 22.12.0 - ~/.nvm/versions/node/v22.12.0/bin/node
    npm: 10.9.0 - ~/.nvm/versions/node/v22.12.0/bin/npm
    pnpm: 9.7.0 - ~/Library/pnpm/pnpm
  Browsers:
    Chrome: 131.0.6778.265
    Firefox Nightly: 129.0a1
    Safari: 17.4.1
  npmPackages:
    vue: latest => 3.5.13

@danielroe
Copy link
Member

That's a helpful example. The issue is that the vitest.config you have set up is for Nuxt runtime tests (i.e. it sets up a number of things for a browser environment) but you are running e2e tests. For this, I recommend two vitest config files, which target different kinds of tests.

You can see an example in my own website repo: https://github.com/danielroe/roe.dev/blob/main/vitest.config.mts and https://github.com/danielroe/roe.dev/blob/main/vitest.nuxt.config.mts.

@danielroe danielroe merged commit 64c6b57 into nuxt:main Jan 11, 2025
3 of 4 checks passed
@github-actions github-actions bot mentioned this pull request Jan 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants