Skip to content

Commit 541d8e1

Browse files
authored
feat: make --fail-on-no-matching true by default for the trigger command [sc-24516] (#1088)
* feat: make --fail-on-no-matching true by default for the trigger command * feat: remove failOnNoMatching from checkly config given it's the default now Realistically the only reason why you'd want to set the flag is to enable it. Since it's now enabled by default, and the option only applied to the trigger command anyway, there is no reason to keep the option anymore. * fix(tests): fix test titles
1 parent 3e3d34e commit 541d8e1

File tree

4 files changed

+23
-15
lines changed

4 files changed

+23
-15
lines changed

packages/cli/e2e/__tests__/trigger.spec.ts

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ describe('trigger', () => {
5353
expect(result.status).toBe(0)
5454
})
5555

56-
test('Should return code 0 when no checks match', async () => {
56+
test('Should return code 1 when no checks match', async () => {
5757
const result = await runChecklyCli({
5858
args: [
5959
'trigger',
@@ -65,10 +65,10 @@ describe('trigger', () => {
6565
})
6666

6767
expect(result.stdout).toContain('No matching checks were found.')
68-
expect(result.status).toBe(0)
68+
expect(result.status).toBe(1)
6969
})
7070

71-
test('Should return code 1 when no checks match and the fail-on-no-match flag is set', async () => {
71+
test('Should return code 1 when no checks match and the fail-on-no-matching flag is set', async () => {
7272
const result = await runChecklyCli({
7373
args: [
7474
'trigger',
@@ -83,4 +83,20 @@ describe('trigger', () => {
8383
expect(result.stdout).toContain('No matching checks were found.')
8484
expect(result.status).toBe(1)
8585
})
86+
87+
test('Should return code 0 when no checks match and the no-fail-on-no-matching flag is set', async () => {
88+
const result = await runChecklyCli({
89+
args: [
90+
'trigger',
91+
'--tags',
92+
'no-checks-match-this-tag',
93+
'--no-fail-on-no-matching',
94+
],
95+
apiKey: config.get('apiKey'),
96+
accountId: config.get('accountId'),
97+
})
98+
99+
expect(result.stdout).toContain('No matching checks were found.')
100+
expect(result.status).toBe(0)
101+
})
86102
})

packages/cli/src/commands/trigger.ts

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,9 @@ export default class Trigger extends AuthCommand {
5959
allowNo: true,
6060
}),
6161
'fail-on-no-matching': Flags.boolean({
62-
description: 'Exit with a failing status code when there are no matching tests.',
62+
description: 'Exit with a failing status code when there are no matching tests. Enabled by default.',
63+
default: true,
64+
allowNo: true,
6365
}),
6466
reporter: Flags.string({
6567
char: 'r',
@@ -99,7 +101,7 @@ export default class Trigger extends AuthCommand {
99101
tags: targetTags,
100102
timeout,
101103
verbose: verboseFlag,
102-
'fail-on-no-matching': failOnNoMatchingFlag,
104+
'fail-on-no-matching': failOnNoMatching,
103105
record: shouldRecord,
104106
reporter: reporterFlag,
105107
env,
@@ -120,7 +122,6 @@ export default class Trigger extends AuthCommand {
120122
privateRunLocation,
121123
})
122124
const verbose = this.prepareVerboseFlag(verboseFlag, checklyConfig?.cli?.verbose)
123-
const failOnNoMatching = this.prepareFailOnNoMatching(failOnNoMatchingFlag, checklyConfig?.cli?.failOnNoMatching)
124125
const reporterTypes = this.prepareReportersTypes(reporterFlag as ReporterType, checklyConfig?.cli?.reporters)
125126
const reporters = createReporters(reporterTypes, location, verbose)
126127
const testRetryStrategy = this.prepareTestRetryStrategy(retries, checklyConfig?.cli?.retries)
@@ -229,10 +230,6 @@ export default class Trigger extends AuthCommand {
229230
return verboseFlag ?? cliVerboseFlag ?? false
230231
}
231232

232-
prepareFailOnNoMatching (failOnNoMatchingFlag?: boolean, cliFailOnNoMatchingFlag?: boolean) {
233-
return failOnNoMatchingFlag ?? cliFailOnNoMatchingFlag ?? false
234-
}
235-
236233
prepareReportersTypes (reporterFlag: ReporterType, cliReporters: ReporterType[] = []): ReporterType[] {
237234
if (!reporterFlag && !cliReporters.length) {
238235
return [isCI ? 'ci' : 'list']

packages/cli/src/services/checkly-config-codegen.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -209,10 +209,6 @@ more information.`))
209209
builder.boolean('verbose', cli.verbose)
210210
}
211211

212-
if (cli.failOnNoMatching !== undefined) {
213-
builder.boolean('failOnNoMatching', cli.failOnNoMatching)
214-
}
215-
216212
if (cli.reporters !== undefined) {
217213
const reporters = cli.reporters
218214
builder.array('reporters', builder => {

packages/cli/src/services/checkly-config-loader.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,6 @@ export type ChecklyConfig = {
8787
runLocation?: keyof Region,
8888
privateRunLocation?: string,
8989
verbose?: boolean,
90-
failOnNoMatching?: boolean,
9190
reporters?: ReporterType[],
9291
retries?: number,
9392
loader?: FileLoader,

0 commit comments

Comments
 (0)