我正在为一个循环遍历输入对象的函数编写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输入一些数字,所有输入都会根据该数字进行测试。但是,当然,我想根据正确的输入测试适当的输出,就像"expect“语法所做的那样。
发布于 2016-03-02 16:50:10
解决了自己的问题。这是一个简单的句法错误。正确的格式是这样。
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
})https://stackoverflow.com/questions/35734702
复制相似问题