-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This commit serves two purposes: One is to output the version of the CLI in the happo-ci logs. The other purpose is to catch a misconfigured HAPPO_COMMAND. By attempting to get the version, we can catch errors and output a helpful message instead of failing with a cryptic message of this kind: 2024-06-24T21:04:09.6031947Z /some/absolute/path/node_modules/.bin/happo-ci: line 104: node_modules/happo.io/build/cli.js: No such file or directory
- Loading branch information
Showing
3 changed files
with
33 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -66,6 +66,16 @@ describe('when CURRENT_SHA is missing', () => { | |
}); | ||
}); | ||
|
||
describe('when HAPPO_COMMAND is pointing to a non-existant file', () => { | ||
beforeEach(() => { | ||
env.HAPPO_COMMAND = './foo/bar.js'; | ||
}); | ||
|
||
it('fails with a message', () => { | ||
expect(subject).toThrow(/Failed to execute \.\/foo\/bar\.js/); | ||
}); | ||
}); | ||
|
||
describe('when CHANGE_URL is missing', () => { | ||
beforeEach(() => { | ||
delete env.CHANGE_URL; | ||
|
@@ -84,6 +94,7 @@ describe('when CURRENT_SHA and PREVIOUS_SHA is the same', () => { | |
it('runs a single report', () => { | ||
subject(); | ||
expect(getCliLog()).toEqual([ | ||
'version', | ||
'run bar --link http://foo.bar/ --message Commit message', | ||
]); | ||
expect(getGitLog()).toEqual([ | ||
|
@@ -99,6 +110,7 @@ describe('when there is a report for PREVIOUS_SHA', () => { | |
it('runs the right happo commands', () => { | ||
subject(); | ||
expect(getCliLog()).toEqual([ | ||
'version', | ||
'start-job foo bar --link http://foo.bar/ --message Commit message', | ||
'run bar --link http://foo.bar/ --message Commit message', | ||
'compare foo bar --link http://foo.bar/ --message Commit message --author Tom Dooner <[email protected]>', | ||
|
@@ -121,6 +133,7 @@ describe('when there is a report for PREVIOUS_SHA', () => { | |
it('runs the right happo commands', () => { | ||
subject(); | ||
expect(getCliLog()).toEqual([ | ||
'version', | ||
'start-job foo bar --link http://foo.bar/ --message Commit message', | ||
'run bar --link http://foo.bar/ --message Commit message', | ||
'has-report foo', | ||
|
@@ -146,6 +159,7 @@ describe('when there is a report for PREVIOUS_SHA', () => { | |
it('runs the right happo commands', () => { | ||
subject(); | ||
expect(getCliLog()).toEqual([ | ||
'version', | ||
'run bar --link http://foo.bar/ --message Commit message', | ||
'compare foo bar --link http://foo.bar/ --message Commit message --author Tom Dooner <[email protected]>', | ||
]); | ||
|
@@ -220,6 +234,7 @@ describe('when there is no report for PREVIOUS_SHA', () => { | |
it('does not checkout anything, runs a single report', () => { | ||
subject(); | ||
expect(getCliLog()).toEqual([ | ||
'version', | ||
'start-job no-report bar --link http://foo.bar/ --message Commit message', | ||
'run bar --link http://foo.bar/ --message Commit message', | ||
'compare no-report bar --link http://foo.bar/ --message Commit message --author Tom Dooner <[email protected]>', | ||
|
@@ -241,6 +256,7 @@ describe('when there is no report for PREVIOUS_SHA', () => { | |
it('runs the right happo commands', () => { | ||
subject(); | ||
expect(getCliLog()).toEqual([ | ||
'version', | ||
'start-job no-report bar --link http://foo.bar/ --message Commit message', | ||
'run bar --link http://foo.bar/ --message Commit message', | ||
'has-report no-report', | ||
|
@@ -272,6 +288,7 @@ describe('when the compare call fails', () => { | |
it('fails the script', () => { | ||
expect(subject).toThrow(); | ||
expect(getCliLog()).toEqual([ | ||
'version', | ||
'start-job fail bar --link http://foo.bar/ --message Commit message', | ||
'run bar --link http://foo.bar/ --message Commit message', | ||
'compare fail bar --link http://foo.bar/ --message Commit message --author Tom Dooner <[email protected]>', | ||
|
@@ -296,6 +313,7 @@ describe('when happo.io is not installed for the PREVIOUS_SHA and HAPPO_IS_ASYNC | |
it('runs the right happo commands', () => { | ||
subject(); | ||
expect(getCliLog()).toEqual([ | ||
'version', | ||
'start-job no-happo bar --link http://foo.bar/ --message Commit message', | ||
'run bar --link http://foo.bar/ --message Commit message', | ||
'has-report no-happo', | ||
|