This implementation of SpookyJS is really spooky. While using Gulp to run Mocha + SpookyJS tests, I am unable to see most console log output. I have been following the Quickstart steps on SpookyJS's github page. Why can't I see these console log outputs?
describe('test', function () {
it('test 1', function(done){
try {
var Spooky = require('spooky');
} catch (e) {
var Spooky = require('../lib/spooky');
}
var spooky = new Spooky({
child: {
transport: 'http'
},
casper: {
logLevel: 'debug',
verbose: true
}
}, function (err) {
if (err) {
e = new Error('Failed to initialize SpookyJS');
e.details = err;
throw e;
}
spooky.start(URL);
console.log('Hello 3'); //currently this is not printing anything to the console
spooky.then(function () {
this.emit('hello', 'Hello, from ' + this.evaluate(function () {
return document.title;
}));
});
spooky.run();
console.log('Hello 1'); //currently this is not printing anything to the console
});
spooky.on('hello', function (line) {
console.log(line);
});
spooky.on('console', function (line) {
console.log(line);
});
spooky.on('error', function (e, stack) {
console.error(e);
if (stack) {
console.log(stack);
}
});
console.log('Hello 2'); //this is printing to the console
done();
});
});
Simplifying your code, it roughly looks like this:
The
spookyobject is created, and after that, the program flow simply continues. Anything that thespookyobject does, it does asynchronously, later on.After creating the
spookyobject, you get yourHello 2and thendone()is called, which ends this test.So, before any
hellostuff can be processed, your tests ends already.What might help is to move the
done()line here:Then your test will end once the
helloevent has been caught.Since I'm not familiar with
Spookyor with what exactly you want to test, I'm afraid I can't be of any more help. Hopefully this gets you a step further.