Allow for separate config file
See original GitHub issueWhat problem does this feature solve?
I work in a non English speaking country, so we are using vue-i18n
to create a bilingual app. It adds a global $t
function. I have to do:
mocks: {
$t: jest.fn()
}
in every test, or the test fails with $t is undefined
, since almost all components have some form of text.
Other users have a similar use case to mock regularly occurring global objects. More comments in this thread: https://github.com/vuejs/vue-test-utils/issues/325
What does the proposed API look like?
I still think a config file would be good. I’m thinking something along the lines of a test-utils.config.js
that could be something like this:
export default {
mocks: {
// mocks to use in all tests
// they should be merged with any mocks passed in `shallow` or `mount`
// the ones from `shallow`, `mount` should take priority and override the ones in this config file
},
stubs: {
/* I often find myself wanting to stub certain components a lot as well */
}
}
You should be able to provide defaults for anything you can pass in the options
object to shallow
and mount
.
vue-test-utils
shouls look for a default config file in the root directory (for example test-utils.config.js
).
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:7 (7 by maintainers)
Thank you for replying.
IMHO, Since it is not necessary to use multiple test runners for same test, I think that not depending test runner does not become benefit. Adding a function is adding maintenance cost and complex. I think if the function provided by a test runner resolve it, it is not necessary to adding this function.
Supporting all options in the config object is other issue.
I agree with @38elements, adding an extra config file adds a lot of work on our end. Since we already have a config object, all the setup can be done in there.
I’m closing this as something we aren’t going to implement.