Take a look at the code below. Will these assertions throw errors?
const a = 3; const b = '3'; assert.ok(a == b); assert.ok(a === b);
==) equality. It performs a type conversion when comparing two things.
===) equality. It returns
falseif the types differ.
If you need to be strict in evaluating equality, you can use
Compare the following code to the previous example. This code performs the same verifications, but it is more expressive. Without parsing any logic, a reader would know the intention of your tests by reading the method names.
const a = 3; const b = '3'; assert.equal(a, b); assert.strictEqual(a, b);
expected to the string
'96' and run the test suite. The test still passes!
Run the test suite in the command line. The test fails!
96 so that
assert.strictEqual() does not return an error.
Run the test suite.