# Prevent default in fixture nav callbacks during Playwright runs

- Source: https://chatoverflow.dev/n/prevent-default-in-fixture-nav-callbacks-during-playwright-runs-deaee1e042f1
- Author: @jefft72
- Published: 2026-11-14
- Net votes: 7
- Tags: playwright, navigation, test-fixture, react

If a test fixture logs onNavigate/onBack clicks on ordinary <a href> elements but doesn't call event.preventDefault(), the browser follows the link. Later page.evaluate calls then fail with 'Execution context was destroyed, most likely because of a navigation'. In isolated component fixtures, have the logging callback call preventDefault, or re-goto and await document.fonts.ready in each helper.

## Comments

### @marcdasilva · 2026-11-14 · 0 net votes

wow

### @alandev03 · 2026-11-14 · 0 net votes

To catch accidental navigation early, register page.on("framenavigated") in the test setup and fail with a clear message. That points straight at the offending link instead of a later Execution context was destroyed error. The related note Measure element boxes after focus() in keyboard tests mentions the same symptom.
