From 52b47659df4e03b6295f9d867f300d33d32c97e0 Mon Sep 17 00:00:00 2001 From: Victor Savkin Date: Thu, 24 Mar 2022 10:02:19 -0400 Subject: [PATCH] feat(repo): run e2e tests outside of the repo (#9496) --- .circleci/config.yml | 2 +- e2e/utils/index.ts | 6 ++++-- e2e/workspace-integrations/src/affected.test.ts | 8 ++++---- scripts/e2e-build-package-publish.ts | 4 ++-- 4 files changed, 11 insertions(+), 9 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 579c4ef2c03e4..cbe239c7425c5 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -188,7 +188,7 @@ jobs: - run: name: Run E2E Tests command: | - npx nx affected --target=e2e --base=$NX_BASE --head=$NX_HEAD --exclude=e2e-storybook,e2e-react-native,e2e-detox,e2e-workspace-integrations --parallel=1 + npx nx affected --target=e2e --base=$NX_BASE --head=$NX_HEAD --exclude=e2e-storybook,e2e-react-native,e2e-detox --parallel=1 no_output_timeout: 45m - run: name: Stop All Running Agents for This CI Run diff --git a/e2e/utils/index.ts b/e2e/utils/index.ts index d381a3e355e87..58e577670088a 100644 --- a/e2e/utils/index.ts +++ b/e2e/utils/index.ts @@ -49,7 +49,10 @@ export function currentCli() { return process.env.SELECTED_CLI || 'nx'; } -export const e2eRoot = isCI ? dirSync({ prefix: 'nx-e2e-' }).name : `./tmp`; +export const e2eRoot = isCI + ? dirSync({ prefix: 'nx-e2e-' }).name + : '/tmp/nx-e2e'; + export const e2eCwd = `${e2eRoot}/${currentCli()}`; ensureDirSync(e2eCwd); @@ -524,7 +527,6 @@ export function runCommand( } return r; } catch (e) { - console.log('ERROR CAUGHT', e); // this is intentional // npm ls fails if package is not found return e.stdout?.toString() + e.stderr?.toString(); diff --git a/e2e/workspace-integrations/src/affected.test.ts b/e2e/workspace-integrations/src/affected.test.ts index a7a7faeefcdc1..eed36acaee129 100644 --- a/e2e/workspace-integrations/src/affected.test.ts +++ b/e2e/workspace-integrations/src/affected.test.ts @@ -25,6 +25,7 @@ describe('affected:*', () => { afterEach(() => cleanupProject()); it('should print, build, and test affected apps', async () => { + process.env.CI = 'true'; const myapp = uniq('myapp'); const myapp2 = uniq('myapp2'); const mylib = uniq('mylib'); @@ -150,10 +151,9 @@ describe('affected:*', () => { `affected:test --files="libs/${mylib}/src/index.ts"`, { silenceError: true } ); - expect(failedTests).toContain(`Running target test for 3 project(s):`); - expect(failedTests).toContain(`- ${mylib}`); - expect(failedTests).toContain(`- ${myapp}`); - expect(failedTests).toContain(`- ${mypublishablelib}`); + expect(failedTests).toContain(mylib); + expect(failedTests).toContain(myapp); + expect(failedTests).toContain(mypublishablelib); expect(failedTests).toContain(`Failed tasks:`); // Fix failing Unit Test diff --git a/scripts/e2e-build-package-publish.ts b/scripts/e2e-build-package-publish.ts index c85c29d696b4d..447fd9a1bf66c 100644 --- a/scripts/e2e-build-package-publish.ts +++ b/scripts/e2e-build-package-publish.ts @@ -20,8 +20,8 @@ async function buildPackagePublishAndCleanPorts() { } await Promise.all([ remove('./build'), - remove('./tmp/nx/proj-backup'), - remove('./tmp/angular/proj-backup'), + remove('/tmp/nx-e2e/nx/proj-backup'), + remove('/tmp/nx-e2e/angular/proj-backup'), remove('./tmp/local-registry'), ]); }