Closed SuperSephy closed 8 years ago
@SuperSephy we don't pass the callback variable through because all commands are running synchronously anyway so you don't need to handle async with done. In cases where you want to use 3rd party libraries I would advise you to either wrap your 3rd party command call in a webdriverio custom command (see http://webdriver.io/guide/usage/customcommands.html bottom) or run the test block async and return a promise like
it("...", function async () {
return new Promise(function(resolve, reject) {
slack_api.webhook('@sampleuser', 'Sample Message', function(err, resp){
if (err) return reject(err);
resolve();
});
});
});
Using a callback is not really a good way to handle async as it won't come with proper stack traces.
Appreciate the response, I'll try that. Thank you.
I have faced the same issue when upgrading from wdio-mocha-framework@0.2.12
to wdio-mocha-framework@0.3.0
.
I had to change my tests from:
it('should show the account debts when we navigate to the route', (done) => {
global.browser
.url(accountDetailDebtsUrl)
.getCssProperty('[data-test="AccountDetailTabDebts"]', 'color')
.then((color) => {
assert.strictEqual(color.value, 'rgba(255,255,255,1)');
})
.call(done);
});
to
it('should show the account debts when we navigate to the route', () => {
return global.browser
.url(accountDetailDebtsUrl)
.getCssProperty('[data-test="AccountDetailTabDebts"]', 'color')
.then((color) => {
assert.strictEqual(color.value, 'rgba(255,255,255,1)');
});
});
@oliviertassinari well help you to debug your test way better 😉
@christian-bromann I'm pointing it out, in case someone if having the same issue.
At least now mocha also get notified when the promise fails. I'm wondering how he is handling it. I guess you are right, that's more information he can take advantage of 👍 .
It appears the mocha test files aren't passing the "done" callback parameter in the frame work. Example below:
package.json
sample.conf.js
tests/login.js
But the slack notification (and several other attempted variants with page interaction) error out with the following:
Running these tests directly with Mocha runs fine, so something is happening in the wdio import of the test files. I should note I've tried setting the sample.conf.js sync value to
false
as well, but this just means that it finishes without waiting for anything and the mocha tests still don't have a defineddone
function. Similar results setting theasync-only: true
mochaOpts in the sample.conf.js