nx/e2e/cypress/src/cypress-legacy.test.ts
Leosvel Pérez Espinosa c92528f65d
feat(misc): remove derived generator paths (#27714)
<!-- Please make sure you have read the submission guidelines before
posting an PR -->
<!--
https://github.com/nrwl/nx/blob/master/CONTRIBUTING.md#-submitting-a-pr
-->

<!-- Please make sure that your commit message follows our format -->
<!-- Example: `fix(nx): must begin with lowercase` -->

<!-- If this is a particularly complex change or feature addition, you
can request a dedicated Nx release for this pull request branch. Mention
someone from the Nx team or the `@nrwl/nx-pipelines-reviewers` and they
will confirm if the PR warrants its own release for testing purposes,
and generate it for you if appropriate. -->

## Current Behavior
<!-- This is the behavior we have today -->

## Expected Behavior
<!-- This is the behavior we should expect with the changes in this PR
-->

## Related Issue(s)
<!-- Please link the issue being fixed so it gets closed when this is
merged. -->

Fixes #

---------

Co-authored-by: Nicholas Cunningham <ndcunningham@gmail.com>
2024-09-23 09:19:42 -04:00

74 lines
2.1 KiB
TypeScript

import {
cleanupProject,
killPort,
newProject,
runCLI,
runE2ETests,
uniq,
} from '@nx/e2e/utils';
const TEN_MINS_MS = 600_000;
describe('Cypress E2E Test runner (legacy)', () => {
beforeAll(() => {
newProject({ packages: ['@nx/angular', '@nx/react'] });
});
afterAll(() => cleanupProject());
it(
'should run e2e in parallel',
async () => {
const ngApp1 = uniq('ng-app1');
const ngApp2 = uniq('ng-app2');
runCLI(
`generate @nx/angular:app ${ngApp1} --e2eTestRunner=cypress --linter=eslint --no-interactive`,
{ env: { NX_ADD_PLUGINS: 'false' } }
);
runCLI(
`generate @nx/angular:app ${ngApp2} --e2eTestRunner=cypress --linter=eslint --no-interactive`,
{ env: { NX_ADD_PLUGINS: 'false' } }
);
if (runE2ETests('cypress')) {
const results = runCLI(
`run-many --target=e2e --parallel=2 --port=cypress-auto --output-style=stream`
);
expect(results).toContain('Successfully ran target e2e for 2 projects');
}
},
TEN_MINS_MS
);
it(
`should allow CT and e2e in same project - react`,
async () => {
const appName = uniq(`react-cy-app`);
runCLI(
`generate @nx/react:app ${appName} --e2eTestRunner=none --no-interactive`,
{ env: { NX_ADD_PLUGINS: 'false' } }
);
runCLI(
`generate @nx/react:component btn --directory=${appName}/src/app/btn --no-interactive`,
{ env: { NX_ADD_PLUGINS: 'false' } }
);
runCLI(
`generate @nx/react:cypress-component-configuration --project=${appName} --generate-tests --no-interactive`,
{ env: { NX_ADD_PLUGINS: 'false' } }
);
runCLI(`generate @nx/cypress:e2e --project=${appName} --no-interactive`, {
env: { NX_ADD_PLUGINS: 'false' },
});
if (runE2ETests('cypress')) {
expect(runCLI(`run ${appName}:component-test`)).toContain(
'All specs passed!'
);
expect(runCLI(`run ${appName}:e2e`)).toContain('All specs passed!');
}
expect(await killPort(4200)).toBeTruthy();
},
TEN_MINS_MS
);
});