Is there a way to verify that cy.mount
throws an error?
#25428
Unanswered
justinsmid
asked this question in
Component Testing
Replies: 2 comments
-
I found #14782, which states that this works: expect(() => cy.mount(MyComponent)).to.throw This makes my test pass, but changing it to the following still passes, so I don't think it actually verifies that an error was thrown: expect(() => cy.mount(MyComponent)).not.to.throw; |
Beta Was this translation helpful? Give feedback.
0 replies
-
I came across this issue. I think the best thing to do if wrap the component in a React error boundary and then assert on the fallback contents. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I have a component that throws an error when it is not wrapped in a particular contextProvider, and a test to verify that it does so.
I have been using
@testing-library/react
for my component tests, and was able to test this behavior like this, which worked:I am currently trying to migrate my component tests over to
cy.mount
, and wasn't able to find a way to make this test work anymore.Beta Was this translation helpful? Give feedback.
All reactions