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

Bug: Yarn 2+ breaks on unlisted dependency #1306

Closed
Benalink opened this issue Feb 10, 2022 · 5 comments · Fixed by #1307
Closed

Bug: Yarn 2+ breaks on unlisted dependency #1306

Benalink opened this issue Feb 10, 2022 · 5 comments · Fixed by #1307
Labels
bug Something isn't working

Comments

@Benalink
Copy link

Describe the bug
Running vitest with yarn on a newly scaffolded vue project fails.

FAIL src/components/tests/HelloWorld.spec.ts [ src/components/tests/HelloWorld.spec.ts ]
Error: @vue/test-utils tried to access @vue/compiler-dom, but it isn't declared in its dependencies; this makes the require call ambiguous and unsound

This appears to be a regression of #245 after the dependency was removed in #1251

To Reproduce
npm init vue@latest
yarn install (with version 2+)
yarn run vitest

Expected behavior
Tests run succesfully

Related information:

  • @vue/test-utils version: 2.0.0-rc.18
  • Vue version: 3
  • node version:
  • npm (or yarn) version: yarn 2+
@Benalink Benalink added the bug Something isn't working label Feb 10, 2022
@cexbrayat
Copy link
Member

Hmm I indeed removed the dependency in January (because I thought we were no longer using it, but we still are as I just realised).

The strange thing is that we did not release this change: rc.18 was released in December. So it's weird that you have this issue with rc.18 🤔 Do you also have it with rc.17 or older versions?

Anyway, I'll revert my mistake, and this will hopefully fix your issue when a make a new release.

@Benalink
Copy link
Author

I think you're right on that commit not being the issue here, my apologies. I've only just noticed this after scaffolding my first Vue 3 project, I've just tested with a bunch of versions starting at rc.1 all the way up to rc.18 and I do indeed have the issue in all versions I tested although I skipped over a lot of them.

I wondered if this might be caused by the pnp typescript plugin so I have done another scaffold with the following setup but get the same issue:

npm init vue@latest
Need to install the following packages:
create-vue@latest
Ok to proceed? (y) y

Vue.js - The Progressive JavaScript Framework

√ Project name: ... test
√ Add TypeScript? ... No / Yes
√ Add JSX Support? ... No / Yes
√ Add Vue Router for Single Page Application development? ... No / Yes
√ Add Pinia for state management? ... No / Yes
√ Add Vitest for Unit Testing? ... No / Yes
√ Add Cypress for End-to-End testing? ... No / Yes
√ Add ESLint for code quality? ... No / Yes
√ Add Prettier for code formatting? ... No / Yes

Scaffolding project in D:\Repos\Personal\test...

cd test
yarn set version stable
yarn install
yarn vitest run

 FAIL  src/components/__tests__/HelloWorld.spec.js [ src/components/__tests__/HelloWorld.spec.js ]
Error: @vue/test-utils tried to access @vue/compiler-dom, but it isn't declared in its dependencies; this makes the require call ambiguous and unsound.

Required package: @vue/compiler-dom (via "@vue\compiler-dom")
Required by: @vue/test-utils@virtual:572974bfd16fba63746e564b946fcd0d5481e3958a2d86b2339f8f9624fc9f4abd3898c4444c731638d6001d3f88ca414f2c05308d6789925602f170e2d31abc#npm:2.0.0-rc.18

@cexbrayat
Copy link
Member

Hmm yeah, that's what I suspected...

I'm not familiar with Yarn 2 myself but I don't think we're doing anything special here. So it's maybe an issue with Yarn itself? We have no issues with other package managers as far as I know (yarn v1, pnpm, or npm v6-8). Maybe try to update your yarn version to be sure that you have the latest fixes, as there are a lot of similar issues in the Yarn repo.

Other than that, I don't know how we can help. Maybe try to open an issue on the yrn repo, and link it back to here if your problem persists with the latest yarn versions.

@Benalink
Copy link
Author

I'm using the latest release of Yarn (3.1.1), I have found a workaround though that works with Yarn 2+ if anyone else runs into this issue.

Try enabling the loose pnpMode

@cexbrayat
Copy link
Member

Awesome, thanks @Benalink

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants