---
title: "Events are missing after a click in a browser test"
description: "A Playwright test clicks a link that leaves the page, and the click and the page view before it never arrive. Remove the test's routes before the click."
canonical: "https://www-stage.togohq.ai/docs/troubleshooting/automated-tests"
applies_to: "@togohq/sdk-browser 2.x, Playwright"
updated: "2026-11-21T00:00:00Z"
---

# Events are missing after a click in a browser test

A Playwright test clicks a link that leaves the page, and the click and the page view before it never arrive. Remove the test's routes before the click.

## What you see

A browser test clicks a link that leaves the page — to another page of your site, to a sign-up
page, to an app store. `verify_tracking` then reports the click, and usually the page view before
it, as missing. Adding `flush()` after every `track()` makes them arrive.

Your site is not losing these events. The SDK sends what is queued as the page is left (on
`pagehide`), and something in the test stops that request.

## The usual causes

1. **The test intercepts requests.** In Playwright, `page.route()` or `context.route()` holds
   **every** request the page makes until the test lets it continue — not only the ones the
   pattern matches. A route that stubs App Store links therefore holds Togo's request too. The
   request sent as the page is left belongs to a page that no longer exists, so it is never let
   through, and it is cancelled when the browser closes, however long the test waits. Your
   visitors' browsers intercept nothing, so production is not affected.
2. **The test reads its own request log.** A request sent while a page unloads may not appear in
   Playwright's `request` events even when it reaches Togo. Check with `verify_tracking`, never with
   the test's network log.

## Check the fix

Remove the routes before the click that leaves the page, then check the run:

```ts
await page.route(/apps\.apple\.com/, (route) => route.fulfill({ status: 200, body: '' }));
await page.goto('http://localhost:4321/');
// ...steps that need the stub...

await page.unrouteAll({ behavior: 'ignoreErrors' });
await page.getByRole('link', { name: 'Sign up' }).click();
```

Then ask your agent to call `verify_tracking` with the test browser's device id and the event names
you expect ([Check that events arrive](/docs/verify)). Every count is 0 when the fix is right.

Do not keep `flush()` after every `track()` to make a test pass. It sends each event as its own
request in every visitor's browser, and it hides the test's problem rather than fixing it. Call
`flush()` where the [browser SDK reference](/docs/reference/sdk-browser#flush) says to.
