fix(angular): support inferred cypress targets in setup-mf generator (#21619)

This commit is contained in:
Leosvel Pérez Espinosa 2024-02-05 20:08:38 +01:00 committed by GitHub
parent 86ba07e2a8
commit 758c1ab70e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 17 additions and 22 deletions

View File

@ -371,21 +371,17 @@ describe('Angular Module Federation', () => {
);
// Build host and remote
const buildOutput = await runCommandUntil(`build ${host}`, (output) =>
output.includes('Successfully ran target build')
);
await killProcessAndPorts(buildOutput.pid);
const remoteOutput = await runCommandUntil(`build ${remote}`, (output) =>
output.includes('Successfully ran target build')
);
await killProcessAndPorts(remoteOutput.pid);
const buildHostOutput = runCLI(`build ${host}`);
expect(buildHostOutput).toContain('Successfully ran target build');
const buildRemoteOutput = runCLI(`build ${remote}`);
expect(buildRemoteOutput).toContain('Successfully ran target build');
if (runE2ETests()) {
const hostE2eResults = await runCommandUntil(
const e2eProcess = await runCommandUntil(
`e2e ${host}-e2e --no-watch --verbose`,
(output) => output.includes('All specs passed!')
);
await killProcessAndPorts(hostE2eResults.pid, hostPort, hostPort + 1);
await killProcessAndPorts(e2eProcess.pid, hostPort, hostPort + 1);
}
}, 500_000);
@ -467,21 +463,17 @@ describe('Angular Module Federation', () => {
);
// Build host and remote
const buildOutput = await runCommandUntil(`build ${host}`, (output) =>
output.includes('Successfully ran target build')
);
await killProcessAndPorts(buildOutput.pid);
const remoteOutput = await runCommandUntil(`build ${remote}`, (output) =>
output.includes('Successfully ran target build')
);
await killProcessAndPorts(remoteOutput.pid);
const buildHostOutput = runCLI(`build ${host}`);
expect(buildHostOutput).toContain('Successfully ran target build');
const buildRemoteOutput = runCLI(`build ${remote}`);
expect(buildRemoteOutput).toContain('Successfully ran target build');
if (runE2ETests()) {
const hostE2eResults = await runCommandUntil(
const e2eProcess = await runCommandUntil(
`e2e ${host}-e2e --no-watch --verbose`,
(output) => output.includes('All specs passed!')
);
await killProcessAndPorts(hostE2eResults.pid, hostPort, hostPort + 1);
await killProcessAndPorts(e2eProcess.pid, hostPort, hostPort + 1);
}
}, 500_000);
});

View File

@ -2,8 +2,10 @@
// as Angular attempt to figure out how to fix HMR when styles.js
// is attached to the index.html with type=module
import { CYPRESS_CONFIG_FILE_NAME_PATTERN } from '@nx/cypress/src/utils/config';
import type { ProjectConfiguration, Tree } from '@nx/devkit';
import {
glob,
joinPathFragments,
logger,
readProjectConfiguration,
@ -31,8 +33,9 @@ export function addCypressOnErrorWorkaround(tree: Tree, schema: Schema) {
}
if (
e2eProject.targets.e2e.executor !== '@nx/cypress:cypress' &&
e2eProject.targets.e2e.executor !== '@nx/cypress:cypress'
e2eProject.targets?.e2e?.executor !== '@nx/cypress:cypress' &&
!glob(tree, [`${e2eProject.root}/${CYPRESS_CONFIG_FILE_NAME_PATTERN}`])
.length
) {
// Not a cypress e2e project, skip
return;