|
@@ -5,7 +5,7 @@ var path = require('path');
|
|
|
|
|
|
var make_list = function(val) {
|
|
var make_list = function(val) {
|
|
return val.split(',');
|
|
return val.split(',');
|
|
-}
|
|
|
|
|
|
+};
|
|
|
|
|
|
program
|
|
program
|
|
.option('-t, --tests <testlist>', 'Run the specified html-file-based test(s). \'testlist\' should be a comma-separated list', make_list, [])
|
|
.option('-t, --tests <testlist>', 'Run the specified html-file-based test(s). \'testlist\' should be a comma-separated list', make_list, [])
|
|
@@ -16,6 +16,7 @@ program
|
|
.option('-p, --provider <name>', 'Use the given provider (defaults to "casper"). Currently, may be "casper" or "zombie"', 'casper')
|
|
.option('-p, --provider <name>', 'Use the given provider (defaults to "casper"). Currently, may be "casper" or "zombie"', 'casper')
|
|
.option('-g, --generate-html', 'Instead of running the tests, just return the path to the generated HTML file, then wait for user interaction to exit (should be used with -i)')
|
|
.option('-g, --generate-html', 'Instead of running the tests, just return the path to the generated HTML file, then wait for user interaction to exit (should be used with -i)')
|
|
.option('-o, --output-html', 'Instead of running the tests, just output the generated HTML source to STDOUT (should be used with -i)')
|
|
.option('-o, --output-html', 'Instead of running the tests, just output the generated HTML source to STDOUT (should be used with -i)')
|
|
|
|
+ .option('-d, --debug', 'Show debug output (the "console" event) from the provider')
|
|
.parse(process.argv);
|
|
.parse(process.argv);
|
|
|
|
|
|
var file_paths = [];
|
|
var file_paths = [];
|
|
@@ -26,13 +27,15 @@ if (program.autoInject) {
|
|
temp.track();
|
|
temp.track();
|
|
|
|
|
|
var template = {
|
|
var template = {
|
|
- header: "<html>\n<head>\n<meta charset='utf-8' />\<link rel='stylesheet' href='node_modules/mocha/mocha.css'/>\n</head>\n<body><div id='mocha'></div>",
|
|
|
|
- script_tag: function(p) { return "<script src='" + p + "'></script>" },
|
|
|
|
|
|
+ header: "<html>\n<head>\n<meta charset='utf-8' />\n<link rel='stylesheet' href='" + path.resolve(__dirname, 'node_modules/mocha/mocha.css') + "'/>\n</head>\n<body><div id='mocha'></div>",
|
|
|
|
+ script_tag: function(p) { return "<script src='" + p + "'></script>"; },
|
|
footer: "<script>\nmocha.checkLeaks();\nmocha.globals(['navigator', 'create', 'ClientUtils', '__utils__']);\nmocha.run();\n</script>\n</body>\n</html>"
|
|
footer: "<script>\nmocha.checkLeaks();\nmocha.globals(['navigator', 'create', 'ClientUtils', '__utils__']);\nmocha.run();\n</script>\n</body>\n</html>"
|
|
};
|
|
};
|
|
|
|
|
|
template.header += "\n" + template.script_tag(path.resolve(__dirname, 'node_modules/chai/chai.js'));
|
|
template.header += "\n" + template.script_tag(path.resolve(__dirname, 'node_modules/chai/chai.js'));
|
|
template.header += "\n" + template.script_tag(path.resolve(__dirname, 'node_modules/mocha/mocha.js'));
|
|
template.header += "\n" + template.script_tag(path.resolve(__dirname, 'node_modules/mocha/mocha.js'));
|
|
|
|
+ template.header += "\n" + template.script_tag(path.resolve(__dirname, 'node_modules/sinon/pkg/sinon.js'));
|
|
|
|
+ template.header += "\n" + template.script_tag(path.resolve(__dirname, 'node_modules/sinon-chai/lib/sinon-chai.js'));
|
|
template.header += "\n<script>mocha.setup('bdd');</script>";
|
|
template.header += "\n<script>mocha.setup('bdd');</script>";
|
|
|
|
|
|
|
|
|
|
@@ -74,7 +77,7 @@ if (program.outputHtml) {
|
|
console.warn(error.stack);
|
|
console.warn(error.stack);
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
cursor
|
|
cursor
|
|
.bold()
|
|
.bold()
|
|
.write(program.tests[path_ind])
|
|
.write(program.tests[path_ind])
|
|
@@ -137,8 +140,8 @@ if (!program.outputHtml && !program.generateHtml) {
|
|
|
|
|
|
console.log('');
|
|
console.log('');
|
|
|
|
|
|
- cursor.write(''+test_json.num_tests+' tests run, ')
|
|
|
|
cursor
|
|
cursor
|
|
|
|
+ .write(''+test_json.num_tests+' tests run, ')
|
|
.green()
|
|
.green()
|
|
.write(''+test_json.num_passes+' passed');
|
|
.write(''+test_json.num_passes+' passed');
|
|
if (test_json.num_slow > 0) {
|
|
if (test_json.num_slow > 0) {
|
|
@@ -157,9 +160,16 @@ if (!program.outputHtml && !program.generateHtml) {
|
|
cursor
|
|
cursor
|
|
.red()
|
|
.red()
|
|
.write(''+test_json.num_fails+' failed');
|
|
.write(''+test_json.num_fails+' failed');
|
|
|
|
+ if (test_json.num_skipped > 0) {
|
|
|
|
+ cursor
|
|
|
|
+ .reset()
|
|
|
|
+ .write(', ')
|
|
|
|
+ .grey()
|
|
|
|
+ .write(''+test_json.num_skipped+' skipped');
|
|
|
|
+ }
|
|
cursor
|
|
cursor
|
|
.reset()
|
|
.reset()
|
|
- .write(' -- duration: '+test_json.duration+"\n");
|
|
|
|
|
|
+ .write(' -- duration: '+test_json.duration+"s\n");
|
|
|
|
|
|
console.log('');
|
|
console.log('');
|
|
|
|
|
|
@@ -168,7 +178,7 @@ if (!program.outputHtml && !program.generateHtml) {
|
|
if (node.type == 'suite') {
|
|
if (node.type == 'suite') {
|
|
if (!node.has_subfailures && !program.printAll) return;
|
|
if (!node.has_subfailures && !program.printAll) return;
|
|
|
|
|
|
- if (indentation == 0) {
|
|
|
|
|
|
+ if (indentation === 0) {
|
|
cursor.bold();
|
|
cursor.bold();
|
|
console.log(node.name);
|
|
console.log(node.name);
|
|
console.log(Array(node.name.length+1).join('-'));
|
|
console.log(Array(node.name.length+1).join('-'));
|
|
@@ -195,17 +205,25 @@ if (!program.outputHtml && !program.generateHtml) {
|
|
cursor.magenta();
|
|
cursor.magenta();
|
|
console.log('- failed: '+node.text+test_json.replay);
|
|
console.log('- failed: '+node.text+test_json.replay);
|
|
cursor.red();
|
|
cursor.red();
|
|
- console.log(' '+node.error.split("\n")[0]); // the split is to avoid a weird thing where in PhantomJS, we get a stack trace too
|
|
|
|
|
|
+ console.log(' '+node.error.split("\n")[0]); // the split is to avoid a weird thing where in PhantomJS where we get a stack trace too
|
|
cursor.reset();
|
|
cursor.reset();
|
|
console.log('');
|
|
console.log('');
|
|
}
|
|
}
|
|
else if (program.printAll) {
|
|
else if (program.printAll) {
|
|
- if (node.slow) cursor.yellow();
|
|
|
|
- else cursor.green();
|
|
|
|
- cursor
|
|
|
|
- .write('- pass: '+node.text)
|
|
|
|
- .grey()
|
|
|
|
- .write(' ('+node.duration+') ');
|
|
|
|
|
|
+ if (node.skipped) {
|
|
|
|
+ cursor
|
|
|
|
+ .grey()
|
|
|
|
+ .write('- skipped: '+node.text);
|
|
|
|
+ }
|
|
|
|
+ else {
|
|
|
|
+ if (node.slow) cursor.yellow();
|
|
|
|
+ else cursor.green();
|
|
|
|
+
|
|
|
|
+ cursor
|
|
|
|
+ .write('- pass: '+node.text)
|
|
|
|
+ .grey()
|
|
|
|
+ .write(' ('+node.duration+') ');
|
|
|
|
+ }
|
|
/*if (node.slow) cursor.yellow();
|
|
/*if (node.slow) cursor.yellow();
|
|
else cursor.green();*/
|
|
else cursor.green();*/
|
|
cursor
|
|
cursor
|
|
@@ -215,23 +233,25 @@ if (!program.outputHtml && !program.generateHtml) {
|
|
console.log('');
|
|
console.log('');
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- }
|
|
|
|
|
|
+ };
|
|
|
|
|
|
for (var i = 0; i < test_json.suites.length; i++) {
|
|
for (var i = 0; i < test_json.suites.length; i++) {
|
|
traverse_tree(0, test_json.suites[i]);
|
|
traverse_tree(0, test_json.suites[i]);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- if (test_json.num_fails == 0) {
|
|
|
|
|
|
+ if (test_json.num_fails === 0) {
|
|
cursor.fg.green();
|
|
cursor.fg.green();
|
|
console.log('all tests passed :-)');
|
|
console.log('all tests passed :-)');
|
|
cursor.reset();
|
|
cursor.reset();
|
|
}
|
|
}
|
|
});
|
|
});
|
|
|
|
|
|
- /*provider.on('console', function(line) {
|
|
|
|
- //console.log(line);
|
|
|
|
- });*/
|
|
|
|
|
|
+ if (program.debug) {
|
|
|
|
+ provider.on('console', function(line) {
|
|
|
|
+ console.log(line);
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
|
|
/*gprom.finally(function(ph) {
|
|
/*gprom.finally(function(ph) {
|
|
ph.exit();
|
|
ph.exit();
|