我想在我的摩卡期望中测试我的 json 的形状。我知道一些东西,例如“名称”,但其他东西(_id)来自数据库。对于他们来说,我只关心他们设置正确的类型。
在这里我有我的期望:
expect(object).to.eql({
recipe:
{
_id: '5fa5503a1fa816347f3c93fe',
name: 'thing',
usedIngredients: []
}
})
如果可能的话我宁愿做这样的事情:
expect(object).to.eql({
recipe:
{
_id: is.a('string'),
name: 'thing',
usedIngredients: []
}
})
有谁知道有什么方法可以实现这一目标?或者最好将其分解为多个测试?
慕田峪4524236
相关分类