This gist contains the minimum needed to run qUnit tests and a example of the most common features you will want to get aquanted with when you start writing tests.
It is viewable online at https://gist.pother.ca/7946371/
For the full API see https://qunitjs.com/api/
-
QUnit.module( name, [options], [scope] )Group related tests under a common label. -
QUnit.start()Start the test runner. -
QUnit.test( name, callback )Define a test.QUnit.test.each()Define tests using a data provider.QUnit.test.if( name, condition, callback )Define a test that is automatically skipped when a condition is false.QUnit.test.only( name, callback )Define a test that is exclusively run.QUnit.test.skip( name, [callback] )Define a test that will be skipped.QUnit.test.todo()Define a test that is not yet expected to pass.
assert.deepEqual( actual, expected, message = "" )/assert.notDeepEqual( actual, expected, message = "" )A strict and recursive (in)equal comparison.assert.equal( actual, expected, message = "" )/assert.notEqual( actual, expected, message = "" )A non-strict (in)equality comparison.expect( amount )Specify how many assertions are expected in a test.assert.false( actual, message = "" )/assert.true( actual, message = "" )A strict boolean comparison.assert.ok( state, message = "" )/assert.notOk( state, message = "" )Check if the first argument is truthy / falsy.assert.propContains( actual, expected, message = "" )/assert.notPropContains( actual, expected, message = "" )Check that an object does (not) contain certain properties.assert.propEqual( actual, expected, message = "" )/assert.notPropEqual( actual, expected, message = "" )Compare an object’s own properties for (in)equality.assert.rejects(promise, [expectedMatcher], message = "" )Test if the provided promise rejects.assert.strictEqual( actual, expected, message = "" )/assert.notStrictEqual( actual, expected, message = "" )A strict type and value comparison, checking for (in)equality.assert.throws( blockFn, [expectedMatcher], message = "" )Test if a callback throws an exception.