Commit fb304b7d fb304b7d95401947cc0fd3c5661abb768f1b0d38 by Nicolas Perriault

fixes #704 - provide an 'exit' tester event to hook before runner exits

casper.test.on("exit", function() {
  console.log("exited");
})

casper.test.begin("sample", function(test) {
  test.assert(true);
  test.done();
});

will print "exited" on the last line of the output.
1 parent 3428e039
...@@ -1524,6 +1524,7 @@ Tester.prototype.renderResults = function renderResults(exit, status, save) { ...@@ -1524,6 +1524,7 @@ Tester.prototype.renderResults = function renderResults(exit, status, save) {
1524 this.saveResults(save); 1524 this.saveResults(save);
1525 } 1525 }
1526 if (exit === true) { 1526 if (exit === true) {
1527 this.emit("exit");
1527 this.casper.exit(status ? ~~status : exitStatus); 1528 this.casper.exit(status ? ~~status : exitStatus);
1528 } 1529 }
1529 }; 1530 };
......
...@@ -317,6 +317,11 @@ class TestCommandOutputTest(CasperExecTestBase): ...@@ -317,6 +317,11 @@ class TestCommandOutputTest(CasperExecTestBase):
317 ], failing=True) 317 ], failing=True)
318 318
319 @timeout(20) 319 @timeout(20)
320 def test_exit_test(self):
321 script_path = os.path.join(TEST_ROOT, 'tester', 'exit.js')
322 self.assertCommandOutputContains('test ' + script_path, ['exited'])
323
324 @timeout(20)
320 def test_skipped_test(self): 325 def test_skipped_test(self):
321 script_path = os.path.join(TEST_ROOT, 'tester', 'skipped.js') 326 script_path = os.path.join(TEST_ROOT, 'tester', 'skipped.js')
322 self.assertCommandOutputContains('test ' + script_path, [ 327 self.assertCommandOutputContains('test ' + script_path, [
......