assert.ok(value[, message])
Tests if value
is truthy. It is equivalent to assert.equal(!!value, true, message)
.
If value
is not truthy, an AssertionError
is thrown with a message
property set equal to the value of the message
parameter. If the message
parameter is undefined
, a default error message is assigned.
const assert = require('assert'); assert.ok(true); // OK assert.ok(1); // OK assert.ok(false); // throws "AssertionError: false == true" assert.ok(0); // throws "AssertionError: 0 == true" assert.ok(false, 'it\'s false'); // throws "AssertionError: it's false"
Please login to continue.