Skip to content

[prefer-to-have-style] error when attempting to fix with computed access of el.style #265

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

Closed
G-Rath opened this issue May 20, 2022 · 1 comment · Fixed by #306
Closed
Labels
bug Something isn't working released

Comments

@G-Rath
Copy link
Collaborator

G-Rath commented May 20, 2022

expect(imageElement.style[computed]).toBe(`inset 0px 0px 0px 400px ${c}`)

This errors:

A fatal parsing error occurred in autofix.
    Error: Parsing error: Unexpected token :
    Autofix output:
    expect(imageElement).toHaveStyle(: inset 0px 0px 0px 400px ${c}`)

We should not provide a fixer for this case, because we can't determine if the matcher value is meant to be a property or a value (since the accessor could either be the name of a property, or the index of one) so can't correctly fix it.

e.g.

expect(el.style[computed]).toEqual('padding');

// should become
expect(el.style[computed]).toHaveStyle({ padding: expect.anything() });

// but instead becomes
expect(el.style[computed]).toHaveStyle('padding');
expect(el.style[computed]).toEqual('padding');

// should become
expect(el.style[computed]).toHaveStyle({ [computed]: '5px' });
expect(el.style[computed]).toHaveStyle({ padding: expect.anything() });

// but instead becomes
expect(el.style[computed]).toHaveStyle({ '5px': expect.anything() });

(because of #264)

@github-actions
Copy link

github-actions bot commented Jun 4, 2023

🎉 This issue has been resolved in version 5.0.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working released
Projects
None yet
1 participant