assert.notEqual()

追加されたバージョン: 1.0.0.

説明

notEqual( actual, expected, message = "" )

緩い不等性比較で、2つの値の厳密ではない差異を確認します。

名前 説明
actual テスト対象の式
expected 既知の比較値
message (string) 簡潔な説明

notEqualアサーションでは、反転した単純な比較演算子 (!=) を使用して、実際の値と期待される値を比較します。それらが等しくない場合、アサーションは合格します。それ以外の場合は失敗します。失敗すると、与えられたメッセージだけでなく、実際の値と期待される値の両方がテスト結果に表示されます。

assert.equal() は等しさをテストするために使用できます。

assert.notStrictEqual() は厳密な不等性をテストするために使用できます。

最も単純なアサーションの例

QUnit.test('passing example', assert => {
  const result = '2';

  // succeeds, 1 and 2 are different.
  assert.notEqual(result, 1);
});

QUnit.test('failing example', assert => {
  const result = '2';

  // fails, the number 2 and the string "2" are considered equal when
  // compared loosely. Use `assert.notStrictEqual` to consider them different.
  assert.notEqual(result, 2);
});