« Back to QUnit

[edit]

ok( state, [message] )

A boolean assertion, equivalent to JUnit's assertTrue. Passes if the first argument is truthy.
Arguments:
stateBoolean
A boolean expression, can be a boolean or any other type, its boolean default is evaluated.
message (Optional)String
A message to output with the assertion result.

Examples:
Add a test that contains a single assertions that is always true.

test("a test", function() {
  ok(true, "always fine");
  ok("", "empty string defaults to false, so this assertion fails");
});

NameType