我正在尝试测试翻译功能,并想针对多个输入(字符串)对其进行测试,以确保其正常工作。该功能应将输入翻译为“强盗语言”。
我想测试数据集(数组或列表)以证明代码可以正常工作。
我找到了test.each方法,但我认为即时通讯使用不正确。
let testInput = [['hello'], ['world']]
test.each(testInput)('translate the input to robber language', (input, expected) => {
expect(translation.translateToRobberLanguage(input)).toEqual(expected)
})
这是终端给我的错误。
expect(received).toEqual(expected) // deep equality
Expected: [Function next]
Received: "hohelollolo"