diff --git a/tests/mountingOptions/mocks.spec.ts b/tests/mountingOptions/mocks.spec.ts index 2d9d410b1..c07bb5937 100644 --- a/tests/mountingOptions/mocks.spec.ts +++ b/tests/mountingOptions/mocks.spec.ts @@ -101,4 +101,29 @@ describe('mocks', () => { expect(wrapper.text()).toContain('hello') expect(wrapper.text()).toContain('mocked') }) + + it('mocks a global function in an option component which includes the setup() option', () => { + const ComponentWithI18nAndSetupOption = defineComponent({ + setup: () => ({ + hello: 'hello' + }), + template: ` +
{{ hello }}
+ + +
{{ $t('world') }}
+ ` + }) + + const wrapper = mount(ComponentWithI18nAndSetupOption, { + global: { + mocks: { + $t: () => 'mocked' + } + } + }) + + expect(wrapper.text()).toContain('hello') + expect(wrapper.text()).toContain('mocked') + }) })