Important: This documentation is about an older version. It's relevant only to the release noted, many of the features and functions have been updated or replaced. Please view the current version.

Open source

toBeGreaterThan()

The toBeGreaterThan() method asserts that a numeric value is greater than another value.

Syntax

JavaScript
expect(actual).toBeGreaterThan(expected);
expect(actual).not.toBeGreaterThan(expected);

Parameters

ParameterTypeDescription
expectednumberThe value to compare against

Returns

TypeDescription
voidNo return value

Description

The toBeGreaterThan() method performs a numeric comparison using the > operator. Both values must be numbers, or the assertion will fail.

Usage

JavaScript
import { expect } from 'https://jslib.k6.io/k6-testing/0.6.1/index.js';

export default function () {
  expect(5).toBeGreaterThan(3);
  expect(10.5).toBeGreaterThan(10);
  expect(-1).toBeGreaterThan(-5);
  expect(0).toBeGreaterThan(-1);
}