JavaScript errors
DrevOps\BehatSteps\Steps\Web\JavascriptTrait - Source, Example, Helpers
Automatically detect JavaScript errors during test execution.
- Collects JavaScript errors from
window.onerror,unhandledrejectionandconsole.error.- Automatically asserts no errors at end of scenarios with
@javascripttag.- Collects errors after every step and re-injects the collector when the URL changes.
- The
@js-errorstag bypasses error checking when errors are expected.Skip processing with tags:
@behat-steps-skip:JavascriptTrait
Special tags:
@js-errors- bypasses error assertion for a scenario.Automatic error detection:
@javascriptScenario: Navigation without JS errors (will fail if errors occur)Given I visit "/home"When I click on "About"Then I should see "About Us"
Bypassing error detection:@javascript @js-errorsScenario: Legacy page with known errors (will not fail)Given I visit "/legacy-page"
Options
| Option | Type | Default | Tag | Description |
|---|---|---|---|---|
javascript.enabled | boolean | TRUE | @behat-steps-skip:JavascriptTrait | Collect JavaScript console errors on a @javascript scenario. |
javascript.fail_on_errors | boolean | TRUE | @js-errors | Fail a scenario that collected a console error. Errors are still collected when this is off. |