-
Notifications
You must be signed in to change notification settings - Fork 123
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
feat(allure-cypress): new real-time lifecycle, hooks, and test plan #1109
Conversation
- fix spec-level after hook test - add some missing assertions - fix some test names - add testplan test and hook exclusion checks - remove reporter instance test (the use case is meaningless)
Also: - add more conveniently named event handlers for Node event forwarding - add docstrings for event handllers
* plugins. More info [here](https://github.com/allure-framework/allure-js/blob/main/packages/allure-cypress/README.md#setupnodeevents-limitations). | ||
* @param spec The first argument of the `after:spec` event. | ||
* @param results The second argument of the `after:spec` event. | ||
* @example |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Better to wrap up @example
content into markdown backticks ```
* }); | ||
*/ | ||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
onAfterRun = (results: CypressCommandLine.CypressFailedRunResult | CypressCommandLine.CypressRunResult) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's remove unused variables with the eslint comments. If we don't use them now, we won't use them in future
Context
The PR contains the following major changes of Allure Cypress:
Real-time reporting
Previously, Allure Cypress reported the results in a batched fashion when the test run ended. The new implementation employs:
afterEach
hookafter
hookThe messages are flushed using Cypress'es tasks mechanism. It works reliably only in hooks, that's why
index.ts
definesafterEach
andafter
hooks.In interactive mode, the spec reporting is finalized in Mocha's
run end
event. Incypress run
mode the finalization is done in Cypress'esafter:spec
event.environment.properties
andcategories.json
are reported inafter:run
.New hooks implementation
The new implementation supports all types of hooks. Spec-level
after
hooks are supported by intercepting theafter
calls and injecting the plugin'safter
hooks right next to user-defined ones. That allows us to issue the reporting chronologically after the user-definedafter
is completed and its corresponding messages are queued.New test plan implementation
The previous implementation requested the test plan from the browser side through the Cypress task. It applies the test plan in a
beforeEach
hook and skipped tests withthis.skip()
.The downside is that, while correctly skipping the tests, this approach fails to disable the associated hooks, meaning all the
before
andafter
hooks will be executed. Given those hooks often contain tasks like spinning up test servers, initializing databases, etc, that may slow down the execution substantially.The new implementation uses Cypress environment variables to pass the test plan down the specs. That allows us to get it early enough to apply before the spec-level suite runs, disabling both the tests and their hooks (even the ones defined on the spec-level).
The only requirement for a user is to pass the Cypress configuration to
allureCypress
:Note
For backward compatibility, passing Allure configuration as the 2nd argument also works.
fixes #1078
fixes #1079
Other changes
Checklist