From 3ec9df1056791d1c12fc571e012d5b27597265f2 Mon Sep 17 00:00:00 2001 From: Luca Fischer Date: Thu, 30 Oct 2025 16:27:55 +0100 Subject: [PATCH 1/4] Conditionally initialize plugin --- cds-plugin.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/cds-plugin.js b/cds-plugin.js index 2f41a06..91fd313 100644 --- a/cds-plugin.js +++ b/cds-plugin.js @@ -1,5 +1,9 @@ -import cds from '@sap/cds'; - -import main from './dist/index.js'; - -cds.on('served', main); +// Prevents CAP console plugin from initializing during Jest test runs. +if (process.env.NODE_ENV !== 'test' || !process.env.JEST_WORKER_ID) { + import('@sap/cds').then(({ default: cds }) => { + cds.on('served', async () => { + const { default: main } = await import('./dist/index.js'); + main(); + }); + }); +} From 9e6d3b146cae53be16e58faa15950ed1ac7b1769 Mon Sep 17 00:00:00 2001 From: Luca Fischer Date: Thu, 30 Oct 2025 16:42:38 +0100 Subject: [PATCH 2/4] Add globals to ESLint --- eslint.config.mjs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/eslint.config.mjs b/eslint.config.mjs index 82bb5da..c0f64d2 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -3,6 +3,7 @@ import vitest from '@vitest/eslint-plugin'; import { globalIgnores } from 'eslint/config'; import eslintPrettierRecommended from 'eslint-plugin-prettier/recommended'; import simpleImportSort from 'eslint-plugin-simple-import-sort'; +import globals from 'globals'; import tseslint from 'typescript-eslint'; const simpleImportSortConfig = { @@ -51,6 +52,13 @@ const vitestConfig = { export default tseslint.config( globalIgnores(['**/node_modules/', '.git/', 'dist/', 'release/', '**/gen/**']), + { + languageOptions: { + globals: { + ...globals.node, + }, + }, + }, simpleImportSortConfig, vitestConfig, eslint.configs.recommended, From 4fe7486e00145e989f4b6796d6d9c956ab65f6cc Mon Sep 17 00:00:00 2001 From: Luca Fischer Date: Thu, 30 Oct 2025 16:51:39 +0100 Subject: [PATCH 3/4] Update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 66b729b..7b52351 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/). ### Deprecated ### Removed ### Fixed +- Prevented CAP Console from blocking Jest test execution by conditionally loading the plugin. (Resolves #4) ### Security ## [1.0.1] - 2025-10-13 From fb88341ed7380ba8270ee7db956fa3a6836ee655 Mon Sep 17 00:00:00 2001 From: Luca Fischer Date: Thu, 30 Oct 2025 16:52:14 +0100 Subject: [PATCH 4/4] Change condition to check for test environments --- cds-plugin.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cds-plugin.js b/cds-plugin.js index 91fd313..9cec268 100644 --- a/cds-plugin.js +++ b/cds-plugin.js @@ -1,5 +1,5 @@ -// Prevents CAP console plugin from initializing during Jest test runs. -if (process.env.NODE_ENV !== 'test' || !process.env.JEST_WORKER_ID) { +// Prevents CAP console plugin from initializing during test runs. +if (process.env.NODE_ENV !== 'test') { import('@sap/cds').then(({ default: cds }) => { cds.on('served', async () => { const { default: main } = await import('./dist/index.js');