Moved browser runner's checkForTestError
Proposed changes
This PR aims to fix an issue with the browser runner where when an error is thrown or an error is logged, it will be caught by the checkForTestError function and the test runner will end without running any succeeding tests.
This also prevents tests from purposely simulating a scenario where an error may be thrown and to properly handle it within the test.
As discussed in this (issue)[https://github.com/webdriverio/webdriverio/issues/14216], the suggested solution is to move the error logic to be near the addInitScript and to just check for errors at the beginning (instead of running it at a set interval while the tests are running).
List of changes:
- Moved browser runner's checkForTestError to be run right after url loading and removed logic to call it at a regular interval.
- Added mocha-browser test to run mocha tests with the browser runner.
- This can be tested by going into the
webdriverio/examples/wdiofolder and running the following commands:pnpm test:mocha-browser- This will run mocha tests that contain failure scenarios with the browser runner.pnpm test:mocha-browser --startFailure=vite- This will simulate a Vite error which will be caught at the beginning and end the test runner.pnpm test:mocha-browser --startFailure=browserLoad- This will simulate a browser load error which will be caught at the beginning and end the test runner.
- This can be tested by going into the
The user can provide their own error handling logic either through a catch block in the test itself or through addInitScript with browser object or BiDi usage.
Types of changes
- [ ] Polish (an improvement for an existing feature)
- [x] Bugfix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
- [ ] Documentation update (improvements to the project's docs)
- [ ] Specification changes (updates to WebDriver command specifications)
- [ ] Internal updates (everything related to internal scripts, governance documentation and CI files)
Checklist
- [x] I have read the CONTRIBUTING doc
- [x] I have added tests that prove my fix is effective or that my feature works
- [x] I have added the necessary documentation (if appropriate)
- [x] I have added proper type definitions for new commands (if appropriate)
Backport Request
//: # (The current main branch is the development branch for WebdriverIO v9. If your change should be released to the current major version of WebdriverIO (v8), please raise another PR with the same changes against the v8 branch.)
- [x] This change is solely for
v9and doesn't need to be back-ported - [ ] Back-ported PR at
#XXXXX
Further comments
Reviewers: @webdriverio/project-committers
- :x: - login: @pegnovi / name: Patrick Ocampo . The commit (970a73223a754a1fc3cf4f93b1f09f1934fc843a, b1c771c27ed1957b24d23c0561592971098511ee) is not authorized under a signed CLA. Please click here to be authorized. For further assistance with EasyCLA, please submit a support request ticket.