Back to Qunit

assert.notOk()

docs/api/assert/notOk.md

2.26.0853 B
Original Source

notOk( state, message = "" )

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

namedescription
stateExpression being tested
message (string)Short description

This assertion requires only one argument. If the argument evaluates to false, the assertion passes; otherwise, it fails.

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

Examples

js
QUnit.test('example', 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');
});