Skip to content

Vitest fails to import under Vite App #1118

@FossPrime

Description

@FossPrime

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/vitest@0.8.4/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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions