-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvitest.config.ts
37 lines (31 loc) · 981 Bytes
/
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
import { resolve } from 'path'
import fs from 'fs'
import { defineConfig } from 'vitest/config'
/**
* Feature film "Snatched"
* https://github.com/nuxt/framework/discussions/5379#discussioncomment-2942984
*/
function sanitizeNuxtTsConfigJson(config: string) {
const regexp = /\\"|"(?:\\"|[^"])*"|(\/\/.*|\/\*[\s\S]*?\*\/)/g
return config.replace(regexp, (m, g) => g ? '' : m)
}
const NuxtTsConfig = fs.readFileSync('./.nuxt/tsconfig.json').toString()
const tsConfigFormated = JSON.parse(sanitizeNuxtTsConfigJson(NuxtTsConfig))
export const alias: Record<string, string> = {}
const NuxtPathPairs: Array<[string, string[]]> = Object.entries(tsConfigFormated.compilerOptions.paths)
for (const [key, value] of NuxtPathPairs) {
alias[key] = resolve(__dirname, value[0])
}
export default defineConfig({
test: {
deps: {
inline: [/@nuxt\/test-utils-edge/]
},
coverage: {
reporter: ['text', 'json', 'html'],
}
},
resolve: {
alias
}
})