Hello again, I am pretty new with K6 and load testing in general.
I am trying to create a PUT request test using the below example. The data I am trying to upload isn’t in a JSON format and when I try to change it it gives “ERRO[0000] ReferenceError: knwf is not defined” Any thought?
import http from 'k6/http';
export default function () {
// send custom payload/put data
const payload = JSON.stringify({
name: 'Bert'
});
// send put request with custom header and payload
const response = http.put('https://httpbin.test.k6.io/put', payload, {
headers: {
'Content-Type': 'application/json',
},
});
// show response code in console
console.log(response.status);
}
Hello, I run a script and I don’t see your error:
max@macbook-m Downloads % k6 run test.js
/\ |‾‾| /‾‾/ /‾‾/
/\ / \ | |/ / / /
/ \/ \ | ( / ‾‾\
/ \ | |\ \ | (‾) |
/ __________ \ |__| \__\ \_____/ .io
execution: local
script: test.js
output: -
scenarios: (100.00%) 1 scenario, 1 max VUs, 10m30s max duration (incl. graceful stop):
* default: 1 iterations for each of 1 VUs (maxDuration: 10m0s, gracefulStop: 30s)
INFO[0001] 200 source=console
running (00m00.6s), 0/1 VUs, 1 complete and 0 interrupted iterations
default ✓ [========================] 1 VUs 00m00.6s/10m0s 1/1 iters, 1 per VU
data_received..................: 4.3 kB 7.2 kB/s
data_sent......................: 524 B 886 B/s
http_req_blocked...............: avg=440.02ms min=440.02ms med=440.02ms max=440.02ms p(90)=440.02ms p(95)=440.02ms
http_req_connecting............: avg=143.76ms min=143.76ms med=143.76ms max=143.76ms p(90)=143.76ms p(95)=143.76ms
http_req_duration..............: avg=149.86ms min=149.86ms med=149.86ms max=149.86ms p(90)=149.86ms p(95)=149.86ms
{ expected_response:true }...: avg=149.86ms min=149.86ms med=149.86ms max=149.86ms p(90)=149.86ms p(95)=149.86ms
http_req_failed................: 0.00% ✓ 0 ✗ 1
http_req_receiving.............: avg=99µs min=99µs med=99µs max=99µs p(90)=99µs p(95)=99µs
http_req_sending...............: avg=85µs min=85µs med=85µs max=85µs p(90)=85µs p(95)=85µs
http_req_tls_handshaking.......: avg=169.5ms min=169.5ms med=169.5ms max=169.5ms p(90)=169.5ms p(95)=169.5ms
http_req_waiting...............: avg=149.67ms min=149.67ms med=149.67ms max=149.67ms p(90)=149.67ms p(95)=149.67ms
http_reqs......................: 1 1.691535/s
iteration_duration.............: avg=590.17ms min=590.17ms med=590.17ms max=590.17ms p(90)=590.17ms p(95)=590.17ms
iterations.....................: 1 1.691535/s
Can you run this example and recheck your error?