Skip to content

Commit

Permalink
feat: disable fancy output for e2e tests because some are super flaky
Browse files Browse the repository at this point in the history
  • Loading branch information
sorccu committed Jan 19, 2025
1 parent 3e7bfea commit 07cfcf4
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 7 deletions.
1 change: 1 addition & 0 deletions packages/cli/e2e/run-checkly.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export function runChecklyCli (options: {
// Once 4.8.0 has been released, we can remove the 4.8.0 fallback here.
CHECKLY_CLI_VERSION: cliVersion ?? '4.8.0',
CHECKLY_E2E_PROMPTS_INJECTIONS: promptsInjection?.length ? JSON.stringify(promptsInjection) : undefined,
CHECKLY_E2E_DISABLE_FANCY_OUTPUT: '1',
...env,
},
cwd: directory ?? process.cwd(),
Expand Down
5 changes: 5 additions & 0 deletions packages/cli/src/commands/baseCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export type BaseCommandClass = typeof Command & {
export abstract class BaseCommand extends Command {
static coreCommand = false
static hidden = true
fancy = true

protected async init (): Promise<void> {
let version = process.env.CHECKLY_CLI_VERSION ?? this.config.version
Expand All @@ -35,6 +36,10 @@ export abstract class BaseCommand extends Command {
}
}

if (process.env.CHECKLY_E2E_DISABLE_FANCY_OUTPUT) {
this.fancy = false
}

return super.init()
}

Expand Down
9 changes: 7 additions & 2 deletions packages/cli/src/commands/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,9 @@ export default class Deploy extends AuthCommand {
}

async run (): Promise<void> {
ux.action.start('Parsing your project', undefined, { stdout: true })
if (this.fancy) {
ux.action.start('Parsing your project', undefined, { stdout: true })
}
const { flags } = await this.parse(Deploy)
const {
force,
Expand Down Expand Up @@ -113,7 +115,10 @@ export default class Deploy extends AuthCommand {
checklyConfigConstructs,
})
const repoInfo = getGitInformation(project.repoUrl)
ux.action.stop()

if (this.fancy) {
ux.action.stop()
}

if (!preview) {
for (const check of Object.values(project.data.check)) {
Expand Down
12 changes: 9 additions & 3 deletions packages/cli/src/commands/sync-playwright.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ export default class SyncPlaywright extends BaseCommand {
static description = 'Copy Playwright config into the Checkly config file.'

async run (): Promise<void> {
ux.action.start('Syncing Playwright config to the Checkly config file', undefined, { stdout: true })
if (this.fancy) {
ux.action.start('Syncing Playwright config to the Checkly config file', undefined, { stdout: true })
}

const config = await loadPlaywrightConfig()
if (!config) {
Expand Down Expand Up @@ -40,13 +42,17 @@ export default class SyncPlaywright extends BaseCommand {
const dir = path.resolve(path.dirname(configFile.fileName))
this.reWriteChecklyConfigFile(checklyConfigData, configFile.fileName, dir)

ux.action.stop('✅ ')
if (this.fancy) {
ux.action.stop('✅ ')
}
this.log('Successfully updated Checkly config file')
this.exit(0)
}

private handleError (message: string) {
ux.action.stop('❌')
if (this.fancy) {
ux.action.stop('❌')
}
this.log(message)
this.exit(1)
}
Expand Down
8 changes: 6 additions & 2 deletions packages/cli/src/commands/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,9 @@ export default class Test extends AuthCommand {
static strict = false

async run (): Promise<void> {
ux.action.start('Parsing your project', undefined, { stdout: true })
if (this.fancy) {
ux.action.start('Parsing your project', undefined, { stdout: true })
}

const { flags, argv } = await this.parse(Test)
const {
Expand Down Expand Up @@ -228,7 +230,9 @@ export default class Test extends AuthCommand {
check.snapshots = await uploadSnapshots(check.rawSnapshots)
}

ux.action.stop()
if (this.fancy) {
ux.action.stop()
}

if (!checks.length) {
this.log(`Unable to find checks to run${filePatterns[0] !== '.*' ? ' using [FILEARGS]=\'' + filePatterns + '\'' : ''}.`)
Expand Down

0 comments on commit 07cfcf4

Please sign in to comment.