Here's the simple problem I'm struggling with. In the first example, no tests are run; whereas in the second one, two tests are run as expected.
Does not work as expected: // testData
gets populated inside before
here
// test.js
const assert = require('assert');
const forEach = require('mocha-each');
describe('compare()', () => {
testData = [];
before(function (done) {
testData = [[1, 1], [2, 2]];
done();
});
forEach(testData)
.it('compares %d and %d', (baseline, actual) => {
assert(baseline == actual);
});
});
Works as expected: // testData
is used as a hardcoded array here
// test.js
const assert = require('assert');
const forEach = require('mocha-each');
describe('compare()', () => {
forEach([[1, 1], [2, 2]])
.it('compares %d and %d', (baseline, actual) => {
assert(baseline == actual);
});
});
I do not understand why the modified value of testData
is not taken by it
in the first example.