Skip to content

Commit

Permalink
✅ mitigate flaky E2E tests
Browse files Browse the repository at this point in the history
  • Loading branch information
BenoitZugmeyer committed Feb 23, 2021
1 parent 1ffb4f3 commit 7c79c83
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion test/e2e/lib/helpers/sdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,22 @@ export async function flushEvents() {
)
await waitForServersIdle()
const servers = await getTestServers()
await browser.url(`${servers.base.url}/empty`)

// TODO: use /empty instead of /ok
//
// The rum-recorder code uses a Web Worker to format the request data to be sent to the intake.
// Because all Worker communication is asynchronous, it cannot send its request during the
// "beforeunload" event, but a few milliseconds after. Thus, when navigating, if the future page
// loads very quickly, the page unload may occur before rum-recorder have time to send its last
// segment.
//
// To avoid flaky e2e tests, we currently use /ok with a duration, to allow a bit more time to
// send requests to intakes when the "beforeunload" event is dispatched.
//
// The issue mainly occurs with local e2e tests (not browserstack), because the network latency is
// very low (same machine), so the request resolves very quickly. In real life conditions, this
// issue is mitigated, because requests will likely take a few milliseconds to reach the server.
await browser.url(`${servers.base.url}/ok?duration=200`)
await waitForServersIdle()
}

Expand Down

0 comments on commit 7c79c83

Please sign in to comment.