-
Notifications
You must be signed in to change notification settings - Fork 668
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
Errors in setup()
are silent if render()
throws an error
#2083
Comments
Is this a vue thing? I've just found that this gives me the behaviour I want: const wrapper = mount(MessageComponent, {
global: {
config: {
errorHandler: (err) => {
throw err;
},
}
},
}); |
I've ended up adding this to our import { config } from '@vue/test-utils';
// By default, vue will attempt to continue past setup errors.
// This will cause tests to fail silently, so we make sure that
// exceptions are thrown immediately in all tests.
config.global.config.errorHandler = (err) => {
throw err;
}; Maybe this could be more prominent in the docs? |
@mikemonteith dude you saved my day. I was chasing false errors.
In my case I was accessing an undefined value in Adding your code gave me the correct error output.
In hindsight it makes sense, because the actual function which defines |
@mikemonteith I think from the version of your package.json it seems you opened the issue on the wrong repository:
This repository is for version 1 for the version 2: https://github.com/vuejs/test-utils/issues and the version you currently have: https://github.com/vuejs/test-utils/releases/tag/v2.4.1 |
@joaopedrodcf Well spotted. In that case, my issue is a duplicate of vuejs/test-utils#2319 |
No problem glad to help ✌️ |
Subject of the issue
Errors thrown in
setup()
are silently caught if the render function throws it's own error.This can lead to confusing test error messages that seem like something is wrong in the template, when the issue is actually in the setup.
Consider the reproduction case below:
Steps to reproduce
package.json:
test.js:
Expected behaviour
I would expect the program to stop when setup() throws the error.
Actual behaviour
The program continues by rendering the template with an empty context, which then throws it's own error due to
t
being undefined.Output:
The text was updated successfully, but these errors were encountered: