cypress-testing-library icon indicating copy to clipboard operation
cypress-testing-library copied to clipboard

Support matchers from @testing-library/jest-dom

Open Andarist opened this issue 4 years ago • 2 comments

It would be quite a nice addition if this would support custom matchers from @testing-library/jest-dom - many of them are somewhat builtin to Cypress so might be better not to touch them but for example, toHaveDescription is something that can't be trivially achieved in raw Cypress.

Andarist avatar Dec 18 '20 23:12 Andarist

I've thought about adding a few custom matchers to Cypress. I've done a few custom ones on projects by overriding should.

Cypress isn't really handling matchers directly, but using Chai and Chai matchers. It is possible to delegate to other systems if you want to use jest-dom directly.

Perhaps this post could help a bit: https://medium.com/@NicholasBoll/using-jest-matchers-in-cypress-5e8e7281f5dd

NicholasBoll avatar Dec 19 '20 05:12 NicholasBoll

Right - it would be nice though if this particular library would do this automatically for me.

Andarist avatar Dec 19 '20 06:12 Andarist