阿西河

所有教程

公众号
🌙
阿西河前端的公众号

我的收藏

    最近访问  (文章)

      教程列表

      抓包专区
      测试专区

      Node.js assert.notDeepEqual

      Node.js assert.notDeepEqual(actual, expected[, message])版本历史

      版本变更
      v9.0.0The Error names and messages are now properly compared
      v8.0.0The Set and Map content is also compared
      v6.4.0, v4.7.1Typed array slices are handled correctly now.
      v6.1.0, v4.5.0Objects with circular references can be used as inputs now.
      v5.10.1, v4.4.3Handle non-Uint8Array typed arrays correctly.
      v0.1.21新增于: v0.1.21
      • actual < any>
      • expected < any>
      • message < string> | < Error>

      Strict mode

      An alias of assert.notDeepStrictEqual().

      Legacy mode

      Tests for any deep inequality. Opposite of assert.deepEqual().

      const assert = require('assert');
      
      const obj1 = {
        a: {
          b: 1
        }
      };
      const obj2 = {
        a: {
          b: 2
        }
      };
      const obj3 = {
        a: {
          b: 1
        }
      };
      const obj4 = Object.create(obj1);
      
      assert.notDeepEqual(obj1, obj1);
      // AssertionError: { a: { b: 1 } } notDeepEqual { a: { b: 1 } }
      
      assert.notDeepEqual(obj1, obj2);
      // OK
      
      assert.notDeepEqual(obj1, obj3);
      // AssertionError: { a: { b: 1 } } notDeepEqual { a: { b: 1 } }
      
      assert.notDeepEqual(obj1, obj4);
      // OK
      

      If the values are deeply equal, 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. If the message parameter is an instance of an Error then it will be thrown instead of the AssertionError.


      更多选项请参考:Node.js assert 断言测试,或者通过 点击对应菜单 进行查看;


      目录
      本文目录
      目录