Skip to content

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

@G-Rath

Description

@G-Rath
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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingreleased

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions