You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: warn about root paths without a leading slash (#2591)
* fix(create-matcher): warn about root paths without a leading slash
close#2550
* fix(create-route-map): warn about root paths without a leading slash
close#2550
* fix(create-route-map): only warn about first route without slash
* fix(create-route-map): handle case of '' route
* fix(create-route-map): remove leftover console.log
* fix(create-route-map): warn about root paths only
* fix(create-route-map): show prettier warning message
Copy file name to clipboardexpand all lines: test/unit/specs/create-map.spec.js
+25
Original file line number
Diff line number
Diff line change
@@ -138,6 +138,31 @@ describe('Creating Route Map', function () {
138
138
)
139
139
})
140
140
141
+
it('in development, warn if a path is missing a leading slash',function(){
142
+
process.env.NODE_ENV='development'
143
+
maps=createRouteMap([
144
+
{path: 'bar',name: 'bar',component: Bar}
145
+
])
146
+
expect(console.warn).toHaveBeenCalledTimes(1)
147
+
expect(console.warn.calls.argsFor(0)[0]).toEqual('[vue-router] Non-nested routes must include a leading slash character. Fix the following routes: \n- bar')
148
+
})
149
+
150
+
it('in development, it does not log the missing leading slash when routes are valid',function(){
151
+
process.env.NODE_ENV='development'
152
+
maps=createRouteMap([
153
+
{path: '/bar',name: 'bar',component: Bar}
154
+
])
155
+
expect(console.warn).not.toHaveBeenCalled()
156
+
})
157
+
158
+
it('in production, it does not log the missing leading slash warning',function(){
0 commit comments