Reduce test flakiness (#8947)

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.
This commit is contained in:
Adam Obuchowicz 2024-02-05 15:20:24 +01:00 committed by GitHub
parent b8612344ca
commit fa4b980d67
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 12 additions and 6 deletions

View File

@ -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 ===
@ -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))
}

View File

@ -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'

View File

@ -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",

View File

@ -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 },
@ -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,