Skip to content

Commit 526cb58

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 526cb58

9 files changed

Lines changed: 128 additions & 162 deletions

File tree

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: 82 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,93 @@
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(__dirname, './packages/tm-core/src/providers'),
29+
'@/storage': path.resolve(__dirname, './packages/tm-core/src/storage'),
30+
'@/parser': path.resolve(__dirname, './packages/tm-core/src/parser'),
31+
'@/utils': path.resolve(__dirname, './packages/tm-core/src/utils'),
32+
'@/errors': path.resolve(__dirname, './packages/tm-core/src/errors')
33+
}
34+
}
35+
},
36+
{
37+
test: {
38+
name: 'core:integration',
39+
root: './packages/tm-core',
40+
include: ['tests/**/*.test.ts', 'src/**/*.test.ts'],
41+
setupFiles: ['./tests/setup.ts']
42+
},
43+
resolve: {
44+
alias: {
45+
'@': path.resolve(__dirname, './packages/tm-core/src'),
46+
'@/types': path.resolve(__dirname, './packages/tm-core/src/types'),
47+
'@/providers': path.resolve(__dirname, './packages/tm-core/src/providers'),
48+
'@/storage': path.resolve(__dirname, './packages/tm-core/src/storage'),
49+
'@/parser': path.resolve(__dirname, './packages/tm-core/src/parser'),
50+
'@/utils': path.resolve(__dirname, './packages/tm-core/src/utils'),
51+
'@/errors': path.resolve(__dirname, './packages/tm-core/src/errors')
52+
}
53+
}
54+
},
1555

16-
// Common test file patterns
17-
include: [
18-
'tests/**/*.test.ts',
19-
'tests/**/*.spec.ts',
20-
'src/**/*.test.ts',
21-
'src/**/*.spec.ts'
22-
],
56+
57+
// CLI app
58+
{
59+
test: {
60+
name: 'cli:unit',
61+
root: './apps/cli',
62+
include: ['tests/**/*.spec.ts', 'src/**/*.spec.ts']
63+
}
64+
},
65+
{
66+
test: {
67+
name: 'cli:integration',
68+
root: './apps/cli',
69+
include: ['tests/**/*.test.ts', 'src/**/*.test.ts'],
70+
// Integration tests spawn CLI processes - need longer timeouts
71+
testTimeout: 30000,
72+
hookTimeout: 15000
73+
}
74+
},
2375

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
76+
// MCP app
77+
{
78+
test: {
79+
name: 'mcp:unit',
80+
root: './apps/mcp',
81+
include: ['tests/**/*.spec.ts', 'src/**/*.spec.ts']
82+
}
83+
},
84+
{
85+
test: {
86+
name: 'mcp:integration',
87+
root: './apps/mcp',
88+
include: ['tests/**/*.test.ts', 'src/**/*.test.ts']
89+
}
5290
}
53-
},
54-
55-
// Test execution settings
56-
testTimeout: 10000,
57-
clearMocks: true,
58-
restoreMocks: true,
59-
mockReset: true
91+
]
6092
}
6193
});

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)