Files
iptvnator/jest.web-esm.workspace.ts
4grayandClaude Opus 5.5 e8902f472a perf(ci): skip unit coverage on PRs that cannot reach it and persist the Jest cache (#1711)
Pull requests whose changes cannot reach any Tier A test (allowlist checked against declared Tier A inputs and an AST scan of cross-project reads) skip the unit coverage suite; master pushes always run it. Jest's transform cache is persisted with actions/cache: PRs restore only, master pushes start empty and save. Paired CI runs: Tier A 9m04s cold -> 6m09s warm. Nx Cloud is intentionally not used.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-27 07:50:07 +02:00

56 lines
2.4 KiB
TypeScript

import { nxPreset } from '@nx/jest/preset';
import { createEsmPreset } from 'jest-preset-angular/presets/index.js';
const angularEsmPreset = createEsmPreset({
diagnostics: false,
tsconfig: '<rootDir>/apps/web/tsconfig.spec.json',
});
const coverageReporters = ['json', 'json-summary', 'lcovonly', 'text-summary'];
export default {
...nxPreset,
...angularEsmPreset,
// See jest.preset.js: CI persists the transform cache from this directory.
...(process.env.JEST_CACHE_DIRECTORY
? { cacheDirectory: process.env.JEST_CACHE_DIRECTORY }
: {}),
rootDir: '.',
roots: ['<rootDir>/apps/web', '<rootDir>/libs'],
// Jest's 5s default is thin for Angular component specs: TestBed compiles
// and instantiates a real component tree per test, and CI runners are far
// slower per-core than a dev machine. A starved worker then fails a test
// that is merely slow, with no defect behind it. Raised as headroom only —
// a spec that genuinely hangs still fails, just later.
testTimeout: 15_000,
setupFilesAfterEnv: ['<rootDir>/apps/web/src/test-setup.ts'],
resolver: nxPreset.resolver,
moduleFileExtensions: Array.from(
new Set([
...(nxPreset.moduleFileExtensions ?? []),
...(angularEsmPreset.moduleFileExtensions ?? []),
])
),
testMatch: nxPreset.testMatch,
testEnvironmentOptions: {},
snapshotSerializers: angularEsmPreset.snapshotSerializers,
moduleNameMapper: {
...(angularEsmPreset.moduleNameMapper ?? {}),
'^@iptvnator/portal/xtream/feature$':
'<rootDir>/apps/web/src/test-stubs/xtream-feature.stub.ts',
tslib: 'tslib/tslib.es6.js',
'^iptv-playlist-parser$':
'<rootDir>/apps/web/src/test-stubs/iptv-playlist-parser.mjs',
'^@package$': '<rootDir>/apps/web/src/test-stubs/package.mjs',
'^shaka-player$': '<rootDir>/apps/web/src/test-stubs/shaka-player.js',
'^rxjs': '<rootDir>/node_modules/rxjs/dist/bundles/rxjs.umd.js',
'^uuid$': '<rootDir>/node_modules/uuid/wrapper.mjs',
},
transform: angularEsmPreset.transform,
transformIgnorePatterns: [],
extensionsToTreatAsEsm: angularEsmPreset.extensionsToTreatAsEsm,
modulePathIgnorePatterns: ['<rootDir>/dist/', '<rootDir>/.nx/'],
watchPathIgnorePatterns: ['<rootDir>/dist/', '<rootDir>/.nx/'],
coverageReporters,
};