Skip to content

Commit

Permalink
Update: Add tests for --require flag
Browse files Browse the repository at this point in the history
  • Loading branch information
Romanx authored and phated committed Dec 21, 2017
1 parent 7523f64 commit dd0d4f1
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
4 changes: 4 additions & 0 deletions test/fixtures/test-module.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
console.log('inside test module');
exports = function() {
console.log('inside test module function');
};
16 changes: 15 additions & 1 deletion test/flags-require.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,19 @@ var fs = require('fs');
var child = require('child_process');

lab.experiment('flag: --require', function() {
lab.test('requires module before running gulpfile');
lab.test('requires module before running gulpfile', function(done) {
child.exec('node ' + __dirname + '\\..\\bin\\gulp.js --require ./test-module.js --cwd ./test/fixtures', function(err, stdout) {
stdout = stdout.replace(/\\/g, '/').split('\n');
code.expect(stdout[0]).to.equal('inside test module');
code.expect(stdout[1]).to.contain('Requiring external module ./test-module.js');
done(err);
});
});
lab.test('errors if module doesn\'t exist', function(done) {
child.exec('node ' + __dirname + '\\..\\bin\\gulp.js --require ./null-module.js --cwd ./test/fixtures', function(err, stdout, stderr) {
stderr = stderr.replace(/\\/g, '/').split('\n');
code.expect(stderr[0]).to.contain('Failed to load external module ./null-module.js');
done(err);
});
});
});

0 comments on commit dd0d4f1

Please sign in to comment.