Skip to content

Commit c1902f0

Browse files
committed
Fix flaky E2E test cases - update BasePage.ts so expectNoErrors() filters out known non-actionable Firefox/Vite HMR websocket noise ('WebSocket closed without opened') before asserting pageErrors().length. Added isIgnorablePageError() helper with documentation.
1 parent 6592798 commit c1902f0

2 files changed

Lines changed: 56 additions & 2 deletions

File tree

e2e-stress-run.sh

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#!/usr/bin/env bash
2+
set -uo pipefail
3+
4+
SUCCESS_FILE="/tmp/e2e-stress-run-success-count"
5+
6+
if [[ ! -f .env.development ]]; then
7+
echo "Missing .env.development file" >&2
8+
exit 1
9+
fi
10+
11+
# Load dev environment variables so every Playwright run matches local stress conditions.
12+
set -a
13+
source .env.development
14+
set +a
15+
16+
if [[ ! -f "$SUCCESS_FILE" ]]; then
17+
echo "0" > "$SUCCESS_FILE"
18+
fi
19+
20+
while true; do
21+
CI=1 FORCE_COLOR=1 E2E_MOCKS=1 npx playwright test
22+
status=$?
23+
24+
if [[ $status -eq 0 ]]; then
25+
count=$(<"$SUCCESS_FILE")
26+
if ! [[ "$count" =~ ^[0-9]+$ ]]; then
27+
count=0
28+
fi
29+
count=$((count + 1))
30+
echo "$count" > "$SUCCESS_FILE"
31+
echo "Number of successful runs: $count"
32+
else
33+
count=$(<"$SUCCESS_FILE")
34+
if ! [[ "$count" =~ ^[0-9]+$ ]]; then
35+
count=0
36+
fi
37+
echo "Number of successful runs before failure: $count"
38+
exit $status
39+
fi
40+
41+
done

test/e2e/helpers/pageObjectModels/BasePage.ts

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -862,8 +862,9 @@ export class BasePage {
862862
async expectNoErrors(): Promise<Array<Error>> {
863863
await this.waitForPageComplete()
864864
const errors = await this._page.pageErrors()
865-
expect(errors).toHaveLength(0)
866-
return await this._page.pageErrors()
865+
const filteredErrors = errors.filter((error) => !this.isIgnorablePageError(error))
866+
expect(filteredErrors).toHaveLength(0)
867+
return filteredErrors
867868
}
868869

869870
/**
@@ -1177,4 +1178,16 @@ export class BasePage {
11771178
await expect(label).toBeVisible()
11781179
await expect(label).toContainText(pattern)
11791180
}
1181+
1182+
/**
1183+
* Filter recurring non-actionable browser errors (e.g., Firefox HMR websockets) from pageErrors().
1184+
*/
1185+
private isIgnorablePageError(error: Error): boolean {
1186+
const message = error?.message ?? ''
1187+
1188+
// Firefox occasionally surfaces this when Vite's HMR websocket retries during stress runs.
1189+
if (message.includes('WebSocket closed without opened')) return true
1190+
1191+
return false
1192+
}
11801193
}

0 commit comments

Comments
 (0)