-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Expand file tree
/
Copy pathvitest.config.ts
More file actions
70 lines (67 loc) · 2.09 KB
/
vitest.config.ts
File metadata and controls
70 lines (67 loc) · 2.09 KB
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
import path from 'path'
import fs from 'fs'
import { defineConfig } from 'vitest/config'
// Use process.cwd() to be safe in both CJS and ESM contexts within Vitest
const ROOT_DIR = process.cwd()
const figmaPath = path.resolve(ROOT_DIR, '../enterprise-plugins/packages/figma/src/index.ts')
const hasFigma = fs.existsSync(figmaPath)
console.log('[Dev Setup] Checking for local Figma plugin at:', figmaPath)
if (hasFigma) {
console.log('[Dev Setup] Using local @payloadcms/figma source')
} else {
console.log('[Dev Setup] Local Figma plugin NOT found, using node_modules')
}
export default defineConfig({
resolve: {
alias: {
...(hasFigma ? { '@payloadcms/figma': figmaPath } : {}),
},
},
test: {
watch: false, // too troublesome especially with the in memory DB setup
// Retry failed tests up to 2 times in CI to handle flaky tests (e.g. due to timing-sensitive int tests like job queues, installation failures due to temporary network issues)
retry: process.env.CI ? 2 : 0,
server: {
deps: {
inline: [/@payloadcms\/figma/],
},
},
projects: [
{
test: {
include: ['packages/**/*.spec.ts'],
name: 'unit',
environment: 'node',
},
},
{
resolve: {
alias: {
graphql: 'node_modules/graphql/index.js', // https://github.com/vitest-dev/vitest/issues/4605
...(hasFigma ? { '@payloadcms/figma': figmaPath } : {}),
},
},
test: {
include: ['test/**/*int.spec.ts'],
name: 'int',
environment: 'node',
fileParallelism: false,
hookTimeout: 90000,
testTimeout: 90000,
setupFiles: ['./test/vitest.setup.ts'],
},
},
{
test: {
include: ['test/evals/**/*.spec.ts'],
name: 'eval',
environment: 'node',
fileParallelism: false,
globalSetup: ['test/evals/globalSetup.ts'],
// 10 minutes per test: LLM call (~60-120s) + tsc wait + scorer + buffer.
testTimeout: 600000,
},
},
],
},
})