Back to Qunit

assert.false()

docs/api/assert/false.md

2.25.0921 B
Original Source

false( actual, message = "" )

A strict comparison that passes if the first argument is boolean false.

namedescription
actualExpression being tested
message (string)Short description

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

This method is similar to the assertFalse() method found in xUnit-style frameworks.

assert.true() can be used to explicitly test for a true value.

Examples

js
QUnit.test('example', function (assert) {
  // success
  assert.false(false, 'boolean false');

  // failure
  assert.false('foo', 'non-empty string');
  assert.false('', 'empty string');
  assert.false(0, 'number zero');
  assert.false(true, 'boolean true');
  assert.false(NaN, 'NaN value');
  assert.false(null, 'null value');
  assert.false(undefined, 'undefined value');
});