-
Notifications
You must be signed in to change notification settings - Fork 110
/
Copy pathvitest.config.ts
76 lines (70 loc) · 2.17 KB
/
vitest.config.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
import type { ViteUserConfig } from 'vitest/config'
import { createRequire } from 'node:module'
import path from 'node:path'
import process from 'node:process'
import pluginVue from '@vitejs/plugin-vue'
import { configDefaults, defineConfig } from 'vitest/config'
import { getMarkdownPlugins } from './@fiction/core/plugin-app/utils/vitePluginMarkdown.js'
const require = createRequire(import.meta.url)
const corePath = path.join(
path.dirname(require.resolve('@fiction/core')),
'/test-utils',
)
export function sourceFolder(moduleName: string): string {
const appPath = require.resolve(moduleName)
return path.dirname(appPath)
}
const jsdom = {
url: 'http://localhost:10000/thepathname?q=example&utm_campaign=testCampaign&utm_medium=testMedium&utm_source=testSource',
referrer: 'https://www.twitter.com',
html: `<!DOCTYPE html><head><title>Test Title</title></head><body>Page Content <a href="#">link</a></body></html>`,
}
export default defineConfig({
plugins: [
pluginVue(),
...getMarkdownPlugins(),
] as ViteUserConfig['plugins'],
build: { sourcemap: true },
root: process.cwd(),
clearScreen: false,
test: {
// browser: {
// provider: 'playwright',
// enabled: true,
// name: 'chromium',
// },
testTimeout: 40000,
hookTimeout: 40000,
env: {
NODE_ENV: 'development',
},
exclude: ['**/node_modules/**', '**/dist/**', '.git', '.cache', '**/.ref/**', '**/.ref-*/**'],
globalSetup: [`${corePath}/setupGlobal.ts`],
setupFiles: [`${corePath}/setupTest.ts`],
environmentOptions: { jsdom },
coverage: {
provider: 'istanbul',
reporter: ['text', 'html'],
exclude: [
...configDefaults.coverage.exclude!,
'**/*.vue',
'**/*.cjs',
'**/*.js',
'**/test-utils/**',
'**/resource/**',
'**/dist/**',
'**/node_modules/**',
'**/coverage/**',
'**/test/**',
'**/scripts/**',
],
},
alias: [
// https://github.com/vitest-dev/vitest/discussions/1806
{
find: /^monaco-editor$/,
replacement: path.join(__dirname, `/node_modules/monaco-editor/esm/vs/editor/editor.api`),
},
],
},
})