This is documentation for the next version of Grafana k6 documentation. For the latest stable release, go to the latest version.

Open source

unroute(url)

The method removes all routes for the url, that were previously added with page.route.

ParameterTypeDefaultDescription
urlstring or Regexp''The exact URL that was used in the page.route(url, handler) call.

Returns

TypeDescription
Promise<void>A Promise that fulfills when the route(s) is(are) removed from the page.

Example

JavaScript
import { browser } from 'k6/browser';

export const options = {
  scenarios: {
    browser: {
      executor: 'shared-iterations',
      options: {
        browser: {
          type: 'chromium',
        },
      },
    },
  },
};

export default async function () {
  const page = await browser.newPage();

  // Abort all image requests
  await page.route(/(\.png$)|(\.jpg$)/, async function (route) {
    await route.abort();
  });

  await page.goto('https://quickpizza.grafana.com/');

  await page.getByRole('button', { name: 'Pizza, Please!' }).click();

  // Stop aborting all image requests
  await page.unroute(/(\.png$)|(\.jpg$)/)

  await page.close();
}