Mocha tests are ignored when used within repetitive stream callbacks

Multi tool use


Mocha tests are ignored when used within repetitive stream callbacks
My task is to test some js function against big test vector corpus (10M+), also requirement to test in browser forced me to stream testvectors from local webserver, rather than synchronously read from file record by record.
So, I'm obtaining (one per line ascii) test vectors this way:
const http = require('http');
const readline = require('readline');
FetchTestVectors = function(filename, recordCb) {
const url = "http://localhost:8080/" + filename;
http.get(url)
.on('response', function(response) {
readline.createInterface({
input: response
})
.on('line', function(line) {
//recordCb(line.split(':'));
recordCb(line);
})
});
}
And when trying to test it, inner describe-it block becomes ignored (all callbacks).
However, I can see correct console dump.
describe('Test vector set', function () {
it('all vectors are ok', function (done) {
FetchTestVectors('1.input', function (record) {
console.log(record);
//throw new Error("oh no");
describe('one more vector', function () {
it('this vector is ok', function(done) {
console.log("==" + record);
done();
});
});
});
done();
});
});
Also throwing exception (commented line) works strange: it just breaks callback series, with no failing tests in report.
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.