diff --git a/apps/xtream-mock-server/src/app/project-config.spec.ts b/apps/xtream-mock-server/src/app/project-config.spec.ts index 9c1895228..b1650df2b 100644 --- a/apps/xtream-mock-server/src/app/project-config.spec.ts +++ b/apps/xtream-mock-server/src/app/project-config.spec.ts @@ -87,3 +87,43 @@ describe('Playwright mock-server launch', () => { } ); }); + +describe('Nx E2E target defaults', () => { + type DependsOn = Array; + const nxJson = JSON.parse( + readFileSync(join(process.cwd(), 'nx.json'), 'utf8') + ) as { + targetDefaults: Record; + }; + + // The Playwright configs start the mocks themselves, so @nx/playwright + // infers the atomized e2e-ci targets as non-parallel, and Nx refuses to + // run a non-parallel task that depends on a continuous `serve` task. + it('never makes an E2E target depend on a mock-server task', () => { + const mockDependencies = Object.entries(nxJson.targetDefaults) + .flatMap(([targetName, config]) => + (config.dependsOn ?? []).map((dependency) => ({ + targetName, + dependency, + })) + ) + .filter(({ dependency }) => + typeof dependency === 'string' + ? dependency.includes('-mock-server:') + : (dependency.projects ?? []).some((project) => + project.endsWith('-mock-server') + ) + ); + + expect(mockDependencies).toEqual([]); + }); + + it('still builds the Electron app before each per-file E2E target', () => { + expect( + nxJson.targetDefaults['e2e-ci--src/*.e2e.ts']?.dependsOn + ).toContainEqual({ + projects: ['electron-backend'], + target: 'build-e2e', + }); + }); +}); diff --git a/docs/architecture/xtream-mock-server.md b/docs/architecture/xtream-mock-server.md index 571c2f461..d9ffca8b4 100644 --- a/docs/architecture/xtream-mock-server.md +++ b/docs/architecture/xtream-mock-server.md @@ -579,7 +579,10 @@ for the serve target's `--tsconfig` flag and is required for the `@iptvnator/*` path aliases. `project-config.spec.ts` pins which configs start which mock, and fails if any of them launches a mock through Nx or a new config starts one without being listed there. The `serve` targets remain the entry point -for starting a mock by hand. The web-e2e `web-backend` entry uses the same +for starting a mock by hand, and no E2E target may depend on them: with no +Nx-launched server, `@nx/playwright` infers the atomized `e2e-ci--*` targets +as non-parallel, and Nx refuses to run a non-parallel task that depends on a +continuous `serve` task. The same spec guards `nx.json` `targetDefaults`. The web-e2e `web-backend` entry uses the same launch form; see [PWA web backend](pwa-self-hosted.md#web-backend). ### Request Interception diff --git a/nx.json b/nx.json index ff0a58753..6ae3b7f96 100644 --- a/nx.json +++ b/nx.json @@ -73,10 +73,6 @@ { "projects": ["electron-backend"], "target": "build-e2e" - }, - { - "projects": ["stalker-mock-server", "xtream-mock-server"], - "target": "serve" } ] }