diff --git a/e2e/release/src/pre-version-command.test.ts b/e2e/release/src/pre-version-command.test.ts index 95a579f955d54..68ceb9269869f 100644 --- a/e2e/release/src/pre-version-command.test.ts +++ b/e2e/release/src/pre-version-command.test.ts @@ -88,51 +88,11 @@ describe('nx release pre-version command', () => { expect(result3).toContain('nx run-many -t build'); expect(result3).toContain(`NX Running target build for project ${pkg1}:`); - updateJson(`nx.json`, (json) => { - json.release = { - version: { - preVersionCommand: 'echo "error" && exit 1', - }, - }; - return json; - }); - - // command should fail because the pre-version command will fail - const result4 = runCLI('release patch -d --first-release', { - silenceError: true, - }); - expect(result4).toContain( - 'NX The pre-version command failed. Retry with --verbose to see the full output of the pre-version command.' - ); - expect(result4).toContain('echo "error" && exit 1'); - - const result5 = runCLI('release patch -d --first-release --verbose', { - silenceError: true, - }); - expect(result5).toContain( - 'NX The pre-version command failed. See the full output above.' - ); - expect(result4).toContain('echo "error" && exit 1'); - }); - - it('should run pre-version command before group versioning step', async () => { - updateJson(`nx.json`, (json) => { - delete json.release; - return json; - }); - const result1 = runCLI('release patch -d --first-release', { - silenceError: true, - }); - - // command should fail because @nx/js:library configures the packageRoot to be dist/{project-name}, which doesn't exist yet - expect(result1).toContain( - `NX The project "${pkg1}" does not have a package.json available at dist/${pkg1}/package.json.` - ); - + const groupName = uniq('group-1'); updateJson(`nx.json`, (json) => { json.release = { groups: { - 'group-1': { + [groupName]: { projects: [pkg1], version: { preVersionCommand: `nx run-many -t build -p ${pkg1}`, @@ -144,51 +104,34 @@ describe('nx release pre-version command', () => { }); // command should succeed because the pre-version command will build the package - const result2 = runCLI('release patch -d -g group-1 --first-release'); - - expect(result2).toContain('NX Executing pre-version command'); + const result4 = runCLI(`release patch -d -g ${groupName} --first-release`); - const result3 = runCLI( - 'release patch -d -g group-1 --first-release --verbose' - ); - - expect(result3).toContain('NX Executing pre-version command'); - expect(result3).toContain('Executing the following pre-version command:'); - expect(result3).toContain(`nx run-many -t build -p ${pkg1}`); - expect(result3).toContain(`NX Running target build for project ${pkg1}:`); + expect(result4).toContain('NX Executing pre-version command'); updateJson(`nx.json`, (json) => { json.release = { - groups: { - 'group-1': { - projects: [pkg1], - version: { - preVersionCommand: `echo "error" && exit 1`, - }, - }, + version: { + preVersionCommand: 'echo "error" && exit 1', }, }; return json; }); // command should fail because the pre-version command will fail - const result4 = runCLI('release patch -d -g group-1 --first-release', { + const result5 = runCLI('release patch -d --first-release', { silenceError: true, }); - expect(result4).toContain( + expect(result5).toContain( 'NX The pre-version command failed. Retry with --verbose to see the full output of the pre-version command.' ); - expect(result4).toContain('echo "error" && exit 1'); + expect(result5).toContain('echo "error" && exit 1'); - const result5 = runCLI( - 'release patch -d -g group-1 --first-release --verbose', - { - silenceError: true, - } - ); - expect(result5).toContain( + const result6 = runCLI('release patch -d --first-release --verbose', { + silenceError: true, + }); + expect(result6).toContain( 'NX The pre-version command failed. See the full output above.' ); - expect(result4).toContain('echo "error" && exit 1'); + expect(result6).toContain('echo "error" && exit 1'); }); });