如何使用 chai.js 断言测试多个输入?

How to test multiple inputs with chai.js assert?

我正在为循环通过输入对象的函数编写一个 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
  })

但作为练习,我正在尝试以 "assert" 风格编写它。

they('should return the number of nodes in the graph', function(graph, xxxx) {
    assert.equal((graph.numberOfNodes()), yyyy)
  })

如果我将 xxxx 留空并为 yyyy 输入一些数字,所有输入都会根据该数字进行测试。但是我当然想根据正确的输入来测试正确的输出,就像 "expect" 语法那样。

解决了我自己的问题。这是一个简单的句法错误。正确的格式是这样的。

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
  })