jasmine-node 中带有 {} 和 [] 的 Jasmine 误报

Jasmine false positive with {} and [] in jasmine-node

出于某种原因茉莉的...

expect({}).toEqual([]);

报告属实(但它们是不同的类型)。我如何使用 jasmine 进行此检查?

使用 lodash 你可以这样做:

expect( _.isEqual(a, b) ).toBe( false );

您可以在 expect 子句中移动相等性检查:

a = {}
b = []
expect(a === b).toBeTruthy();

看看 JasmineMatchers 项目。它添加了 toBeEmptyObjecttoBeArraytoBeEmptyArray 等匹配器。