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
How to properly mock/stub/plugin vue-i18n with Vitest, Vue3, Typescript ? #1630
Labels
Status: Review Needed
Request for review comments
Comments
The results are always the same. Error: FAIL test/vitest/__tests__/MainComponent.test.ts > Main > renders the main component
TypeError: $setup.t is not a function |
@cmcleese did you found a solution for this? Edit: let router: Router
let i18n: I18n
beforeEach(async() => {
i18n = createI18n({
locale: 'en',
fallbackLocale: 'en',
legacy: false,
messages
})
router = createRouter({
history: createWebHistory(),
routes: routes
})
router.push('/')
await router.isReady()
})
describe('Testing login view', async () => {
it.only('should render', () => {
const wrapper = mount(LoginView, {
global: {
plugins: [i18n, router],
}
})
wrapper.isVisible()
})
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Reporting a bug?
I have Vue 3 components that do not pass test and always fail with the error:
TypeError: $setup.t is not a function
Expected behavior
Defining the global plugin should work.
Even trying to manually mock
t
doesnt work:Reproduction
I am using Quasar for rapid scaffolding but should not matter.
Clone repo: https://github.com/cmcleese/quasar-vuei18n-vitest
Simply run in cmd:
vitest
Test & component:
test/vitest/__tests__/NotifyComponent.test.ts
test/vitest/__tests__/demo/NotifyComponent.vue
System Info
Screenshot
No response
Additional context
No response
Validations
The text was updated successfully, but these errors were encountered: