Comments (9)
Makes sense. Are you up to contributing this improvement?
from jest-dom.
I'm giving it a try in #563. One particularly contentious aspect of it is that I had to tread lightly with an existing feature of .toHaveClass
: the ability to match the full class exactly when passing toHaveClass('…', {exact: true})
. In the end, I opted for disabling regexp support when enabling this option, since it does not make sense to make it work with regular expressions, which are inherently about checking the class names partially and not exactly.
from jest-dom.
Thanks for the reminder. Will try to get it merged and released today.
from jest-dom.
I also faced the same thing now:
expect(audioBtn).toHaveClass(/audio-btn/i)
and get this:
expect(element).toHaveClass(expected)
At least one expected class must be provided.
from jest-dom.
Hello! I saw the PR is approved by one, but the branch seems to be out of date. Is this being prioritized still? Do you need any support here, by any chance? This would be great for a test I've been just trying to write now.
Thanks!
from jest-dom.
🎉 This issue has been resolved in version 6.3.0 🎉
The release is available on:
Your semantic-release bot 📦🚀
from jest-dom.
Hello!
@gnapse, thanks for tackling this! I really appreciate it 😄
So, I just tried this out (i.e. expect(el).toHaveClass(/disabled/)
with a list of classes label select has-value root search disabled
) and I'm coming across the following error: At least one expected class must be provided.
, but if I do expect(el).toHaveClass('disabled')
, the tests do pass... am I missing something here?
from jest-dom.
Also, I just tried expect(el).toHaveClass(/disabled/, 'root')
on the same example as above, and I'm getting str.split is not a function
, but if I do expect(el).toHaveClass('root', /disabled/)
, all the tests pass - could there a check on the first argument of toHaveClass
that might prevent it to be a Regex?
from jest-dom.
@gnapse, just wanted to follow up on this. Let me know if there's anything I can do to help here, yes?
from jest-dom.
Related Issues (20)
- I am using Signalr in react and writing unit test, but test cases fails where signalr used HOT 1
- jest-dom 6.1.4 breaks jest types HOT 6
- Checking if input value is empty string using toHaveValue
- Property 'toBeInTheDocument' does not exist on type 'JestMatchers<HTMLElement>' HOT 24
- Support assertions for each DOM query HOT 8
- toHaveStyle fails on custom property names containing uppercase letters HOT 4
- TypeScript types for the `"./matchers"` export don't match implementations HOT 3
- toBeVisible is not seeing svelte-kit classes HOT 1
- `"types": ["jest", "@testing-library/jest-dom"]` not working after v6 upgrade HOT 3
- .toHaveAttribute('disabled') and .toBeDisabled() HOT 1
- toHaveStyle does not behave consistently between number and string values HOT 10
- toHaveStyle for property `font-size` behaves incorrectly for number values HOT 2
- Does not work with vitest 1.x.x HOT 10
- `.toHaveStyle()` doesn't know about aspect-ratio HOT 6
- Property 'toBeInTheDocument, toBeDisabled, etc' does not exist on type 'JestMatchers<HTMLElement>' HOT 4
- Types breakage in v6.4.0 HOT 9
- Remove unused and deprecated package `jest-environment-jsdom-sixteen`
- [attribute selector]:has(+ el) pseudo-class selector with emotionStyled reported as syntax error
- Memory leak when importing @testing-library/jest-dom in jest-setup file with NodeJS 20
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jest-dom.