Files
iptvnator/jest.web-esm.workspace.ts
T
4grayandClaude Opus 5 7952e6444d test(playback): stub the inline player in the VOD details spec (#1440)
`VodDetailsComponent` specs imported the real component tree, so every
`createComponent` pulled in `PortalInlinePlayerComponent` ->
`WebPlayerViewComponent` -> ArtPlayer, video.js and the embedded-MPV
bridge, and instantiated all of it. The suite's slowest test measured
2521ms idle on a 10-core machine -- a 2.0x margin against Jest's 5000ms
default, thin enough that a loaded worker failed tests that had no defect
behind them.

Swap the inline player for a stand-in that mirrors the selector and the
template's bindings; the specs only assert what the host hands the
player. Worst test drops 2521ms -> 306ms and the summed test time 3427ms
-> 632ms. Assertions are unchanged.

Also raise testTimeout to 15s for the shared web-ESM config. The 5s
default is thin for Angular component specs generally: TestBed compiles
and instantiates a real tree per test, and CI runners are much slower
per-core than a dev machine. This is headroom, not a mute -- a spec that
genuinely hangs still fails, just later.

Attribution, full suite at --maxWorkers=48 on 10 cores:
- forced back to 5000ms: VodDetails no longer fails (it did before this
  change); HtmlVideoPlayer still does, which is what the timeout covers
- shipped 15000ms: 2/2 runs, 975/975 passing

All six projects sharing the config pass: 1656 tests.

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
2026-08-13 22:28:50 +02:00

51 lines
2.1 KiB
TypeScript

import { nxPreset } from '@nx/jest/preset.js';
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,
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',
'^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,
};