Skip to content

Conversation

AgnesToulet
Copy link
Contributor

@AgnesToulet AgnesToulet commented Oct 7, 2025

What?

This PR implements two functions to remove routes that were added using the page.route function:

  • page.unroute(url): removes the route(s) that match the same URL (url needs to be exactly what was used in the route function, it can't be a regex that matches the string used in route - this is the behavior of Playwright as well).
  • page.unrouteAll(): removes all routes

Note: unroute(url, handler) as in PW will be way harder to implement in the k6 project because of the Sobek layer so this isn't included in this PR. We are waiting for strong interest from users before deciding to look into it.

Why?

This allows users to reset the routes setup during a test or between tests if needed.

Checklist

  • I have performed a self-review of my code.
  • I have commented on my code, particularly in hard-to-understand areas.
  • I have added tests for my changes.
  • I have run linter and tests locally (make check) and all pass.

Checklist: Documentation (only for k6 maintainers and if relevant)

Please do not merge this PR until the following items are filled out.

  • I have added the correct milestone and labels to the PR.
  • I have updated the release notes: link
  • I have updated or added an issue to the k6-documentation: grafana/k6-docs#NUMBER if applicable
  • I have updated or added an issue to the TypeScript definitions: grafana/k6-DefinitelyTyped#NUMBER if applicable

Related PR(s)/Issue(s)

Closes #4501

@AgnesToulet AgnesToulet requested a review from a team as a code owner October 7, 2025 09:35
@AgnesToulet AgnesToulet requested review from joanlopez and mstoykov and removed request for a team October 7, 2025 09:35
@AgnesToulet AgnesToulet added area: browser browser: playwright related to Playwright compatibility labels Oct 7, 2025
@AgnesToulet AgnesToulet added this to the v1.4.0 milestone Oct 7, 2025
@AgnesToulet AgnesToulet temporarily deployed to azure-trusted-signing October 7, 2025 09:41 — with GitHub Actions Inactive
@AgnesToulet AgnesToulet temporarily deployed to azure-trusted-signing October 7, 2025 09:44 — with GitHub Actions Inactive
@AgnesToulet AgnesToulet temporarily deployed to azure-trusted-signing October 14, 2025 12:35 — with GitHub Actions Inactive
@AgnesToulet AgnesToulet temporarily deployed to azure-trusted-signing October 14, 2025 12:37 — with GitHub Actions Inactive
@AgnesToulet AgnesToulet changed the title Implement unroute(url) and unrouteAll browser: Implement unroute(url) and unrouteAll Oct 14, 2025
joanlopez
joanlopez previously approved these changes Oct 16, 2025
Copy link
Contributor

@joanlopez joanlopez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great!! 🚀 I left a minor suggestion, but it's non-blocking at all.

@AgnesToulet AgnesToulet merged commit 4b59af8 into master Oct 17, 2025
39 of 40 checks passed
@AgnesToulet AgnesToulet deleted the add/unroute-unrouteAll branch October 17, 2025 07:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: browser browser: playwright related to Playwright compatibility

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement unroute(url[, handler])

3 participants