From 33af5cb212189ddd959846f21d47059a43340992 Mon Sep 17 00:00:00 2001 From: Wil Wilsman Date: Fri, 11 Sep 2020 17:59:48 -0500 Subject: [PATCH] =?UTF-8?q?=E2=9C=85=20Fix=20tests=20when=20throwing=20CLI?= =?UTF-8?q?=20errors?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/cli-build/test/wait.test.js | 4 ++-- packages/cli-exec/test/exec.test.js | 2 +- packages/cli-exec/test/start.test.js | 2 +- packages/cli-snapshot/test/snapshot.test.js | 8 ++++---- packages/cli-upload/test/upload.test.js | 6 +++--- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/packages/cli-build/test/wait.test.js b/packages/cli-build/test/wait.test.js index 566228f68..e5f618d8f 100644 --- a/packages/cli-build/test/wait.test.js +++ b/packages/cli-build/test/wait.test.js @@ -39,9 +39,9 @@ describe('percy build:wait', () => { ]); }); - it('logs an error when required args are missing', async () => { + it('logs an error and exits when required args are missing', async () => { await expect(stdio.capture(() => Wait.run([]))) - .rejects.toThrow('Missing build ID or commit SHA'); + .rejects.toThrow('EEXIT: 1'); expect(stdio[1]).toHaveLength(0); expect(stdio[2]).toEqual([ '[percy] Error: Missing build ID or commit SHA\n' diff --git a/packages/cli-exec/test/exec.test.js b/packages/cli-exec/test/exec.test.js index 56a82e8ee..1431f8b4a 100644 --- a/packages/cli-exec/test/exec.test.js +++ b/packages/cli-exec/test/exec.test.js @@ -93,7 +93,7 @@ describe('percy exec', () => { await expect(stdio.capture(() => ( Exec.run(['--', 'foobar']) - ))).rejects.toThrow('ENOENT'); + ))).rejects.toThrow('EEXIT: 1'); expect(stdio[2]).toEqual([ '[percy] Error: spawn foobar ENOENT\n' diff --git a/packages/cli-exec/test/start.test.js b/packages/cli-exec/test/start.test.js index 59d64a73d..c3d59ad86 100644 --- a/packages/cli-exec/test/start.test.js +++ b/packages/cli-exec/test/start.test.js @@ -41,7 +41,7 @@ describe('percy exec:start', () => { it('logs an error when percy is already running', async () => { await expect(stdio.capture(() => ( Start.run([]) - ))).rejects.toThrow('Percy is already running'); + ))).rejects.toThrow('EEXIT: 1'); expect(stdio[1]).toHaveLength(0); expect(stdio[2]).toEqual([ diff --git a/packages/cli-snapshot/test/snapshot.test.js b/packages/cli-snapshot/test/snapshot.test.js index 088b912b9..3e1e0af40 100644 --- a/packages/cli-snapshot/test/snapshot.test.js +++ b/packages/cli-snapshot/test/snapshot.test.js @@ -80,7 +80,7 @@ describe('percy snapshot', () => { it('errors when the provided path doesn\'t exist', async () => { await expect(stdio.capture(() => ( Snapshot.run(['./404']) - ))).rejects.toThrow('Not found: ./404'); + ))).rejects.toThrow('EEXIT: 1'); expect(stdio[1]).toHaveLength(0); expect(stdio[2]).toEqual([ @@ -91,7 +91,7 @@ describe('percy snapshot', () => { it('errors when the base-url is invalid', async () => { await expect(stdio.capture(() => ( Snapshot.run(['./public', '--base-url=wrong']) - ))).rejects.toThrow('The base-url flag must begin with a forward slash (/)'); + ))).rejects.toThrow('EEXIT: 1'); expect(stdio[1]).toHaveLength(0); expect(stdio[2]).toEqual([ @@ -102,7 +102,7 @@ describe('percy snapshot', () => { it('errors when there are no snapshots to take', async () => { await expect(stdio.capture(() => ( Snapshot.run(['./public', '--files=no-match']) - ))).rejects.toThrow('No snapshots found'); + ))).rejects.toThrow('EEXIT: 1'); expect(stdio[1]).toHaveLength(0); expect(stdio[2]).toEqual([ @@ -232,7 +232,7 @@ describe('percy snapshot', () => { it('errors with unknown file extensions', async () => { await expect(stdio.capture(() => ( Snapshot.run(['./nope']) - ))).rejects.toThrow('Unsupported filetype: ./nope'); + ))).rejects.toThrow('EEXIT: 1'); expect(stdio[1]).toHaveLength(0); expect(stdio[2]).toEqual([ diff --git a/packages/cli-upload/test/upload.test.js b/packages/cli-upload/test/upload.test.js index f97028393..bcbfd31e2 100644 --- a/packages/cli-upload/test/upload.test.js +++ b/packages/cli-upload/test/upload.test.js @@ -58,7 +58,7 @@ describe('percy upload', () => { it('errors when the directory is not found', async () => { await expect(stdio.capture(() => ( Upload.run(['./404']) - ))).rejects.toThrow('Not found: ./404'); + ))).rejects.toThrow('EEXIT: 1'); expect(stdio[1]).toHaveLength(0); expect(stdio[2]).toEqual([ @@ -69,7 +69,7 @@ describe('percy upload', () => { it('errors when the path is not a directory', async () => { await expect(stdio.capture(() => ( Upload.run(['./nope']) - ))).rejects.toThrow('Not a directory: ./nope'); + ))).rejects.toThrow('EEXIT: 1'); expect(stdio[1]).toHaveLength(0); expect(stdio[2]).toEqual([ @@ -80,7 +80,7 @@ describe('percy upload', () => { it('errors when there are no matching files', async () => { await expect(stdio.capture(() => ( Upload.run(['./images', '--files=no-match.png']) - ))).rejects.toThrow('No matching files found in \'./images\''); + ))).rejects.toThrow('EEXIT: 1'); expect(stdio[1]).toHaveLength(0); expect(stdio[2]).toEqual([