Skip to content

Commit

Permalink
fix #3469 REPL interface exits on error
Browse files Browse the repository at this point in the history
  • Loading branch information
prudhvi22 committed Nov 17, 2022
1 parent 0c52846 commit 25528ae
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/api/client-commands/debug.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const util = require('util');
const EventEmitter = require('events');
const NightwatchRepl = require('../../testsuite/repl');
const Debuggability = require('../../utils/debuggability.js');

/**
* This command halts the test execution and provides users with a REPL interface where they can type
Expand Down Expand Up @@ -46,9 +47,13 @@ Debug.prototype.command = function(config, cb) {
const context = {
browser: this.api
};
// Before starting REPL server, Ser debugMode to true
Debuggability.debugMode = true;
repl.startServer(context);

repl.onExit(() => {
// On exit, Set debugMode to false
Debuggability.debugMode = false;
// if we have a callback, call it right before the complete event
if (cb) {
cb.call(this.client.api);
Expand Down
6 changes: 6 additions & 0 deletions lib/core/treenode.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const EventEmitter = require('events');
const Utils = require('../utils');
const Debuggability = require('../utils/debuggability.js');

class TreeNode {
get command() {
Expand Down Expand Up @@ -109,6 +110,11 @@ class TreeNode {

handleError(err) {
err.abortOnFailure = err.abortOnFailure || err.abortOnFailure === undefined;

// Set abortOnFailure to false when command is being executed in debugMode
if (Debuggability.debugMode) {
err.abortOnFailure = false;
}
let errorName = err.name !== 'Error' ? `[${err.name}] ` : '';
let originalError = `${errorName}${err.message}`;

Expand Down
8 changes: 8 additions & 0 deletions lib/utils/debuggability.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@ class Debuggability {
this._stepOverAndPause = value;
}

static get debugMode() {
return this._debugMode;
}

static set debugMode(value) {
this._debugMode = value;
}

static reset() {
this._stepOverAndPause = false;
}
Expand Down

0 comments on commit 25528ae

Please sign in to comment.