-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathvitest.config.mjs
More file actions
32 lines (30 loc) · 903 Bytes
/
Copy pathvitest.config.mjs
File metadata and controls
32 lines (30 loc) · 903 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
import { defineConfig } from 'vitest/config';
import { transformAsync } from '@babel/core';
/**
* The components are .js files containing JSX, which Vite does not treat as
* JSX by default. Running them through the project's own Babel config keeps the
* tests on the same transform as the build.
*/
const babelJsx = {
name: 'deep-viz:babel-jsx',
async transform(code, id) {
if (!/\/src\/.*\.js$/.test(id)) return null;
const result = await transformAsync(code, {
filename: id,
presets: [['@babel/preset-react', { runtime: 'classic' }]],
sourceMaps: true,
babelrc: false,
configFile: false,
});
return { code: result.code, map: result.map };
},
};
export default defineConfig({
plugins: [babelJsx],
test: {
environment: 'jsdom',
globals: true,
setupFiles: ['./tests/setup.js'],
include: ['tests/**/*.test.{js,jsx}'],
},
});