UNPKG

616 BJavaScriptView Raw
1var test = require('tap').test;
2var exec = require('child_process').exec;
3
4var vm = require('vm');
5var fs = require('fs');
6
7var html = fs.readFileSync(__dirname + '/files/robot.html', 'utf8');
8
9test('cmd.js', function (t) {
10 t.plan(1);
11 exec(__dirname + '/../bin/cmd.js ' + __dirname + '/files/main.js',
12 function (error, stdout, stderr) {
13 if (error !== null) {
14 t.fail();
15 } else {
16 vm.runInNewContext(stdout, {
17 require: function () {},
18 console: { log: log }
19 });
20 function log (msg) {
21 t.equal(html, msg);
22 };
23 };
24 }
25 );
26});
\No newline at end of file