Skip to content

Commit

Permalink
✅ Fix tests when throwing CLI errors
Browse files Browse the repository at this point in the history
  • Loading branch information
wwilsman committed Sep 11, 2020
1 parent f1e74c9 commit 33af5cb
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions packages/cli-build/test/wait.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
2 changes: 1 addition & 1 deletion packages/cli-exec/test/exec.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
2 changes: 1 addition & 1 deletion packages/cli-exec/test/start.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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([
Expand Down
8 changes: 4 additions & 4 deletions packages/cli-snapshot/test/snapshot.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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([
Expand All @@ -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([
Expand All @@ -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([
Expand Down Expand Up @@ -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([
Expand Down
6 changes: 3 additions & 3 deletions packages/cli-upload/test/upload.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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([
Expand All @@ -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([
Expand All @@ -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([
Expand Down

0 comments on commit 33af5cb

Please sign in to comment.