Skip to content

Commit

Permalink
fix: create provider if missing and has route definitions
Browse files Browse the repository at this point in the history
Fixes #188
  • Loading branch information
harlan-zw committed Mar 1, 2024
1 parent 0743b03 commit a9d0f24
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion packages/core/src/unlighthouse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,8 @@ export async function createUnlighthouse(userConfig: UserConfig, provider?: Prov
}

if (ctx.routeDefinitions?.length) {
if (typeof ctx.provider.mockRouter === 'function')
ctx.provider = ctx.provider || {}
if (typeof ctx.provider?.mockRouter === 'function')
ctx.provider.mockRouter = ctx.provider.mockRouter(ctx.routeDefinitions)
else if (!ctx.provider.mockRouter)
ctx.provider.mockRouter = createMockRouter(ctx.routeDefinitions)
Expand Down

0 comments on commit a9d0f24

Please sign in to comment.