Skip to content

Commit

Permalink
Reduce test flakiness (#8947)
Browse files Browse the repository at this point in the history
Probably fixes the first point in #8942

My guess is that the mockExpressionUpdate may be not set in cases when the test runs before App mounting. To make sure all the setup is done, we wait for `App` widget to being mounted before proceeding.

# Important Notes
This PR also change the way we run test's server. Before it was always a production build, but this makes development iteration long. Now we test production build only on CI or when `PROD=true` env variable is set.
  • Loading branch information
farmaazon authored and MichaelMauderer committed Feb 6, 2024
1 parent 235a65d commit 2c788ac
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 6 deletions.
8 changes: 6 additions & 2 deletions app/gui2/e2e/actions.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { type Page } from '@playwright/test'
import { expect, type Page } from '@playwright/test'
import * as customExpect from './customExpect'
import * as locate from './locate'

// =================
// === goToGraph ===
Expand All @@ -7,5 +9,7 @@ import { type Page } from '@playwright/test'
/** Perform a successful login. */
export async function goToGraph(page: Page) {
await page.goto('/')
// Originally this clicked the play button but for now that is out of scope.
await expect(page.locator('.App')).toBeVisible()
// Wait until nodes are loaded.
await customExpect.toExist(locate.graphNode(page))
}
2 changes: 1 addition & 1 deletion app/gui2/e2e/typesOnNodeHover.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { expect, Locator, Page, test } from '@playwright/test'
import { expect, test, type Locator, type Page } from '@playwright/test'
import assert from 'assert'
import * as actions from './actions'
import { mockExpressionUpdate } from './expressionUpdates'
Expand Down
2 changes: 1 addition & 1 deletion app/gui2/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"build": "npm --workspace enso-dashboard run compile && run-p typecheck build-only",
"build:cloud": "cross-env CLOUD_BUILD=true npm run build",
"preview": "vite preview",
"test": "vitest run && playwright test --reporter=html",
"test": "vitest run && playwright test",
"test:unit": "vitest",
"test:e2e": "playwright test",
"story:dev": "histoire dev",
Expand Down
6 changes: 4 additions & 2 deletions app/gui2/playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ export default defineConfig({
forbidOnly: !!process.env.CI,
retries: process.env.CI ? 2 : 0,
...(process.env.CI ? { workers: 1 } : {}),
reporter: 'line',
expect: {
timeout: 5000,
toHaveScreenshot: { threshold: 0 },
Expand Down Expand Up @@ -110,7 +109,10 @@ export default defineConfig({
env: {
E2E: 'true',
},
command: `npx vite build && npx vite preview --port ${PORT} --strictPort`,
command:
process.env.CI || process.env.PROD
? `npx vite build && npx vite preview --port ${PORT} --strictPort`
: `npx vite dev --port ${PORT}`,
// Build from scratch apparently can take a while on CI machines.
timeout: 120 * 1000,
port: PORT,
Expand Down

0 comments on commit 2c788ac

Please sign in to comment.