diff --git a/lib/jasmine-core/jasmine.js b/lib/jasmine-core/jasmine.js index 4f7c6a91..f2230d10 100644 --- a/lib/jasmine-core/jasmine.js +++ b/lib/jasmine-core/jasmine.js @@ -118,6 +118,9 @@ var getJasmineRequireObj = (function() { j$.private.matchers = jRequire.requireMatchers(jRequire, j$); j$.private.asyncMatchers = jRequire.requireAsyncMatchers(jRequire, j$); + j$.private.loadedAsBrowserEsm = + globalThis.document && !globalThis.document.currentScript; + return j$; }; @@ -1594,6 +1597,14 @@ getJasmineRequireObj().Env = function(j$) { this.execute = async function(runablesToRun) { installGlobalErrors(); + // Karma incorrectly loads jasmine-core as an ES module. It isn't one, + // and we don't test that configuration. Warn about it. + if (j$.private.loadedAsBrowserEsm) { + this.deprecated( + "jasmine-core isn't an ES module but it was loaded as one. This is not a supported configuration." + ); + } + if (parallelLoadingState) { validateConfigForParallel(); } diff --git a/src/core/Env.js b/src/core/Env.js index 52eefbe7..ad39d25c 100644 --- a/src/core/Env.js +++ b/src/core/Env.js @@ -402,6 +402,14 @@ getJasmineRequireObj().Env = function(j$) { this.execute = async function(runablesToRun) { installGlobalErrors(); + // Karma incorrectly loads jasmine-core as an ES module. It isn't one, + // and we don't test that configuration. Warn about it. + if (j$.private.loadedAsBrowserEsm) { + this.deprecated( + "jasmine-core isn't an ES module but it was loaded as one. This is not a supported configuration." + ); + } + if (parallelLoadingState) { validateConfigForParallel(); } diff --git a/src/core/requireCore.js b/src/core/requireCore.js index fc63800b..77d45121 100644 --- a/src/core/requireCore.js +++ b/src/core/requireCore.js @@ -94,6 +94,9 @@ var getJasmineRequireObj = (function() { j$.private.matchers = jRequire.requireMatchers(jRequire, j$); j$.private.asyncMatchers = jRequire.requireAsyncMatchers(jRequire, j$); + j$.private.loadedAsBrowserEsm = + globalThis.document && !globalThis.document.currentScript; + return j$; };