我正在为循环访问输入对象的函数编写一个 chai 测试。 此代码工作正常。
they('should return the number of nodes in the graph', function (graph, expected) {
expect(graph.numberOfNodes()).to.equal(expected)
}, {
basic: 6,
withNewline: 6,
doubleDigits: 13,
nonConsecutive: 5
})
但作为练习,我试图以"断言"风格编写它。
they('should return the number of nodes in the graph', function(graph, xxxx) {
assert.equal((graph.numberOfNodes()), yyyy)
})
如果我将 xxxx 留空并为 yyyy 输入一些数字,则所有输入都将针对该数字进行测试。 但是,当然,我想针对正确的输入测试正确的输出,就像"期望"语法一样。
解决了
我自己的问题。 这是一个简单的句法错误。 正确的格式是这样的。
they('should return the number of nodes in the graph', function(graph, results) {
assert.equal((graph.numberOfNodes()), results)
}, {
basic: 6,
doubleDigits: 13,
nonConsecutive: 5,
withNewline: 6
})