Skip to content

Commit 89df56f

Browse files
author
Marvin Zhang
committed
feat: Update Vitest configuration across packages and add shared base config
1 parent 294a3de commit 89df56f

File tree

7 files changed

+110
-40
lines changed

7 files changed

+110
-40
lines changed

package.json

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,13 @@
77
"build:test": "pnpm --filter @devlog/ai build && pnpm --filter @devlog/core build && pnpm --filter @devlog/web build:test",
88
"start": "pnpm --filter @devlog/mcp start",
99
"dev": "pnpm --filter @devlog/mcp dev",
10-
"test": "pnpm -r test",
11-
"test:watch": "pnpm -r test:watch",
12-
"test:coverage": "pnpm --filter @devlog/mcp test -- --coverage",
10+
"test": "vitest run",
11+
"test:watch": "vitest",
12+
"test:ui": "vitest --ui",
13+
"test:coverage": "vitest run --coverage",
14+
"test:packages": "pnpm -r test",
15+
"test:watch:packages": "pnpm -r test:watch",
16+
"test:coverage:packages": "pnpm -r test -- --coverage",
1317
"test:integration": "pnpm --filter @devlog/mcp test:integration",
1418
"clean": "pnpm -r clean && rm -f *.tsbuildinfo",
1519
"install-all": "pnpm install",
@@ -45,7 +49,8 @@
4549
"husky": "9.1.7",
4650
"lint-staged": "16.1.2",
4751
"prettier": "3.6.1",
48-
"typescript": "^5.0.0"
52+
"typescript": "^5.0.0",
53+
"vitest": "^2.1.9"
4954
},
5055
"engines": {
5156
"node": ">=18",

packages/ai/vitest.config.ts

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
1-
import { defineConfig } from 'vitest/config';
1+
import { defineConfig, mergeConfig } from 'vitest/config';
2+
import { baseConfig } from '../../vitest.config.base.js';
23

3-
export default defineConfig({
4-
test: {
5-
globals: true,
6-
environment: 'node',
7-
passWithNoTests: true,
8-
},
9-
});
4+
export default defineConfig(
5+
mergeConfig(baseConfig, {
6+
// AI-specific overrides
7+
test: {
8+
// AI package might not have tests yet, so pass with no tests
9+
passWithNoTests: true,
10+
},
11+
}),
12+
);

packages/core/vitest.config.ts

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
1-
import { defineConfig } from 'vitest/config';
1+
import { defineConfig, mergeConfig } from 'vitest/config';
2+
import { baseConfig } from '../../vitest.config.base.js';
23

3-
export default defineConfig({
4-
test: {
5-
environment: 'node',
6-
globals: true,
7-
testTimeout: 30000,
8-
// Handle dynamic imports better
9-
deps: {
10-
external: ['better-sqlite3'],
4+
export default defineConfig(
5+
mergeConfig(baseConfig, {
6+
// Core-specific overrides
7+
test: {
8+
// Handle dynamic imports better for core package
9+
deps: {
10+
external: ['better-sqlite3'],
11+
},
12+
// Keep the existing timeout since core has longer-running tests
13+
testTimeout: 30000,
1114
},
12-
},
13-
});
15+
}),
16+
);

packages/mcp/vitest.config.ts

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,13 @@
1-
import { defineConfig } from 'vitest/config';
1+
import { defineConfig, mergeConfig } from 'vitest/config';
2+
import { baseConfig } from '../../vitest.config.base.js';
23

3-
export default defineConfig({
4-
test: {
5-
globals: true,
6-
environment: 'node',
7-
include: ['src/**/*.test.ts', 'tests/**/*.test.ts'],
8-
exclude: ['node_modules', 'build'],
9-
coverage: {
10-
provider: 'v8',
11-
reporter: ['text', 'json', 'html'],
12-
exclude: [
13-
'node_modules/',
14-
'build/',
15-
'src/test.ts', // Keep the old integration test file
16-
],
4+
export default defineConfig(
5+
mergeConfig(baseConfig, {
6+
// MCP-specific overrides
7+
test: {
8+
// Add any MCP-specific test configuration here
9+
// For example, if you need different timeout:
10+
// testTimeout: 45000,
1711
},
18-
},
19-
});
12+
}),
13+
);

pnpm-lock.yaml

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vitest.config.base.ts

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
import { defineConfig } from 'vitest/config';
2+
import type { ViteUserConfig as UserConfig } from 'vitest/config';
3+
4+
/**
5+
* Shared Vitest configuration for all packages in the monorepo
6+
*/
7+
export const baseConfig: UserConfig = {
8+
test: {
9+
globals: true,
10+
environment: 'node',
11+
include: ['src/**/*.test.ts', 'tests/**/*.test.ts'],
12+
exclude: ['node_modules', 'build', 'dist'],
13+
testTimeout: 30000,
14+
coverage: {
15+
provider: 'v8',
16+
reporter: ['text', 'json', 'html'],
17+
include: [
18+
'src/**/*.ts', // Include all source files
19+
'app/**/*.ts', // Include app-specific files
20+
],
21+
exclude: [
22+
'node_modules/',
23+
'build/',
24+
'dist/',
25+
'src/__tests__/**', // Exclude test files from coverage
26+
'src/types/**', // Exclude type definitions
27+
'**/index.ts', // Exclude barrel export files
28+
'**/*.d.ts', // Exclude TypeScript declaration files
29+
'src/config/**', // Configuration files
30+
'tmp/**', // Temporary files
31+
],
32+
// Coverage thresholds (can be overridden per package)
33+
thresholds: {
34+
global: {
35+
branches: 60,
36+
functions: 60,
37+
lines: 60,
38+
statements: 60
39+
}
40+
}
41+
},
42+
},
43+
};
44+
45+
/**
46+
* Default configuration that can be used by packages
47+
*/
48+
export default defineConfig(baseConfig);

vitest.workspace.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { defineWorkspace } from 'vitest/config';
2+
3+
/**
4+
* Vitest workspace configuration for the devlog monorepo
5+
* This allows running tests across all packages from the root
6+
*/
7+
export default defineWorkspace([
8+
// Include all packages with tests
9+
'packages/core',
10+
'packages/mcp',
11+
'packages/ai',
12+
// Add web package when it gets tests
13+
// 'packages/web',
14+
]);

0 commit comments

Comments
 (0)