forked from zereight/gitlab-mcp
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathjest.config.js
More file actions
73 lines (69 loc) · 2.96 KB
/
jest.config.js
File metadata and controls
73 lines (69 loc) · 2.96 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
const fs = require('fs');
const path = require('path');
// Check if we're explicitly running unit tests only
const forceUnitOnly = process.env.JEST_UNIT_ONLY === 'true';
// Check if .env.test exists to determine if integration tests should run
const envTestPath = path.resolve(__dirname, '.env.test');
const integrationTestsEnabled = !forceUnitOnly && fs.existsSync(envTestPath);
// Check for verbose flag from command line
const isVerbose = process.argv.includes('--verbose');
/** @type {import('jest').Config} */
module.exports = {
preset: 'ts-jest',
testEnvironment: 'node',
setupFilesAfterEnv: [
integrationTestsEnabled
? '<rootDir>/tests/setup/setupTests.ts'
: '<rootDir>/tests/setup/setupTests.unit.ts',
],
transform: {
'^.+\\.ts$': [
'ts-jest',
{
tsconfig: {
// ts-jest requires node resolution (bundler not supported by ts-jest)
ignoreDeprecations: '6.0',
module: 'commonjs',
moduleResolution: 'node',
allowSyntheticDefaultImports: true,
esModuleInterop: true,
},
},
],
},
// Map .js imports to .ts files for ESM compatibility with CommonJS Jest
// This allows proper resolution of imports like "from './file.js'" to find ./file.ts
moduleNameMapper: {
'^(\\.{1,2}/.*)\\.js$': '$1',
},
// Transform ESM modules from node_modules
transformIgnorePatterns: ['node_modules/(?!(@clack/prompts|@clack/core|sisteransi|picocolors)/)'],
testMatch: integrationTestsEnabled
? ['**/tests/**/*.test.ts', '**/?(*.)+(spec|test).ts']
: ['**/tests/unit/**/*.test.ts'],
collectCoverageFrom: ['src/**/*.ts', '!src/**/*.d.ts', '!tests/**/*', '!dist/**/*'],
coverageDirectory: 'coverage',
coverageReporters: ['text', 'lcov', 'html', 'json-summary'],
// Control output verbosity - by default suppress verbose output, show only warnings/errors
verbose: isVerbose,
silent: !isVerbose, // Suppress console.log output in tests unless verbose mode
testPathIgnorePatterns: integrationTestsEnabled
? ['<rootDir>/dist/', '<rootDir>/node_modules/']
: ['<rootDir>/dist/', '<rootDir>/node_modules/', '<rootDir>/tests/integration/'],
modulePathIgnorePatterns: ['<rootDir>/dist/'],
globalSetup: integrationTestsEnabled ? '<rootDir>/tests/setup/globalSetup.js' : undefined,
globalTeardown: integrationTestsEnabled ? '<rootDir>/tests/setup/globalTeardown.js' : undefined,
moduleDirectories: ['node_modules', 'src'],
// Use lifecycle pattern for integration tests with proper sequencing
...(integrationTestsEnabled && {
testSequencer: '<rootDir>/tests/setup/sequencer.js',
maxWorkers: 1, // Serial execution for lifecycle tests
testTimeout: 30000, // Longer timeout for API calls
}),
...(!integrationTestsEnabled && {
testTimeout: 10000, // Standard timeout for unit tests
maxWorkers: '50%', // Parallel execution with proper per-file mock isolation
verbose: false,
silent: true, // Suppress console.log output in unit tests
}),
};