I'm using mocha programmatically and want to access the result in my program for later computation.
Currently, I have:
var mocha = new Mocha({
reporter: 'json'
});
files.forEach(file => {
var path = process.cwd() + '/' + file;
mocha.addFile(path);
});
mocha.run()
.on('start', function() {
// do something
})
// ...
.on('end', function() {
// I want to resolve the promise with the result generated by mocha:
resolve(result);
});
However, I never get access to the result reported by the json reporter (Only on command line). Is there a way to access the result as json in my program? For example, by writing the result to a file an reading it later?
Aucun commentaire:
Enregistrer un commentaire