chore(testing): update nightly ci to ensure cy is available (#18951)

This commit is contained in:
Caleb Ukle 2023-08-31 14:50:36 -05:00 committed by GitHub
parent 6d686564fa
commit 5146a7c9fb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -94,16 +94,17 @@ describe('env vars', () => {
});` });`
); );
// contains the correct output and works if (runE2ETests()) {
const run1 = runCLI( // contains the correct output and works
`e2e ${myapp}-e2e --no-watch --env.cliArg="i am from the cli args"` const run1 = runCLI(
); `e2e ${myapp}-e2e --no-watch --env.cliArg="i am from the cli args"`
expect(run1).toContain('All specs passed!'); );
await killPort(4200); expect(run1).toContain('All specs passed!');
// tests should not fail because of a config change await killPort(4200);
updateFile( // tests should not fail because of a config change
`apps/${myapp}-e2e/cypress.config.ts`, updateFile(
` `apps/${myapp}-e2e/cypress.config.ts`,
`
import { defineConfig } from 'cypress'; import { defineConfig } from 'cypress';
import { nxE2EPreset } from '@nx/cypress/plugins/cypress-preset'; import { nxE2EPreset } from '@nx/cypress/plugins/cypress-preset';
@ -113,18 +114,18 @@ export default defineConfig({
fixturesFolder: undefined, fixturesFolder: undefined,
}, },
});` });`
); );
const run2 = runCLI( const run2 = runCLI(
`e2e ${myapp}-e2e --no-watch --env.cliArg="i am from the cli args"` `e2e ${myapp}-e2e --no-watch --env.cliArg="i am from the cli args"`
); );
expect(run2).toContain('All specs passed!'); expect(run2).toContain('All specs passed!');
await killPort(4200); await killPort(4200);
// make sure project.json env vars also work // make sure project.json env vars also work
updateFile( updateFile(
`apps/${myapp}-e2e/src/e2e/env.cy.ts`, `apps/${myapp}-e2e/src/e2e/env.cy.ts`,
` `
describe('env vars', () => { describe('env vars', () => {
it('should not have cli args', () => { it('should not have cli args', () => {
assert.equal(Cypress.env('cliArg'), undefined); assert.equal(Cypress.env('cliArg'), undefined);
@ -144,11 +145,12 @@ describe('env vars', () => {
); );
}); });
});` });`
); );
const run3 = runCLI(`e2e ${myapp}-e2e --no-watch`); const run3 = runCLI(`e2e ${myapp}-e2e --no-watch`);
expect(run3).toContain('All specs passed!'); expect(run3).toContain('All specs passed!');
expect(await killPort(4200)).toBeTruthy(); expect(await killPort(4200)).toBeTruthy();
}
}, },
TEN_MINS_MS TEN_MINS_MS
); );
@ -164,16 +166,18 @@ describe('env vars', () => {
`generate @nx/angular:app ${ngAppName} --e2eTestRunner=cypress --linter=eslint --no-interactive` `generate @nx/angular:app ${ngAppName} --e2eTestRunner=cypress --linter=eslint --no-interactive`
); );
const results = runCLI( if (runE2ETests()) {
`run-many --target=e2e --parallel=2 --port=cypress-auto --output-style=stream` const results = runCLI(
); `run-many --target=e2e --parallel=2 --port=cypress-auto --output-style=stream`
expect(results).toContain('Using port 4200'); );
expect(results).toContain('Using port 4201'); expect(results).toContain('Using port 4200');
expect(results).toContain('Successfully ran target e2e for 2 projects'); expect(results).toContain('Using port 4201');
checkFilesDoNotExist( expect(results).toContain('Successfully ran target e2e for 2 projects');
`node_modules/@nx/cypress/src/executors/cypress/4200.txt`, checkFilesDoNotExist(
`node_modules/@nx/cypress/src/executors/cypress/4201.txt` `node_modules/@nx/cypress/src/executors/cypress/4200.txt`,
); `node_modules/@nx/cypress/src/executors/cypress/4201.txt`
);
}
}, },
TEN_MINS_MS TEN_MINS_MS
); );