Skip to content

🐛 BUG: Installing vitest and writing test.ts files causes errors #3856

@kungpaogao

Description

@kungpaogao

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

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    - P2: nice to haveNot breaking anything but nice to have (priority)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions