Skip to content

Commit

Permalink
repro: 'set' on proxy: trap returned falsish for property with Vue v3…
Browse files Browse the repository at this point in the history
….2.45

This comes from the fact that mocks are set via a mixin (Options API) and we run into the more strict behavior of Vue v3.2.45
introduced in vuejs/core@f73925d#diff-ea4d1ddabb7e22e17e80ada458eef70679af4005df2a1a6b73418fec897603ceR404
  • Loading branch information
cexbrayat committed Nov 14, 2022
1 parent 59331e9 commit fb36908
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
2 changes: 1 addition & 1 deletion tests/components/ScriptSetup.vue
Expand Up @@ -12,6 +12,6 @@ const inc = () => {
</script>

<template>
<button @click="inc">{{ count }}</button>
<button @click="inc()">{{ count }}</button>
<Hello />
</template>
19 changes: 18 additions & 1 deletion tests/expose.spec.ts
@@ -1,4 +1,4 @@
import { describe, expect, it } from 'vitest'
import { describe, expect, it, vi } from 'vitest'
import { nextTick } from 'vue'
import { mount } from '../src'
import Hello from './components/Hello.vue'
Expand Down Expand Up @@ -61,4 +61,21 @@ describe('expose', () => {
await nextTick()
expect(wrapper.html()).toContain('2')
})

it('should not throw when mocking', async () => {
const spiedIncrement = vi.fn()
const wrapper = mount(ScriptSetup, {
global: {
mocks: {
inc: spiedIncrement
}
}
})

await wrapper.find('button').trigger('click')
await nextTick()

expect(spiedIncrement).toHaveBeenCalled()
expect(wrapper.html()).toContain('0')
})
})

0 comments on commit fb36908

Please sign in to comment.