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 ...
}
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
There are two techniques which can be used to record/capture/convert browser user activity into a test:
npm install --save har-to-k6
. This captures protocol-level interaction.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:
npx har-to-k6 archive.har -o my-k6-script.js
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
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