feat(allure-cypress): new real-time lifecycle, hooks, and test plan #1109
+1,786
−1,221
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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