forked from Invoice-Liquidity-Network/ILN-Frontend
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvitest.config.ts
More file actions
96 lines (95 loc) · 3.57 KB
/
Copy pathvitest.config.ts
File metadata and controls
96 lines (95 loc) · 3.57 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
import { defineConfig, configDefaults } from 'vitest/config';
import react from '@vitejs/plugin-react';
import path from 'path';
import { fileURLToPath } from 'node:url';
import { storybookTest } from '@storybook/addon-vitest/vitest-plugin';
import { playwright } from '@vitest/browser-playwright';
const dirname = path.dirname(fileURLToPath(import.meta.url));
// More info at: https://storybook.js.org/docs/next/writing-tests/integrations/vitest-addon
export default defineConfig({
plugins: [react()],
resolve: {
alias: [
{ find: '@/app', replacement: path.resolve(dirname, 'app') },
{ find: '@', replacement: path.resolve(dirname, 'src') },
],
},
test: {
// Playwright specs live in ./e2e (see playwright.config.ts testDir) and are
// run by `pnpm test:e2e`. They match Vitest's default include glob, so they
// must be excluded here or Playwright throws
// "Playwright Test did not expect test.describe() to be called here".
exclude: [...configDefaults.exclude, 'e2e/**'],
// A handful of suites render large trees (LP dashboard, activity heatmap,
// full page routes). The 5s default is tight enough that they flake on a
// loaded runner - especially under `--coverage`, which instruments every
// module - while still catching genuinely hung tests.
testTimeout: 15_000,
hookTimeout: 15_000,
coverage: {
provider: 'v8',
include: [
'src/utils/soroban.ts',
'src/utils/contract-stats.ts',
'src/utils/governance.ts',
'src/lib/contract-events.ts',
'src/lib/contract-event-stream-state.ts',
'src/lib/contract/**/*.ts',
],
thresholds: {
lines: 90,
functions: 90,
// soroban.ts has many internal XDR-parsing branches (transaction
// result decoding, retry/error paths) that are only reachable with
// deep Stellar SDK payload mocking. 74% is the current, verified
// level; raise this incrementally as those paths get covered.
branches: 74,
statements: 90,
},
reporter: ['text', 'json', 'json-summary', 'html'],
reportsDirectory: './coverage',
},
projects: [
{
extends: true,
test: {
globals: true,
environment: 'jsdom',
setupFiles: ['./vitest.setup.ts'],
},
},
// The Storybook project is only added when STORYBOOK_TESTS=1 is set
// (requires: npx playwright install chromium). Setting browser.enabled
// to false still collects and executes every .stories.tsx file outside
// a browser context, crashing with "window is not defined" - so the
// whole project must be omitted, not just disabled.
...(process.env.STORYBOOK_TESTS === '1'
? [
{
extends: true as const,
plugins: [
// The plugin will run tests for the stories defined in your Storybook config
// See options at: https://storybook.js.org/docs/next/writing-tests/integrations/vitest-addon#storybooktest
storybookTest({
configDir: path.join(dirname, '.storybook'),
}),
],
test: {
name: 'storybook',
browser: {
enabled: true,
headless: true,
provider: playwright({}),
instances: [
{
browser: 'chromium' as const,
},
],
},
},
},
]
: []),
],
},
});