Skip to content
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

Support toContain with element.classList #2395

Closed
4 tasks done
vekunz opened this issue Nov 30, 2022 · 0 comments · Fixed by #4239
Closed
4 tasks done

Support toContain with element.classList #2395

vekunz opened this issue Nov 30, 2022 · 0 comments · Fixed by #4239
Labels
enhancement New feature or request good first issue Good for newcomers p2-nice-to-have Not breaking anything but nice to have (priority) pr welcome

Comments

@vekunz
Copy link

vekunz commented Nov 30, 2022

Clear and concise description of the problem

We are building a lot of components and want to test as many features as possible. One of the things we often have to test is if classes are attached correctly to an HTMLElement. Currently, we use this approach:

expect(element.classList.contains('something')).toBeTruthy();

This works but does not give us a good error message if the expectation fails. In this case, we just get the message that it is not true but false (except we add an error message manually).

Suggested solution

It would be great if we could use .toContain for this purpose. It would have the benefit of meaningful error messages if the expectation fails (e.g. a list of the actual classes of the element).

expect(element.classList).toContain('something');

Alternative

No response

Additional context

No response

Validations

@vekunz vekunz changed the title Support classList with toContain Support toContain with element.classList Nov 30, 2022
@sheremet-va sheremet-va added the enhancement New feature or request label Nov 30, 2022
@sheremet-va sheremet-va added good first issue Good for newcomers pr welcome p2-nice-to-have Not breaking anything but nice to have (priority) labels Oct 4, 2023
@github-actions github-actions bot locked and limited conversation to collaborators Nov 30, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request good first issue Good for newcomers p2-nice-to-have Not breaking anything but nice to have (priority) pr welcome
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants