mirror of
https://github.com/hanzoai/chat.git
synced 2026-09-30 20:51:17 +00:00
`babel-jest` is jest's default transformer, and with no babel config it is a
no-op. The api workspace has none — not in api/, not at the repo root, not in
package.json — so nothing there was ever converted. That is invisible until a
CommonJS `require` reaches a dependency that ships ESM:
models/tx.spec.js
-> @hanzochat/api
-> @hanzochat/agents
-> @langchain/mistralai
-> @mistralai/mistralai/esm/index.js "export * from './lib/config.js'"
node throws `SyntaxError: Unexpected token 'export'` at import time, jest counts
one failed suite and ZERO tests, and every suite that touches a model or an
agent goes quiet. 66 of the 80 silent suites died on that one line.
Both halves are load-bearing and were verified separately: with the babel config
but @mistralai/mistralai still excluded by `transformIgnorePatterns`, tx.spec.js
is back to 0 tests; the allow-list alone never worked because there was no
transformer behind it.
MEASURED, `jest --ci` over the api workspace:
suites 57 passed / 122 failed -> 105 passed / 73 failed
tests 1079 run, 717 passed -> 2707 run, 2280 passed
suites reporting zero tests: 80 -> 18
suites that passed before and fail after: 0
suites that ran fewer tests after than before: 0
The remaining 18 are not one lever. Each is a spec whose own `jest.mock` factory
for @hanzochat/data-schemas or @hanzochat/api omits a member the module under
test calls at require time — `createModels` (10), `createMethods`, `isEnabled`,
`violationCache`, and three express routers handed an undefined handler. They
need one fix each and are left failing loudly rather than skipped.
Co-authored-by: Hanzo Dev <[email protected]>
22 lines
1000 B
JavaScript
22 lines
1000 B
JavaScript
module.exports = {
|
|
testEnvironment: 'node',
|
|
clearMocks: true,
|
|
roots: ['<rootDir>'],
|
|
coverageDirectory: 'coverage',
|
|
testTimeout: 30000, // 30 seconds timeout for all tests
|
|
setupFiles: ['./test/jestSetup.js', './test/__mocks__/logger.js'],
|
|
moduleNameMapper: {
|
|
'~/(.*)': '<rootDir>/$1',
|
|
'~/data/auth.json': '<rootDir>/__mocks__/auth.mock.json',
|
|
'^openid-client/passport$': '<rootDir>/test/__mocks__/openid-client-passport.js', // Mock for the passport strategy part
|
|
'^openid-client$': '<rootDir>/test/__mocks__/openid-client.js',
|
|
},
|
|
/* `@hanzochat/agents` requires `@mistralai/mistralai`, whose entry point is
|
|
* ESM. Left untransformed it throws `SyntaxError: Unexpected token 'export'`
|
|
* at import time, which jest counts as one failed suite and ZERO tests — so
|
|
* every suite that reaches a model or an agent reports nothing at all. */
|
|
transformIgnorePatterns: [
|
|
'/node_modules/(?!(openid-client|oauth4webapi|jose|@mistralai/mistralai)/).*/',
|
|
],
|
|
};
|