Skip to content

Commit

Permalink
Fixed a problem with incorrectly reporting errors after a passed asse…
Browse files Browse the repository at this point in the history
…rtion
  • Loading branch information
beatfactor committed Dec 30, 2018
1 parent 6686486 commit 56dd994
Show file tree
Hide file tree
Showing 7 changed files with 65 additions and 9 deletions.
2 changes: 1 addition & 1 deletion lib/core/asynctree.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class AsyncTree {

if (!this.currentNode.done) {
// if the current node hasn't finished yet
return this.currentNode.result
return this.currentNode.result;
}

this.currentNode = this.currentNode.parent;
Expand Down
10 changes: 8 additions & 2 deletions lib/core/queue.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,11 @@ class CommandQueue extends EventEmitter {
return err;
})
.then(err => {
this.done(err);
const args = [];
if (err instanceof Error) {
args.push(err);
}
this.done.apply(this, args);
});

return this;
Expand All @@ -92,7 +96,9 @@ class CommandQueue extends EventEmitter {
}

this.emit('queue:finished', err);
this.deferred.resolve(err);
if (this.deferred) {
this.deferred.resolve(err);
}
}

run() {
Expand Down
5 changes: 5 additions & 0 deletions test/extra/commands/customCommandWithFailure.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module.exports = {
command : function(cb) {
this.waitForElementPresent('#badElement', 100);
}
};
9 changes: 7 additions & 2 deletions test/sampletests/syncnames/sampleTest.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
module.exports = {
demoTest: function (client) {
client.url('http://localhost')
.assert.elementPresent('#weblogin')
.end();
.waitForElementVisible('#finlandia', 1000)
.waitForElementVisible('#finlandia')
.assert.containsText('#finlandia', 'sibelius');
},

after(client) {
client.end();
}
};
13 changes: 13 additions & 0 deletions test/sampletests/withcustomcommands/sampleWithFailures.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
module.exports = {
before(client) {
client.globals.increment++;
},

demoTestAsync(client) {
client.url('http://localhost').customCommandWithFailure().end();
},

after(client) {
client.globals.increment++;
},
};
29 changes: 28 additions & 1 deletion test/src/runner/testRunTestsuite.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,10 +178,37 @@ describe('testRunTestSuite', function() {
});

it('testRunModuleSyncName', function() {
MockServer.addMock({
url: '/wd/hub/session/1352110219202/elements',
postdata : '{"using":"css selector","value":"#finlandia"}',
response: JSON.stringify({sessionId:"1352110219202",status:0,value:[{ELEMENT: '10'}]})
});

MockServer.addMock({
url: '/wd/hub/session/1352110219202/element/10/displayed',
statusCode: 200,
method: 'GET',
response: JSON.stringify({"sessionId":"1352110219202","status":0,"value":true})
});

MockServer.addMock({
url: '/wd/hub/session/1352110219202/element',
statusCode: 200,
response: JSON.stringify({"sessionId":"1352110219202","status":0,"value": {ELEMENT: '10'}})
});

MockServer.addMock({
url: '/wd/hub/session/1352110219202/element/10/text',
statusCode: 200,
method: 'GET',
response: JSON.stringify({"sessionId":"1352110219202","status":0,"value":'jean sibelius'})
}, true);

let globals = {
calls: 0,
reporter(results, cb) {
assert.ok('sampleTest' in results.modules);
assert.strictEqual(results.errors, 0);
if (results.lastError) {
throw results.lastError;
}
Expand All @@ -200,7 +227,7 @@ describe('testRunTestSuite', function() {
version2: true,
start_process: true
},
silent: true,
silent: false,
output: false,
sync_test_names: true,
persist_globals: true,
Expand Down
6 changes: 3 additions & 3 deletions test/src/runner/testRunWithCustomCommands.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ const Logger = common.require('util/logger.js');

describe('testRunWithCustomCommands', function() {

Logger.enable();
Logger.setOutputEnabled(true);
//Logger.enable();
//Logger.setOutputEnabled(true);

before(function(done) {
this.server = MockServer.init();
Expand Down Expand Up @@ -52,7 +52,7 @@ describe('testRunWithCustomCommands', function() {
version2: true,
start_process: true
},
output: true,
output: false,
silent: false,
custom_commands_path: [path.join(__dirname, '../../extra/commands')],
persist_globals: true,
Expand Down

0 comments on commit 56dd994

Please sign in to comment.