Closed wyne closed 11 years ago
wyne,
I think I understand your problem, you are logging info statements and aren't seeing them in stdout
After looking at the docs, it seems as if you need to flag it with verbose : true in order to see the logging. Let me know if that works.
http://docs.casperjs.org/en/latest/logging.html
Now, there are two things to distinguish: log storage and log display; by default CasperJS won’t print the logs to the standard output. In order to do so, you must enable the verbose Casper option:
Correct, that's the problem I'm experiencing.
I'm actually already using verbose: true
in my casper setup. The strange thing is that if I keep everything the same and just use grunt-casperjs instead of this one, all the log messages are output.
Thanks for the reply. I'll keep investigating.
I am starting to look into it. How are you defining your tests to run with grunt-casper? Could you provide a sample test file?
I'll be in #grunt-casper IRC, if you want to step through it.
Gruntfile.js
module.exports = function(grunt) {
grunt.initConfig({
'pkg': grunt.file.readJSON('package.json'),
casper: {
options: {
test: true,
direct: true,
'log-level': 'info',
'fail-fast': false
},
mytask: {
src: ['tests/website/basic-tests.js']
},
}
});
grunt.loadNpmTasks('grunt-casper');
// Default use from command line
grunt.registerTask('default', ['casper']);
grunt.registerTask('mytask', ['casper:mytask']);
};
basic-tests.js
// Patching phantomjs' require()
var require = patchRequire(require);
// Casper config
var casper = require('casper').create({
clientScripts: [
'includes/jquery.js',
'includes/underscore.js'
],
pageSettings: {
loadImages: false,
loadPlugins: false
},
verbose: true
});
// Initialize test
casper.test.begin('Website loads', 1, function suite(test) {
casper.start('http://localhost').then(function() {
// ...
test.pass("This worked");
}).then(function() {
test.info("Output");
}).then(function() {
test.done();
});
casper.run();
});
Output
$ grunt website
Running "casper:mytask" (casper) task
Done, without errors.
Expected to see [info] output
as well the "This worked" test pass.
Try This: logLevel : 'info' in the create options hash
var casper = require('casper').create({ clientScripts: [ 'includes/jquery.js', 'includes/underscore.js' ], pageSettings: { loadImages: false, loadPlugins: false }, verbose: true, logLevel : 'info' });
I will look into making it work on a global level defined in the Gruntfile
Sorry, I tried that earlier and that didn't work either.
Are you using the casper dev branch? 1.1.0-DEV?
After looking into the task, I realized i am logging to grunts verbose output. Adding a verbose flag when running grunt will work or you can pull master (v0.1.3) and I replaced the grunt.verbose.write() -> grunt.log.write(). For caught errors it naturally would grunt.log the error. All casper output is now printed to the console.
Awesome! That fixed it. Thanks!
Will this be available in npm?
No Problem,
I just published the new version on NPM.
I can't get any log output unless a test throws an error. I'm trying to get output of tests that are passing and any other test.info() calls. Here's the options I'm using: