|
|
@@ -206,6 +206,51 @@ describe('api: defineAsyncComponent', () => {
|
|
|
expect(serializeInner(root)).toBe('resolved')
|
|
|
})
|
|
|
|
|
|
+ // #2129
|
|
|
+ test('error with error component, without global handler', async () => {
|
|
|
+ let resolve: (comp: Component) => void
|
|
|
+ let reject: (e: Error) => void
|
|
|
+ const Foo = defineAsyncComponent({
|
|
|
+ loader: () =>
|
|
|
+ new Promise((_resolve, _reject) => {
|
|
|
+ resolve = _resolve as any
|
|
|
+ reject = _reject
|
|
|
+ }),
|
|
|
+ errorComponent: (props: { error: Error }) => props.error.message
|
|
|
+ })
|
|
|
+
|
|
|
+ const toggle = ref(true)
|
|
|
+ const root = nodeOps.createElement('div')
|
|
|
+ const app = createApp({
|
|
|
+ render: () => (toggle.value ? h(Foo) : null)
|
|
|
+ })
|
|
|
+
|
|
|
+ app.mount(root)
|
|
|
+ expect(serializeInner(root)).toBe('<!---->')
|
|
|
+
|
|
|
+ const err = new Error('errored out')
|
|
|
+ reject!(err)
|
|
|
+ await timeout()
|
|
|
+ expect(serializeInner(root)).toBe('errored out')
|
|
|
+ expect(
|
|
|
+ 'Unhandled error during execution of async component loader'
|
|
|
+ ).toHaveBeenWarned()
|
|
|
+
|
|
|
+ toggle.value = false
|
|
|
+ await nextTick()
|
|
|
+ expect(serializeInner(root)).toBe('<!---->')
|
|
|
+
|
|
|
+ // errored out on previous load, toggle and mock success this time
|
|
|
+ toggle.value = true
|
|
|
+ await nextTick()
|
|
|
+ expect(serializeInner(root)).toBe('<!---->')
|
|
|
+
|
|
|
+ // should render this time
|
|
|
+ resolve!(() => 'resolved')
|
|
|
+ await timeout()
|
|
|
+ expect(serializeInner(root)).toBe('resolved')
|
|
|
+ })
|
|
|
+
|
|
|
test('error with error + loading components', async () => {
|
|
|
let resolve: (comp: Component) => void
|
|
|
let reject: (e: Error) => void
|