Skip to content

Commit 2bdd656

Browse files
chore: refactor Vitest configuration for unit and integration tests
- Split the main Vitest configuration into separate unit and integration configurations for better clarity and management. - Update CLI and MCP package scripts to use the new configuration files. - Remove legacy configuration files from CLI and MCP packages.
1 parent c7dff2c commit 2bdd656

10 files changed

Lines changed: 148 additions & 162 deletions

File tree

.github/workflows/ci.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,8 @@ jobs:
184184
root: ${{ steps.filter.outputs.root }}
185185
steps:
186186
- uses: actions/checkout@v4
187+
with:
188+
fetch-depth: 0
187189

188190
- uses: dorny/paths-filter@v3
189191
id: filter
@@ -205,6 +207,7 @@ jobs:
205207
root:
206208
- 'src/**'
207209
- 'tests/**'
210+
- 'package.json'
208211
- 'package-lock.json'
209212
- 'jest.config.*'
210213

apps/cli/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
"test": "vitest run",
1717
"test:watch": "vitest",
1818
"test:coverage": "vitest run --coverage",
19-
"test:unit": "vitest run '**/*.spec.ts'",
20-
"test:integration": "vitest run '**/*.test.ts'",
19+
"test:unit": "vitest run --config ../../vitest.unit.config.ts",
20+
"test:integration": "vitest run --config ../../vitest.integration.config.ts",
2121
"test:e2e": "vitest run --dir tests/e2e",
2222
"test:ci": "vitest run --coverage --reporter=dot"
2323
},

apps/cli/vitest.config.ts

Lines changed: 0 additions & 28 deletions
This file was deleted.

apps/mcp/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
"test": "vitest run",
1818
"test:watch": "vitest",
1919
"test:coverage": "vitest run --coverage",
20-
"test:unit": "vitest run '**/*.spec.ts'",
21-
"test:integration": "vitest run '**/*.test.ts'",
20+
"test:unit": "vitest run --config ../../vitest.unit.config.ts",
21+
"test:integration": "vitest run --config ../../vitest.integration.config.ts",
2222
"test:ci": "vitest run --coverage --reporter=dot"
2323
},
2424
"dependencies": {

apps/mcp/vitest.config.ts

Lines changed: 0 additions & 21 deletions
This file was deleted.

packages/tm-core/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121
},
2222
"scripts": {
2323
"test": "vitest run",
24-
"test:unit": "vitest run '**/*.spec.ts'",
25-
"test:integration": "vitest run '**/*.test.ts'",
24+
"test:unit": "vitest run --config ../../vitest.unit.config.ts",
25+
"test:integration": "vitest run --config ../../vitest.integration.config.ts",
2626
"test:watch": "vitest",
2727
"test:coverage": "vitest run --coverage",
2828
"lint": "biome check --write",

packages/tm-core/vitest.config.ts

Lines changed: 0 additions & 57 deletions
This file was deleted.

vitest.config.ts

Lines changed: 99 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,110 @@
1+
import path from 'node:path';
2+
import { fileURLToPath } from 'node:url';
13
import { defineConfig } from 'vitest/config';
24

5+
const __filename = fileURLToPath(import.meta.url);
6+
const __dirname = path.dirname(__filename);
7+
38
/**
4-
* Root Vitest configuration for Task Master monorepo
5-
* Provides shared defaults for all packages
6-
* Individual packages can extend this config with package-specific settings
9+
* Vitest workspace configuration for Task Master monorepo
10+
*
11+
* Convention: .spec.ts = unit tests, .test.ts = integration tests
712
*/
813
export default defineConfig({
914
test: {
10-
// Enable global test APIs (describe, it, expect, etc.)
11-
globals: true,
12-
13-
// Default environment for all packages (Node.js)
14-
environment: 'node',
15+
projects: [
16+
// Core package
17+
{
18+
test: {
19+
name: 'core:unit',
20+
root: './packages/tm-core',
21+
include: ['tests/**/*.spec.ts', 'src/**/*.spec.ts'],
22+
setupFiles: ['./tests/setup.ts']
23+
},
24+
resolve: {
25+
alias: {
26+
'@': path.resolve(__dirname, './packages/tm-core/src'),
27+
'@/types': path.resolve(__dirname, './packages/tm-core/src/types'),
28+
'@/providers': path.resolve(
29+
__dirname,
30+
'./packages/tm-core/src/providers'
31+
),
32+
'@/storage': path.resolve(
33+
__dirname,
34+
'./packages/tm-core/src/storage'
35+
),
36+
'@/parser': path.resolve(
37+
__dirname,
38+
'./packages/tm-core/src/parser'
39+
),
40+
'@/utils': path.resolve(__dirname, './packages/tm-core/src/utils'),
41+
'@/errors': path.resolve(__dirname, './packages/tm-core/src/errors')
42+
}
43+
}
44+
},
45+
{
46+
test: {
47+
name: 'core:integration',
48+
root: './packages/tm-core',
49+
include: ['tests/**/*.test.ts', 'src/**/*.test.ts'],
50+
setupFiles: ['./tests/setup.ts']
51+
},
52+
resolve: {
53+
alias: {
54+
'@': path.resolve(__dirname, './packages/tm-core/src'),
55+
'@/types': path.resolve(__dirname, './packages/tm-core/src/types'),
56+
'@/providers': path.resolve(
57+
__dirname,
58+
'./packages/tm-core/src/providers'
59+
),
60+
'@/storage': path.resolve(
61+
__dirname,
62+
'./packages/tm-core/src/storage'
63+
),
64+
'@/parser': path.resolve(
65+
__dirname,
66+
'./packages/tm-core/src/parser'
67+
),
68+
'@/utils': path.resolve(__dirname, './packages/tm-core/src/utils'),
69+
'@/errors': path.resolve(__dirname, './packages/tm-core/src/errors')
70+
}
71+
}
72+
},
1573

16-
// Common test file patterns
17-
include: [
18-
'tests/**/*.test.ts',
19-
'tests/**/*.spec.ts',
20-
'src/**/*.test.ts',
21-
'src/**/*.spec.ts'
22-
],
74+
// CLI app
75+
{
76+
test: {
77+
name: 'cli:unit',
78+
root: './apps/cli',
79+
include: ['tests/**/*.spec.ts', 'src/**/*.spec.ts']
80+
}
81+
},
82+
{
83+
test: {
84+
name: 'cli:integration',
85+
root: './apps/cli',
86+
include: ['tests/**/*.test.ts', 'src/**/*.test.ts'],
87+
// Integration tests spawn CLI processes - need longer timeouts
88+
testTimeout: 30000,
89+
hookTimeout: 15000
90+
}
91+
},
2392

24-
// Common exclusions
25-
exclude: ['node_modules', 'dist', '.git', '.cache', '**/node_modules/**'],
26-
27-
// Coverage configuration
28-
coverage: {
29-
provider: 'v8',
30-
enabled: true,
31-
reporter: ['text', 'json', 'html'],
32-
include: ['src/**/*.ts'],
33-
exclude: [
34-
'node_modules/',
35-
'dist/',
36-
'tests/',
37-
'**/*.test.ts',
38-
'**/*.spec.ts',
39-
'**/*.d.ts',
40-
'**/mocks/**',
41-
'**/fixtures/**',
42-
'**/types/**',
43-
'vitest.config.ts',
44-
'src/index.ts'
45-
],
46-
// Default thresholds (can be overridden per package)
47-
thresholds: {
48-
branches: 70,
49-
functions: 70,
50-
lines: 70,
51-
statements: 70
93+
// MCP app
94+
{
95+
test: {
96+
name: 'mcp:unit',
97+
root: './apps/mcp',
98+
include: ['tests/**/*.spec.ts', 'src/**/*.spec.ts']
99+
}
100+
},
101+
{
102+
test: {
103+
name: 'mcp:integration',
104+
root: './apps/mcp',
105+
include: ['tests/**/*.test.ts', 'src/**/*.test.ts']
106+
}
52107
}
53-
},
54-
55-
// Test execution settings
56-
testTimeout: 10000,
57-
clearMocks: true,
58-
restoreMocks: true,
59-
mockReset: true
108+
]
60109
}
61110
});

vitest.integration.config.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { defineConfig } from 'vitest/config';
2+
3+
/**
4+
* Integration test configuration
5+
* Runs .test.ts files only, no coverage
6+
*/
7+
export default defineConfig({
8+
test: {
9+
globals: true,
10+
environment: 'node',
11+
include: ['tests/**/*.test.ts', 'src/**/*.test.ts'],
12+
exclude: ['node_modules', 'dist', '.git', '.cache', '**/node_modules/**'],
13+
coverage: { enabled: false },
14+
passWithNoTests: true,
15+
testTimeout: 30000,
16+
clearMocks: true,
17+
restoreMocks: true,
18+
mockReset: true
19+
}
20+
});

vitest.unit.config.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { defineConfig } from 'vitest/config';
2+
3+
/**
4+
* Unit test configuration
5+
* Runs .spec.ts files only, no coverage
6+
*/
7+
export default defineConfig({
8+
test: {
9+
globals: true,
10+
environment: 'node',
11+
include: ['tests/**/*.spec.ts', 'src/**/*.spec.ts'],
12+
exclude: ['node_modules', 'dist', '.git', '.cache', '**/node_modules/**'],
13+
coverage: { enabled: false },
14+
passWithNoTests: true,
15+
testTimeout: 10000,
16+
clearMocks: true,
17+
restoreMocks: true,
18+
mockReset: true
19+
}
20+
});

0 commit comments

Comments
 (0)