Skip to content

Commit

Permalink
test: test case for #11286
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed Jul 17, 2024
1 parent c10e40a commit 3dc5a1a
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions packages/runtime-core/__tests__/errorHandling.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {
type VNode,
computed,
createApp,
defineComponent,
h,
Expand Down Expand Up @@ -639,5 +640,35 @@ describe('error handling', () => {
)
})

// #11286
test('handle error in computed', async () => {
const err = new Error()
const handler = vi.fn()

const count = ref(1)
const x = computed(() => {
if (count.value === 2) throw err
return count.value + 1
})

const app = createApp({
setup() {
return () => x.value
},
})

app.config.errorHandler = handler
app.mount(nodeOps.createElement('div'))

count.value = 2

await nextTick()
expect(handler).toHaveBeenCalledWith(
err,
{},
ErrorTypeStrings[ErrorCodes.COMPONENT_UPDATE],
)
})

// native event handler handling should be tested in respective renderers
})

0 comments on commit 3dc5a1a

Please sign in to comment.