mirror of
https://github.com/hanzoai/mcp.git
synced 2026-10-15 12:30:12 +00:00
Every suite had stopped executing. ts-jest peers on `typescript >=4.3 <7` and this repo builds against 7, so all twenty files died inside ConfigSet with "Cannot read properties of undefined (reading 'fileExists')" — twenty failures, zero tests, and nothing to read them by because the push gate deliberately runs typecheck and build rather than jest. swc transforms instead: it strips types rather than asking the compiler to, so it has no TypeScript version to disagree with, and `tsc --noEmit` already answers the question ts-jest was answering twice. Running as real ESM then exposed what the CommonJS fallback had hidden. jest.mock does not hoist there, so a static import binds the real module and the suite fails on `mockReturnValue is not a function` — an absent mock reported as a broken one. The search, autogui and ui suites now register through unstable_mockModule and import after it. One of them had never mocked fs at all: it cast fs.promises to a mocked type and called mockImplementation on the real module. 384 tests, twenty suites, all passing.
35 lines
1.1 KiB
JavaScript
35 lines
1.1 KiB
JavaScript
/** @type {import('jest').Config} */
|
|
export default {
|
|
extensionsToTreatAsEsm: ['.ts'],
|
|
testEnvironment: 'node',
|
|
testMatch: [
|
|
'**/test/**/*.test.ts',
|
|
'**/test/**/*.spec.ts'
|
|
],
|
|
// swc, not ts-jest: ts-jest peers on `typescript >=4.3 <7` and this repo builds
|
|
// against 7, so every suite died in ConfigSet before a test ran — 20 files, 0
|
|
// tests, reported as twenty separate failures. swc strips types instead of
|
|
// asking the compiler to, so it has no TypeScript version to disagree with.
|
|
//
|
|
// Nothing is lost by not typechecking here: `tsc --noEmit` is a gate of its own
|
|
// and runs on every push, so a type error fails the build rather than one suite.
|
|
transform: {
|
|
'^.+\\.ts$': ['@swc/jest', {
|
|
jsc: { parser: { syntax: 'typescript' }, target: 'es2022' },
|
|
module: { type: 'es6' },
|
|
}]
|
|
},
|
|
moduleNameMapper: {
|
|
'^(\\.{1,2}/.*)\\.js$': '$1',
|
|
},
|
|
collectCoverageFrom: [
|
|
'src/**/*.ts',
|
|
'!src/**/*.d.ts',
|
|
'!src/**/index.ts'
|
|
],
|
|
coverageDirectory: 'coverage',
|
|
coverageReporters: ['text', 'lcov', 'html'],
|
|
setupFilesAfterEnv: ['<rootDir>/test/setup.ts'],
|
|
testTimeout: 10000,
|
|
verbose: true
|
|
}; |