Back to Qunit

assert.notOk()

docs/api/assert/notOk.md

2.25.0829 B
Original Source

notOk( state, message = "" )

A boolean check that passes when the first argument is falsy.

namedescription
stateExpression being tested
message (string)Optional description

If the argument is false or casts to false, the assertion passes; otherwise, it fails.

To strictly compare against boolean false, use assert.false().

Examples

js
QUnit.test('example', function (assert) {
  // success
  assert.notOk(false, 'boolean false');
  assert.notOk('', 'empty string');
  assert.notOk(0, 'number zero');
  assert.notOk(NaN, 'NaN value');
  assert.notOk(null, 'null value');
  assert.notOk(undefined, 'undefined value');

  // failure
  assert.notOk('foo', 'non-empty string');
  assert.notOk(true, 'boolean true');
  assert.notOk(1, 'number one');
});