dimanche 22 février 2015

Unit Testing Node Script with chai-spy ... function spied on is undefined

Writing my first node.js test for my first gulp-plugin....using mocha and chai. I get TypeError: Cannot read property 'Assertion' of undefined for ar errorCheckArg = spy(errorCheckArg);. It seems the errorCheckArg function is not available in the testing enviroment(I did a console.log(errorCheckArg) and it showed undefined).


Any idea what I am doing wrong?



describe('gulp-foobar', function() {
var fakeFile;

beforeEach(function() {
var fakeFile = new File({
contents: new Buffer('abufferwiththiscontent')
});
});

describe('get files', function() {

it('should do something', function(done) {
var foo = function() { };
foobar(foo);
var errorCheckArg = spy(errorCheckArg);
expect(errorCheckArg).to.have.been.called.with(arguments);


done();
});
});
});




being tested:



function foorbar(callback) {
var destinationFile;
errorCheckArg(arguments);
return through2.obj(function(file, enc, next) {
...

Aucun commentaire:

Enregistrer un commentaire