chai-samsam

使用 samsam 扩展 Chai,提供一个断言用于深度匹配任何类型的对象。
这个项目最初是 chai-deep-match 的分支。
它保留了原来的接口和测试用例,并且全部通过。因此,它可以作为直接替换。
然而,它允许更松散和更深层的匹配。(查看 samsam 文档)
安装
$ npm install --save chai
$ npm install --save chai-samsam
使用
const chai = require('chai')
const chaiSamSam = require('chai-samsam')
chai.use(chaiSamSam)
expect([{
firstName: 'John',
lastName: 'Doe',
jobs: [{ bartender: true, barista: true }]
}]).to.deep.match([
{ jobs: [{ barista: true }] }
])
// => pass
expect([{
firstName: 'John',
lastName: 'Doe',
jobs: [{ bartender: true, barista: true }]
}]).to.not.deep.match([
{ jobs: [{ pilot: true }] }
])
// => pass
// also possible
assert.deepMatch(a, b)
assert.notDeepMatch(a, b)
许可证
版权所有 (c) 2017, Tim Beyer (MIT 许可证)