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

Vitest fails to import under Vite App #1118

Closed
6 tasks done
FossPrime opened this issue Apr 6, 2022 · 2 comments
Closed
6 tasks done

Vitest fails to import under Vite App #1118

FossPrime opened this issue Apr 6, 2022 · 2 comments

Comments

@FossPrime
Copy link

FossPrime commented Apr 6, 2022

Describe the bug

I'd like to use the same syntax for my client side assertions as my build time testing framework. Unfortunately, Vite seems to load Node.js dependent code when you import Vitest. Is Vitest not compatible with browsers?

ERROR: No matching export in "browser-external:fs" for import "existsSync"

I'm using v0.8.4: https://unpkg.com/browse/[email protected]/package.json

Reproduction

https://stackblitz.com/edit/vitest-dev-vitest-6undtu?file=src%2Fmain.ts&initialPath=__vitest__

System Info

StackBlitz
Vite: 2.9.0

Used Package Manager

npm

Validations

@sheremet-va
Copy link
Member

sheremet-va commented Apr 6, 2022

Vitest cannot run in a browser at the moment, but there is a PR that allows a fraction of Vitest functionality to be used in a browser: #891

We are recommending using cypress for testing in browser right now.

@FossPrime
Copy link
Author

Ended up using straight up chai/expect. Pretty sure cypress will not run in the browser due to the dependency of a browser.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants