Jest Testing with async errors #904
Answered
by
posva
nathanthibert
asked this question in
Help and Questions
-
I have a test where I'm rejecting a service call. We can use the documentation example. async registerUser(login, password) {
try {
this.userData = await api.post({ login, password })
showTooltip(`Welcome back ${this.userData.name}!`)
} catch (error) {
showTooltip(error)
// let the form component display the error
return error
}
}, How do we test the return value of the error? I assume this hooks into the |
Beta Was this translation helpful? Give feedback.
Answered by
posva
Dec 16, 2021
Replies: 1 comment 1 reply
-
You can instantiate a regular store in a test and call the action and check the returned value: expect(await store.registerUser(...)).toEqual(...) |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
nathanthibert
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can instantiate a regular store in a test and call the action and check the returned value: