MARIE CRUZ
@mcruzdrake | testingwithmarie.com
Developer Advocate at k6.io, Grafana Labs
@mcruzdrake | testingwithmarie.com
@mcruzdrake | testingwithmarie.com
@mcruzdrake | testingwithmarie.com
@mcruzdrake | testingwithmarie.com
@mcruzdrake | testingwithmarie.com
@mcruzdrake | testingwithmarie.com
@mcruzdrake | testingwithmarie.com
@mcruzdrake | testingwithmarie.com
@mcruzdrake | testingwithmarie.com
@mcruzdrake | testingwithmarie.com
@mcruzdrake | testingwithmarie.com
SMOKE TESTING
STRESS TESTING
LOAD TESTING
SPIKE TESTING
SOAK TESTING
@mcruzdrake | testingwithmarie.com
@mcruzdrake | testingwithmarie.com
@mcruzdrake | testingwithmarie.com
@mcruzdrake | testingwithmarie.com
@mcruzdrake | testingwithmarie.com
@mcruzdrake | testingwithmarie.com
@mcruzdrake | testingwithmarie.com
@mcruzdrake | testingwithmarie.com
import http from 'k6/http';
import { check, sleep } from 'k6';
export const options = {
stages: [
{ duration: '30s', target: 20 },
{ duration: '1m30s', target: 10 },
{ duration: '20s', target: 0 },
],
};
export default function () {
const res = http.get('https://httpbin.test.k6.io/');
check(res, { 'status was 200': (r) => r.status == 200 });
sleep(1);
}
@mcruzdrake | testingwithmarie.com
k6 run <filename>
@mcruzdrake | testingwithmarie.com
@mcruzdrake | testingwithmarie.com
@mcruzdrake | testingwithmarie.com
@mcruzdrake | testingwithmarie.com
@mcruzdrake | testingwithmarie.com
// Install xk6
go install go.k6.io/xk6/cmd/xk6@latest
// Build xk6-browser binary
xk6 build --output xk6-browser --with github.com/grafana/xk6-browser
@mcruzdrake | testingwithmarie.com
import { chromium } from 'k6/x/browser';
export default function () {
const browser = chromium.launch({ headless: false })
const page = browser.newPage()
page.goto('https://test.k6.io/my_messages.php', { waitUntil: 'networkidle' })
page.close()
browser.close()
}
@mcruzdrake | testingwithmarie.com
xk6-browser run <filename>
@mcruzdrake | testingwithmarie.com
@mcruzdrake | testingwithmarie.com
export default function () {
const browser = chromium.launch({
headless: false,
slowMo: '500ms'
})
const page = browser.newPage()
page.goto('https://test.k6.io/my_messages.php', { waitUntil: 'networkidle' })
page.locator('input[name="login"]').type('admin');
page.locator('input[name="password"]').type('123');
Promise.all([
page.waitForNavigation(),
page.locator('input[type="submit"]').click()
]).then(() => {
check(page, {
'header': page.locator('h2').textContent() == 'Welcome, admin!',
});
}).finally(() => {
page.close();
browser.close();
})
}
@mcruzdrake | testingwithmarie.com
@mcruzdrake | testingwithmarie.com
@mcruzdrake | testingwithmarie.com
import { chromium } from 'k6/x/browser'
import { check } from 'k6'
import http from 'k6/http'
export const options = {
scenarios: {
messages: {
executor: 'constant-vus',
exec: 'messages',
vus: 1,
duration: '10s',
},
news: {
executor: 'constant-vus',
exec: 'news',
vus: 20,
duration: '1m',
},
}
}
export function messages() {
const browser = chromium.launch({ headless: false })
const page = browser.newPage()
page.goto('https://test.k6.io/my_messages.php', { waitUntil: 'networkidle' })
page.close()
browser.close()
}
export function news() {
const res = http.get('https://test.k6.io/news.php')
check(res, {
'status is 200': (r) => r.status === 200
});
}
@mcruzdrake | testingwithmarie.com
@mcruzdrake | testingwithmarie.com
@mcruzdrake | testingwithmarie.com
@mcruzdrake | testingwithmarie.com
MARIE CRUZ
@mcruzdrake | testingwithmarie.com
Developer Advocate at k6.io, Grafana Labs