forked from wxt-dev/wxt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vitest.workspace.ts
51 lines (46 loc) · 1.14 KB
/
vitest.workspace.ts
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
39
40
41
42
43
44
45
46
47
48
49
50
51
import { defineWorkspace } from 'vitest/config';
import fs from 'fs-extra';
import pc from 'picocolors';
import type { Plugin } from 'vite';
import path from 'node:path';
const seed = Math.round(Math.random() * Number.MAX_SAFE_INTEGER);
console.info('Test seed: ' + pc.cyan(seed));
// config.define doesn't work with workspaces, so we have to set it inisde a plugin
const testSeed = (): Plugin => ({
name: 'test-seed',
config(config) {
config.define ??= {};
config.define.__TEST_SEED__ = JSON.stringify(seed);
},
});
const resolve = {
alias: {
'~': path.resolve('src'),
'webextension-polyfill': path.resolve('src/virtual/mock-browser'),
'wxt/testing': path.resolve('src/testing'),
},
};
// Clear e2e test projects
await fs.rm('e2e/dist', { recursive: true, force: true });
export default defineWorkspace([
{
test: {
name: 'unit',
dir: 'src',
mockReset: true,
restoreMocks: true,
setupFiles: 'vitest.setup.ts',
},
plugins: [testSeed()],
resolve,
},
{
test: {
name: 'e2e',
dir: 'e2e',
testTimeout: 120e3,
},
plugins: [testSeed()],
resolve,
},
]);