vitest/examples/mocks/vite.config.ts
Vladimir 6b3e36d4e9
fix: allow mocking CJS module with interoped default (#2598)
* fix: allow mocking CJS module with interoped default

* chore: cleanup

* chore: cleanup
2023-01-06 13:11:10 +01:00

32 lines
580 B
TypeScript

/// <reference types="vitest" />
import { defineConfig } from 'vite'
// https://vitejs.dev/config/
export default defineConfig({
plugins: [
{
name: 'example',
resolveId(source) {
if (source === 'virtual-module')
return source
},
load(id) {
if (id === 'virtual-module') {
return `
export const value = 'original';
`
}
},
},
],
test: {
globals: true,
environment: 'node',
deps: {
external: [/src\/external/],
interopDefault: true,
},
},
})