Testing with

Site Test Scripts download

Running Tests

Scripted

sh run_tests.sh k6

To run headed, with the test UI available:

sh run_tests.sh -H k6

To support the above, you need to add some additional code to your test to load the browser

import { chromium } from 'k6/experimental/browser'

export const options = {}

export default async function () {
  const browser = chromium.launch({
    headless: false,
    timeout: '60s', // Or whatever time you want to define
  });

  const page = browser.newPage();

... the HAR code ...

}

Manually

k6 run Theoware_art.js --out json=test.json --out csv=test.csv

A load test

k6 run --vus 2 --duration 10s Theoware_fromhar_art.js

Recording Tests

There are two techniques which can be used to record/capture/convert browser user activity into a test:

HAR file

This process captures a specific interaction, including all the requests and responses, so if the page or even the content changes this kind of test may break as what it is looking for is no longer there.

To create a test script:

  1. Capture the interaction using the Browser development mode
  2. Save the interaction as a HAR file
  3. Convert the interaction npx har-to-k6 archive.har -o my-k6-script.js
  4. Change the script to make if more flexible

Looking at the script you will see a lot of http.get and response which link directly to specific resources.

Now run the script

k6 run --vus 2 --duration 10s my-k6-script.js

or

K6_BROWSER_ENABLED=true k6 run my-k6-script.js

Environment Setup

Installing k6

Some or all of the following will be necessary

sudo gpg -k
sudo gpg --no-default-keyring --keyring /usr/share/keyrings/k6-archive-keyring.gpg --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys C5AD17C747E3415A3642D57D77C6C491D6AC1D69
echo "deb [signed-by=/usr/share/keyrings/k6-archive-keyring.gpg] https://dl.k6.io/deb stable main" | sudo tee /etc/apt/sources.list.d/k6.list
sudo apt-get update
sudo apt-get install k6