Menu
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.5.0/index.js';

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