Skip to content

fix: catch error in after test #2715

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 18, 2020

Conversation

elukoyanov
Copy link
Collaborator

@elukoyanov elukoyanov commented Dec 10, 2020

Motivation/Description of the PR

In case of error in _after function, for example, browser is closed during test, tests executions is stopped, but error is not logged.
It lead to tests are failed, but exit code is returned 0.

example:

sspjs % yarn test:e2e && echo 'ok'
yarn run v1.21.1
$ codeceptjs run -c ./specs/e2e/codecept.conf.js --reporter mochawesome


  Banner initialization methods
    ✓ 'test name' (800ms)
(node:71219) UnhandledPromiseRejectionWarning: no such window: no such window: window was already closed
  (Session info: chrome=87.0.4280.88)
    at Object.getErrorFromResponseBody (<there is path>/node_modules/webdriver/build/utils.js:94:12)
    at WebDriverRequest._request (<there is path>/node_modules/webdriver/build/request.js:133:31)
    at processTicksAndRejections (internal/process/task_queues.js:94:5)
    at Browser.wrapCommandFn (<there is path>/node_modules/@wdio/utils/build/shim.js:58:29)
    at Browser.wrapCommandFn (<there is path>/node_modules/@wdio/utils/build/shim.js:58:29)
    at WebDriver._after (<there is path>/node_modules/codeceptjs/lib/helper/WebDriver.js:560:7)
(node:71219) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:71219) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
✨  Done in 10.09s.
ok

How to reproduce:

  1. run codeceptjs tests
  2. close browser (or browser connection) in middle of tests
  3. see for exit code

Applicable helpers:

  • WebDriver
  • Puppeteer
  • Nightmare
  • REST
  • FileHelper
  • Appium
  • Protractor
  • TestCafe
  • Playwright

Applicable plugins:

  • allure
  • autoDelay
  • autoLogin
  • customLocator
  • pauseOnFail
  • puppeteerCoverage
  • retryFailedStep
  • screenshotOnFail
  • selenoid
  • stepByStepReport
  • wdio

Type of change

  • 🔥 Breaking changes
  • 🚀 New functionality
  • 🐛 Bug fix
  • 📋 Documentation changes/updates
  • ♨️ Hot fix
  • 🔨 Markdown files fix - not related to source code
  • 💅 Polish code

Checklist:

  • Tests have been added
  • Documentation has been added (Run npm run docs)
  • Lint checking (Run npm run lint) - linting will be fixed in Fix defenitions generation error #2707
  • Local tests are passed (Run npm test)

UPD
added the same for before to fix #1181

@elukoyanov elukoyanov added the bug label Dec 10, 2020
@DavertMik
Copy link
Contributor

Thanks! I will try to look at what might be wrong with tests

@Arhell Arhell requested a review from DavertMik December 13, 2020 10:32
@DavertMik DavertMik merged commit fc2616b into codeceptjs:3.x Dec 18, 2020
@elukoyanov elukoyanov deleted the fix/after-test-failure-exit-code branch December 19, 2020 10:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Exit Code when failing in Before
3 participants