Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(warn): throws if history is missing #844

Merged
merged 3 commits into from Mar 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 7 additions & 0 deletions __tests__/router.spec.ts
Expand Up @@ -93,6 +93,13 @@ describe('Router', () => {
createDom()
})

it('fails if history option is missing', () => {
// @ts-ignore
expect(() => createRouter({ routes })).toThrowError(
'Provide the "history" option'
)
})

it('starts at START_LOCATION', () => {
const history = createMemoryHistory()
const router = createRouter({ history, routes })
Expand Down
5 changes: 5 additions & 0 deletions src/router.ts
Expand Up @@ -343,6 +343,11 @@ export function createRouter(options: RouterOptions): Router {
let parseQuery = options.parseQuery || originalParseQuery
let stringifyQuery = options.stringifyQuery || originalStringifyQuery
let routerHistory = options.history
if (__DEV__ && !routerHistory)
throw new Error(
'Provide the "history" option when calling "createRouter()":' +
' https://next.router.vuejs.org/api/#history.'
)

const beforeGuards = useCallbacks<NavigationGuardWithThis<undefined>>()
const beforeResolveGuards = useCallbacks<NavigationGuardWithThis<undefined>>()
Expand Down