red-refrigerator-13075
04/14/2021, 11:50 PMimport { config } from '@vue/test-utils'
config.mocks.$t = key => key
I found a link to an example on the @cypress/vue repo but it's brokenstocky-dream-36427
04/14/2021, 11:51 PMstocky-dream-36427
04/14/2021, 11:51 PMstocky-dream-36427
04/14/2021, 11:52 PMred-refrigerator-13075
04/14/2021, 11:53 PMstocky-dream-36427
04/14/2021, 11:53 PMtest('routing', () => {
const wrapper = mount(App, {
global: {
plugins: [router]
}
})
expect(wrapper.html()).toContain('Welcome to the blogging app')
})
stocky-dream-36427
04/14/2021, 11:54 PMstocky-dream-36427
04/14/2021, 11:54 PMstocky-dream-36427
04/14/2021, 11:54 PMstocky-dream-36427
04/14/2021, 11:54 PMred-refrigerator-13075
04/14/2021, 11:55 PMstocky-dream-36427
04/14/2021, 11:56 PMstocky-dream-36427
04/14/2021, 11:57 PMstocky-dream-36427
04/14/2021, 11:58 PMstocky-dream-36427
04/14/2021, 11:58 PMred-refrigerator-13075
04/14/2021, 11:59 PMred-refrigerator-13075
04/15/2021, 12:47 PMmount(BaseSaveButton, {
mocks: {
$t: key => key
}
})
But still don't know how to mock vue-i18n in the global context, I tried a few things but nothing works, so if anyone can please provide an example of how to do it that would be great 😃red-refrigerator-13075
04/15/2021, 12:50 PMexpect(wrapper.emitted('click')).toBeTruthy()
user
04/15/2021, 2:27 PMVue.use(VueI18n)
, and at least in my project I always create only the messages that I need in my test:
js
mount(Component, {
...
i18n: new VueI18n({
locale: 'en-us',
messages: {
'en-us': {
message: 'message',
},
},
}),
...
})
red-refrigerator-13075
04/15/2021, 3:43 PMmocks: {
$t: key => key
}
Now, instead of doing that for each test, I want to use the mock globally, that's where I'm stuck.
In case I wanted to use vue-i18n with the translated messages that I already have in the locales folder, how could I set it up? because I already try to import the vue-i8n plugin file that I'm using for the project into the cypress/support folder but it doesn't work 😦red-refrigerator-13075
04/15/2021, 4:15 PMlittle-shampoo-74692
04/15/2021, 4:15 PMbulky-sundown-74498
04/15/2021, 4:16 PMred-refrigerator-13075
04/15/2021, 4:16 PMmount(BaseSaveButton, {
mocks: {
$t: key => key
}
})
bulky-sundown-74498
04/15/2021, 4:17 PMbulky-sundown-74498
04/15/2021, 4:18 PMfunction mounti18n()
that has the same signature as mount()
in which I merge this mockbulky-sundown-74498
04/15/2021, 4:18 PMbulky-sundown-74498
04/15/2021, 4:19 PMbulky-sundown-74498
04/15/2021, 4:19 PMlittle-shampoo-74692
04/15/2021, 4:20 PM