We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 9ed97d4 commit bed7838Copy full SHA for bed7838
1 file changed
x-pack/plugins/enterprise_search/server/__mocks__/router.mock.ts
@@ -51,9 +51,12 @@ export class MockRouter {
51
52
public callRoute = async (request: TMockRouterRequest) => {
53
const routerCalls = this.router[this.method].mock.calls as any[];
54
+ if (!routerCalls.length) throw new Error('No routes registered.');
55
+
56
const route = routerCalls.find(([router]: any) => router.path === this.path);
- const [, handler] = route;
57
+ if (!route) throw new Error('No matching registered routes found - check method/path keys');
58
59
+ const [, handler] = route;
60
const context = {} as jest.Mocked<RequestHandlerContext>;
61
await handler(context, httpServerMock.createKibanaRequest(request as any), this.response);
62
};
0 commit comments