Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Core: Add memory to the
runEnd
event to allow late event listeners
While this is not in any way a documented API, it is quite common for QUnit runners that are based on Selenium/Webdriver to use HTML scraping to obtain a simple summary of whether the run passed. Intruce memory for `runEnd` event so that anything JS-based has a stable and documented way to obtain the result in a machine-readable format, without needing to resort to HTML scraping. One common reason sometimes avoid the event emitter is that, depending on various circumstances, a custom test runner might end up injecting code slightly too late, at which point JS code to listen for our event might not fire, whereas the DOM is still available. This is rare, but can happen: * if the file is served as-is. browserstack-runner and QTap solves this by proxying the HTML file and inject an inline script to reliable listen early. Karma solves this by proxing the test framework instead (qunit.js) and adapting it to include relevant event listeners upfront. * and, if the browser is driven without early JS control. When WebDriver v1 is used, something like webdriver "execute" is not guruanteed to run before DOM-ready or window.onload. If the Node.js process is slow or far away from the browser (e.g. cloud), and if the test suite is relatively small/fast, then the injected code might arrive after the tests have already finished. grunt-contrib-qunit avoids this by using Puppeteer and its `Page.evaluateOnNewDocument()` method, to reliably run a script before any others. * and, if the test is relatively small/fast. Example at mauriciolauffer/wdio-qunit-service#13 Solve this once and for all by adding memory to the `runEnd` event. This allows late event listers to handle the event retroactively. Cherry-picked from 8f25f26 (3.0.0-dev).
- Loading branch information