Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(repo): ensure cypress is installed for the e2e tests #12615

Merged
merged 2 commits into from Oct 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions e2e/cypress/src/cypress.test.ts
Expand Up @@ -2,6 +2,7 @@ import {
checkFilesExist,
cleanupProject,
createFile,
ensureCypressInstallation,
killPorts,
newProject,
readJson,
Expand All @@ -16,6 +17,7 @@ describe('Cypress E2E Test runner', () => {

beforeAll(() => {
newProject();
ensureCypressInstallation();
});

afterAll(() => cleanupProject());
Expand Down
32 changes: 30 additions & 2 deletions e2e/utils/index.ts
@@ -1,5 +1,4 @@
import {
createProjectGraphAsync,
joinPathFragments,
parseJson,
ProjectConfiguration,
Expand Down Expand Up @@ -399,7 +398,36 @@ export async function cleanupProject(opts?: RunCmdOpts) {
}

export function runCypressTests() {
return process.env.NX_E2E_RUN_CYPRESS === 'true';
if (process.env.NX_E2E_RUN_CYPRESS === 'true') {
barbados-clemens marked this conversation as resolved.
Show resolved Hide resolved
ensureCypressInstallation();
return true;
}
return false;
}

export function ensureCypressInstallation() {
let cypressVerified = true;
try {
const r = execSync('npx cypress verify', {
stdio: 'inherit',
encoding: 'utf-8',
cwd: tmpProjPath(),
});
if (r.indexOf('Verified Cypress!') === -1) {
cypressVerified = false;
}
} catch {
cypressVerified = false;
} finally {
if (!cypressVerified) {
e2eConsoleLogger('Cypress was not verified. Installing Cypress now.');
execSync('npx cypress install', {
stdio: 'inherit',
encoding: 'utf-8',
cwd: tmpProjPath(),
});
}
}
}

export function isNotWindows() {
Expand Down