diff --git a/packages/cli/e2e/__tests__/pw-test.spec.ts b/packages/cli/e2e/__tests__/pw-test.spec.ts index fb7abad20..8cf8f5f09 100644 --- a/packages/cli/e2e/__tests__/pw-test.spec.ts +++ b/packages/cli/e2e/__tests__/pw-test.spec.ts @@ -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') }) }) diff --git a/packages/cli/src/commands/pw-test.ts b/packages/cli/src/commands/pw-test.ts index ec45e14d5..28d2c7b3b 100644 --- a/packages/cli/src/commands/pw-test.ts +++ b/packages/cli/src/commands/pw-test.ts @@ -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, @@ -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) @@ -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') @@ -336,6 +344,7 @@ export default class PwTestCommand extends AuthCommand { runLocation: keyof Region, privateRunLocation: string | undefined, dir: string, + frequency: number = 10, ): Promise { const parseArgs = args.map(arg => shellQuote(arg)) const input = parseArgs.join(' ') || '' @@ -352,7 +361,7 @@ export default class PwTestCommand extends AuthCommand { name: `Playwright Test: ${input}`, testCommand, ...locationConfig, - frequency: 10, + frequency, } }