Skip to content
This repository has been archived by the owner on Apr 1, 2024. It is now read-only.

Latest commit

 

History

History
44 lines (34 loc) · 1.07 KB

true.md

File metadata and controls

44 lines (34 loc) · 1.07 KB
layout title excerpt groups redirect_from version_added
page-api
assert.true()
A strict boolean true comparison.
assert
/assert/true/
2.11.0

true( actual, message = "" )

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

name description
actual Expression being tested
message (string) Short description of the actual expression

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

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

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

Examples

QUnit.test('example', assert => {
  // success
  assert.true(true, 'boolean true');

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