-
Notifications
You must be signed in to change notification settings - Fork 30
Expand file tree
/
Copy pathvitest.config.ts
More file actions
38 lines (32 loc) · 981 Bytes
/
vitest.config.ts
File metadata and controls
38 lines (32 loc) · 981 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
36
37
38
import path from 'node:path';
import { defineConfig } from 'vitest/config';
/**
* Assets extensions RegExp.
*/
const RE_ASSET_EXTENSIONS = /\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$/;
/**
* Styles extensions RegExp.
*/
const RE_STYLE_EXTENSIONS = /\.(css|less|pcss|sass|scss)$/;
export default defineConfig({
test: {
environment: 'jsdom',
setupFiles: [
'./tests/__setups__/mocks.ts',
'./tests/__setups__/chrome.ts',
],
},
plugins: [{
name: 'mock-assets-imports',
enforce: 'pre',
resolveId(source: string) {
if (RE_ASSET_EXTENSIONS.test(source)) {
return path.resolve(__dirname, 'tests/__mocks__/fileMock.ts');
}
if (RE_STYLE_EXTENSIONS.test(source)) {
return path.resolve(__dirname, 'tests/__mocks__/styleMock.ts');
}
return null;
},
}],
});