jest-serializer-html icon indicating copy to clipboard operation
jest-serializer-html copied to clipboard

Replace/Filter dynamic values in attributes

Open sschneider-ihre-pvs opened this issue 3 years ago • 5 comments

Using v-for on inputs with labels generates can generate a random for and matching id. It would be cool if there was an option similar to the property matcher where you could define those.

sschneider-ihre-pvs avatar Nov 04 '21 12:11 sschneider-ihre-pvs

I'm not sure if this is possible, as this simply stringifies the html directly, so there's no information whether something is an attribute. I would suggest mocking your randomiser to generate something predictable

Haroenv avatar Nov 04 '21 12:11 Haroenv

oh well, the framework component gives the matching for/id pairs a generated uid I guess I cannot easily mock that

sschneider-ihre-pvs avatar Nov 04 '21 12:11 sschneider-ihre-pvs

I guess worst case you could use createSerialiser and add a regex after? not sure how to solve this

Haroenv avatar Nov 04 '21 12:11 Haroenv

That seems to be the way right now. regex for uuid and replace with a static value.

sschneider-ihre-pvs avatar Nov 04 '21 12:11 sschneider-ihre-pvs

I guess what you could do is have some kind of override for https://github.com/algolia/diffable-html/blob/8911a117070d3e70ee5bf5674753c7ec0ccea436/index.js#L87

Haroenv avatar Nov 04 '21 13:11 Haroenv