name: 'Param',
})
})
+
+ it('warns when the parent route is missing', async () => {
+ const { router } = await newRouter()
+ router.addRoute('parent-route', {
+ path: '/p',
+ component: components.Foo,
+ })
+ expect(
+ 'Parent route "parent-route" not found when adding child route'
+ ).toHaveBeenWarned()
+ })
+
+ it('warns when removing a missing route', async () => {
+ const { router } = await newRouter()
+ router.removeRoute('route-name')
+ expect('Cannot remove non-existent route "route-name"').toHaveBeenWarned()
+ })
})
})
let record: RouteRecordRaw
if (isRouteName(parentOrRoute)) {
parent = matcher.getRecordMatcher(parentOrRoute)
+ if (__DEV__ && !parent) {
+ warn(
+ `Parent route "${String(
+ parentOrRoute
+ )}" not found when adding child route`,
+ route
+ )
+ }
record = route!
} else {
record = parentOrRoute