All notes
Quni

Quick Start

qunitjs.com.


npm install -g qunitjs

# Create test files in a test directory and then simply run:
qunit

# Run a set of tests
qunit 'tests/*-test.js'

qunit --help

tests.js:


QUnit.test( "hello test", function( assert ) {
  assert.ok( 1 == "1", "Passed!" );
});

Assertions

api.qunitjs.com.

ok
A boolean check, equivalent to CommonJS's assert.ok() and JUnit's assertTrue(). Passes if the first argument is truthy.

equal
A non-strict comparison.

deepEqual
A deep recursive comparison, working on primitive types, arrays, objects, regular expressions, dates and functions.

propEqual
A strict type and value comparison of an object's own properties.

strictEqual
A strict type and value comparison.

----------

notOk
  A boolean check. Passes if the first argument is falsy.

notEqual
  A non-strict comparison, checking for inequality.

notDeepEqual
  An inverted deep recursive comparison, working on primitive types, arrays, objects, regular expressions, dates and functions.

notPropEqual
  A strict comparison of an object's own properties, checking for inequality.

notStrictEqual
  A strict comparison, checking for inequality.

----------

async
Instruct QUnit to wait for an asynchronous operation.

expect
Specify how many assertions are expected to run within a test.

pushResult
Report the result of a custom assertion.

rejects
Test if the provided promise rejects, and optionally compare the rejection value.

step
A marker for progress in a given test.

throws
Test if a callback throws an exception, and optionally compare the thrown error.

timeout
Sets the length of time to wait for async operations before failing the test.

verifySteps
A helper assertion to verify the order and number of steps in a test.