go.k6.io/k6/v2 v2.0.0-20260424133653-c3427b0487c8
Backtick shell command-substitution syntaxBasename is uppercase README.md
SHA-2563ad6db2b44be8185ca4dccf2aa2d4e96db4dae6d78bd2fdd667f1590db09c317
Evidence
1import { group, check, sleep } from "k6";
2import { Counter, Rate } from "k6/metrics";
3import http from "k6/http";
4
5export let options = {
⋯4 lines
10};
11
12let mCounter = new Counter("my_counter");
13let mRate = new Rate("my_rate");
14
15export default function() {
⋯9 lines
25
26 group("json", function() {
27 let res = http.get("https://httpbin.org/get", {
28 headers: { "X-Test": "abc123" },
29 });
30
31 check(res, {
32 "status is 200": (res) => res.status === 200,
33 "X-Test header is correct": (res) => res.json().headers['X-Test'] === "abc123",
34 });
35 });
36
37 group("html", function() {
38 const res = http.get("https://quickpizza.grafana.com/test.k6.io/")
39 console.log(res.html("p.description").text())
40 check(res, {
⋯8 lines
118:48… ources
119function doFrontPage() {
120 // Load the front page.
121 check(http.get(baseURL + "/"), {
122 "title is correct": (res) => res.html("title").text() == "Welcome to David li commerce-test | David li comme …
130:17… () {
131 // Request the login page.
132 let res = http.get(baseURL + "/user/login");
133 check(res, {
134 "title is correct": (res) => res.html("title").text() == "User account | David li commerce-test",
⋯13 lines
148 pass: creds.password,
149 form_build_id: formBuildID,
150 form_id: "user_login",
151 op: "Log in",
152 };
153 let headers = { "Content-Type": "application/x-www-form-urlencoded" };
154 // Send login request
155 let res = http.post(baseURL + "/user/login", formdata, { headers: headers });
156 // Verify that we ended up on the user page
157 check(res, {
158 "login succeeded": (res) => res.url == `${baseURL}/users/${creds.username}`,
159 }) || fail("login failed");
160 });
161}
162
163// Load a product category page, then potentially load some product pa …
300:84… ommerce_payment_example",
301 "commerce_payment[payment_details][credit_card][number]": "4111111111111111",
302 "commerce_payment[payment_details][credit_card][exp_month]": "03",
303 "commerce_payment[payment_details][credit_card][exp_year]": "2019",
304 "form_build_id": formBuildID,
305 "form_token": formToken,
306 "form_id": formID,
307 "op": "Continue to next step"
308 …
313:2… // /checkout/7/paypal_ec, in turn, will redirect to /checkout/7/complete
314 check(res, {
315 "Checkout 6: checkout complete": (res) => res.html("h1").text() === "Checkout complete"
316 }) || fail("review a …
Showing the top 5 files — 3 more files (39 regions) not shown.