0Pricing
Load Testing & Performance Benchmarking (JMeter & k6) · Lesson

Checks, Thresholds, and Metrics

Understand k6 checks for response validation and thresholds for defining performance goals.

Validate Test Responses

When performance testing, simply sending requests isn't enough. We need to confirm that the server is responding correctly, not just quickly.

This is where checks come in. Checks allow you to validate the content and status of server responses.

Simple k6 Checks

A basic check in k6 confirms a condition about the response. If the condition is false, the check fails, but the test continues.

Here's how to check if an HTTP response status is 200 (OK):

import http from 'k6/http';
import { check } from 'k6';

export default function () {
  const res = http.get('https://test.k6.io');
  check(res, {
    'status is 200': (r) => r.status === 200,
  });
  console.log(`Status: ${res.status}`);
}

All lessons in this course

  1. k6 Installation and CLI
  2. Writing Basic k6 Scripts
  3. Checks, Thresholds, and Metrics
  4. Groups and Tags for Organizing Tests
← Back to Load Testing & Performance Benchmarking (JMeter & k6)