mocha: đ Bug: Negative functional tests started to throw "Uncaught Error" after mocha update to 8.2.0
Prerequisites
- Checked that your issue hasnât already been filed by cross-referencing issues with the
faq
label - Checked next-gen ES issues and syntax problems by using the same environment and/or transpiler configuration without Mocha to ensure it isnât just a feature that actually isnât supported in the environment in question or a bug in your code.
- âSmoke testedâ the code to be tested by running it outside the real test suite to get a better sense of whether the problem is in the code under test, your usage of Mocha, or Mocha itself
- Ensured that there is no discrepancy between the locally and globally installed versions of Mocha. You can find them with:
node node_modules/.bin/mocha --version
(Local) andmocha --version
(Global). We recommend that you not install Mocha globally.
Description
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.
Steps to Reproduce
- Checkout the https://github.com/appium/appium-espresso-driver repository
- Run
npm i
on it - Start Android Emulator named âAndroidâ
- Mark only the test should not work if getting an attribute that does not exist for execution to save the time
- Run
gulp transpile
to transpile the source - Run mocha:
npx mocha --timeout 6000000 --reporter mocha-multi-reporters --reporter-options config-file=./ci-jobs/mocha-config.json --recursive build/test/functional/ -g @skip-ci -i --exit
Expected 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 CI/_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
Versions
- The output of
mocha --version
andnode node_modules/.bin/mocha --version
: 8.2.0 - The output of
node --version
: Tried locally with v13.12.0 and CI (v10) - Your operating system
- name and version: Mac OS 10.15.6
- architecture (32 or 64-bit): 64
- Your shell (e.g., bash, zsh, PowerShell, cmd): zsh
- Your browser and version (if running browser tests):
- Any third-party Mocha-related modules (and their versions):
- Any code transpiler (e.g., TypeScript, CoffeeScript, Babel) being used (and its version): Babel v7.12.1
Additional Information
Downgrading mocha to 8.1.0 solves the issue
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 2
- Comments: 24 (13 by maintainers)
Commits related to this issue
- delegate to Node on non-Mocha unhandled rejections This is not intended as a _fix_ for #4481, since it's possible that Mocha's behavior in v8.2.0 uncovers false positives. In other cases--depending ... — committed to mochajs/mocha by boneskull 4 years ago
- delegate to Node on non-Mocha unhandled rejections (#4489) This is not intended as a _fix_ for #4481, since it's possible that Mocha's behavior in v8.2.0 uncovers false positives. In other cases--de... — committed to mochajs/mocha by boneskull 4 years ago
For me, Downgrading mocha to 8.1.3 figures it out
will have a PR up soon
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.