I just want to check which user failed the login… so I used below code, but the variable of login name is not getting in the custom text “user login error ${username}”
check(response, {
"user login error `${username}`" : (r) =>
r.body.includes('welcome user'),
});
Hi @venkatareddy
I think you’ll need a slightly different syntax. The following example works for me:
import { check } from 'k6';
import http from 'k6/http';
const url = 'http://test.k6.io/';
export default function () {
const res = http.get(url);
check(res, {
[`${url} is status 200`]: (r) => r.status === 200,
});
}
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)
✓ http://test.k6.io/ is status 200
checks.........................: 100.00% ✓ 1 ✗ 0
data_received..................: 17 kB 31 kB/s
data_sent......................: 547 B 985 B/s
http_req_blocked...............: avg=169.05ms min=114.26ms med=169.05ms max=223.84ms p(90)=212.88ms p(95)=218.36ms
http_req_connecting............: avg=107.74ms min=102.99ms med=107.74ms max=112.5ms p(90)=111.55ms p(95)=112.02ms
http_req_duration..............: avg=108ms min=102.52ms med=108ms max=113.49ms p(90)=112.39ms p(95)=112.94ms
{ expected_response:true }...: avg=108ms min=102.52ms med=108ms max=113.49ms p(90)=112.39ms p(95)=112.94ms
http_req_failed................: 0.00% ✓ 0 ✗ 2
http_req_receiving.............: avg=174.5µs min=134µs med=174.5µs max=215µs p(90)=206.9µs p(95)=210.95µs
http_req_sending...............: avg=46µs min=42µs med=46µs max=50µs p(90)=49.2µs p(95)=49.6µs
http_req_tls_handshaking.......: avg=60.36ms min=0s med=60.36ms max=120.72ms p(90)=108.65ms p(95)=114.68ms
http_req_waiting...............: avg=107.78ms min=102.34ms med=107.78ms max=113.23ms p(90)=112.14ms p(95)=112.68ms
http_reqs......................: 2 3.602695/s
iteration_duration.............: avg=554.98ms min=554.98ms med=554.98ms max=554.98ms p(90)=554.98ms p(95)=554.98ms
iterations.....................: 1 1.801347/s
running (00m00.6s), 0/1 VUs, 1 complete and 0 interrupted iterations
default ✓ [======================================] 1 VUs 00m00.6s/10m0s 1/1 iters, 1 per VU
I hope this helps 
Cheers!
@eyeveebee Thanks for your help and support.