Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions packages/cli/e2e/__tests__/pw-test.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,20 @@ describe('pw-test', { timeout: 45000 }, () => {
expect(checklyConfig.config?.checks?.playwrightChecks.length).toBe(1)
expect(checklyConfig.config?.checks?.playwrightChecks[0].name).toBe('Playwright Test: --grep @TAG-B')
expect(checklyConfig.config?.checks?.playwrightChecks[0].testCommand).toBe('npx playwright test --grep @TAG-B')
expect(checklyConfig.config?.checks?.playwrightChecks[0].frequency).toBe(10)
})

it('Should add a Playwright test with custom frequency', async () => {
const result = await runChecklyCli({
args: ['pw-test', '--create-check', '--frequency', '5', '--', `--grep`, '@TAG-B'],
apiKey: config.get('apiKey'),
accountId: config.get('accountId'),
directory: FIXTURE_TEST_PWT_NATIVE,
timeout: 120000, // 2 minutes
})
expect(result.status).toBe(0)
const configContent = fs.readFileSync(
path.join(FIXTURE_TEST_PWT_NATIVE, 'checkly.config.ts'), 'utf-8')
expect(configContent).toContain('frequency: 5')
})
})
11 changes: 10 additions & 1 deletion packages/cli/src/commands/pw-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,12 @@ export default class PwTestCommand extends AuthCommand {
description: 'Create a Checkly check from the Playwright test.',
default: false,
}),
'frequency': Flags.integer({
char: 'f',
description: 'The frequency in minutes for the created check.',
default: 10,
options: ['1', '2', '5', '10', '15', '30', '60', '120', '180', '360', '720', '1440'],
}),
'stream-logs': Flags.boolean({
description: 'Stream logs from the test run to the console.',
default: true,
Expand Down Expand Up @@ -121,6 +127,7 @@ export default class PwTestCommand extends AuthCommand {
'create-check': createCheck,
'stream-logs': streamLogs,
'include': includeFlag,
'frequency': frequency,
} = flags
const { configDirectory, configFilenames } = splitConfigFilePath(configFilename)
const pwPathFlag = this.getConfigPath(playwrightFlags)
Expand All @@ -147,6 +154,7 @@ export default class PwTestCommand extends AuthCommand {
runLocation as keyof Region,
privateRunLocation,
dir,
frequency,
)
if (createCheck) {
this.style.actionStart('Adding check with specified options to the Checkly config file')
Expand Down Expand Up @@ -336,6 +344,7 @@ export default class PwTestCommand extends AuthCommand {
runLocation: keyof Region,
privateRunLocation: string | undefined,
dir: string,
frequency: number = 10,
): Promise<PlaywrightSlimmedProp> {
const parseArgs = args.map(arg => shellQuote(arg))
const input = parseArgs.join(' ') || ''
Expand All @@ -352,7 +361,7 @@ export default class PwTestCommand extends AuthCommand {
name: `Playwright Test: ${input}`,
testCommand,
...locationConfig,
frequency: 10,
frequency,
}
}

Expand Down