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

Cannot run vitest using examples/with-vitest with astro 5.0.3 #12662

Closed
1 task
maiwald opened this issue Dec 6, 2024 · 5 comments · Fixed by #12876
Closed
1 task

Cannot run vitest using examples/with-vitest with astro 5.0.3 #12662

maiwald opened this issue Dec 6, 2024 · 5 comments · Fixed by #12876
Labels
ecosystem: upstream Upstream package has issue

Comments

@maiwald
Copy link

maiwald commented Dec 6, 2024

Astro Info

Astro                    v5.0.3
Node                     v18.17.1
System                   macOS (arm64)
Package Manager          npm
Output                   static
Adapter                  none
Integrations             none

If this issue only occurs in one browser, which browser is a problem?

No response

Describe the Bug

Hi there!

Running npm run test run fails with Unknown Error: [object object]. I also ran this using node v20.18.0 but the result is the same.
Screenshot 2024-12-06 at 09 24 09

The code is using the Stackblitz link found on the example README.md

There is an issue that is probably related: #12384

What's the expected result?

I would expect the tests to run. :)

Link to Minimal Reproducible Example

https://stackblitz.com/github/withastro/astro/tree/latest/examples/with-vitest?file=README.md

Participation

  • I am willing to submit a pull request for this issue.
@github-actions github-actions bot added the needs triage Issue needs to be triaged label Dec 6, 2024
@ArmandPhilippot
Copy link
Member

ArmandPhilippot commented Dec 6, 2024

I can confirm the issue and yes this is related to the closed one. Vitest has reverted its support for Vite 6 in 2.1.7 so it seems there are some conflicts...

I tried to use "vitest": "2.1.6" instead of "vitest": "^2.1.6" but it doesn't seem to work... What worked for me, as suggested by HiDeoo:

"pnpm": {
    "overrides": {
      "@vitest/coverage-v8>vite": "6.0.2",
      "@vitest/mocker>vite": "6.0.2",
      "vitest>vite": "6.0.2"
    }
}

If you use npm, you can add the following lines to package.json (tested with the vitest example and it works for me):

"overrides": {
    "vite": "6.0.2"
}

However, I don't know if we should update the example in the meantime since this should be temporary... According to a Vitest issue (vitest-dev/vitest#6992), Vite 6 will only be supported from Vitest 3 expected in January.

@cliffmeyers
Copy link

I can confirm that the npm override worked for me. Thanks!

@anotheri
Copy link

anotheri commented Dec 7, 2024

Had the same problem. Ii'm using yarn, so solved it by setting resolutions in package.json like this:

"resolutions": {
    "vite": "6.0.3",
}

@maiwald
Copy link
Author

maiwald commented Dec 8, 2024

The workaround works for me as well! 👍

However, I don't know if we should update the example in the meantime since this should be temporary... According to a Vitest issue (vitest-dev/vitest#6992), Vite 6 will only be supported from Vitest 3 expected in January.

I understand. What would you say to adding a note to the migration page? The workaround might be a little hard to find for others in an issue.

omidantilong added a commit to omidantilong/astro-tenant that referenced this issue Dec 9, 2024
@ascorbic ascorbic added ecosystem: upstream Upstream package has issue and removed needs triage Issue needs to be triaged labels Dec 12, 2024
@ascorbic
Copy link
Contributor

I'll keep this open to make it easier for people to find, but this is an issue which needs to be fixed upstream in Vitest. In the meantime, the overrides are the best approach.

joshka added a commit to ratatui/ratatui-website that referenced this issue Dec 16, 2024
allison-truhlar added a commit to JaneliaSciComp/ossi-website that referenced this issue Dec 17, 2024
note: had to install vite 6.0.3 to allow the override. see the issue here: withastro/astro#12662
hex46 added a commit to hex46/workshop-astro that referenced this issue Dec 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ecosystem: upstream Upstream package has issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants