Skip to content

Filipoliko/vitest-environment-bug

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Vitest Environment

Minimal reproduction of a Vite bug where defining 2+ non-client environments in vitest.config.ts causes a require is not defined error. Vite's mergeConfig shares nested object references across environments, so when Vitest's configEnvironment hook mutates resolve.noExternal for one environment, it leaks to others — causing jsdom (CJS) to be inlined into an ESM-only evaluator.

Setup

npm ci

Reproduce

npm test

You should see ReferenceError: require is not defined. Removing one of the two environments from vitest.config.ts makes the error go away. So does uncommenting the resolve: {} block, which prevents the mutation from happening in the first place.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors