eslint-plugin-jest-dom
eslint-plugin-jest-dom copied to clipboard
[prefer-to-have-style] error when attempting to fix with computed access of `el.style`
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 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)