-
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): impose some limits on step parameter values created from Cypress command arguments #1127
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
delatrie
force-pushed
the
issue1070-cypress-cmd-json
branch
from
August 30, 2024 12:58
919c03f
to
c66ed9f
Compare
This will allow using 'serialize' from environments other than Node.js.
allure-cypress now uses the new implementation of allure-js-commons'es serialize instead of its own version.
github-actions
bot
added
theme:api
Javascript API related issue
theme:mocha
Mocha related issue
labels
Sep 3, 2024
epszaw
approved these changes
Sep 5, 2024
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.
Good job here! I noticed nothing serious, so if you want to fix nothing – just skip the comments.
The new name is getRuntimeConfigDefaults
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
theme:api
Javascript API related issue
theme:cypress
theme:mocha
Mocha related issue
type:new feature
New feature or request
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
Allure Cypress converts Cypress commands to Allure steps. Command argument values are converted to Allure step parameter values:
JSON.stringify(value, null, 2)
.The drawbacks:
TypeError: Converting circular structure to JSON
is thrown if the value is an object with circular references. This is often the case when using Cypress commands with complex UI objects like Vue components, etc. See some examples in issue allure-cypress : getting error - 'Converting circular structure to JSON' #1070.serialize
enhancementsWe have an existing function
serialize
defined inallure-js-commons/sdk/reporter/utils
, which behaves similarly to what Allure Cypress does with Cypress step arguments. This PR:allure-js-commons/sdk/utils
to make it usable from environments other than Node.js.maxDepth
,maxLength
. The value of each property must be an integer number greater than or equal to 0 (which is the default). The value of zero means the property doesn't affectserialize
.serialize
:maxDepth
is given and is greater than 0, properties that create nesting levels beyond that limit are precluded from serialization.maxLength
is given and is greater than 0, and if the length of the resulting string is greater than that value, the remaining part of the string is replaced with"..."
.Examples
allure-cypress now uses
serialize
to convert Cypress command arguments to strings.Configuration changes
The PR introduces two new configuration properties
maxArgumentLength
andmaxArgumentDepth
to customize the abovementioned limits for allure-cypress. The properties are grouped under thestepsFromCommands
option:The default values are 128 (for
maxArgumentLength
) and 3 (formaxArgumentDepth
).Fixes #1070
Other minor changes
serialize
: now they may nest in other objects and contain circular references, which are properly removed upon serialization. The values are serialized as arrays instead of the"[object Map]"
and"[object Set]"
literals.allureCypress
)Potential future changes
serialize
implementation to take objects of any types inattachment
(currently, only strings and buffers are allowed);disabled
) into thestepsFromCommands
object of the Allure Cypress config to preclude Cypress steps from getting into Allure Report (see How to turn off automatic steps and substeps creation for Cypress? allure2#2712).Checklist