Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 1,000,000+ packages pre-installed, including qunit-assert-compare with all npm packages installed. Try it out:

require("qunitjs/package.json"); // qunitjs is a peer dependency. var qunitAssertCompare = require("qunit-assert-compare")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

qunit-assert-compare v1.1.0

A QUnit plugin for asserting numerical comparisons like greater than, less than, etc.

Build Status NPM version


A QUnit plugin for asserting numerical comparisons like greater than, less than, etc.

QUnit numerical comparison assertion plugin

This plugin for QUnit adds a handful of custom assertion methods to test for various numerical comparison situations:

  • eq: equal to
  • neq: not equal to
  • lt: less than
  • lte: less than or equal to
  • gt: greater than
  • gte: greater than or equal to
  • compare: sorting-style comparisons


assert.eq(num1, num2, message);
assert.neq(num1, num2, message);, num2, message);
assert.lte(num1, num2, message);, num2, message);
assert.gte(num1, num2, message);, num2, expected, message);


  • num1: The lefthand operand
  • num2: The righthand operand
  • message: Optional message, same as for other assertions
  • expected: [ONLY used for!] A sorting-style return value for the numerical comparison:
    • -1 (less than)
    • 0 (equal to)
    • 1 (greater than)


module('Example module')

test('Example unit test', function(assert) {
  assert.eq(2, 2);
  assert.neq(-2, 2);, 2);
  assert.lte(2, 2);, -2);
  assert.gte(2, 2);, 2, -1);

For more examples, refer to the unit tests.


In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using grunt.


Copyright (c) 2015-2016 James M. Greene Licensed under the MIT license.

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free