Allow the use of the PhantomJS remote debugger

This commit adds the '--debugger <port>' option, which triggers
the PhantomJS remote debugger.  The initial output of the terminal
when running the debugger gives more information on how to use
it.
This commit is contained in:
Solly Ross 2015-05-28 15:07:43 -04:00
parent 48deea531c
commit 1bcd031ba2
2 changed files with 15 additions and 2 deletions

View File

@ -15,7 +15,19 @@ var casper_opts = {
}
};
var provide_emitter = function(file_paths) {
var provide_emitter = function(file_paths, debug_port) {
if (debug_port) {
casper_opts.child['remote-debugger-port'] = debug_port;
var debug_url = ('https://localhost:' + debug_port +
'/webkit/inspector/inspector.html?page=');
console.info('[remote-debugger] Navigate to ' + debug_url + '1 and ' +
'run `__run();` in the console to continue loading.' +
'\n[remote-debugger] Navigate to ' + debug_url + '2 to ' +
'view the actual page source.\n' +
'[remote-debugger] Use the `debugger;` statement to ' +
'trigger an initial breakpoint.');
}
var spooky = new Spooky(casper_opts, function(err) {
if (err) {
if (err.stack) console.warn(err.stack);

View File

@ -20,6 +20,7 @@ program
.option('--output-html', 'Instead of running the tests, just output the generated HTML source to STDOUT (should be used with .js tests)')
.option('-d, --debug', 'Show debug output (the "console" event) from the provider')
.option('-r, --relative', 'Use relative paths in the generated HTML file')
.option('--debugger <port>', 'Enable the remote debugger for CasperJS')
.parse(process.argv);
if (program.tests.length === 0) {
@ -202,7 +203,7 @@ if (!program.outputHtml && !program.generateHtml) {
.write("\n");
//console.log("Running tests %s using provider %s", program.tests.join(', '), prov.name);
var provider = prov.provide_emitter(file_paths);
var provider = prov.provide_emitter(file_paths, program.debugger);
provider.on('test_ready', function(test_json) {
console.log('');