From a4a9c2763759894c2078addc9486beca1973cbe4 Mon Sep 17 00:00:00 2001 From: Craigory Coppola Date: Thu, 2 Mar 2023 16:20:45 -0500 Subject: [PATCH] fix(nx-plugin): e2e utils should work (#15397) --- e2e/nx-plugin/src/nx-plugin.test.ts | 14 ++++++-------- .../src/utils/testing-utils/async-commands.ts | 2 +- .../nx-plugin/src/utils/testing-utils/commands.ts | 2 +- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/e2e/nx-plugin/src/nx-plugin.test.ts b/e2e/nx-plugin/src/nx-plugin.test.ts index 6378d8abc5..6988acc304 100644 --- a/e2e/nx-plugin/src/nx-plugin.test.ts +++ b/e2e/nx-plugin/src/nx-plugin.test.ts @@ -73,14 +73,12 @@ describe('Nx Plugin', () => { // doesn't use the collection we are building // we should change it to point to the right collection using relative path // TODO: Re-enable this to work with pnpm - xit(`should run the plugin's e2e tests`, async () => { - if (isNotWindows()) { - const plugin = uniq('plugin-name'); - runCLI(`generate @nrwl/nx-plugin:plugin ${plugin} --linter=eslint`); - const e2eResults = runCLI(`e2e ${plugin}-e2e`); - expect(e2eResults).toContain('Successfully ran target e2e'); - expect(await killPorts()).toBeTruthy(); - } + it(`should run the plugin's e2e tests`, async () => { + const plugin = uniq('plugin-name'); + runCLI(`generate @nrwl/nx-plugin:plugin ${plugin} --linter=eslint`); + const e2eResults = runCLI(`e2e ${plugin}-e2e`); + expect(e2eResults).toContain('Successfully ran target e2e'); + expect(await killPorts()).toBeTruthy(); }, 250000); it('should be able to generate a migration', async () => { diff --git a/packages/nx-plugin/src/utils/testing-utils/async-commands.ts b/packages/nx-plugin/src/utils/testing-utils/async-commands.ts index 7766ed3ac9..863e2be8b3 100644 --- a/packages/nx-plugin/src/utils/testing-utils/async-commands.ts +++ b/packages/nx-plugin/src/utils/testing-utils/async-commands.ts @@ -43,7 +43,7 @@ export function runNxCommandAsync( silenceError: false, } ): Promise<{ stdout: string; stderr: string }> { - if (fileExists('package.json')) { + if (fileExists(tmpProjPath('package.json'))) { const pmc = getPackageManagerCommand(); return runCommandAsync(`${pmc.exec} nx ${command}`, opts); } else if (process.platform === 'win32') { diff --git a/packages/nx-plugin/src/utils/testing-utils/commands.ts b/packages/nx-plugin/src/utils/testing-utils/commands.ts index 69af28dfdc..7e82296880 100644 --- a/packages/nx-plugin/src/utils/testing-utils/commands.ts +++ b/packages/nx-plugin/src/utils/testing-utils/commands.ts @@ -21,7 +21,7 @@ export function runNxCommand( cwd: tmpProjPath(), env: { ...process.env, ...opts.env }, }; - if (fileExists('package.json')) { + if (fileExists(tmpProjPath('package.json'))) { const pmc = getPackageManagerCommand(); return execSync(`${pmc.exec} nx ${command}`, execSyncOptions); } else if (process.platform === 'win32') {