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 diff --git a/cds-plugin.js b/cds-plugin.js index 2f41a06..9cec268 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 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'); + main(); + }); + }); +} 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,