Skip to content

Commit 5dbc83f

Browse files
authored
fix: fix broken and flaky e2e test (#1008)
* feat: disable fancy output for e2e tests because some are super flaky * fix: flaky e2e test only passed due to varying progress messages
1 parent 611733f commit 5dbc83f

File tree

7 files changed

+59
-8
lines changed

7 files changed

+59
-8
lines changed

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

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,29 @@ Update and Unchanged:
234234
})
235235
expect(resultOne.status).toBe(0)
236236
expect(resultTwo.status).toBe(0)
237-
expect(resultOne.stdout).not.toEqual(resultTwo.stdout)
237+
expect(resultOne.stdout).toContain(
238+
`Create:
239+
ApiCheck: api-check
240+
ApiCheck: api-check-high-freq
241+
HeartbeatCheck: heartbeat-check-1
242+
BrowserCheck: homepage-browser-check
243+
CheckGroup: my-group-1
244+
Dashboard: dashboard-1
245+
MaintenanceWindow: maintenance-window-1
246+
PrivateLocation: private-location-1
247+
`)
248+
expect(resultTwo.stdout).toContain(
249+
`Create:
250+
ApiCheck: api-check
251+
ApiCheck: api-check-high-freq
252+
HeartbeatCheck: heartbeat-check-1
253+
BrowserCheck: homepage-browser-check
254+
BrowserCheck: snapshot-test.test.ts
255+
CheckGroup: my-group-1
256+
Dashboard: dashboard-1
257+
MaintenanceWindow: maintenance-window-1
258+
PrivateLocation: private-location-1
259+
`)
238260
})
239261

240262
it('Should terminate when no resources are found', async () => {
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { expect, test } from '@playwright/test'
2+
3+
test.use({ actionTimeout: 10000 })
4+
5+
test('Danube Snapshot Test', async ({ page }) => {
6+
await page.goto('https://danube-web.shop')
7+
await expect(page).toHaveScreenshot({ maxDiffPixels: 10000 })
8+
})

packages/cli/e2e/run-checkly.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ export function runChecklyCli (options: {
3737
// Once 4.8.0 has been released, we can remove the 4.8.0 fallback here.
3838
CHECKLY_CLI_VERSION: cliVersion ?? '4.8.0',
3939
CHECKLY_E2E_PROMPTS_INJECTIONS: promptsInjection?.length ? JSON.stringify(promptsInjection) : undefined,
40+
CHECKLY_E2E_DISABLE_FANCY_OUTPUT: '1',
4041
...env,
4142
},
4243
cwd: directory ?? process.cwd(),

packages/cli/src/commands/baseCommand.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ export type BaseCommandClass = typeof Command & {
1010
export abstract class BaseCommand extends Command {
1111
static coreCommand = false
1212
static hidden = true
13+
fancy = true
1314

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

39+
if (process.env.CHECKLY_E2E_DISABLE_FANCY_OUTPUT) {
40+
this.fancy = false
41+
}
42+
3843
return super.init()
3944
}
4045

packages/cli/src/commands/deploy.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,9 @@ export default class Deploy extends AuthCommand {
7474
}
7575

7676
async run (): Promise<void> {
77-
ux.action.start('Parsing your project', undefined, { stdout: true })
77+
if (this.fancy) {
78+
ux.action.start('Parsing your project', undefined, { stdout: true })
79+
}
7880
const { flags } = await this.parse(Deploy)
7981
const {
8082
force,
@@ -113,7 +115,10 @@ export default class Deploy extends AuthCommand {
113115
checklyConfigConstructs,
114116
})
115117
const repoInfo = getGitInformation(project.repoUrl)
116-
ux.action.stop()
118+
119+
if (this.fancy) {
120+
ux.action.stop()
121+
}
117122

118123
if (!preview) {
119124
for (const check of Object.values(project.data.check)) {

packages/cli/src/commands/sync-playwright.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ export default class SyncPlaywright extends BaseCommand {
1212
static description = 'Copy Playwright config into the Checkly config file.'
1313

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

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

43-
ux.action.stop('✅ ')
45+
if (this.fancy) {
46+
ux.action.stop('✅ ')
47+
}
4448
this.log('Successfully updated Checkly config file')
4549
this.exit(0)
4650
}
4751

4852
private handleError (message: string) {
49-
ux.action.stop('❌')
53+
if (this.fancy) {
54+
ux.action.stop('❌')
55+
}
5056
this.log(message)
5157
this.exit(1)
5258
}

packages/cli/src/commands/test.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,9 @@ export default class Test extends AuthCommand {
124124
static strict = false
125125

126126
async run (): Promise<void> {
127-
ux.action.start('Parsing your project', undefined, { stdout: true })
127+
if (this.fancy) {
128+
ux.action.start('Parsing your project', undefined, { stdout: true })
129+
}
128130

129131
const { flags, argv } = await this.parse(Test)
130132
const {
@@ -228,7 +230,9 @@ export default class Test extends AuthCommand {
228230
check.snapshots = await uploadSnapshots(check.rawSnapshots)
229231
}
230232

231-
ux.action.stop()
233+
if (this.fancy) {
234+
ux.action.stop()
235+
}
232236

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

0 commit comments

Comments
 (0)