Back to Qunit

assert.strictEqual()

docs/api/assert/strictEqual.md

2.25.0905 B
Original Source

strictEqual( actual, expected, message = "" )

A strict type and value comparison.

namedescription
actualExpression being tested
expectedKnown comparison value
message (string)Optional description of the actual expression

The strictEqual() assertion provides the most rigid comparison of type and value with the strict equality operator (===).

assert.equal() can be used to test non-strict equality.

assert.notStrictEqual() can be used to explicitly test strict inequality.

Changelog

  • Prior to QUnit 1.1, this method was known as assert.same(). The alias was removed in QUnit 1.3.

Examples

Compare the value of two primitives, having the same value and type.

js
QUnit.test('strictEqual example', function (assert) {
  const result = 2;

  assert.strictEqual(result, 2);
});