Skip to content

Commit

Permalink
Add option to exit on fail
Browse files Browse the repository at this point in the history
  • Loading branch information
schipiga committed Mar 29, 2018
1 parent 9b5271a commit 2f8260d
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Expand Up @@ -89,6 +89,7 @@ glace [options] [sequence-of-test-files-or-folders]
- `--uncaught [type]` - Strategy to process uncaught exceptions. Default value is `log`. Supported values are `log` just to log uncaught exceptions, `fail` to fail test if uncaught exception happened, `mocha` to use default `mocha` mechanism ([unreliable](tutorial-mocha-uncaught.html)).
- `--kill-procs <sequence>` - List of process names separated with comma, which will be killed before tests run.
- `--debug-on-fail` - Enter to interactive debug mode on step failure.
- `--exit-on-fail` - Finish test run on first failure.
- `--interactive, -i` - Launch interactive mode to execute steps manually in terminal.

`Plugins`
Expand Down
1 change: 1 addition & 0 deletions lib/config.js
Expand Up @@ -86,6 +86,7 @@ config.logsDir = config.reportsDir;
/* Use CLI arguments */
config.interactive = args.i || args.interactive;
config.debugOnFail = args.debugOnFail;
config.exitOnFail = args.exitOnFail;
config.timeouts.chunk = (args.chunkTimeout || 180) * 1000 || Infinity;
config.clearReport = !args.dontClearReport;
config.uncaught = (args.uncaught || "log").toLowerCase();
Expand Down
5 changes: 5 additions & 0 deletions lib/help.js
Expand Up @@ -99,6 +99,11 @@ module.exports = (d, cb) => {
type: "boolean",
group: "Core:",
},
"exit-on-fail": {
describe: d("Finish test run on first failure."),
type: "boolean",
group: "Core:",
},
"interactive": {
describe: d("Launch interactive mode to execute steps",
"manually in terminal."),
Expand Down
5 changes: 5 additions & 0 deletions lib/reporter/base.js
Expand Up @@ -132,6 +132,11 @@ var GlaceReporter = function (runner) {
for (var reporter of reporters) {
if (reporter.fail) reporter.fail(mochaTest, err);
}

if (CONF.exitOnFail) {
CONF.curTestCase.end(TestCase.FAILED);
runner.emit("end");
}
});

runner.on("pending", mochaTest => {
Expand Down
1 change: 1 addition & 0 deletions tests/e2e/testBasic.js
Expand Up @@ -10,6 +10,7 @@ test("It should be failed", () => {
chunk("My chunk", () => {
throw new Error("BOOM!");
});
chunk(() => {});
});

test("It should contain skipped chunk", () => {
Expand Down

0 comments on commit 2f8260d

Please sign in to comment.