This repository has been archived on 2026-11-17. You can view files and clone it, but cannot push or open issues or pull requests.
gitgram-ai/gitgram/backend/jest.config.js
caelum0x bab51cd428 test(backend): exclude e2e suite from default jest run
The default jest.config.js matched tests/e2e/*.e2e.test.ts, which are meant to
run only under jest.e2e.config.js against a real Postgres + Redis (npm run
test:e2e). Running them under the default (mocked) config made the parallel
suite non-deterministic: posts.e2e and snippets.e2e collided on shared DB state
and intermittently failed, while passing in isolation/serial.

Add testPathIgnorePatterns for tests/e2e so the default unit/integration run is
deterministic and needs no Docker datastores. The e2e suite still runs via its
own config. Default suite now green in parallel (57 suites / 1434 tests).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-09-06 12:13:32 +03:00

32 lines
1.2 KiB
JavaScript

module.exports = {
preset: 'ts-jest',
testEnvironment: 'node',
roots: ['<rootDir>/src', '<rootDir>/tests'],
testMatch: ['**/__tests__/**/*.ts', '**/?(*.)+(spec|test).ts'],
// The end-to-end suite (tests/e2e/*.e2e.test.ts) runs the REAL Express app
// against a REAL Postgres + Redis and has its own config (jest.e2e.config.js,
// run via `npm run test:e2e`). Excluding it here keeps the default unit /
// integration run deterministic — it must not require Docker datastores and
// must not collide on ports when run in parallel.
testPathIgnorePatterns: ['/node_modules/', '<rootDir>/tests/e2e/'],
transform: {
'^.+\\.ts$': ['ts-jest', { diagnostics: false }],
},
collectCoverageFrom: [
'src/**/*.ts',
'!src/**/*.d.ts',
'!src/index.ts',
],
coverageDirectory: 'coverage',
coverageReporters: ['text', 'lcov', 'html'],
moduleNameMapper: {
'^@/(.*)$': '<rootDir>/src/$1',
'^@trpc/server(.*)$': '<rootDir>/tests/__mocks__/@trpc/server$1',
'^../trpc/adapter$': '<rootDir>/tests/__mocks__/trpcAdapter',
'^../../trpc/adapter$': '<rootDir>/tests/__mocks__/trpcAdapter',
'^./trpc/adapter$': '<rootDir>/tests/__mocks__/trpcAdapter',
},
setupFilesAfterEnv: ['<rootDir>/tests/setup.ts'],
};