diff --git a/packages/cli/src/commands/test.ts b/packages/cli/src/commands/test.ts index 36f323ee..bff0c871 100644 --- a/packages/cli/src/commands/test.ts +++ b/packages/cli/src/commands/test.ts @@ -16,7 +16,7 @@ import { loadChecklyConfig } from '../services/checkly-config-loader' import { filterByFileNamePattern, filterByCheckNamePattern, filterByTags } from '../services/test-filters' import type { Runtime } from '../rest/runtimes' import { AuthCommand } from './authCommand' -import { BrowserCheck, Check, HeartbeatCheck, Session } from '../constructs' +import { BrowserCheck, Check, HeartbeatCheck, Project, Session } from '../constructs' import type { Region } from '..' import { splitConfigFilePath, getGitInformation, getCiInformation, getEnvs } from '../services/util' import { createReporters, ReporterType } from '../reporters/reporter' @@ -181,7 +181,13 @@ export default class Test extends AuthCommand { return filterByCheckNamePattern(grep, check.name) }) .filter(([, check]) => { - return filterByTags(targetTags?.map((tags: string) => tags.split(',')) ?? [], check.tags) + const tags = check.tags ?? [] + const checkGroup = this.getCheckGroup(project, check) + if (checkGroup) { + const checkGroupTags = checkGroup.tags ?? [] + tags.concat(checkGroupTags) + } + return filterByTags(targetTags?.map((tags: string) => tags.split(',')) ?? [], tags) }) .map(([key, check]) => { check.logicalId = key @@ -346,4 +352,12 @@ export default class Test extends AuthCommand { } } } + + private getCheckGroup (project: Project, check: Check) { + if (!check.groupId) { + return + } + const ref = check.groupId.ref.toString() + return project.data['check-group'][ref] + } }