I have to test this svg, now don't ask me why, I need it and I'm doing some tests!
<svg class="custom-background" width="1864" height="441" style="background: linear-gradient(to right, rgb(255, 255, 255) 3.21888%, rgba(255, 0, 0, 0.1) 3.21888%) 0% 0% / auto 381px no-repeat;">
</svg>
In my text I wrote this:
cy.get('svg')
.should(`have.attr', 'style', 'background: linear-gradient(to right, rgb(255, 255, 255) 91.4872%, rgba(255, 0, 0, 0.1) 91.4872%) 0% 0% / auto 403px no-repeat`);
I'm just trying, because then in the future I'll have to insert percentages that come from dynamically calculated variables. But this is something else. The point is that already doing this gives me an error:
The chainer attr', 'style', 'background: linear-gradient(to right, rgb(255, 255, 255) 91 was not found. Could not build assertion.
I can't understand why, it's the first time I've done this kind of test, and I couldn't find much about it in the documentation...
Instead of adding the entire value of the style
attribute, you can just add the value that you want to assert using include
.
cy.get('svg')
.should('have.attr', 'style')
.and('include', '91.4872%')