Closed louis-vinchon closed 4 years ago
I would have happily done it myself but the lack (absence) of documentation killed my motivation.
This might work (untested):
cy.get('div')
.its('outerHtml')
.then(html => html.replace(/ id=\".*?\"/g, ''))
.toMatchSnapshot();
@K41eb let me know if it works. If it does not, I will reopen this issue.
Is your feature request related to a problem? Please describe. It is currently impossible to ignore anything while snapshoting a DOM element or a DOM tree. Which means that snapshot testing is simply impossible for application where
id
s are generated, e.g. in Angular ag-grid generates row ids dynamically therefore two snapshots of the grid will never be the same since allid
s have been changed.Describe the solution you'd like An option to ignore elements attributes, or the possibility to pass a function to freely
str.replace()
anything on the stringified DOM tree.Describe alternatives you've considered Selecting several elements that do not have generated
id
s withcy.get()
. Doesn't work as this feature is broken/missing.