-
-
Notifications
You must be signed in to change notification settings - Fork 189
Expand file tree
/
Copy pathvitest.config.js
More file actions
35 lines (33 loc) · 842 Bytes
/
vitest.config.js
File metadata and controls
35 lines (33 loc) · 842 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import { defineConfig } from 'vitest/config';
import { transformSync } from 'esbuild';
function jsxInJs() {
return {
name: 'treat-js-as-jsx',
enforce: 'pre',
transform(code, id) {
if (!/node_modules/.test(id) && /\.js$/.test(id) && code.includes('<')) {
const result = transformSync(code, {
loader: 'jsx',
jsx: 'automatic',
sourcefile: id,
sourcemap: true,
});
return { code: result.code, map: result.map };
}
return null;
},
};
}
export default defineConfig({
plugins: [jsxInJs()],
test: {
environment: 'jsdom',
setupFiles: ['@testing-library/jest-dom'],
include: ['tests/**/*.test.{js,jsx}'],
exclude: ['tests/typescript/**'],
globals: true,
coverage: {
include: ['src/**/*.{js,jsx}'],
},
},
});