-
-
Notifications
You must be signed in to change notification settings - Fork 3.3k
🐛 BUG: Installing vitest and writing test.ts files causes errors #3856
Copy link
Copy link
Closed
Labels
- P2: nice to haveNot breaking anything but nice to have (priority)Not breaking anything but nice to have (priority)
Description
What version of astro are you using?
1.0.0-beta.64
Are you using an SSR adapter? If so, which one?
None
What package manager are you using?
yarn
What operating system are you using?
Mac
Describe the Bug
Context
I wrote a script (.ts file) to fetch and parse some data from Notion during build time. I wanted to test my parser, so I installed vitest and made a .test.ts file. However, this creates a bunch of errors when I run yarn dev. This doesn't seem to prevent the dev server from starting/running, nor does it affect the build.
Questions
- Is it possible to ignore files (like
**/*.test.ts) during Astro builds? - Do these scripts get shipped to the user?
- Is it related to this issue: Vitest fails to import under Vite App vitest-dev/vitest#1118?
- Is there official guidance on writing tests in Astro projects?
Error output
[vite] error while updating dependencies:
Error: Build failed with 10 errors:
node_modules/local-pkg/dist/shared.mjs:54:9: ERROR: No matching export in "browser-external:fs" for import "existsSync"
node_modules/local-pkg/dist/shared.mjs:54:21: ERROR: No matching export in "browser-external:fs" for import "promises"
node_modules/local-pkg/dist/shared.mjs:62:13: ERROR: No matching export in "browser-external:node:fs" for import "promises"
node_modules/local-pkg/dist/shared.mjs:235:14: ERROR: No matching export in "browser-external:node:fs" for import "promises"
node_modules/local-pkg/index.mjs:1:9: ERROR: No matching export in "browser-external:path" for import "join"
...
Link to Minimal Reproducible Example
https://stackblitz.com/edit/github-rpxbwm?file=src/lib/something.test.ts
Participation
- I am willing to submit a pull request for this issue.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
- P2: nice to haveNot breaking anything but nice to have (priority)Not breaking anything but nice to have (priority)