faq labelnode node_modules/.bin/mocha --version(Local) and mocha --version(Global). We recommend that you _not_ install Mocha globally.After the recent mocha bump to 8.2.0 our functional tests on CI started to throw unexpected "Uncaught Error" failures while before everything was working kist fine.
npm i on itgulp transpile to transpile the sourcenpx mocha --timeout 6000000 --reporter mocha-multi-reporters --reporter-options config-file=./ci-jobs/mocha-config.json --recursive build/test/functional/ -g @skip-ci -i --exitExpected behavior: [What you expect to happen]
The test should pass
Actual behavior: [What actually happens]
The test is shown twice as passing and failing with an "Unexpected error" exception:
2 passing (1m)
2 failing
1) element attributes
getAttribute
should not work if getting an attribute that does not exist:
Uncaught Error: [element.getAttribute("some-fake-property")] Error response status: 13, , UnknownError - An unknown server-side error occurred while processing the command. Selenium error: An unknown server-side error occurred while processing the command. Original error: Attribute name should be one of [content-desc, class, text, package, checkable, checked, clickable, enabled, focusable, focused, scrollable, long-clickable, password, selected, visible, no-multiline-buttons, no-overlaps, no-ellipsized-text, bounds, resource-id, instance, index, adapters, adapter-type, hint, view-tag]. 'some-fake-property' is given instead
at exports.newError (node_modules/wd/lib/utils.js:152:13)
at /Users/elf/code/appium-espresso-driver/node_modules/wd/lib/callbacks.js:94:19
at /Users/elf/code/appium-espresso-driver/node_modules/wd/lib/webdriver.js:205:5
at Request._callback (node_modules/wd/lib/http-utils.js:89:7)
at Request.self.callback (node_modules/request/request.js:185:22)
at Request.<anonymous> (node_modules/request/request.js:1161:10)
at IncomingMessage.<anonymous> (node_modules/request/request.js:1083:12)
at endReadableNT (_stream_readable.js:1201:12)
at processTicksAndRejections (internal/process/task_queues.js:84:21)
2) element attributes
getAttribute
should not work if getting an attribute that does not exist:
Uncaught Error: [element.getAttribute("some-fake-property")] Error response status: 13, , UnknownError - An unknown server-side error occurred while processing the command. Selenium error: An unknown server-side error occurred while processing the command. Original error: Attribute name should be one of [content-desc, class, text, package, checkable, checked, clickable, enabled, focusable, focused, scrollable, long-clickable, password, selected, visible, no-multiline-buttons, no-overlaps, no-ellipsized-text, bounds, resource-id, instance, index, adapters, adapter-type, hint, view-tag]. 'some-fake-property' is given instead
at exports.newError (node_modules/wd/lib/utils.js:152:13)
at /Users/elf/code/appium-espresso-driver/node_modules/wd/lib/callbacks.js:94:19
at /Users/elf/code/appium-espresso-driver/node_modules/wd/lib/webdriver.js:205:5
at Request._callback (node_modules/wd/lib/http-utils.js:89:7)
at Request.self.callback (node_modules/request/request.js:185:22)
at Request.<anonymous> (node_modules/request/request.js:1161:10)
at IncomingMessage.<anonymous> (node_modules/request/request.js:1083:12)
at endReadableNT (_stream_readable.js:1201:12)
at processTicksAndRejections (internal/process/task_queues.js:84:21)
The results of full CI run: https://dev.azure.com/AppiumCI/Appium%20CI/_build/results?buildId=11913&view=logs&j=ea3a8326-8ae1-5392-57d8-7054c454cdab&t=bf55eb97-8c00-5287-3ece-aba70d92322c&l=8299
Reproduces how often: [What percentage of the time does it reproduce?]
Always
mocha --version and node node_modules/.bin/mocha --version: 8.2.0node --version: Tried locally with v13.12.0 and CI (v10)Downgrading mocha to 8.1.0 solves the issue
For me, Downgrading mocha to 8.1.3 figures it out
We experience the same issue with mocha upgrade to 8.2.0
We are also experiencing the same issue, we have a simple test like the one below that fails after upgrading. After downgrading the test succeeds reliably.
let error;
try {
await foo();
} catch(err) {
error = err;
}
should.exist(error);
We are also experiencing this issue!!!
Tried bumping to 8.2.0 in several projects, in some of them we were experiencing this issue so we downgraded to 8.1.3 in some of them. By using 8.1.3 it solved the issue, this is definitely a breaking change.
For everyone other than the original reporter in this issue: I need more information. Please provide:
async/await)@StefanSafeguard I can't reproduce that:
// test.js
const should = require('should');
it('should do a thing', async function() {
let error;
try {
await foo();
} catch(err) {
error = err;
}
should.exist(error);
});
Used mocha v8.2.0 and the latest version of should, then ran via mocha test.js.
I am pretty sure that this is because Mocha v8.2.0 needs to trap unhandled rejections.
It's very likely that what's happening is this:
Previously to v8.2.0, your test (or code-under-test) was raising an unhandled rejection and was being silently ignored. Now it is not. I'm going to test this theory on the appium-espresso-driver repo; hopefully it won't be to onerous to get a dev environment going.
It's going to be too difficult to debug that appium driver, so... I really need a minimal, complete, verifiable example for this. If it's a webdriver-specific thing, a repo with the proper dependencies, configuration, and a single test should do it.
@boneskull Thank you for checking this issue. Unfortunately I was not able to reproduce it by just awaiting a generic function that is expected to be rejected. It must be some complex interaction that happens in wd module while it is sending its requests.
@mykola-mokhnach yeah, I think that's probably the case. but I also think I'm probably right about the unhandled rejection behavior. Mocha really ought to be delegating what to do in this case to Node. I am going to propose a workaround... maybe you can test it for me?
will have a PR up soon
Mocha really ought to be delegating what to do in this case to Node. I am going to propose a workaround... maybe you can test it for me?
Of course, Just tell me what to do. Unfortunately I'm in a different time zone (CET), so my responses might arrive late
@boneskull I'm PDT, have an affected project, and can help test as well. Thanks for looking into this!
Please checkout #4489 and see if it works better for you.
perhaps wd depends upon the pre-Node.js-v15 behavior of warning on unhandled rejections. given that's no longer the default in Node.js, they may want to decide to emit these warnings some other way, or encourage its users to run with --unhandled-rejections=warn. #4489 will cause Mocha to respect that for rejections that come out of user code
I've checked out the boneskull/issue/4481-uncaught branch, replaced mocha 8.2.0 in node_modules with these sources and it seems like the current issue is no more reproducible 馃帀
Btw, I got some interesting traceback while playing with version 8.2.0:
/Users/elf/code/appium-espresso-driver/node_modules/mocha/lib/runner.js:936
throw err;
^
Error: done() called multiple times in hook <element attributes "after all" hook in "element attributes"> of file /Users/elf/code/appium-espresso-driver/build/test/functional/commands/attributes-e2e-specs.js
at createMultipleDoneError (/Users/elf/code/appium-espresso-driver/node_modules/mocha/lib/errors.js:364:13)
at multiple (/Users/elf/code/appium-espresso-driver/node_modules/mocha/lib/runnable.js:288:24)
at done (/Users/elf/code/appium-espresso-driver/node_modules/mocha/lib/runnable.js:299:14)
at /Users/elf/code/appium-espresso-driver/node_modules/mocha/lib/runnable.js:369:11 {
code: 'ERR_MOCHA_MULTIPLE_DONE',
valueType: 'undefined',
value: undefined
}
ok good
hmm no that doesn't seem right either.
I don't think it's wise to merge #4489 or any fixes here until I have a minimal case I can debug with, sorry. Hopefully somebody can provide this.
@mykola-mokhnach wait, is that "multiple done" coming from v8.2.0 proper, or my branch?
@boneskull Your branch is fine. That error was coming from the currently released 8.2.0 version
ok, I'll reconsider not merging the fix.
Most helpful comment
For me, Downgrading mocha to 8.1.3 figures it out