Skip to content

Latest commit

 

History

History
43 lines (35 loc) · 1018 Bytes

File metadata and controls

43 lines (35 loc) · 1018 Bytes
layout page-api
title assert.notOk()
excerpt Check if the first argument is falsy.
groups
assert
redirect_from
/assert/notOk/
/notOk/
version_added 1.18.0

notOk( state, message = "" )

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

name description
state Expression 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

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');
});