forked from ezedike-evan/stellar-intel
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvitest.config.mts
More file actions
125 lines (123 loc) · 5.47 KB
/
Copy pathvitest.config.mts
File metadata and controls
125 lines (123 loc) · 5.47 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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
import { defineConfig, configDefaults } from 'vitest/config';
import react from '@vitejs/plugin-react';
import path from 'path';
import { fileURLToPath } from 'url';
const rootDir = path.dirname(fileURLToPath(import.meta.url));
export default defineConfig({
plugins: [react()],
test: {
// teardownTimeout is a NonProjectOptions field in vitest ≥ 4 and cannot
// appear inside a project's test block. Set it once at the top level so
// it applies to every project in the workspace.
teardownTimeout: 15000,
// ── Projects ────────────────────────────────────────────────────────────
//
// Two named projects separate the mocked unit suite from any future tests
// that must hit live anchors:
//
// unit – the full mocked suite run by `npm test` on every
// PR/push. A third-party anchor being down CANNOT fail
// a merge: nothing in this project makes a real network
// call.
//
// live-anchors – tests tagged `{ tags: ['live-anchor'] }`. These are
// intentionally NOT included in the default `npm test`
// command. They run only in the scheduled
// live-anchor-checks.yml workflow (`npm run test:live`).
// See .github/workflows/live-anchor-checks.yml for the
// full job definition and issue-opening logic.
//
// To add a live test:
// describe('my probe', { tags: ['live-anchor'] }, () => { … });
// // or at the individual test level:
// it('fetches real TOML', { tags: ['live-anchor'] }, async () => { … });
//
// The project filter is what keeps live tests out of CI, not an env-var
// guard. That means the split is structural and cannot be accidentally
// bypassed by setting an environment variable.
projects: [
{
// ── Unit project ───────────────────────────────────────────────────
// All existing tests that mock the network. This is what `npm test`
// and `npm run test:coverage` run.
extends: true,
test: {
name: 'unit',
pool: 'forks',
maxWorkers: 4,
environment: 'happy-dom',
setupFiles: ['./tests/setup.ts'],
globals: true,
// Bound every test/hook so an unmocked network call or stray
// open handle fails fast instead of hanging the whole suite (and CI)
// forever. teardownTimeout is set at the top level (NonProjectOptions).
testTimeout: 15000,
hookTimeout: 15000,
// Exclude Playwright specs, worktree checkouts, and live-anchor tests.
exclude: [
...configDefaults.exclude,
'tests/e2e/**',
'**/.claude/worktrees/**',
],
// Exclude tests explicitly tagged as live-anchor; those belong to the
// `live-anchors` project below.
includeTaskLocation: true,
env: {
// Silence pino in tests — info-level logging floods stdout with
// thousands of lines and was pushing the suite past CI timeouts
// (looked like a hang).
LOG_LEVEL: 'silent',
NEXT_PUBLIC_STELLAR_NETWORK: 'mainnet',
NEXT_PUBLIC_HORIZON_URL: 'https://horizon.stellar.org',
NEXT_PUBLIC_USDC_ISSUER: 'GA5ZSEJYB37JRC5AVCIA5MOP4RHTM335X2KGX3IHOJAPP5RE34K4KZVN',
NEXT_PUBLIC_APP_NAME: 'Stellar Intel',
CRON_SECRET: 'test-secret',
},
},
},
{
// ── Live-anchors project ───────────────────────────────────────────
// Tests that make real network calls to registered anchors.
// Run exclusively by the scheduled live-anchor-checks.yml workflow.
//
// Only files that contain at least one test tagged `live-anchor` are
// collected here. A file with no such tag is ignored.
extends: true,
test: {
name: 'live-anchors',
pool: 'forks',
maxWorkers: 2,
environment: 'node',
setupFiles: ['./tests/setup.ts'],
globals: true,
// Live network calls need more headroom than the 15 s unit ceiling.
// teardownTimeout is set at the top level (NonProjectOptions).
testTimeout: 60000,
hookTimeout: 30000,
include: ['tests/**/*.{spec,test}.{ts,mts,mjs,tsx}'],
exclude: [
...configDefaults.exclude,
'tests/e2e/**',
'**/.claude/worktrees/**',
],
// Only run tests carrying the live-anchor tag.
// Tests without the tag are collected but immediately skipped.
includeTaskLocation: true,
env: {
LOG_LEVEL: 'silent',
NEXT_PUBLIC_STELLAR_NETWORK: 'mainnet',
NEXT_PUBLIC_HORIZON_URL: 'https://horizon.stellar.org',
NEXT_PUBLIC_USDC_ISSUER: 'GA5ZSEJYB37JRC5AVCIA5MOP4RHTM335X2KGX3IHOJAPP5RE34K4KZVN',
NEXT_PUBLIC_APP_NAME: 'Stellar Intel',
CRON_SECRET: 'test-secret',
},
},
},
],
},
resolve: {
alias: {
'@': path.resolve(rootDir, '.'),
},
},
});