Trying to run a bunch of dynamically-generated tests within a single describe()
. I've copied in the example from the Mocha docs, and it works fine:
describe('add()', function() {
var tests = [
{args: [1, 2], expected: 3},
{args: [1, 2, 3], expected: 6},
{args: [1, 2, 3, 4], expected: 10}
];
tests.forEach(function(test) {
it('correctly adds ' + test.args.length + ' args', function() {
var res = add.apply(null, test.args);
assert.equal(res, test.expected);
});
});
});
BUT, when I try iterating over an array (or cursor) from a database call the entire describe()
module is ignored - no errors, just doesn't run at all and doesn't appear in the reporter.
i.e. if I replace the tests array with
const tests = Tests.find().fetch();
the whole thing is just skipped.
What am I doing wrong? Is there a way around this?
Aucun commentaire:
Enregistrer un commentaire