mirror of
https://github.com/eyaltoledano/claude-task-master.git
synced 2026-01-30 06:12:05 +00:00
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.
This commit is contained in:
@@ -16,8 +16,8 @@
|
|||||||
"test": "vitest run",
|
"test": "vitest run",
|
||||||
"test:watch": "vitest",
|
"test:watch": "vitest",
|
||||||
"test:coverage": "vitest run --coverage",
|
"test:coverage": "vitest run --coverage",
|
||||||
"test:unit": "vitest run '**/*.spec.ts'",
|
"test:unit": "vitest run --config ../../vitest.unit.config.ts",
|
||||||
"test:integration": "vitest run '**/*.test.ts'",
|
"test:integration": "vitest run --config ../../vitest.integration.config.ts",
|
||||||
"test:e2e": "vitest run --dir tests/e2e",
|
"test:e2e": "vitest run --dir tests/e2e",
|
||||||
"test:ci": "vitest run --coverage --reporter=dot"
|
"test:ci": "vitest run --coverage --reporter=dot"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,28 +0,0 @@
|
|||||||
import { defineConfig, mergeConfig } from 'vitest/config';
|
|
||||||
import rootConfig from '../../vitest.config';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* CLI package Vitest configuration
|
|
||||||
* Extends root config with CLI-specific settings
|
|
||||||
*
|
|
||||||
* Integration tests (.test.ts) spawn CLI processes and need more time.
|
|
||||||
* The 30s timeout is reasonable now that auto-update network calls are skipped
|
|
||||||
* when TASKMASTER_SKIP_AUTO_UPDATE=1 or NODE_ENV=test.
|
|
||||||
*/
|
|
||||||
export default mergeConfig(
|
|
||||||
rootConfig,
|
|
||||||
defineConfig({
|
|
||||||
test: {
|
|
||||||
// CLI-specific test patterns
|
|
||||||
include: [
|
|
||||||
'tests/**/*.test.ts',
|
|
||||||
'tests/**/*.spec.ts',
|
|
||||||
'src/**/*.test.ts',
|
|
||||||
'src/**/*.spec.ts'
|
|
||||||
],
|
|
||||||
// Integration tests spawn CLI processes - 30s is reasonable with optimized startup
|
|
||||||
testTimeout: 30000,
|
|
||||||
hookTimeout: 15000
|
|
||||||
}
|
|
||||||
})
|
|
||||||
);
|
|
||||||
@@ -17,8 +17,8 @@
|
|||||||
"test": "vitest run",
|
"test": "vitest run",
|
||||||
"test:watch": "vitest",
|
"test:watch": "vitest",
|
||||||
"test:coverage": "vitest run --coverage",
|
"test:coverage": "vitest run --coverage",
|
||||||
"test:unit": "vitest run '**/*.spec.ts'",
|
"test:unit": "vitest run --config ../../vitest.unit.config.ts",
|
||||||
"test:integration": "vitest run '**/*.test.ts'",
|
"test:integration": "vitest run --config ../../vitest.integration.config.ts",
|
||||||
"test:ci": "vitest run --coverage --reporter=dot"
|
"test:ci": "vitest run --coverage --reporter=dot"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|||||||
@@ -1,21 +0,0 @@
|
|||||||
import { defineConfig, mergeConfig } from 'vitest/config';
|
|
||||||
import rootConfig from '../../vitest.config';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* MCP package Vitest configuration
|
|
||||||
* Extends root config with MCP-specific settings
|
|
||||||
*/
|
|
||||||
export default mergeConfig(
|
|
||||||
rootConfig,
|
|
||||||
defineConfig({
|
|
||||||
test: {
|
|
||||||
// MCP-specific test patterns
|
|
||||||
include: [
|
|
||||||
'tests/**/*.test.ts',
|
|
||||||
'tests/**/*.spec.ts',
|
|
||||||
'src/**/*.test.ts',
|
|
||||||
'src/**/*.spec.ts'
|
|
||||||
]
|
|
||||||
}
|
|
||||||
})
|
|
||||||
);
|
|
||||||
@@ -21,8 +21,8 @@
|
|||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "vitest run",
|
"test": "vitest run",
|
||||||
"test:unit": "vitest run '**/*.spec.ts'",
|
"test:unit": "vitest run --config ../../vitest.unit.config.ts",
|
||||||
"test:integration": "vitest run '**/*.test.ts'",
|
"test:integration": "vitest run --config ../../vitest.integration.config.ts",
|
||||||
"test:watch": "vitest",
|
"test:watch": "vitest",
|
||||||
"test:coverage": "vitest run --coverage",
|
"test:coverage": "vitest run --coverage",
|
||||||
"lint": "biome check --write",
|
"lint": "biome check --write",
|
||||||
|
|||||||
@@ -1,57 +0,0 @@
|
|||||||
import path from 'node:path';
|
|
||||||
import { fileURLToPath } from 'node:url';
|
|
||||||
import { defineConfig, mergeConfig } from 'vitest/config';
|
|
||||||
import rootConfig from '../../vitest.config';
|
|
||||||
|
|
||||||
// __dirname in ESM
|
|
||||||
const __filename = fileURLToPath(import.meta.url);
|
|
||||||
const __dirname = path.dirname(__filename);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Core package Vitest configuration
|
|
||||||
* Extends root config with core-specific settings including:
|
|
||||||
* - Path aliases for cleaner imports
|
|
||||||
* - Test setup file
|
|
||||||
* - Higher coverage thresholds (80%)
|
|
||||||
*/
|
|
||||||
export default mergeConfig(
|
|
||||||
rootConfig,
|
|
||||||
defineConfig({
|
|
||||||
test: {
|
|
||||||
// Core-specific test patterns
|
|
||||||
include: [
|
|
||||||
'tests/**/*.test.ts',
|
|
||||||
'tests/**/*.spec.ts',
|
|
||||||
'tests/{unit,integration,e2e}/**/*.{test,spec}.ts',
|
|
||||||
'src/**/*.test.ts',
|
|
||||||
'src/**/*.spec.ts'
|
|
||||||
],
|
|
||||||
|
|
||||||
// Core-specific setup
|
|
||||||
setupFiles: ['./tests/setup.ts'],
|
|
||||||
|
|
||||||
// Higher coverage thresholds for core package
|
|
||||||
coverage: {
|
|
||||||
thresholds: {
|
|
||||||
branches: 80,
|
|
||||||
functions: 80,
|
|
||||||
lines: 80,
|
|
||||||
statements: 80
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
// Path aliases for cleaner imports
|
|
||||||
resolve: {
|
|
||||||
alias: {
|
|
||||||
'@': path.resolve(__dirname, './src'),
|
|
||||||
'@/types': path.resolve(__dirname, './src/types'),
|
|
||||||
'@/providers': path.resolve(__dirname, './src/providers'),
|
|
||||||
'@/storage': path.resolve(__dirname, './src/storage'),
|
|
||||||
'@/parser': path.resolve(__dirname, './src/parser'),
|
|
||||||
'@/utils': path.resolve(__dirname, './src/utils'),
|
|
||||||
'@/errors': path.resolve(__dirname, './src/errors')
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
);
|
|
||||||
132
vitest.config.ts
132
vitest.config.ts
@@ -1,61 +1,93 @@
|
|||||||
|
import path from 'node:path';
|
||||||
|
import { fileURLToPath } from 'node:url';
|
||||||
import { defineConfig } from 'vitest/config';
|
import { defineConfig } from 'vitest/config';
|
||||||
|
|
||||||
|
const __filename = fileURLToPath(import.meta.url);
|
||||||
|
const __dirname = path.dirname(__filename);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Root Vitest configuration for Task Master monorepo
|
* Vitest workspace configuration for Task Master monorepo
|
||||||
* Provides shared defaults for all packages
|
*
|
||||||
* Individual packages can extend this config with package-specific settings
|
* Convention: .spec.ts = unit tests, .test.ts = integration tests
|
||||||
*/
|
*/
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
test: {
|
test: {
|
||||||
// Enable global test APIs (describe, it, expect, etc.)
|
projects: [
|
||||||
globals: true,
|
// Core package
|
||||||
|
{
|
||||||
|
test: {
|
||||||
|
name: 'core:unit',
|
||||||
|
root: './packages/tm-core',
|
||||||
|
include: ['tests/**/*.spec.ts', 'src/**/*.spec.ts'],
|
||||||
|
setupFiles: ['./tests/setup.ts']
|
||||||
|
},
|
||||||
|
resolve: {
|
||||||
|
alias: {
|
||||||
|
'@': path.resolve(__dirname, './packages/tm-core/src'),
|
||||||
|
'@/types': path.resolve(__dirname, './packages/tm-core/src/types'),
|
||||||
|
'@/providers': path.resolve(__dirname, './packages/tm-core/src/providers'),
|
||||||
|
'@/storage': path.resolve(__dirname, './packages/tm-core/src/storage'),
|
||||||
|
'@/parser': path.resolve(__dirname, './packages/tm-core/src/parser'),
|
||||||
|
'@/utils': path.resolve(__dirname, './packages/tm-core/src/utils'),
|
||||||
|
'@/errors': path.resolve(__dirname, './packages/tm-core/src/errors')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
test: {
|
||||||
|
name: 'core:integration',
|
||||||
|
root: './packages/tm-core',
|
||||||
|
include: ['tests/**/*.test.ts', 'src/**/*.test.ts'],
|
||||||
|
setupFiles: ['./tests/setup.ts']
|
||||||
|
},
|
||||||
|
resolve: {
|
||||||
|
alias: {
|
||||||
|
'@': path.resolve(__dirname, './packages/tm-core/src'),
|
||||||
|
'@/types': path.resolve(__dirname, './packages/tm-core/src/types'),
|
||||||
|
'@/providers': path.resolve(__dirname, './packages/tm-core/src/providers'),
|
||||||
|
'@/storage': path.resolve(__dirname, './packages/tm-core/src/storage'),
|
||||||
|
'@/parser': path.resolve(__dirname, './packages/tm-core/src/parser'),
|
||||||
|
'@/utils': path.resolve(__dirname, './packages/tm-core/src/utils'),
|
||||||
|
'@/errors': path.resolve(__dirname, './packages/tm-core/src/errors')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
// Default environment for all packages (Node.js)
|
|
||||||
environment: 'node',
|
// CLI app
|
||||||
|
{
|
||||||
|
test: {
|
||||||
|
name: 'cli:unit',
|
||||||
|
root: './apps/cli',
|
||||||
|
include: ['tests/**/*.spec.ts', 'src/**/*.spec.ts']
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
test: {
|
||||||
|
name: 'cli:integration',
|
||||||
|
root: './apps/cli',
|
||||||
|
include: ['tests/**/*.test.ts', 'src/**/*.test.ts'],
|
||||||
|
// Integration tests spawn CLI processes - need longer timeouts
|
||||||
|
testTimeout: 30000,
|
||||||
|
hookTimeout: 15000
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
// Common test file patterns
|
// MCP app
|
||||||
include: [
|
{
|
||||||
'tests/**/*.test.ts',
|
test: {
|
||||||
'tests/**/*.spec.ts',
|
name: 'mcp:unit',
|
||||||
'src/**/*.test.ts',
|
root: './apps/mcp',
|
||||||
'src/**/*.spec.ts'
|
include: ['tests/**/*.spec.ts', 'src/**/*.spec.ts']
|
||||||
],
|
}
|
||||||
|
},
|
||||||
// Common exclusions
|
{
|
||||||
exclude: ['node_modules', 'dist', '.git', '.cache', '**/node_modules/**'],
|
test: {
|
||||||
|
name: 'mcp:integration',
|
||||||
// Coverage configuration
|
root: './apps/mcp',
|
||||||
coverage: {
|
include: ['tests/**/*.test.ts', 'src/**/*.test.ts']
|
||||||
provider: 'v8',
|
}
|
||||||
enabled: true,
|
|
||||||
reporter: ['text', 'json', 'html'],
|
|
||||||
include: ['src/**/*.ts'],
|
|
||||||
exclude: [
|
|
||||||
'node_modules/',
|
|
||||||
'dist/',
|
|
||||||
'tests/',
|
|
||||||
'**/*.test.ts',
|
|
||||||
'**/*.spec.ts',
|
|
||||||
'**/*.d.ts',
|
|
||||||
'**/mocks/**',
|
|
||||||
'**/fixtures/**',
|
|
||||||
'**/types/**',
|
|
||||||
'vitest.config.ts',
|
|
||||||
'src/index.ts'
|
|
||||||
],
|
|
||||||
// Default thresholds (can be overridden per package)
|
|
||||||
thresholds: {
|
|
||||||
branches: 70,
|
|
||||||
functions: 70,
|
|
||||||
lines: 70,
|
|
||||||
statements: 70
|
|
||||||
}
|
}
|
||||||
},
|
]
|
||||||
|
|
||||||
// Test execution settings
|
|
||||||
testTimeout: 10000,
|
|
||||||
clearMocks: true,
|
|
||||||
restoreMocks: true,
|
|
||||||
mockReset: true
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
20
vitest.integration.config.ts
Normal file
20
vitest.integration.config.ts
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
import { defineConfig } from 'vitest/config';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Integration test configuration
|
||||||
|
* Runs .test.ts files only, no coverage
|
||||||
|
*/
|
||||||
|
export default defineConfig({
|
||||||
|
test: {
|
||||||
|
globals: true,
|
||||||
|
environment: 'node',
|
||||||
|
include: ['tests/**/*.test.ts', 'src/**/*.test.ts'],
|
||||||
|
exclude: ['node_modules', 'dist', '.git', '.cache', '**/node_modules/**'],
|
||||||
|
coverage: { enabled: false },
|
||||||
|
passWithNoTests: true,
|
||||||
|
testTimeout: 30000,
|
||||||
|
clearMocks: true,
|
||||||
|
restoreMocks: true,
|
||||||
|
mockReset: true
|
||||||
|
}
|
||||||
|
});
|
||||||
20
vitest.unit.config.ts
Normal file
20
vitest.unit.config.ts
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
import { defineConfig } from 'vitest/config';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Unit test configuration
|
||||||
|
* Runs .spec.ts files only, no coverage
|
||||||
|
*/
|
||||||
|
export default defineConfig({
|
||||||
|
test: {
|
||||||
|
globals: true,
|
||||||
|
environment: 'node',
|
||||||
|
include: ['tests/**/*.spec.ts', 'src/**/*.spec.ts'],
|
||||||
|
exclude: ['node_modules', 'dist', '.git', '.cache', '**/node_modules/**'],
|
||||||
|
coverage: { enabled: false },
|
||||||
|
passWithNoTests: true,
|
||||||
|
testTimeout: 10000,
|
||||||
|
clearMocks: true,
|
||||||
|
restoreMocks: true,
|
||||||
|
mockReset: true
|
||||||
|
}
|
||||||
|
});
|
||||||
Reference in New Issue
Block a user