From 25c255bc27e02a9eaa7ff3dac2dc126592038e1b Mon Sep 17 00:00:00 2001 From: Miki Date: Wed, 18 Dec 2024 00:26:04 -0800 Subject: [PATCH] coverage Signed-off-by: Miki --- cypress.config.ts | 3 +++ src/core/server/http/http_server.ts | 6 ++++++ 2 files changed, 9 insertions(+) diff --git a/cypress.config.ts b/cypress.config.ts index 77ac2890ce21..a2b665695a35 100644 --- a/cypress.config.ts +++ b/cypress.config.ts @@ -32,6 +32,9 @@ module.exports = defineConfig({ DATASOURCE_MANAGEMENT_ENABLED: false, ML_COMMONS_DASHBOARDS_ENABLED: true, WAIT_FOR_LOADER_BUFFER_MS: 0, + codeCoverage: { + url: 'http://localhost:5601/__coverage__', + }, }, e2e: { baseUrl: 'http://localhost:5601', diff --git a/src/core/server/http/http_server.ts b/src/core/server/http/http_server.ts index a3ec4e951c68..67e774401264 100644 --- a/src/core/server/http/http_server.ts +++ b/src/core/server/http/http_server.ts @@ -220,6 +220,12 @@ export class HttpServer { } } + // @ts-expect-error + if (global.__coverage__) { + // eslint-disable-next-line @typescript-eslint/no-var-requires + require('@cypress/code-coverage/middleware/hapi')(this.server); + } + await this.server.start(); const serverPath = this.config && this.config.rewriteBasePath && this.config.basePath !== undefined