Skip to content

[jest-dom/prefer-to-have-class] wrong autofix for toBeTrue() #380

Open
@danielrentz

Description

@danielrentz
  • eslint-plugin-jest-dom version: 5.4.0
  • node version: 20.9
  • npm version: 9.8.1

Relevant code or config

Using jest-extended's method toBeTrue() does not work with autofixer of jest-dom/prefer-to-have-class

expect(node.classList.contains('a')).toBe(true);
expect(node.classList.contains('b')).toBeTrue();

What you did:

Run auto-fixer for jest-dom/prefer-to-have-class assertions

What happened:

expect(node).toHaveClass('a');
expect(node).not.toHaveClass('b');

Problem description:

toBeTrue() will be fixed to not.toHaveClass()

Suggested solution:

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions