QA Wolf logo

QA Wolf

/

Star

2.8k

Use localhost

In this tutorial, we'll create a test on localhost. For now, you should use a service like ngrok or localtunnel to do this.

This is helpful for:

  • testing a new feature while you are developing it
  • adding test attributes like data-qa=search-button to your site while creating a test

We are considering making testing localhost easier. If this is something you're interested in, please contact us.

Start localtunnel

First, we need to install a service like ngrok or localtunnel. Install localtunnel with the following command:

npm install -g localtunnel

First we need to start a local runner.

Now create a URL to your site by running the following command. This will create a URL that points to localhost:3000:

lt --port 3000

The result of this command is a URL you can use to create your test.

Localtunnel URL

To stop running localtunnel, press CTRL+C.

Test localhost

To create a test on localhost, use the tunnel URL in your test.

const { context } = await launch();
const page = await context.newPage();
await page.goto("https://dry-sloth-7.loca.lt");

Now we are creating our test on localhost. 🎉