首页 > 解决方案 > 使用 Jest 深入测试来自属性对象的匿名函数的嵌套返回值

问题描述

标签: javascriptunit-testingnestedjestjs

解决方案


你可能想要这样的东西:

const {prop1, prop2, prop3} = myFunction({
    someProp1: 'a',
    someProp2: 'b',
    someProp3: 'c',
})
expect(prop1(value)).toEqual(
// something here
)
expect(prop2(value)).toEqual(
// something here
)
expect(prop3(value)).toEqual(
// something here
)


推荐阅读