I\'m trying to test the output of child process with mocha.
My test looks like this:
var should = require(\"should\"),
exec = require(\"child_pro
Years later, mocha has matured and supports testing asynchronous code.
Simply add a callback (usually named done
) to it()
and Mocha will know that it should wait for this function to be called to complete the test.
const should = require("should"),
{ exec } = require("child_process");
describe('users', function() {
describe('andrei', function() {
it('should be part of group dev', function(done) {
exec('id andrei', function(error, stdout, stderr) {
stdout.should.containEql('dev');
done();
})
})
})
})