From f12f4395f0f96e2ca63b7cb045f71b1a6600c483 Mon Sep 17 00:00:00 2001 From: Steve Gravrock Date: Sun, 15 Feb 2026 13:41:19 -0800 Subject: [PATCH] Redesigned moudule system * Top level private APIs (e.g. jasmine.private.whatever) are no longer exposed * jasmineRequire is no longer exposed * core is self-booting * Globals are automatically created in browsers. (They can subsequently be removed by user code if desired.) * Globals are *not* automatically created in Node. An installGlobals function is exported instead. The jasmine package calls installGlobals unless configured not to do so. * In Node, the same instance is returned each time jasmine-core is imported. A reset function is exported. It effectively resets all state by discarding the env and creating a new one. This allows mulitple sequential runs within the same process to be independent of each other, but does not allow multiple concurrent runs. (That probably never worked anyway.) Fixes #2094 --- .github/CONTRIBUTING.md | 10 +- lib/jasmine-core.js | 114 +-- lib/jasmine-core/{boot1.js => boot.js} | 24 +- lib/jasmine-core/boot0.js | 68 -- lib/jasmine-core/jasmine-html.js | 126 ++- lib/jasmine-core/jasmine.js | 953 +++++++++--------- package.json | 5 +- scripts/buildStandaloneDist.js | 3 +- scripts/lib/buildDistribution.js | 53 +- scripts/runSpecsInNode.js | 7 +- spec/core/ExceptionFormatterSpec.js | 20 +- spec/core/SpecSpec.js | 6 +- spec/core/SuiteSpec.js | 6 +- spec/core/UtilSpec.js | 1 - spec/core/integration/EnvSpec.js | 4 +- spec/core/jasmineNamespaceSpec.js | 1 - spec/helpers/defineJasmineUnderTest.js | 14 +- spec/helpers/integrationMatchers.js | 4 +- spec/helpers/nodeDefineJasmineUnderTest.js | 29 +- spec/npmPackage/npmPackageSpec.js | 2 +- spec/support/jasmine-browser.js | 4 +- src/SpecRunner.html.ejs | 4 +- src/boot/{boot1.js => boot.js} | 22 +- src/boot/boot0.js | 44 - src/boot/jasmine-core.js | 112 +- src/core/CallTracker.js | 6 +- src/core/Clock.js | 2 +- src/core/CompleteOnFirstErrorSkipPolicy.js | 2 +- src/core/Configuration.js | 2 +- src/core/DelayedFunctionScheduler.js | 2 +- src/core/Deprecator.js | 10 +- src/core/Env.js | 58 +- src/core/ExceptionFormatter.js | 8 +- src/core/Expectation.js | 10 +- src/core/Expector.js | 6 +- src/core/GlobalErrors.js | 8 +- src/core/MockDate.js | 2 +- src/core/NeverSkipPolicy.js | 2 +- src/core/ParallelReportDispatcher.js | 13 +- src/core/PrettyPrinter.js | 22 +- src/core/QueueRunner.js | 16 +- src/core/ReportDispatcher.js | 2 +- src/core/RunableResources.js | 16 +- src/core/Runner.js | 10 +- src/core/SkipAfterBeforeAllErrorPolicy.js | 2 +- src/core/Spec.js | 14 +- src/core/Spy.js | 8 +- src/core/SpyFactory.js | 10 +- src/core/SpyRegistry.js | 17 +- src/core/SpyStrategy.js | 14 +- src/core/StackClearer.js | 2 +- src/core/StackTrace.js | 2 +- src/core/Suite.js | 20 +- src/core/SuiteBuilder.js | 26 +- src/core/TreeProcessor.js | 2 +- src/core/TreeRunner.js | 12 +- src/core/UserContext.js | 2 +- src/core/asymmetric_equality/AllOf.js | 2 +- src/core/asymmetric_equality/Any.js | 4 +- src/core/asymmetric_equality/Anything.js | 2 +- .../asymmetric_equality/ArrayContaining.js | 4 +- .../ArrayWithExactContents.js | 4 +- src/core/asymmetric_equality/Empty.js | 10 +- src/core/asymmetric_equality/Falsy.js | 2 +- src/core/asymmetric_equality/Is.js | 2 +- src/core/asymmetric_equality/MapContaining.js | 8 +- src/core/asymmetric_equality/NotEmpty.js | 10 +- .../asymmetric_equality/ObjectContaining.js | 4 +- src/core/asymmetric_equality/SetContaining.js | 8 +- .../asymmetric_equality/StringContaining.js | 6 +- .../asymmetric_equality/StringMatching.js | 4 +- src/core/asymmetric_equality/Truthy.js | 2 +- src/core/base.js | 120 +-- src/core/buildExpectationResult.js | 6 +- src/core/matchers/DiffBuilder.js | 12 +- src/core/matchers/MismatchTree.js | 4 +- src/core/matchers/NullDiffBuilder.js | 2 +- src/core/matchers/ObjectPath.js | 2 +- src/core/matchers/async/toBePending.js | 4 +- src/core/matchers/async/toBeRejected.js | 4 +- src/core/matchers/async/toBeRejectedWith.js | 4 +- .../matchers/async/toBeRejectedWithError.js | 12 +- src/core/matchers/async/toBeResolved.js | 4 +- src/core/matchers/async/toBeResolvedTo.js | 4 +- src/core/matchers/matchersUtil.js | 48 +- src/core/matchers/requireAsyncMatchers.js | 4 +- src/core/matchers/requireMatchers.js | 4 +- src/core/matchers/toBe.js | 2 +- src/core/matchers/toBeInstanceOf.js | 10 +- src/core/matchers/toBeNaN.js | 2 +- src/core/matchers/toBeNegativeInfinity.js | 2 +- src/core/matchers/toBePositiveInfinity.js | 2 +- src/core/matchers/toEqual.js | 4 +- src/core/matchers/toHaveBeenCalled.js | 4 +- src/core/matchers/toHaveBeenCalledBefore.js | 4 +- src/core/matchers/toHaveBeenCalledOnceWith.js | 6 +- src/core/matchers/toHaveBeenCalledTimes.js | 6 +- src/core/matchers/toHaveBeenCalledWith.js | 6 +- src/core/matchers/toHaveClass.js | 4 +- src/core/matchers/toHaveClasses.js | 4 +- .../matchers/toHaveNoOtherSpyInteractions.js | 6 +- src/core/matchers/toHaveSize.js | 10 +- src/core/matchers/toHaveSpyInteractions.js | 6 +- src/core/matchers/toMatch.js | 9 +- src/core/matchers/toThrow.js | 4 +- src/core/matchers/toThrowError.js | 14 +- src/core/matchers/toThrowMatching.js | 6 +- src/core/reporterEvents.js | 2 +- src/core/requireCore.js | 159 +-- src/core/requireSuffix.js | 35 + src/core/util.js | 6 +- src/html/AlertsView.js | 4 +- src/html/Banner.js | 4 +- src/html/FailuresView.js | 4 +- src/html/HtmlReporterV2.js | 20 +- src/html/HtmlReporterV2Urls.js | 4 +- src/html/HtmlSpecFilterv2.js | 2 +- src/html/OverallStatusBar.js | 4 +- src/html/PerformanceView.js | 4 +- src/html/QueryString.js | 2 +- src/html/ResultsNode.js | 2 +- src/html/ResultsStateBuilder.js | 4 +- src/html/SummaryTreeView.js | 4 +- src/html/TabBar.js | 4 +- src/html/htmlReporterUtils.js | 2 +- src/html/requireHtml.js | 52 +- src/html/requireSuffix.js | 4 + 127 files changed, 1336 insertions(+), 1367 deletions(-) rename lib/jasmine-core/{boot1.js => boot.js} (70%) delete mode 100644 lib/jasmine-core/boot0.js rename src/boot/{boot1.js => boot.js} (50%) delete mode 100644 src/boot/boot0.js create mode 100644 src/core/requireSuffix.js create mode 100644 src/html/requireSuffix.js diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index d4442127..4ac6d612 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -41,13 +41,11 @@ Jasmine tests itself. The files in `lib` are loaded first, defining the referenc The tests should always use `jasmineUnderTest` to refer to the objects and functions that are being tested. But the tests can use functions on `jasmine` as needed. _Be careful how you structure any new test code_. Copy the patterns you see in the existing code - this ensures that the code you're testing is not leaking into the `jasmine` reference and vice-versa. -### `boot0.js` and `boot1.js` +### `boot.js` -These files file does all of the setup necessary for Jasmine to work in a -browser. They load all of the code, create an `Env`, attach the global -functions, and build the reporter. It also sets up the execution of the -`Env` - for browsers this is in `window.onload`. While the default in `lib` -is appropriate for browsers, projects may wish to customize this file. +This file does all the setup necessary for Jasmine to work in a browser. While +the default in `lib`is appropriate for most uses, users may wish to customize +this file. ### Compatibility diff --git a/lib/jasmine-core.js b/lib/jasmine-core.js index 6efa2367..17f41e8f 100644 --- a/lib/jasmine-core.js +++ b/lib/jasmine-core.js @@ -1,6 +1,6 @@ /* Copyright (c) 2008-2019 Pivotal Labs -Copyright (c) 2008-2025 The Jasmine developers +Copyright (c) 2008-2026 The Jasmine developers Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the @@ -24,70 +24,25 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 'use strict'; -/** - * Note: Only available on Node. - * @module jasmine-core - */ +const path = require('path'); +const fs = require('fs'); +const { + globals, + installGlobals, + private$ +} = require('./jasmine-core/jasmine.js'); -const jasmineRequire = require('./jasmine-core/jasmine.js'); -module.exports = jasmineRequire; - -const bootWithoutGlobals = (function() { - let jasmine, jasmineInterface; - - return function bootWithoutGlobals(reinitialize) { - if (!jasmineInterface || reinitialize === true) { - jasmine = jasmineRequire.core(jasmineRequire); - const env = jasmine.getEnv({ suppressLoadErrors: true }); - jasmineInterface = jasmineRequire.interface(jasmine, env); - } - - return { jasmine, jasmineInterface }; - }; -})(); - -/** - * Boots a copy of Jasmine and returns an object as described in {@link jasmine}. - * @param {boolean} [reinitialize=true] Whether to create a new copy of Jasmine if one already exists - * @type {function} - * @return {jasmine} - */ -module.exports.boot = function(reinitialize) { - if (reinitialize === undefined) { - reinitialize = true; - } - - const { jasmine, jasmineInterface } = bootWithoutGlobals(reinitialize); - - for (const k in jasmineInterface) { - global[k] = jasmineInterface[k]; - } - - return jasmine; -}; - -/** - * Boots a copy of Jasmine and returns an object containing the properties - * that would normally be added to the global object. If noGlobals is called - * multiple times, the same object is returned every time. - * - * @example - * const {describe, beforeEach, it, expect, jasmine} = require('jasmine-core').noGlobals(); - */ -module.exports.noGlobals = function() { - const { jasmineInterface } = bootWithoutGlobals(false); - return jasmineInterface; -}; - -const path = require('path'), - fs = require('fs'); +function reset() { + private$.currentEnv_ = null; + const env = jasmine.getEnv({ suppressLoadErrors: true }); + rebindInterface(env); +} const rootPath = path.join(__dirname, 'jasmine-core'), - bootFiles = ['boot0.js', 'boot1.js'], - legacyBootFiles = ['boot.js'], + bootFiles = ['boot.js'], cssFiles = [], jsFiles = [], - jsFilesToSkip = ['jasmine.js'].concat(bootFiles, legacyBootFiles); + jsFilesToSkip = ['jasmine.js'].concat(bootFiles); fs.readdirSync(rootPath).forEach(function(file) { if (fs.statSync(path.join(rootPath, file)).isFile()) { @@ -104,12 +59,35 @@ fs.readdirSync(rootPath).forEach(function(file) { } }); -module.exports.files = { - self: __filename, - path: rootPath, - bootDir: rootPath, - bootFiles: bootFiles, - cssFiles: cssFiles, - jsFiles: ['jasmine.js'].concat(jsFiles), - imagesDir: path.join(__dirname, '../images') +/** + * Note: Only available on Node. + * + * In addition to the members documented here, this module's exports include all + * {@link globals}. + * @module jasmine-core + */ +module.exports = { + ...globals, + /** + * Copies Jasmine globals (jasmine, describe, it, etc) to the specified + * object or to globalThis. + * @function + * @param {object} [dest] - The object to copy globals to. + */ + installGlobals, + /** + * Resets all of jasmine-core's state, including removing specs, suites, and + * reporters, and resetting configuration to the default. + * @function + */ + reset, + files: { + self: __filename, + path: rootPath, + bootDir: rootPath, + bootFiles: bootFiles, + cssFiles: cssFiles, + jsFiles: ['jasmine.js'].concat(jsFiles), + imagesDir: path.join(__dirname, '../images') + } }; diff --git a/lib/jasmine-core/boot1.js b/lib/jasmine-core/boot.js similarity index 70% rename from lib/jasmine-core/boot1.js rename to lib/jasmine-core/boot.js index 9f3401d3..120cbd17 100644 --- a/lib/jasmine-core/boot1.js +++ b/lib/jasmine-core/boot.js @@ -1,6 +1,6 @@ /* Copyright (c) 2008-2019 Pivotal Labs -Copyright (c) 2008-2025 The Jasmine developers +Copyright (c) 2008-2026 The Jasmine developers Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the @@ -24,19 +24,6 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 'use strict'; -/** - This file finishes 'booting' Jasmine, performing all of the necessary - initialization before executing the loaded environment and all of a project's - specs. This file should be loaded after `boot0.js` but before any project - source files or spec files are loaded. Thus this file can also be used to - customize Jasmine for a project. - - If a project is using Jasmine via the standalone distribution, this file can - be customized directly. If you only wish to configure the Jasmine env, you - can load another file that calls `jasmine.getEnv().configure({...})` - after `boot0.js` is loaded and before this file is loaded. - */ - (function() { const env = jasmine.getEnv(); const urls = new jasmine.HtmlReporterV2Urls(); @@ -49,11 +36,16 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ env.configure(urls.configFromCurrentUrl()); - window.addEventListener('load', function() { + const currentWindowOnload = window.onload; + window.onload = function() { + if (currentWindowOnload) { + currentWindowOnload(); + } + // The HTML reporter needs to be set up here so it can access the DOM. Other // reporters can be added at any time before env.execute() is called. const htmlReporter = new jasmine.HtmlReporterV2({ env, urls }); env.addReporter(htmlReporter); env.execute(); - }); + }; })(); diff --git a/lib/jasmine-core/boot0.js b/lib/jasmine-core/boot0.js deleted file mode 100644 index 53887758..00000000 --- a/lib/jasmine-core/boot0.js +++ /dev/null @@ -1,68 +0,0 @@ -/* -Copyright (c) 2008-2019 Pivotal Labs -Copyright (c) 2008-2025 The Jasmine developers - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -'use strict'; - -/** - This file starts the process of "booting" Jasmine. It initializes Jasmine, - makes its globals available, and creates the env. This file should be loaded - after `jasmine.js` and `jasmine_html.js`, but before `boot1.js` or any project - source files or spec files are loaded. - */ -(function() { - const jasmineRequire = window.jasmineRequire || require('./jasmine.js'); - - /** - * ## Require & Instantiate - * - * Require Jasmine's core files. Specifically, this requires and attaches all of Jasmine's code to the `jasmine` reference. - */ - const jasmine = jasmineRequire.core(jasmineRequire), - global = jasmine.getGlobal(); - global.jasmine = jasmine; - - /** - * Since this is being run in a browser and the results should populate to an HTML page, require the HTML-specific Jasmine code, injecting the same reference. - */ - jasmineRequire.html(jasmine); - - /** - * Create the Jasmine environment. This is used to run all specs in a project. - */ - const env = jasmine.getEnv(); - - /** - * ## The Global Interface - * - * Build up the functions that will be exposed as the Jasmine public interface. A project can customize, rename or alias any of these functions as desired, provided the implementation remains unchanged. - */ - const jasmineInterface = jasmineRequire.interface(jasmine, env); - - /** - * Add all of the Jasmine global/public interface to the global scope, so a project can use the public interface directly. For example, calling `describe` in specs instead of `jasmine.getEnv().describe`. - */ - for (const property in jasmineInterface) { - global[property] = jasmineInterface[property]; - } -})(); diff --git a/lib/jasmine-core/jasmine-html.js b/lib/jasmine-core/jasmine-html.js index a565dfab..8c098d84 100644 --- a/lib/jasmine-core/jasmine-html.js +++ b/lib/jasmine-core/jasmine-html.js @@ -1,6 +1,6 @@ /* Copyright (c) 2008-2019 Pivotal Labs -Copyright (c) 2008-2025 The Jasmine developers +Copyright (c) 2008-2026 The Jasmine developers Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the @@ -22,27 +22,44 @@ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -// eslint-disable-next-line no-var -var jasmineRequire = window.jasmineRequire || require('./jasmine.js'); +(function() { +// eslint-disable-next-line no-unused-vars +const getJasmineHtmlRequireObj = (function() { + 'use strict'; + const htmlRequire = {}; -jasmineRequire.html = function(j$) { - j$.private.ResultsNode = jasmineRequire.ResultsNode(); - j$.private.ResultsStateBuilder = jasmineRequire.ResultsStateBuilder(j$); - j$.private.htmlReporterUtils = jasmineRequire.htmlReporterUtils(j$); - j$.private.AlertsView = jasmineRequire.AlertsView(j$); - j$.private.OverallStatusBar = jasmineRequire.OverallStatusBar(j$); - j$.private.Banner = jasmineRequire.Banner(j$); - j$.private.SummaryTreeView = jasmineRequire.SummaryTreeView(j$); - j$.private.FailuresView = jasmineRequire.FailuresView(j$); - j$.private.PerformanceView = jasmineRequire.PerformanceView(j$); - j$.private.TabBar = jasmineRequire.TabBar(j$); - j$.HtmlReporterV2Urls = jasmineRequire.HtmlReporterV2Urls(j$); - j$.HtmlReporterV2 = jasmineRequire.HtmlReporterV2(j$); - j$.QueryString = jasmineRequire.QueryString(); - j$.private.HtmlSpecFilterV2 = jasmineRequire.HtmlSpecFilterV2(); -}; + function getJasmineHtmlRequire() { + return htmlRequire; + } -jasmineRequire.ResultsNode = function() { + htmlRequire.html = function(j$, private$) { + if (!private$) { + private$ = {}; + } + + private$.ResultsNode = htmlRequire.ResultsNode(); + private$.ResultsStateBuilder = htmlRequire.ResultsStateBuilder( + j$, + private$ + ); + private$.htmlReporterUtils = htmlRequire.htmlReporterUtils(j$, private$); + private$.AlertsView = htmlRequire.AlertsView(j$, private$); + private$.OverallStatusBar = htmlRequire.OverallStatusBar(j$, private$); + private$.Banner = htmlRequire.Banner(j$, private$); + private$.SummaryTreeView = htmlRequire.SummaryTreeView(j$, private$); + private$.FailuresView = htmlRequire.FailuresView(j$, private$); + private$.PerformanceView = htmlRequire.PerformanceView(j$, private$); + private$.TabBar = htmlRequire.TabBar(j$, private$); + j$.HtmlReporterV2Urls = htmlRequire.HtmlReporterV2Urls(j$, private$); + j$.HtmlReporterV2 = htmlRequire.HtmlReporterV2(j$, private$); + j$.QueryString = htmlRequire.QueryString(); + private$.HtmlSpecFilterV2 = htmlRequire.HtmlSpecFilterV2(); + }; + + return getJasmineHtmlRequire; +})(); + +getJasmineHtmlRequireObj().ResultsNode = function() { 'use strict'; function ResultsNode(result, type, parent) { @@ -68,7 +85,7 @@ jasmineRequire.ResultsNode = function() { return ResultsNode; }; -jasmineRequire.QueryString = function() { +getJasmineHtmlRequireObj().QueryString = function() { 'use strict'; /** @@ -154,10 +171,10 @@ jasmineRequire.QueryString = function() { return QueryString; }; -jasmineRequire.AlertsView = function(j$) { +getJasmineHtmlRequireObj().AlertsView = function(j$, private$) { 'use strict'; - const { createDom } = j$.private.htmlReporterUtils; + const { createDom } = private$.htmlReporterUtils; const errorBarClassName = 'jasmine-bar jasmine-errored'; const afterAllMessagePrefix = 'AfterAll '; @@ -273,10 +290,10 @@ jasmineRequire.AlertsView = function(j$) { return AlertsView; }; -jasmineRequire.Banner = function(j$) { +getJasmineHtmlRequireObj().Banner = function(j$, private$) { 'use strict'; - const { createDom } = j$.private.htmlReporterUtils; + const { createDom } = private$.htmlReporterUtils; class Banner { #navigateWithNewParam; @@ -435,10 +452,10 @@ jasmineRequire.Banner = function(j$) { return Banner; }; -jasmineRequire.FailuresView = function(j$) { +getJasmineHtmlRequireObj().FailuresView = function(j$, private$) { 'use strict'; - const { createDom } = j$.private.htmlReporterUtils; + const { createDom } = private$.htmlReporterUtils; class FailuresView { #urlBuilder; @@ -602,7 +619,7 @@ jasmineRequire.FailuresView = function(j$) { return FailuresView; }; -jasmineRequire.htmlReporterUtils = function(j$) { +getJasmineHtmlRequireObj().htmlReporterUtils = function(j$, private$) { 'use strict'; function createDom(type, attrs, childrenArrayOrVarArgs) { @@ -655,10 +672,10 @@ jasmineRequire.htmlReporterUtils = function(j$) { return { createDom, noExpectations }; }; -jasmineRequire.HtmlReporterV2 = function(j$) { +getJasmineHtmlRequireObj().HtmlReporterV2 = function(j$, private$) { 'use strict'; - const { createDom, noExpectations } = j$.private.htmlReporterUtils; + const { createDom, noExpectations } = private$.htmlReporterUtils; const specListTabId = 'jasmine-specListTab'; const failuresTabId = 'jasmine-failuresTab'; @@ -714,14 +731,14 @@ jasmineRequire.HtmlReporterV2 = function(j$) { this.#config = options.env ? options.env.configuration() : {}; - this.#stateBuilder = new j$.private.ResultsStateBuilder(); + this.#stateBuilder = new private$.ResultsStateBuilder(); - this.#alerts = new j$.private.AlertsView(this.#urlBuilder); - this.#statusBar = new j$.private.OverallStatusBar(this.#urlBuilder); + this.#alerts = new private$.AlertsView(this.#urlBuilder); + this.#statusBar = new private$.OverallStatusBar(this.#urlBuilder); this.#statusBar.showRunning(); this.#alerts.addBar(this.#statusBar.rootEl); - this.#tabBar = new j$.private.TabBar( + this.#tabBar = new private$.TabBar( [ { id: specListTabId, label: 'Spec List' }, { id: failuresTabId, label: 'Failures' }, @@ -740,11 +757,11 @@ jasmineRequire.HtmlReporterV2 = function(j$) { this.#alerts.addBar(this.#tabBar.rootEl); this.#progress = new ProgressView(); - this.#banner = new j$.private.Banner( + this.#banner = new private$.Banner( this.#queryString.navigateWithNewParam.bind(this.#queryString), true ); - this.#failures = new j$.private.FailuresView(this.#urlBuilder); + this.#failures = new private$.FailuresView(this.#urlBuilder); this.#htmlReporterMain = createDom( 'div', { className: 'jasmine_html-reporter' }, @@ -825,13 +842,13 @@ jasmineRequire.HtmlReporterV2 = function(j$) { } const results = this.#find('.jasmine-results'); - const summary = new j$.private.SummaryTreeView( + const summary = new private$.SummaryTreeView( this.#urlBuilder, this.#filterSpecs ); summary.addResults(this.#stateBuilder.topResults); results.appendChild(summary.rootEl); - const perf = new j$.private.PerformanceView(); + const perf = new private$.PerformanceView(); perf.addResults(this.#stateBuilder.topResults); results.appendChild(perf.rootEl); this.#tabBar.showTab(specListTabId); @@ -935,7 +952,7 @@ jasmineRequire.HtmlReporterV2 = function(j$) { return HtmlReporterV2; }; -jasmineRequire.HtmlReporterV2Urls = function(j$) { +getJasmineHtmlRequireObj().HtmlReporterV2Urls = function(j$, private$) { 'use strict'; // TODO unify with V2 UrlBuilder? @@ -986,7 +1003,7 @@ jasmineRequire.HtmlReporterV2Urls = function(j$) { config.seed = seed; } - const specFilter = new j$.private.HtmlSpecFilterV2({ + const specFilter = new private$.HtmlSpecFilterV2({ filterParams: () => ({ path: this.queryString.getParam('path'), spec: this.queryString.getParam('spec') @@ -1008,7 +1025,7 @@ jasmineRequire.HtmlReporterV2Urls = function(j$) { return HtmlReporterV2Urls; }; -jasmineRequire.HtmlSpecFilterV2 = function() { +getJasmineHtmlRequireObj().HtmlSpecFilterV2 = function() { class HtmlSpecFilterV2 { #getFilterParams; @@ -1050,10 +1067,10 @@ jasmineRequire.HtmlSpecFilterV2 = function() { return HtmlSpecFilterV2; }; -jasmineRequire.OverallStatusBar = function(j$) { +getJasmineHtmlRequireObj().OverallStatusBar = function(j$, private$) { 'use strict'; - const { createDom } = j$.private.htmlReporterUtils; + const { createDom } = private$.htmlReporterUtils; const staticClassNames = 'jasmine-overall-result jasmine-bar'; class OverallStatusBar { @@ -1159,8 +1176,8 @@ jasmineRequire.OverallStatusBar = function(j$) { return OverallStatusBar; }; -jasmineRequire.PerformanceView = function(j$) { - const createDom = j$.private.htmlReporterUtils.createDom; +getJasmineHtmlRequireObj().PerformanceView = function(j$, private$) { + const createDom = private$.htmlReporterUtils.createDom; const MAX_SLOW_SPECS = 20; class PerformanceView { @@ -1258,12 +1275,12 @@ jasmineRequire.PerformanceView = function(j$) { return PerformanceView; }; -jasmineRequire.ResultsStateBuilder = function(j$) { +getJasmineHtmlRequireObj().ResultsStateBuilder = function(j$, private$) { 'use strict'; class ResultsStateBuilder { constructor() { - this.topResults = new j$.private.ResultsNode({}, '', null); + this.topResults = new private$.ResultsNode({}, '', null); this.currentParent = this.topResults; this.suitesById = {}; this.totalSpecsDefined = 0; @@ -1341,10 +1358,10 @@ jasmineRequire.ResultsStateBuilder = function(j$) { return ResultsStateBuilder; }; -jasmineRequire.SummaryTreeView = function(j$) { +getJasmineHtmlRequireObj().SummaryTreeView = function(j$, private$) { 'use strict'; - const { createDom, noExpectations } = j$.private.htmlReporterUtils; + const { createDom, noExpectations } = private$.htmlReporterUtils; class SummaryTreeView { #urlBuilder; @@ -1450,8 +1467,8 @@ jasmineRequire.SummaryTreeView = function(j$) { return SummaryTreeView; }; -jasmineRequire.TabBar = function(j$) { - const createDom = j$.private.htmlReporterUtils.createDom; +getJasmineHtmlRequireObj().TabBar = function(j$, private$) { + const createDom = private$.htmlReporterUtils.createDom; class TabBar { #tabs; @@ -1527,3 +1544,10 @@ jasmineRequire.TabBar = function(j$) { return TabBar; }; + +(function() { + 'use strict'; + getJasmineHtmlRequireObj().html(jasmine); +})(); + +})() \ No newline at end of file diff --git a/lib/jasmine-core/jasmine.js b/lib/jasmine-core/jasmine.js index 08c41db5..a8ef9188 100644 --- a/lib/jasmine-core/jasmine.js +++ b/lib/jasmine-core/jasmine.js @@ -1,6 +1,6 @@ /* Copyright (c) 2008-2019 Pivotal Labs -Copyright (c) 2008-2025 The Jasmine developers +Copyright (c) 2008-2026 The Jasmine developers Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the @@ -22,8 +22,9 @@ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -// eslint-disable-next-line no-unused-vars,no-var -var getJasmineRequireObj = (function() { +(function() { +// eslint-disable-next-line no-unused-vars +const getJasmineRequireObj = (function() { 'use strict'; let jasmineRequire; @@ -36,7 +37,7 @@ var getJasmineRequireObj = (function() { jasmineRequire = exports; } else { // Browser - jasmineRequire = globalThis.jasmineRequire = {}; + jasmineRequire = {}; } function getJasmineRequire() { @@ -44,94 +45,107 @@ var getJasmineRequireObj = (function() { } getJasmineRequire().core = function(jRequire) { + const private$ = {}; const j$ = {}; - Object.defineProperty(j$, 'private', { - enumerable: true, - value: {} - }); - jRequire.base(j$, globalThis); - j$.private.util = jRequire.util(j$); - j$.private.errors = jRequire.errors(); - j$.private.formatErrorMsg = jRequire.formatErrorMsg(j$); - j$.private.AllOf = jRequire.AllOf(j$); - j$.private.Any = jRequire.Any(j$); - j$.private.Anything = jRequire.Anything(j$); - j$.private.CallTracker = jRequire.CallTracker(j$); - j$.private.MockDate = jRequire.MockDate(j$); - j$.private.getStackClearer = jRequire.StackClearer(j$); - j$.private.Clock = jRequire.Clock(j$); - j$.private.DelayedFunctionScheduler = jRequire.DelayedFunctionScheduler(j$); - j$.private.Deprecator = jRequire.Deprecator(j$); - j$.private.Configuration = jRequire.Configuration(j$); - j$.private.Env = jRequire.Env(j$); - j$.private.StackTrace = jRequire.StackTrace(j$); - j$.private.ExceptionFormatter = jRequire.ExceptionFormatter(j$); - j$.private.ExpectationFilterChain = jRequire.ExpectationFilterChain(); - j$.private.Expector = jRequire.Expector(j$); - j$.private.Expectation = jRequire.Expectation(j$); - j$.private.buildExpectationResult = jRequire.buildExpectationResult(j$); - j$.private.makePrettyPrinter = jRequire.makePrettyPrinter(j$); - j$.private.basicPrettyPrinter = j$.private.makePrettyPrinter(); - j$.private.MatchersUtil = jRequire.MatchersUtil(j$); - j$.private.ObjectContaining = jRequire.ObjectContaining(j$); - j$.private.ArrayContaining = jRequire.ArrayContaining(j$); - j$.private.ArrayWithExactContents = jRequire.ArrayWithExactContents(j$); - j$.private.MapContaining = jRequire.MapContaining(j$); - j$.private.SetContaining = jRequire.SetContaining(j$); - j$.private.QueueRunner = jRequire.QueueRunner(j$); - j$.private.NeverSkipPolicy = jRequire.NeverSkipPolicy(j$); - j$.private.SkipAfterBeforeAllErrorPolicy = jRequire.SkipAfterBeforeAllErrorPolicy( + jRequire.base(j$, private$, globalThis); + private$.util = jRequire.util(j$, private$); + private$.errors = jRequire.errors(); + private$.formatErrorMsg = jRequire.formatErrorMsg(j$, private$); + private$.AllOf = jRequire.AllOf(j$, private$); + private$.Any = jRequire.Any(j$, private$); + private$.Anything = jRequire.Anything(j$, private$); + private$.CallTracker = jRequire.CallTracker(j$, private$); + private$.MockDate = jRequire.MockDate(j$, private$); + private$.getStackClearer = jRequire.StackClearer(j$, private$); + private$.Clock = jRequire.Clock(j$, private$); + private$.DelayedFunctionScheduler = jRequire.DelayedFunctionScheduler( + j$, + private$ + ); + private$.Deprecator = jRequire.Deprecator(j$, private$); + private$.Configuration = jRequire.Configuration(j$, private$); + private$.Env = jRequire.Env(j$, private$); + private$.StackTrace = jRequire.StackTrace(j$, private$); + private$.ExceptionFormatter = jRequire.ExceptionFormatter(j$, private$); + private$.ExpectationFilterChain = jRequire.ExpectationFilterChain(); + private$.Expector = jRequire.Expector(j$, private$); + private$.Expectation = jRequire.Expectation(j$, private$); + private$.buildExpectationResult = jRequire.buildExpectationResult( + j$, + private$ + ); + private$.makePrettyPrinter = jRequire.makePrettyPrinter(j$, private$); + private$.basicPrettyPrinter = private$.makePrettyPrinter(); + private$.MatchersUtil = jRequire.MatchersUtil(j$, private$); + private$.ObjectContaining = jRequire.ObjectContaining(j$, private$); + private$.ArrayContaining = jRequire.ArrayContaining(j$, private$); + private$.ArrayWithExactContents = jRequire.ArrayWithExactContents( + j$, + private$ + ); + private$.MapContaining = jRequire.MapContaining(j$, private$); + private$.SetContaining = jRequire.SetContaining(j$, private$); + private$.QueueRunner = jRequire.QueueRunner(j$, private$); + private$.NeverSkipPolicy = jRequire.NeverSkipPolicy(j$, private$); + private$.SkipAfterBeforeAllErrorPolicy = jRequire.SkipAfterBeforeAllErrorPolicy( j$ ); - j$.private.CompleteOnFirstErrorSkipPolicy = jRequire.CompleteOnFirstErrorSkipPolicy( + private$.CompleteOnFirstErrorSkipPolicy = jRequire.CompleteOnFirstErrorSkipPolicy( j$ ); - j$.private.reporterEvents = jRequire.reporterEvents(j$); - j$.private.ReportDispatcher = jRequire.ReportDispatcher(j$); - j$.ParallelReportDispatcher = jRequire.ParallelReportDispatcher(j$); - j$.private.CurrentRunableTracker = jRequire.CurrentRunableTracker(); - j$.private.RunableResources = jRequire.RunableResources(j$); - j$.private.Runner = jRequire.Runner(j$); - j$.private.Spec = jRequire.Spec(j$); - j$.private.Spy = jRequire.Spy(j$); - j$.private.SpyFactory = jRequire.SpyFactory(j$); - j$.private.SpyRegistry = jRequire.SpyRegistry(j$); - j$.private.SpyStrategy = jRequire.SpyStrategy(j$); - j$.private.StringMatching = jRequire.StringMatching(j$); - j$.private.StringContaining = jRequire.StringContaining(j$); - j$.private.UserContext = jRequire.UserContext(j$); - j$.private.Suite = jRequire.Suite(j$); - j$.private.SuiteBuilder = jRequire.SuiteBuilder(j$); + private$.reporterEvents = jRequire.reporterEvents(j$, private$); + private$.ReportDispatcher = jRequire.ReportDispatcher(j$, private$); + j$.ParallelReportDispatcher = jRequire.ParallelReportDispatcher( + j$, + private$ + ); + private$.CurrentRunableTracker = jRequire.CurrentRunableTracker(); + private$.RunableResources = jRequire.RunableResources(j$, private$); + private$.Runner = jRequire.Runner(j$, private$); + private$.Spec = jRequire.Spec(j$, private$); + private$.Spy = jRequire.Spy(j$, private$); + private$.SpyFactory = jRequire.SpyFactory(j$, private$); + private$.SpyRegistry = jRequire.SpyRegistry(j$, private$); + private$.SpyStrategy = jRequire.SpyStrategy(j$, private$); + private$.StringMatching = jRequire.StringMatching(j$, private$); + private$.StringContaining = jRequire.StringContaining(j$, private$); + private$.UserContext = jRequire.UserContext(j$, private$); + private$.Suite = jRequire.Suite(j$, private$); + private$.SuiteBuilder = jRequire.SuiteBuilder(j$, private$); j$.Timer = jRequire.Timer(); - j$.private.TreeProcessor = jRequire.TreeProcessor(j$); - j$.private.TreeRunner = jRequire.TreeRunner(j$); + private$.TreeProcessor = jRequire.TreeProcessor(j$, private$); + private$.TreeRunner = jRequire.TreeRunner(j$, private$); j$.version = jRequire.version(); - j$.private.Order = jRequire.Order(); - j$.private.DiffBuilder = jRequire.DiffBuilder(j$); - j$.private.NullDiffBuilder = jRequire.NullDiffBuilder(j$); - j$.private.ObjectPath = jRequire.ObjectPath(j$); - j$.private.MismatchTree = jRequire.MismatchTree(j$); - j$.private.GlobalErrors = jRequire.GlobalErrors(j$); - j$.private.Truthy = jRequire.Truthy(j$); - j$.private.Falsy = jRequire.Falsy(j$); - j$.private.Empty = jRequire.Empty(j$); - j$.private.NotEmpty = jRequire.NotEmpty(j$); - j$.private.Is = jRequire.Is(j$); + private$.Order = jRequire.Order(); + private$.DiffBuilder = jRequire.DiffBuilder(j$, private$); + private$.NullDiffBuilder = jRequire.NullDiffBuilder(j$, private$); + private$.ObjectPath = jRequire.ObjectPath(j$, private$); + private$.MismatchTree = jRequire.MismatchTree(j$, private$); + private$.GlobalErrors = jRequire.GlobalErrors(j$, private$); + private$.Truthy = jRequire.Truthy(j$, private$); + private$.Falsy = jRequire.Falsy(j$, private$); + private$.Empty = jRequire.Empty(j$, private$); + private$.NotEmpty = jRequire.NotEmpty(j$, private$); + private$.Is = jRequire.Is(j$, private$); - j$.private.matchers = jRequire.requireMatchers(jRequire, j$); - j$.private.asyncMatchers = jRequire.requireAsyncMatchers(jRequire, j$); + private$.matchers = jRequire.requireMatchers(jRequire, j$, private$); + private$.asyncMatchers = jRequire.requireAsyncMatchers( + jRequire, + j$, + private$ + ); - j$.private.loadedAsBrowserEsm = + private$.loadedAsBrowserEsm = globalThis.document && !globalThis.document.currentScript; - return j$; + return { jasmine: j$, private: private$ }; }; return getJasmineRequire; })(this); -getJasmineRequireObj().requireMatchers = function(jRequire, j$) { +getJasmineRequireObj().requireMatchers = function(jRequire, j$, private$) { 'use strict'; const availableMatchers = [ @@ -174,13 +188,13 @@ getJasmineRequireObj().requireMatchers = function(jRequire, j$) { matchers = {}; for (const name of availableMatchers) { - matchers[name] = jRequire[name](j$); + matchers[name] = jRequire[name](j$, private$); } return matchers; }; -getJasmineRequireObj().base = function(j$, jasmineGlobal) { +getJasmineRequireObj().base = function(j$, private$, jasmineGlobal) { 'use strict'; /** @@ -229,7 +243,7 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) { return DEFAULT_TIMEOUT_INTERVAL; }, set: function(newValue) { - j$.private.util.validateTimeout( + private$.util.validateTimeout( newValue, 'jasmine.DEFAULT_TIMEOUT_INTERVAL' ); @@ -252,58 +266,58 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) { Object.defineProperty(j$, 'getEnv', { enumerable: true, value: function(options) { - const env = (j$.private.currentEnv_ = - j$.private.currentEnv_ || new j$.private.Env(options)); + const env = (private$.currentEnv_ = + private$.currentEnv_ || new private$.Env(options)); //jasmine. singletons in here (setTimeout blah blah). return env; } }); - j$.private.isObject = function(value) { + private$.isObject = function(value) { return ( - value !== undefined && value !== null && j$.private.isA('Object', value) + value !== undefined && value !== null && private$.isA('Object', value) ); }; - j$.private.isString = function(value) { - return j$.private.isA('String', value); + private$.isString = function(value) { + return private$.isA('String', value); }; - j$.private.isNumber = function(value) { - return j$.private.isA('Number', value); + private$.isNumber = function(value) { + return private$.isA('Number', value); }; - j$.private.isFunction = function(value) { - return j$.private.isA('Function', value); + private$.isFunction = function(value) { + return private$.isA('Function', value); }; - j$.private.isAsyncFunction = function(value) { - return j$.private.isA('AsyncFunction', value); + private$.isAsyncFunction = function(value) { + return private$.isA('AsyncFunction', value); }; - j$.private.isGeneratorFunction = function(value) { - return j$.private.isA('GeneratorFunction', value); + private$.isGeneratorFunction = function(value) { + return private$.isA('GeneratorFunction', value); }; - j$.private.isTypedArray = function(value) { + private$.isTypedArray = function(value) { return ( - j$.private.isA('Float32Array', value) || - j$.private.isA('Float64Array', value) || - j$.private.isA('Int16Array', value) || - j$.private.isA('Int32Array', value) || - j$.private.isA('Int8Array', value) || - j$.private.isA('Uint16Array', value) || - j$.private.isA('Uint32Array', value) || - j$.private.isA('Uint8Array', value) || - j$.private.isA('Uint8ClampedArray', value) + private$.isA('Float32Array', value) || + private$.isA('Float64Array', value) || + private$.isA('Int16Array', value) || + private$.isA('Int32Array', value) || + private$.isA('Int8Array', value) || + private$.isA('Uint16Array', value) || + private$.isA('Uint32Array', value) || + private$.isA('Uint8Array', value) || + private$.isA('Uint8ClampedArray', value) ); }; - j$.private.isA = function(typeName, value) { - return j$.private.getType(value) === '[object ' + typeName + ']'; + private$.isA = function(typeName, value) { + return private$.getType(value) === '[object ' + typeName + ']'; }; - j$.private.isError = function(value) { + private$.isError = function(value) { if (!value) { return false; } @@ -315,15 +329,15 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) { return typeof value.stack === 'string' && typeof value.message === 'string'; }; - j$.private.isAsymmetricEqualityTester = function(obj) { - return obj ? j$.private.isA('Function', obj.asymmetricMatch) : false; + private$.isAsymmetricEqualityTester = function(obj) { + return obj ? private$.isA('Function', obj.asymmetricMatch) : false; }; - j$.private.getType = function(value) { + private$.getType = function(value) { return Object.prototype.toString.apply(value); }; - j$.private.isDomNode = function(obj) { + private$.isDomNode = function(obj) { // Node is a function, because constructors return typeof jasmineGlobal.Node !== 'undefined' ? obj instanceof jasmineGlobal.Node @@ -334,7 +348,7 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) { // return obj.nodeType > 0; }; - j$.private.isMap = function(obj) { + private$.isMap = function(obj) { return ( obj !== null && typeof obj !== 'undefined' && @@ -342,7 +356,7 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) { ); }; - j$.private.isSet = function(obj) { + private$.isSet = function(obj) { return ( obj !== null && typeof obj !== 'undefined' && @@ -350,7 +364,7 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) { ); }; - j$.private.isWeakMap = function(obj) { + private$.isWeakMap = function(obj) { return ( obj !== null && typeof obj !== 'undefined' && @@ -358,7 +372,7 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) { ); }; - j$.private.isURL = function(obj) { + private$.isURL = function(obj) { return ( obj !== null && typeof obj !== 'undefined' && @@ -366,11 +380,11 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) { ); }; - j$.private.isIterable = function(value) { + private$.isIterable = function(value) { return value && !!value[Symbol.iterator]; }; - j$.private.isDataView = function(obj) { + private$.isDataView = function(obj) { return ( obj !== null && typeof obj !== 'undefined' && @@ -378,15 +392,15 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) { ); }; - j$.private.isPromise = function(obj) { + private$.isPromise = function(obj) { return !!obj && obj.constructor === jasmineGlobal.Promise; }; - j$.private.isPromiseLike = function(obj) { - return !!obj && j$.private.isFunction(obj.then); + private$.isPromiseLike = function(obj) { + return !!obj && private$.isFunction(obj.then); }; - j$.private.fnNameFor = function(func) { + private$.fnNameFor = function(func) { if (func.name) { return func.name; } @@ -398,7 +412,7 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) { return matches ? matches[1] : ''; }; - j$.private.isPending = function(promise) { + private$.isPending = function(promise) { const sentinel = {}; return Promise.race([promise, Promise.resolve(sentinel)]).then( function(result) { @@ -433,7 +447,7 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) { * @param {Constructor} clazz - The constructor to check against. */ j$.any = function(clazz) { - return new j$.private.Any(clazz); + return new private$.Any(clazz); }; /** @@ -445,7 +459,7 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) { * @function */ j$.anything = function() { - return new j$.private.Anything(); + return new private$.Anything(); }; /** @@ -457,7 +471,7 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) { * @function */ j$.truthy = function() { - return new j$.private.Truthy(); + return new private$.Truthy(); }; /** @@ -470,7 +484,7 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) { * @function */ j$.falsy = function() { - return new j$.private.Falsy(); + return new private$.Falsy(); }; /** @@ -482,7 +496,7 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) { * @function */ j$.empty = function() { - return new j$.private.Empty(); + return new private$.Empty(); }; /** @@ -494,7 +508,7 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) { * @param {Object} sample - The value to compare the actual to. */ j$.is = function(sample) { - return new j$.private.Is(sample); + return new private$.Is(sample); }; /** @@ -506,7 +520,7 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) { * @function */ j$.notEmpty = function() { - return new j$.private.NotEmpty(); + return new private$.NotEmpty(); }; /** @@ -519,7 +533,7 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) { * @param {Object} sample - The subset of properties that _must_ be in the actual. */ j$.objectContaining = function(sample) { - return new j$.private.ObjectContaining(sample); + return new private$.ObjectContaining(sample); }; /** @@ -532,7 +546,7 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) { * @param {RegExp|String} expected */ j$.stringMatching = function(expected) { - return new j$.private.StringMatching(expected); + return new private$.StringMatching(expected); }; /** @@ -545,7 +559,7 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) { * @param {String} expected */ j$.stringContaining = function(expected) { - return new j$.private.StringContaining(expected); + return new private$.StringContaining(expected); }; /** @@ -558,7 +572,7 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) { * @param {Array} sample */ j$.arrayContaining = function(sample) { - return new j$.private.ArrayContaining(sample); + return new private$.ArrayContaining(sample); }; /** @@ -572,7 +586,7 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) { * @param {Array} sample */ j$.arrayWithExactContents = function(sample) { - return new j$.private.ArrayWithExactContents(sample); + return new private$.ArrayWithExactContents(sample); }; /** @@ -586,7 +600,7 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) { * @param {Map} sample - The subset of items that _must_ be in the actual. */ j$.mapContaining = function(sample) { - return new j$.private.MapContaining(sample); + return new private$.MapContaining(sample); }; /** @@ -600,7 +614,7 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) { * @param {Set} sample - The subset of items that _must_ be in the actual. */ j$.setContaining = function(sample) { - return new j$.private.SetContaining(sample); + return new private$.SetContaining(sample); }; /** @@ -616,8 +630,8 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) { return false; } return ( - putativeSpy.and instanceof j$.private.SpyStrategy && - putativeSpy.calls instanceof j$.private.CallTracker + putativeSpy.and instanceof private$.SpyStrategy && + putativeSpy.calls instanceof private$.CallTracker ); }; @@ -693,7 +707,7 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) { }; }; -getJasmineRequireObj().util = function(j$) { +getJasmineRequireObj().util = function(j$, private$) { 'use strict'; const util = {}; @@ -724,7 +738,7 @@ getJasmineRequireObj().util = function(j$) { } else if (str === '[object Date]') { return new Date(arg.valueOf()); } else { - return j$.private.util.clone(arg); + return private$.util.clone(arg); } }); }; @@ -746,7 +760,7 @@ getJasmineRequireObj().util = function(j$) { }; function callerFile() { - const trace = new j$.private.StackTrace(new Error()); + const trace = new private$.StackTrace(new Error()); return trace.frames[1].file; } @@ -791,7 +805,7 @@ getJasmineRequireObj().util = function(j$) { return util; }; -getJasmineRequireObj().Spec = function(j$) { +getJasmineRequireObj().Spec = function(j$, private$) { 'use strict'; class Spec { @@ -839,7 +853,7 @@ getJasmineRequireObj().Spec = function(j$) { } addExpectationResult(passed, data, isError) { - const expectationResult = j$.private.buildExpectationResult(data); + const expectationResult = private$.buildExpectationResult(data); if (passed) { this.#executionState.passedExpectations.push(expectationResult); @@ -851,7 +865,7 @@ getJasmineRequireObj().Spec = function(j$) { } if (this.#throwOnExpectationFailure && !isError) { - throw new j$.private.errors.ExpectationFailed(); + throw new private$.errors.ExpectationFailed(); } } } @@ -865,10 +879,10 @@ getJasmineRequireObj().Spec = function(j$) { // Key and value will eventually be cloned during reporting. The error // thrown at that point if they aren't cloneable isn't very helpful. // Throw a better one now. - if (!j$.private.isString(key)) { + if (!private$.isString(key)) { throw new Error('Key must be a string'); } - j$.private.util.assertReporterCloneable(value, 'Value'); + private$.util.assertReporterCloneable(value, 'Value'); this.#executionState.properties = this.#executionState.properties || {}; this.#executionState.properties[key] = value; @@ -1001,7 +1015,7 @@ getJasmineRequireObj().Spec = function(j$) { return; } - if (e instanceof j$.private.errors.ExpectationFailed) { + if (e instanceof private$.errors.ExpectationFailed) { return; } @@ -1068,7 +1082,7 @@ getJasmineRequireObj().Spec = function(j$) { deprecation = { message: deprecation }; } this.#executionState.deprecationWarnings.push( - j$.private.buildExpectationResult(deprecation) + private$.buildExpectationResult(deprecation) ); } @@ -1224,7 +1238,7 @@ getJasmineRequireObj().Order = function() { return Order; }; -getJasmineRequireObj().Env = function(j$) { +getJasmineRequireObj().Env = function(j$, private$) { 'use strict'; const DEFAULT_IT_DESCRIBE_STACK_DEPTH = 3; @@ -1241,18 +1255,18 @@ getJasmineRequireObj().Env = function(j$) { envOptions = envOptions || {}; const self = this; - const GlobalErrors = envOptions.GlobalErrors || j$.private.GlobalErrors; + const GlobalErrors = envOptions.GlobalErrors || private$.GlobalErrors; const global = envOptions.global || j$.getGlobal(); const realSetTimeout = global.setTimeout; const realClearTimeout = global.clearTimeout; - const stackClearer = j$.private.getStackClearer(global); - this.clock = new j$.private.Clock( + const stackClearer = private$.getStackClearer(global); + this.clock = new private$.Clock( global, function() { - return new j$.private.DelayedFunctionScheduler(); + return new private$.DelayedFunctionScheduler(); }, - new j$.private.MockDate(global) + new private$.MockDate(global) ); const globalErrors = new GlobalErrors( @@ -1280,7 +1294,7 @@ getJasmineRequireObj().Env = function(j$) { }; })(); - const runableResources = new j$.private.RunableResources({ + const runableResources = new private$.RunableResources({ getCurrentRunableId: function() { const r = runner.currentRunable(); return r ? r.id : null; @@ -1293,7 +1307,7 @@ getJasmineRequireObj().Env = function(j$) { let runner; let parallelLoadingState = null; // 'specs', 'helpers', or null for non-parallel - const config = new j$.private.Configuration(); + const config = new private$.Configuration(); if (!envOptions.suppressLoadErrors) { installGlobalErrors(); @@ -1363,11 +1377,11 @@ getJasmineRequireObj().Env = function(j$) { runableResources.customObjectFormatters().push(formatter); }; - j$.private.Expectation.addCoreMatchers(j$.private.matchers); - j$.private.Expectation.addAsyncCoreMatchers(j$.private.asyncMatchers); + private$.Expectation.addCoreMatchers(private$.matchers); + private$.Expectation.addAsyncCoreMatchers(private$.asyncMatchers); const expectationFactory = function(actual, spec) { - return j$.private.Expectation.factory({ + return private$.Expectation.factory({ matchersUtil: runableResources.makeMatchersUtil(), customMatchers: runableResources.customMatchers(), actual: actual, @@ -1400,7 +1414,7 @@ getJasmineRequireObj().Env = function(j$) { }; const throwUnlessFactory = function(actual, spec) { - return j$.private.Expectation.factory({ + return private$.Expectation.factory({ matchersUtil: runableResources.makeMatchersUtil(), customMatchers: runableResources.customMatchers(), actual: actual, @@ -1409,7 +1423,7 @@ getJasmineRequireObj().Env = function(j$) { }; const throwUnlessAsyncFactory = function(actual, spec) { - return j$.private.Expectation.asyncFactory({ + return private$.Expectation.asyncFactory({ matchersUtil: runableResources.makeMatchersUtil(), customAsyncMatchers: runableResources.customAsyncMatchers(), actual: actual, @@ -1424,7 +1438,7 @@ getJasmineRequireObj().Env = function(j$) { error.matcherName !== undefined && error.passed !== undefined; const result = isExpectationResult ? error - : j$.private.buildExpectationResult({ + : private$.buildExpectationResult({ error, passed: false, matcherName: '', @@ -1485,7 +1499,7 @@ getJasmineRequireObj().Env = function(j$) { } const asyncExpectationFactory = function(actual, spec, runableType) { - return j$.private.Expectation.asyncFactory({ + return private$.Expectation.asyncFactory({ matchersUtil: runableResources.makeMatchersUtil(), customAsyncMatchers: runableResources.customAsyncMatchers(), actual: actual, @@ -1544,10 +1558,10 @@ getJasmineRequireObj().Env = function(j$) { (runner.currentRunable() || topSuite).handleException(e); }; - new j$.private.QueueRunner(options).execute(); + new private$.QueueRunner(options).execute(); } - const suiteBuilder = new j$.private.SuiteBuilder({ + const suiteBuilder = new private$.SuiteBuilder({ env: this, expectationFactory, asyncExpectationFactory, @@ -1556,7 +1570,7 @@ getJasmineRequireObj().Env = function(j$) { }); topSuite = suiteBuilder.topSuite; const deprecator = - envOptions?.deprecator ?? new j$.private.Deprecator(topSuite); + envOptions?.deprecator ?? new private$.Deprecator(topSuite); /** * Provides the root suite, through which all suites and specs can be @@ -1576,23 +1590,23 @@ getJasmineRequireObj().Env = function(j$) { * @interface Reporter * @see custom_reporter */ - reportDispatcher = new j$.private.ReportDispatcher( - j$.private.reporterEvents, + reportDispatcher = new private$.ReportDispatcher( + private$.reporterEvents, function(options) { - options.SkipPolicy = j$.private.NeverSkipPolicy; + options.SkipPolicy = private$.NeverSkipPolicy; return runQueue(options); }, recordLateError ); - runner = new j$.private.Runner({ + runner = new private$.Runner({ topSuite, totalSpecsDefined: () => suiteBuilder.totalSpecsDefined, focusedRunables: () => suiteBuilder.focusedRunables, runableResources, reportDispatcher, runQueue, - TreeProcessor: j$.private.TreeProcessor, + TreeProcessor: private$.TreeProcessor, globalErrors, getConfig: () => config }); @@ -1637,7 +1651,7 @@ getJasmineRequireObj().Env = function(j$) { // 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) { + if (private$.loadedAsBrowserEsm) { this.deprecated( "jasmine-core isn't an ES module but it was loaded as one. This is not a supported configuration." ); @@ -1766,7 +1780,7 @@ getJasmineRequireObj().Env = function(j$) { try { const maybePromise = fn(spy); - if (!j$.private.isPromiseLike(maybePromise)) { + if (!private$.isPromiseLike(maybePromise)) { throw new Error( 'The callback to spyOnGlobalErrorsAsync must be an async or promise-returning function' ); @@ -2009,7 +2023,7 @@ getJasmineRequireObj().Env = function(j$) { }; this.pending = function(message) { - let fullMessage = j$.private.Spec.pendingSpecExceptionMessage; + let fullMessage = private$.Spec.pendingSpecExceptionMessage; if (message) { fullMessage += message; } @@ -2028,7 +2042,7 @@ getJasmineRequireObj().Env = function(j$) { message += ': '; if (error.message) { message += error.message; - } else if (j$.private.isString(error)) { + } else if (private$.isString(error)) { message += error; } else { // pretty print all kind of objects. This includes arrays. @@ -2054,7 +2068,7 @@ getJasmineRequireObj().Env = function(j$) { this.pp = function(value) { const pp = runner.currentRunable() ? runableResources.makePrettyPrinter() - : j$.private.basicPrettyPrinter; + : private$.basicPrettyPrinter; return pp(value); }; @@ -2064,7 +2078,7 @@ getJasmineRequireObj().Env = function(j$) { } function indirectCallerFilename(depth) { - const frames = new j$.private.StackTrace(new Error()).frames; + const frames = new private$.StackTrace(new Error()).frames; // The specified frame should always exist except in Jasmine's own tests, // which bypass the global it/describe layer, but could be absent in case // of misconfiguration. Don't crash if it's absent. @@ -2074,7 +2088,7 @@ getJasmineRequireObj().Env = function(j$) { return Env; }; -getJasmineRequireObj().AllOf = function(j$) { +getJasmineRequireObj().AllOf = function(j$, private$) { 'use strict'; function AllOf() { @@ -2104,7 +2118,7 @@ getJasmineRequireObj().AllOf = function(j$) { return AllOf; }; -getJasmineRequireObj().Any = function(j$) { +getJasmineRequireObj().Any = function(j$, private$) { 'use strict'; function Any(expectedObject) { @@ -2146,13 +2160,13 @@ getJasmineRequireObj().Any = function(j$) { }; Any.prototype.jasmineToString = function() { - return ''; + return ''; }; return Any; }; -getJasmineRequireObj().Anything = function(j$) { +getJasmineRequireObj().Anything = function(j$, private$) { 'use strict'; function Anything() {} @@ -2168,7 +2182,7 @@ getJasmineRequireObj().Anything = function(j$) { return Anything; }; -getJasmineRequireObj().ArrayContaining = function(j$) { +getJasmineRequireObj().ArrayContaining = function(j$, private$) { 'use strict'; function ArrayContaining(sample) { @@ -2179,7 +2193,7 @@ getJasmineRequireObj().ArrayContaining = function(j$) { if (!Array.isArray(this.sample)) { throw new Error( 'You must provide an array to arrayContaining, not ' + - j$.private.basicPrettyPrinter(this.sample) + + private$.basicPrettyPrinter(this.sample) + '.' ); } @@ -2207,7 +2221,7 @@ getJasmineRequireObj().ArrayContaining = function(j$) { return ArrayContaining; }; -getJasmineRequireObj().ArrayWithExactContents = function(j$) { +getJasmineRequireObj().ArrayWithExactContents = function(j$, private$) { 'use strict'; function ArrayWithExactContents(sample) { @@ -2221,7 +2235,7 @@ getJasmineRequireObj().ArrayWithExactContents = function(j$) { if (!Array.isArray(this.sample)) { throw new Error( 'You must provide an array to arrayWithExactContents, not ' + - j$.private.basicPrettyPrinter(this.sample) + + private$.basicPrettyPrinter(this.sample) + '.' ); } @@ -2246,25 +2260,25 @@ getJasmineRequireObj().ArrayWithExactContents = function(j$) { return ArrayWithExactContents; }; -getJasmineRequireObj().Empty = function(j$) { +getJasmineRequireObj().Empty = function(j$, private$) { 'use strict'; function Empty() {} Empty.prototype.asymmetricMatch = function(other) { if ( - j$.private.isString(other) || + private$.isString(other) || Array.isArray(other) || - j$.private.isTypedArray(other) + private$.isTypedArray(other) ) { return other.length === 0; } - if (j$.private.isMap(other) || j$.private.isSet(other)) { + if (private$.isMap(other) || private$.isSet(other)) { return other.size === 0; } - if (j$.private.isObject(other)) { + if (private$.isObject(other)) { return Object.keys(other).length === 0; } return false; @@ -2277,7 +2291,7 @@ getJasmineRequireObj().Empty = function(j$) { return Empty; }; -getJasmineRequireObj().Falsy = function(j$) { +getJasmineRequireObj().Falsy = function(j$, private$) { 'use strict'; function Falsy() {} @@ -2293,7 +2307,7 @@ getJasmineRequireObj().Falsy = function(j$) { return Falsy; }; -getJasmineRequireObj().Is = function(j$) { +getJasmineRequireObj().Is = function(j$, private$) { 'use strict'; class Is { @@ -2313,14 +2327,14 @@ getJasmineRequireObj().Is = function(j$) { return Is; }; -getJasmineRequireObj().MapContaining = function(j$) { +getJasmineRequireObj().MapContaining = function(j$, private$) { 'use strict'; function MapContaining(sample) { - if (!j$.private.isMap(sample)) { + if (!private$.isMap(sample)) { throw new Error( 'You must provide a map to `mapContaining`, not ' + - j$.private.basicPrettyPrinter(sample) + private$.basicPrettyPrinter(sample) ); } @@ -2328,7 +2342,7 @@ getJasmineRequireObj().MapContaining = function(j$) { } MapContaining.prototype.asymmetricMatch = function(other, matchersUtil) { - if (!j$.private.isMap(other)) { + if (!private$.isMap(other)) { return false; } @@ -2361,25 +2375,25 @@ getJasmineRequireObj().MapContaining = function(j$) { return MapContaining; }; -getJasmineRequireObj().NotEmpty = function(j$) { +getJasmineRequireObj().NotEmpty = function(j$, private$) { 'use strict'; function NotEmpty() {} NotEmpty.prototype.asymmetricMatch = function(other) { if ( - j$.private.isString(other) || + private$.isString(other) || Array.isArray(other) || - j$.private.isTypedArray(other) + private$.isTypedArray(other) ) { return other.length !== 0; } - if (j$.private.isMap(other) || j$.private.isSet(other)) { + if (private$.isMap(other) || private$.isSet(other)) { return other.size !== 0; } - if (j$.private.isObject(other)) { + if (private$.isObject(other)) { return Object.keys(other).length !== 0; } @@ -2393,7 +2407,7 @@ getJasmineRequireObj().NotEmpty = function(j$) { return NotEmpty; }; -getJasmineRequireObj().ObjectContaining = function(j$) { +getJasmineRequireObj().ObjectContaining = function(j$, private$) { 'use strict'; function ObjectContaining(sample) { @@ -2437,7 +2451,7 @@ getJasmineRequireObj().ObjectContaining = function(j$) { }; ObjectContaining.prototype.valuesForDiff_ = function(other, pp) { - if (!j$.private.isObject(other)) { + if (!private$.isObject(other)) { return { self: this.jasmineToString(pp), other: other @@ -2464,14 +2478,14 @@ getJasmineRequireObj().ObjectContaining = function(j$) { return ObjectContaining; }; -getJasmineRequireObj().SetContaining = function(j$) { +getJasmineRequireObj().SetContaining = function(j$, private$) { 'use strict'; function SetContaining(sample) { - if (!j$.private.isSet(sample)) { + if (!private$.isSet(sample)) { throw new Error( 'You must provide a set to `setContaining`, not ' + - j$.private.basicPrettyPrinter(sample) + private$.basicPrettyPrinter(sample) ); } @@ -2479,7 +2493,7 @@ getJasmineRequireObj().SetContaining = function(j$) { } SetContaining.prototype.asymmetricMatch = function(other, matchersUtil) { - if (!j$.private.isSet(other)) { + if (!private$.isSet(other)) { return false; } @@ -2510,11 +2524,11 @@ getJasmineRequireObj().SetContaining = function(j$) { return SetContaining; }; -getJasmineRequireObj().StringContaining = function(j$) { +getJasmineRequireObj().StringContaining = function(j$, private$) { 'use strict'; function StringContaining(expected) { - if (!j$.private.isString(expected)) { + if (!private$.isString(expected)) { throw new Error('Expected is not a String'); } @@ -2522,7 +2536,7 @@ getJasmineRequireObj().StringContaining = function(j$) { } StringContaining.prototype.asymmetricMatch = function(other) { - if (!j$.private.isString(other)) { + if (!private$.isString(other)) { // Arrays, etc. don't match no matter what their indexOf returns. return false; } @@ -2537,11 +2551,11 @@ getJasmineRequireObj().StringContaining = function(j$) { return StringContaining; }; -getJasmineRequireObj().StringMatching = function(j$) { +getJasmineRequireObj().StringMatching = function(j$, private$) { 'use strict'; function StringMatching(expected) { - if (!j$.private.isString(expected) && !j$.private.isA('RegExp', expected)) { + if (!private$.isString(expected) && !private$.isA('RegExp', expected)) { throw new Error('Expected is not a String or a RegExp'); } @@ -2559,7 +2573,7 @@ getJasmineRequireObj().StringMatching = function(j$) { return StringMatching; }; -getJasmineRequireObj().Truthy = function(j$) { +getJasmineRequireObj().Truthy = function(j$, private$) { 'use strict'; function Truthy() {} @@ -2576,11 +2590,11 @@ getJasmineRequireObj().Truthy = function(j$) { }; //TODO: expectation result may make more sense as a presentation of an expectation. -getJasmineRequireObj().buildExpectationResult = function(j$) { +getJasmineRequireObj().buildExpectationResult = function(j$, private$) { 'use strict'; function buildExpectationResult(options) { - const exceptionFormatter = new j$.private.ExceptionFormatter(); + const exceptionFormatter = new private$.ExceptionFormatter(); /** * Describes the result of evaluating an expectation @@ -2610,7 +2624,7 @@ getJasmineRequireObj().buildExpectationResult = function(j$) { } if (!result.passed) { - if (options.error && !j$.private.isString(options.error)) { + if (options.error && !private$.isString(options.error)) { if ('code' in options.error) { result.code = options.error.code; } @@ -2659,7 +2673,7 @@ getJasmineRequireObj().buildExpectationResult = function(j$) { return buildExpectationResult; }; -getJasmineRequireObj().CallTracker = function(j$) { +getJasmineRequireObj().CallTracker = function(j$, private$) { 'use strict'; /** @@ -2786,9 +2800,7 @@ getJasmineRequireObj().CallTracker = function(j$) { * @param {Function} [argsCloner] A function to use to clone the arguments. Defaults to a shallow cloning function. * @function */ - this.saveArgumentsByValue = function( - argsCloner = j$.private.util.cloneArgs - ) { + this.saveArgumentsByValue = function(argsCloner = private$.util.cloneArgs) { opts.cloneArgs = true; opts.argsCloner = argsCloner; }; @@ -2801,7 +2813,7 @@ getJasmineRequireObj().CallTracker = function(j$) { return CallTracker; }; -getJasmineRequireObj().Clock = function(j$) { +getJasmineRequireObj().Clock = function(j$, private$) { 'use strict'; /* global process */ @@ -3151,7 +3163,7 @@ callbacks to execute _before_ running the next one. return Clock; }; -getJasmineRequireObj().CompleteOnFirstErrorSkipPolicy = function(j$) { +getJasmineRequireObj().CompleteOnFirstErrorSkipPolicy = function(j$, private$) { 'use strict'; function CompleteOnFirstErrorSkipPolicy(queueableFns) { @@ -3205,7 +3217,7 @@ getJasmineRequireObj().CompleteOnFirstErrorSkipPolicy = function(j$) { return CompleteOnFirstErrorSkipPolicy; }; -getJasmineRequireObj().Configuration = function(j$) { +getJasmineRequireObj().Configuration = function(j$, private$) { 'use strict'; /** @@ -3493,7 +3505,7 @@ getJasmineRequireObj().CurrentRunableTracker = function() { return CurrentRunableTracker; }; -getJasmineRequireObj().DelayedFunctionScheduler = function(j$) { +getJasmineRequireObj().DelayedFunctionScheduler = function(j$, private$) { 'use strict'; function DelayedFunctionScheduler() { @@ -3703,7 +3715,7 @@ getJasmineRequireObj().DelayedFunctionScheduler = function(j$) { return DelayedFunctionScheduler; }; -getJasmineRequireObj().Deprecator = function(j$) { +getJasmineRequireObj().Deprecator = function(j$, private$) { 'use strict'; function Deprecator(topSuite) { @@ -3730,7 +3742,7 @@ getJasmineRequireObj().Deprecator = function(j$) { ) { options = options || {}; - if (!this.verbose_ && !j$.private.isError(deprecation)) { + if (!this.verbose_ && !private$.isError(deprecation)) { if (this.toSuppress_.indexOf(deprecation) !== -1) { return; } @@ -3742,7 +3754,7 @@ getJasmineRequireObj().Deprecator = function(j$) { }; Deprecator.prototype.log_ = function(runnable, deprecation, options) { - if (j$.private.isError(deprecation)) { + if (private$.isError(deprecation)) { // eslint-disable-next-line no-console console.error(deprecation); return; @@ -3771,7 +3783,7 @@ getJasmineRequireObj().Deprecator = function(j$) { }; Deprecator.prototype.stackTrace_ = function() { - const formatter = new j$.private.ExceptionFormatter(); + const formatter = new private$.ExceptionFormatter(); return formatter.stack(new Error()).replace(/^Error\n/m, ''); }; @@ -3780,7 +3792,7 @@ getJasmineRequireObj().Deprecator = function(j$) { runnable = this.topSuite_; } - if (j$.private.isError(deprecation)) { + if (private$.isError(deprecation)) { runnable.addDeprecationWarning(deprecation); return; } @@ -3811,7 +3823,7 @@ getJasmineRequireObj().errors = function() { }; }; -getJasmineRequireObj().ExceptionFormatter = function(j$) { +getJasmineRequireObj().ExceptionFormatter = function(j$, private$) { 'use strict'; const ignoredProperties = [ @@ -3829,7 +3841,7 @@ getJasmineRequireObj().ExceptionFormatter = function(j$) { function ExceptionFormatter(options) { const jasmineFile = - (options && options.jasmineFile) || j$.private.util.jasmineFile(); + (options && options.jasmineFile) || private$.util.jasmineFile(); this.message = function(error) { let message = ''; @@ -3873,7 +3885,7 @@ getJasmineRequireObj().ExceptionFormatter = function(j$) { lines.pop(); } - const stackTrace = new j$.private.StackTrace(error); + const stackTrace = new private$.StackTrace(error); lines = lines.concat(filterJasmine(stackTrace)); if (messageHandling === 'require') { @@ -3927,7 +3939,7 @@ getJasmineRequireObj().ExceptionFormatter = function(j$) { if (!empty) { return ( - 'error properties: ' + j$.private.basicPrettyPrinter(result) + '\n' + 'error properties: ' + private$.basicPrettyPrinter(result) + '\n' ); } @@ -3938,7 +3950,7 @@ getJasmineRequireObj().ExceptionFormatter = function(j$) { return ExceptionFormatter; }; -getJasmineRequireObj().Expectation = function(j$) { +getJasmineRequireObj().Expectation = function(j$, private$) { 'use strict'; /** @@ -3946,7 +3958,7 @@ getJasmineRequireObj().Expectation = function(j$) { * @namespace matchers */ function Expectation(options) { - this.expector = new j$.private.Expector(options); + this.expector = new private$.Expector(options); const customMatchers = options.customMatchers || {}; for (const matcherName in customMatchers) { @@ -4022,7 +4034,7 @@ getJasmineRequireObj().Expectation = function(j$) { * @namespace async-matchers */ function AsyncExpectation(options) { - this.expector = new j$.private.Expector(options); + this.expector = new private$.Expector(options); const customAsyncMatchers = options.customAsyncMatchers || {}; for (const matcherName in customAsyncMatchers) { @@ -4115,7 +4127,7 @@ getJasmineRequireObj().Expectation = function(j$) { function negatedFailureMessage(result, matcherName, args, matchersUtil) { if (result.message) { - if (j$.private.isFunction(result.message)) { + if (private$.isFunction(result.message)) { return result.message(); } else { return result.message; @@ -4160,7 +4172,7 @@ getJasmineRequireObj().Expectation = function(j$) { return function(actual) { const matcherArgs = arguments; - return j$.private.isPending(actual).then(function(isPending) { + return private$.isPending(actual).then(function(isPending) { if (isPending) { return { pass: false, @@ -4260,7 +4272,7 @@ getJasmineRequireObj().ExpectationFilterChain = function() { return ExpectationFilterChain; }; -getJasmineRequireObj().Expector = function(j$) { +getJasmineRequireObj().Expector = function(j$, private$) { 'use strict'; function Expector(options) { @@ -4269,7 +4281,7 @@ getJasmineRequireObj().Expector = function(j$) { }; this.actual = options.actual; this.addExpectationResult = options.addExpectationResult || function() {}; - this.filters = new j$.private.ExpectationFilterChain(); + this.filters = new private$.ExpectationFilterChain(); } Expector.prototype.instantiateMatcher = function( @@ -4303,7 +4315,7 @@ getJasmineRequireObj().Expector = function(j$) { this.matchersUtil, args ); - } else if (j$.private.isFunction(result.message)) { + } else if (private$.isFunction(result.message)) { return result.message(); } else { return result.message; @@ -4368,7 +4380,7 @@ getJasmineRequireObj().formatErrorMsg = function() { return generateErrorMsg; }; -getJasmineRequireObj().GlobalErrors = function(j$) { +getJasmineRequireObj().GlobalErrors = function(j$, private$) { 'use strict'; class GlobalErrors { @@ -4396,7 +4408,7 @@ getJasmineRequireObj().GlobalErrors = function(j$) { if ( global.process && global.process.listeners && - j$.private.isFunction(global.process.on) + private$.isFunction(global.process.on) ) { this.#adapter = new NodeAdapter(global, dispatch); } else { @@ -4553,7 +4565,7 @@ getJasmineRequireObj().GlobalErrors = function(j$) { const jasmineMessage = 'Unhandled promise rejection: ' + event.reason; let reason; - if (j$.private.isError(event.reason)) { + if (private$.isError(event.reason)) { reason = event.reason; reason.jasmineMessage = jasmineMessage; } else { @@ -4632,7 +4644,7 @@ getJasmineRequireObj().GlobalErrors = function(j$) { jasmineMessagePrefix = 'Uncaught exception'; } - if (j$.private.isError(error)) { + if (private$.isError(error)) { error.jasmineMessage = jasmineMessagePrefix + ': ' + error; return error; } else { @@ -4672,7 +4684,7 @@ getJasmineRequireObj().GlobalErrors = function(j$) { return GlobalErrors; }; -getJasmineRequireObj().toBePending = function(j$) { +getJasmineRequireObj().toBePending = function(j$, private$) { 'use strict'; /** @@ -4687,7 +4699,7 @@ getJasmineRequireObj().toBePending = function(j$) { return function toBePending() { return { compare: function(actual) { - if (!j$.private.isPromiseLike(actual)) { + if (!private$.isPromiseLike(actual)) { throw new Error( `Expected toBePending to be called on a promise but was on a ${typeof actual}.` ); @@ -4706,7 +4718,7 @@ getJasmineRequireObj().toBePending = function(j$) { }; }; -getJasmineRequireObj().toBeRejected = function(j$) { +getJasmineRequireObj().toBeRejected = function(j$, private$) { 'use strict'; /** @@ -4723,7 +4735,7 @@ getJasmineRequireObj().toBeRejected = function(j$) { return function toBeRejected() { return { compare: function(actual) { - if (!j$.private.isPromiseLike(actual)) { + if (!private$.isPromiseLike(actual)) { throw new Error( `Expected toBeRejected to be called on a promise but was on a ${typeof actual}.` ); @@ -4741,7 +4753,7 @@ getJasmineRequireObj().toBeRejected = function(j$) { }; }; -getJasmineRequireObj().toBeRejectedWith = function(j$) { +getJasmineRequireObj().toBeRejectedWith = function(j$, private$) { 'use strict'; /** @@ -4759,7 +4771,7 @@ getJasmineRequireObj().toBeRejectedWith = function(j$) { return function toBeRejectedWith(matchersUtil) { return { compare: function(actualPromise, expectedValue) { - if (!j$.private.isPromiseLike(actualPromise)) { + if (!private$.isPromiseLike(actualPromise)) { throw new Error( `Expected toBeRejectedWith to be called on a promise but was on a ${typeof actualPromise}.` ); @@ -4804,7 +4816,7 @@ getJasmineRequireObj().toBeRejectedWith = function(j$) { }; }; -getJasmineRequireObj().toBeRejectedWithError = function(j$) { +getJasmineRequireObj().toBeRejectedWithError = function(j$, private$) { 'use strict'; /** @@ -4825,7 +4837,7 @@ getJasmineRequireObj().toBeRejectedWithError = function(j$) { return function toBeRejectedWithError(matchersUtil) { return { compare: function(actualPromise, arg1, arg2) { - if (!j$.private.isPromiseLike(actualPromise)) { + if (!private$.isPromiseLike(actualPromise)) { throw new Error( `Expected toBeRejectedWithError to be called on a promise but was on a ${typeof actualPromise}.` ); @@ -4849,14 +4861,14 @@ getJasmineRequireObj().toBeRejectedWithError = function(j$) { }; function matchError(actual, expected, matchersUtil) { - if (!j$.private.isError(actual)) { + if (!private$.isError(actual)) { return fail(expected, 'rejected with ' + matchersUtil.pp(actual)); } if (!(actual instanceof expected.error)) { return fail( expected, - 'rejected with type ' + j$.private.fnNameFor(actual.constructor) + 'rejected with type ' + private$.fnNameFor(actual.constructor) ); } @@ -4916,7 +4928,7 @@ getJasmineRequireObj().toBeRejectedWithError = function(j$) { error: error, message: message, printValue: - j$.private.fnNameFor(error) + + private$.fnNameFor(error) + (typeof message === 'undefined' ? '' : ': ' + matchersUtil.pp(message)) }; } @@ -4924,12 +4936,12 @@ getJasmineRequireObj().toBeRejectedWithError = function(j$) { function isErrorConstructor(value) { return ( typeof value === 'function' && - (value === Error || j$.private.isError(value.prototype)) + (value === Error || private$.isError(value.prototype)) ); } }; -getJasmineRequireObj().toBeResolved = function(j$) { +getJasmineRequireObj().toBeResolved = function(j$, private$) { 'use strict'; /** @@ -4946,7 +4958,7 @@ getJasmineRequireObj().toBeResolved = function(j$) { return function toBeResolved(matchersUtil) { return { compare: function(actual) { - if (!j$.private.isPromiseLike(actual)) { + if (!private$.isPromiseLike(actual)) { throw new Error( `Expected toBeResolved to be called on a promise but was on a ${typeof actual}.` ); @@ -4972,7 +4984,7 @@ getJasmineRequireObj().toBeResolved = function(j$) { }; }; -getJasmineRequireObj().toBeResolvedTo = function(j$) { +getJasmineRequireObj().toBeResolvedTo = function(j$, private$) { 'use strict'; /** @@ -4990,7 +5002,7 @@ getJasmineRequireObj().toBeResolvedTo = function(j$) { return function toBeResolvedTo(matchersUtil) { return { compare: function(actualPromise, expectedValue) { - if (!j$.private.isPromiseLike(actualPromise)) { + if (!private$.isPromiseLike(actualPromise)) { throw new Error( `Expected toBeResolvedTo to be called on a promise but was on a ${typeof actualPromise}.` ); @@ -5039,15 +5051,15 @@ getJasmineRequireObj().toBeResolvedTo = function(j$) { }; }; -getJasmineRequireObj().DiffBuilder = function(j$) { +getJasmineRequireObj().DiffBuilder = function(j$, private$) { 'use strict'; class DiffBuilder { constructor(config) { this.prettyPrinter_ = - (config || {}).prettyPrinter || j$.private.makePrettyPrinter(); - this.mismatches_ = new j$.private.MismatchTree(); - this.path_ = new j$.private.ObjectPath(); + (config || {}).prettyPrinter || private$.makePrettyPrinter(); + this.mismatches_ = new private$.MismatchTree(); + this.path_ = new private$.ObjectPath(); this.actualRoot_ = undefined; this.expectedRoot_ = undefined; } @@ -5108,8 +5120,8 @@ getJasmineRequireObj().DiffBuilder = function(j$) { const handleAsymmetricExpected = () => { if ( - j$.private.isAsymmetricEqualityTester(expected) && - j$.private.isFunction(expected.valuesForDiff_) + private$.isAsymmetricEqualityTester(expected) && + private$.isFunction(expected.valuesForDiff_) ) { const asymmetricResult = expected.valuesForDiff_( actual, @@ -5155,7 +5167,7 @@ getJasmineRequireObj().DiffBuilder = function(j$) { return DiffBuilder; }; -getJasmineRequireObj().MatchersUtil = function(j$) { +getJasmineRequireObj().MatchersUtil = function(j$, private$) { 'use strict'; /** @@ -5195,7 +5207,7 @@ getJasmineRequireObj().MatchersUtil = function(j$) { return false; } - if (j$.private.isSet(haystack)) { + if (private$.isSet(haystack)) { // Try .has() first. It should be faster in cases where // needle === something in haystack. Fall back to .equals() comparison // if that fails. @@ -5204,7 +5216,7 @@ getJasmineRequireObj().MatchersUtil = function(j$) { } } - if (j$.private.isIterable(haystack) && !j$.private.isString(haystack)) { + if (private$.isIterable(haystack) && !private$.isString(haystack)) { // Arrays, Sets, etc. for (const candidate of haystack) { if (this.equals(candidate, needle)) { @@ -5220,7 +5232,7 @@ getJasmineRequireObj().MatchersUtil = function(j$) { return haystack.indexOf(needle) >= 0; } - if (j$.private.isNumber(haystack.length)) { + if (private$.isNumber(haystack.length)) { // Objects that are shaped like arrays but aren't iterable for (let i = 0; i < haystack.length; i++) { if (this.equals(haystack[i], needle)) { @@ -5267,7 +5279,7 @@ getJasmineRequireObj().MatchersUtil = function(j$) { bStack, diffBuilder ) { - if (j$.private.isFunction(b.valuesForDiff_)) { + if (private$.isFunction(b.valuesForDiff_)) { const values = b.valuesForDiff_(a, this.pp); this.eq_(values.other, values.self, aStack, bStack, diffBuilder); } else { @@ -5282,8 +5294,8 @@ getJasmineRequireObj().MatchersUtil = function(j$) { bStack, diffBuilder ) { - const asymmetricA = j$.private.isAsymmetricEqualityTester(a); - const asymmetricB = j$.private.isAsymmetricEqualityTester(b); + const asymmetricA = private$.isAsymmetricEqualityTester(a); + const asymmetricB = private$.isAsymmetricEqualityTester(b); if (asymmetricA === asymmetricB) { return undefined; @@ -5318,7 +5330,7 @@ getJasmineRequireObj().MatchersUtil = function(j$) { * @returns {boolean} True if the values are equal */ MatchersUtil.prototype.equals = function(a, b, diffBuilder) { - diffBuilder = diffBuilder || j$.private.NullDiffBuilder(); + diffBuilder = diffBuilder || private$.NullDiffBuilder(); diffBuilder.setRoots(a, b); return this.eq_(a, b, [], [], diffBuilder); @@ -5433,8 +5445,8 @@ getJasmineRequireObj().MatchersUtil = function(j$) { return false; } - const aIsDomNode = j$.private.isDomNode(a); - const bIsDomNode = j$.private.isDomNode(b); + const aIsDomNode = private$.isDomNode(a); + const bIsDomNode = private$.isDomNode(b); if (aIsDomNode && bIsDomNode) { // At first try to use DOM3 method isEqualNode result = a.isEqualNode(b); @@ -5448,8 +5460,8 @@ getJasmineRequireObj().MatchersUtil = function(j$) { return false; } - const aIsPromise = j$.private.isPromise(a); - const bIsPromise = j$.private.isPromise(b); + const aIsPromise = private$.isPromise(a); + const bIsPromise = private$.isPromise(b); if (aIsPromise && bIsPromise) { return a === b; } @@ -5503,7 +5515,7 @@ getJasmineRequireObj().MatchersUtil = function(j$) { if (!result) { return false; } - } else if (j$.private.isMap(a) && j$.private.isMap(b)) { + } else if (private$.isMap(a) && private$.isMap(b)) { if (a.size != b.size) { diffBuilder.recordMismatch(); return false; @@ -5536,14 +5548,14 @@ getJasmineRequireObj().MatchersUtil = function(j$) { // otherwise explicitly look up the mapKey in the other Map since we want keys with unique // obj identity (that are otherwise equal) to not match. if ( - j$.private.isAsymmetricEqualityTester(mapKey) || - (j$.private.isAsymmetricEqualityTester(cmpKey) && + private$.isAsymmetricEqualityTester(mapKey) || + (private$.isAsymmetricEqualityTester(cmpKey) && this.eq_( mapKey, cmpKey, aStack, bStack, - j$.private.NullDiffBuilder() + private$.NullDiffBuilder() )) ) { mapValueB = b.get(cmpKey); @@ -5555,7 +5567,7 @@ getJasmineRequireObj().MatchersUtil = function(j$) { mapValueB, aStack, bStack, - j$.private.NullDiffBuilder() + private$.NullDiffBuilder() ); } } @@ -5564,7 +5576,7 @@ getJasmineRequireObj().MatchersUtil = function(j$) { diffBuilder.recordMismatch(); return false; } - } else if (j$.private.isSet(a) && j$.private.isSet(b)) { + } else if (private$.isSet(a) && private$.isSet(b)) { if (a.size != b.size) { diffBuilder.recordMismatch(); return false; @@ -5600,7 +5612,7 @@ getJasmineRequireObj().MatchersUtil = function(j$) { otherValue, baseStack, otherStack, - j$.private.NullDiffBuilder() + private$.NullDiffBuilder() ); if (!found && prevStackSize !== baseStack.length) { baseStack.splice(prevStackSize); @@ -5615,7 +5627,7 @@ getJasmineRequireObj().MatchersUtil = function(j$) { diffBuilder.recordMismatch(); return false; } - } else if (j$.private.isURL(a) && j$.private.isURL(b)) { + } else if (private$.isURL(a) && private$.isURL(b)) { // URLs have no enumrable properties, so the default object comparison // would consider any two URLs to be equal. return a.toString() === b.toString(); @@ -5653,7 +5665,7 @@ getJasmineRequireObj().MatchersUtil = function(j$) { for (const key of aKeys) { // Deep compare each member - if (!j$.private.util.has(b, key)) { + if (!private$.util.has(b, key)) { diffBuilder.recordMismatch( objectKeysAreDifferentFormatter.bind(null, this.pp) ); @@ -5683,7 +5695,7 @@ getJasmineRequireObj().MatchersUtil = function(j$) { const allKeys = (function(o) { const keys = []; for (const key in o) { - if (j$.private.util.has(o, key)) { + if (private$.util.has(o, key)) { keys.push(key); } } @@ -5724,7 +5736,7 @@ getJasmineRequireObj().MatchersUtil = function(j$) { // and not in objB. function extraKeysAndValues(objA, objB) { return MatchersUtil.keys(objA) - .filter(key => !j$.private.util.has(objB, key)) + .filter(key => !private$.util.has(objB, key)) .map(key => [key, objA[key]]); } @@ -5763,7 +5775,7 @@ getJasmineRequireObj().MatchersUtil = function(j$) { 'Expected ' + path + ' to be a kind of ' + - j$.private.fnNameFor(expected.constructor) + + private$.fnNameFor(expected.constructor) + ', but was ' + pp(actual) + '.' @@ -5842,7 +5854,7 @@ getJasmineRequireObj().MatchersUtil = function(j$) { * @return {String} */ -getJasmineRequireObj().MismatchTree = function(j$) { +getJasmineRequireObj().MismatchTree = function(j$, private$) { 'use strict'; /* @@ -5854,7 +5866,7 @@ getJasmineRequireObj().MismatchTree = function(j$) { */ class MismatchTree { constructor(path) { - this.path = path || new j$.private.ObjectPath([]); + this.path = path || new private$.ObjectPath([]); this.formatter = undefined; this.children = []; this.isMismatch = false; @@ -5925,7 +5937,7 @@ getJasmineRequireObj().nothing = function() { return nothing; }; -getJasmineRequireObj().NullDiffBuilder = function(j$) { +getJasmineRequireObj().NullDiffBuilder = function(j$, private$) { 'use strict'; return function() { @@ -5939,7 +5951,7 @@ getJasmineRequireObj().NullDiffBuilder = function(j$) { }; }; -getJasmineRequireObj().ObjectPath = function(j$) { +getJasmineRequireObj().ObjectPath = function(j$, private$) { 'use strict'; class ObjectPath { @@ -5987,7 +5999,7 @@ getJasmineRequireObj().ObjectPath = function(j$) { return ObjectPath; }; -getJasmineRequireObj().requireAsyncMatchers = function(jRequire, j$) { +getJasmineRequireObj().requireAsyncMatchers = function(jRequire, j$, private$) { 'use strict'; const availableMatchers = [ @@ -6001,13 +6013,13 @@ getJasmineRequireObj().requireAsyncMatchers = function(jRequire, j$) { matchers = {}; for (const name of availableMatchers) { - matchers[name] = jRequire[name](j$); + matchers[name] = jRequire[name](j$, private$); } return matchers; }; -getJasmineRequireObj().toBe = function(j$) { +getJasmineRequireObj().toBe = function(j$, private$) { 'use strict'; /** @@ -6222,10 +6234,10 @@ getJasmineRequireObj().toBeGreaterThanOrEqual = function() { return toBeGreaterThanOrEqual; }; -getJasmineRequireObj().toBeInstanceOf = function(j$) { +getJasmineRequireObj().toBeInstanceOf = function(j$, private$) { 'use strict'; - const usageError = j$.private.formatErrorMsg( + const usageError = private$.formatErrorMsg( '', 'expect(value).toBeInstanceOf()' ); @@ -6246,16 +6258,16 @@ getJasmineRequireObj().toBeInstanceOf = function(j$) { compare: function(actual, expected) { const actualType = actual && actual.constructor - ? j$.private.fnNameFor(actual.constructor) + ? private$.fnNameFor(actual.constructor) : matchersUtil.pp(actual); const expectedType = expected - ? j$.private.fnNameFor(expected) + ? private$.fnNameFor(expected) : matchersUtil.pp(expected); let expectedMatcher; let pass; try { - expectedMatcher = new j$.private.Any(expected); + expectedMatcher = new private$.Any(expected); pass = expectedMatcher.asymmetricMatch(actual); // eslint-disable-next-line no-unused-vars } catch (error) { @@ -6340,7 +6352,7 @@ getJasmineRequireObj().toBeLessThanOrEqual = function() { return toBeLessThanOrEqual; }; -getJasmineRequireObj().toBeNaN = function(j$) { +getJasmineRequireObj().toBeNaN = function(j$, private$) { 'use strict'; /** @@ -6374,7 +6386,7 @@ getJasmineRequireObj().toBeNaN = function(j$) { return toBeNaN; }; -getJasmineRequireObj().toBeNegativeInfinity = function(j$) { +getJasmineRequireObj().toBeNegativeInfinity = function(j$, private$) { 'use strict'; /** @@ -6456,7 +6468,7 @@ getJasmineRequireObj().toBeNullish = function() { return toBeNullish; }; -getJasmineRequireObj().toBePositiveInfinity = function(j$) { +getJasmineRequireObj().toBePositiveInfinity = function(j$, private$) { 'use strict'; /** @@ -6588,7 +6600,7 @@ getJasmineRequireObj().toContain = function() { return toContain; }; -getJasmineRequireObj().toEqual = function(j$) { +getJasmineRequireObj().toEqual = function(j$, private$) { 'use strict'; /** @@ -6606,7 +6618,7 @@ getJasmineRequireObj().toEqual = function(j$) { const result = { pass: false }, - diffBuilder = new j$.private.DiffBuilder({ + diffBuilder = new private$.DiffBuilder({ prettyPrinter: matchersUtil.pp }); @@ -6623,10 +6635,10 @@ getJasmineRequireObj().toEqual = function(j$) { return toEqual; }; -getJasmineRequireObj().toHaveBeenCalled = function(j$) { +getJasmineRequireObj().toHaveBeenCalled = function(j$, private$) { 'use strict'; - const getErrorMsg = j$.private.formatErrorMsg( + const getErrorMsg = private$.formatErrorMsg( '', 'expect().toHaveBeenCalled()' ); @@ -6675,10 +6687,10 @@ getJasmineRequireObj().toHaveBeenCalled = function(j$) { return toHaveBeenCalled; }; -getJasmineRequireObj().toHaveBeenCalledBefore = function(j$) { +getJasmineRequireObj().toHaveBeenCalledBefore = function(j$, private$) { 'use strict'; - const getErrorMsg = j$.private.formatErrorMsg( + const getErrorMsg = private$.formatErrorMsg( '', 'expect().toHaveBeenCalledBefore()' ); @@ -6773,10 +6785,10 @@ getJasmineRequireObj().toHaveBeenCalledBefore = function(j$) { return toHaveBeenCalledBefore; }; -getJasmineRequireObj().toHaveBeenCalledOnceWith = function(j$) { +getJasmineRequireObj().toHaveBeenCalledOnceWith = function(j$, private$) { 'use strict'; - const getErrorMsg = j$.private.formatErrorMsg( + const getErrorMsg = private$.formatErrorMsg( '', 'expect().toHaveBeenCalledOnceWith(...arguments)' ); @@ -6839,7 +6851,7 @@ getJasmineRequireObj().toHaveBeenCalledOnceWith = function(j$) { function getDiffs() { return actual.calls.allArgs().map(function(argsForCall, callIx) { - const diffBuilder = new j$.private.DiffBuilder(); + const diffBuilder = new private$.DiffBuilder(); matchersUtil.equals(argsForCall, expectedArgs, diffBuilder); return diffBuilder.getMessage(); }); @@ -6884,10 +6896,10 @@ getJasmineRequireObj().toHaveBeenCalledOnceWith = function(j$) { return toHaveBeenCalledOnceWith; }; -getJasmineRequireObj().toHaveBeenCalledTimes = function(j$) { +getJasmineRequireObj().toHaveBeenCalledTimes = function(j$, private$) { 'use strict'; - const getErrorMsg = j$.private.formatErrorMsg( + const getErrorMsg = private$.formatErrorMsg( '', 'expect().toHaveBeenCalledTimes()' ); @@ -6915,7 +6927,7 @@ getJasmineRequireObj().toHaveBeenCalledTimes = function(j$) { const args = Array.prototype.slice.call(arguments, 0), result = { pass: false }; - if (!j$.private.isNumber(expected)) { + if (!private$.isNumber(expected)) { throw new Error( getErrorMsg( 'The expected times failed is a required argument and must be a number.' @@ -6962,10 +6974,10 @@ getJasmineRequireObj().toHaveBeenCalledTimes = function(j$) { return toHaveBeenCalledTimes; }; -getJasmineRequireObj().toHaveBeenCalledWith = function(j$) { +getJasmineRequireObj().toHaveBeenCalledWith = function(j$, private$) { 'use strict'; - const getErrorMsg = j$.private.formatErrorMsg( + const getErrorMsg = private$.formatErrorMsg( '', 'expect().toHaveBeenCalledWith(...arguments)' ); @@ -7037,7 +7049,7 @@ getJasmineRequireObj().toHaveBeenCalledWith = function(j$) { const diffs = actual.calls .allArgs() .map(function(argsForCall, callIx) { - const diffBuilder = new j$.private.DiffBuilder(); + const diffBuilder = new private$.DiffBuilder(); matchersUtil.equals(argsForCall, expectedArgs, diffBuilder); return ( 'Call ' + @@ -7071,7 +7083,7 @@ getJasmineRequireObj().toHaveBeenCalledWith = function(j$) { return toHaveBeenCalledWith; }; -getJasmineRequireObj().toHaveClass = function(j$) { +getJasmineRequireObj().toHaveClass = function(j$, private$) { 'use strict'; /** @@ -7103,14 +7115,14 @@ getJasmineRequireObj().toHaveClass = function(j$) { return ( maybeEl && maybeEl.classList && - j$.private.isFunction(maybeEl.classList.contains) + private$.isFunction(maybeEl.classList.contains) ); } return toHaveClass; }; -getJasmineRequireObj().toHaveClasses = function(j$) { +getJasmineRequireObj().toHaveClasses = function(j$, private$) { 'use strict'; /** @@ -7142,17 +7154,17 @@ getJasmineRequireObj().toHaveClasses = function(j$) { return ( maybeEl && maybeEl.classList && - j$.private.isFunction(maybeEl.classList.contains) + private$.isFunction(maybeEl.classList.contains) ); } return toHaveClasses; }; -getJasmineRequireObj().toHaveNoOtherSpyInteractions = function(j$) { +getJasmineRequireObj().toHaveNoOtherSpyInteractions = function(j$, private$) { 'use strict'; - const getErrorMsg = j$.private.formatErrorMsg( + const getErrorMsg = private$.formatErrorMsg( '', 'expect().toHaveNoOtherSpyInteractions()' ); @@ -7170,7 +7182,7 @@ getJasmineRequireObj().toHaveNoOtherSpyInteractions = function(j$) { compare: function(actual) { const result = {}; - if (!j$.private.isObject(actual)) { + if (!private$.isObject(actual)) { throw new Error( getErrorMsg('Expected an object, but got ' + typeof actual + '.') ); @@ -7237,7 +7249,7 @@ getJasmineRequireObj().toHaveNoOtherSpyInteractions = function(j$) { return toHaveNoOtherSpyInteractions; }; -getJasmineRequireObj().toHaveSize = function(j$) { +getJasmineRequireObj().toHaveSize = function(j$, private$) { 'use strict'; /** @@ -7258,15 +7270,15 @@ getJasmineRequireObj().toHaveSize = function(j$) { }; if ( - j$.private.isA('WeakSet', actual) || - j$.private.isWeakMap(actual) || - j$.private.isDataView(actual) + private$.isA('WeakSet', actual) || + private$.isWeakMap(actual) || + private$.isDataView(actual) ) { throw new Error('Cannot get size of ' + actual + '.'); } let actualSize; - if (j$.private.isSet(actual) || j$.private.isMap(actual)) { + if (private$.isSet(actual) || private$.isMap(actual)) { actualSize = actual.size; } else if (isLength(actual.length)) { actualSize = actual.length; @@ -7308,10 +7320,10 @@ getJasmineRequireObj().toHaveSize = function(j$) { return toHaveSize; }; -getJasmineRequireObj().toHaveSpyInteractions = function(j$) { +getJasmineRequireObj().toHaveSpyInteractions = function(j$, private$) { 'use strict'; - const getErrorMsg = j$.private.formatErrorMsg( + const getErrorMsg = private$.formatErrorMsg( '', 'expect().toHaveSpyInteractions()' ); @@ -7330,7 +7342,7 @@ getJasmineRequireObj().toHaveSpyInteractions = function(j$) { compare: function(actual) { const result = {}; - if (!j$.private.isObject(actual)) { + if (!private$.isObject(actual)) { throw new Error( getErrorMsg('Expected a spy object, but got ' + typeof actual + '.') ); @@ -7389,10 +7401,10 @@ getJasmineRequireObj().toHaveSpyInteractions = function(j$) { return toHaveSpyInteractions; }; -getJasmineRequireObj().toMatch = function(j$) { +getJasmineRequireObj().toMatch = function(j$, private$) { 'use strict'; - const getErrorMsg = j$.private.formatErrorMsg( + const getErrorMsg = private$.formatErrorMsg( '', 'expect().toMatch( || )' ); @@ -7410,10 +7422,7 @@ getJasmineRequireObj().toMatch = function(j$) { function toMatch() { return { compare: function(actual, expected) { - if ( - !j$.private.isString(expected) && - !j$.private.isA('RegExp', expected) - ) { + if (!private$.isString(expected) && !private$.isA('RegExp', expected)) { throw new Error(getErrorMsg('Expected is not a String or a RegExp')); } @@ -7429,10 +7438,10 @@ getJasmineRequireObj().toMatch = function(j$) { return toMatch; }; -getJasmineRequireObj().toThrow = function(j$) { +getJasmineRequireObj().toThrow = function(j$, private$) { 'use strict'; - const getErrorMsg = j$.private.formatErrorMsg( + const getErrorMsg = private$.formatErrorMsg( '', 'expect(function() {}).toThrow()' ); @@ -7512,10 +7521,10 @@ getJasmineRequireObj().toThrow = function(j$) { return toThrow; }; -getJasmineRequireObj().toThrowError = function(j$) { +getJasmineRequireObj().toThrowError = function(j$, private$) { 'use strict'; - const getErrorMsg = j$.private.formatErrorMsg( + const getErrorMsg = private$.formatErrorMsg( '', 'expect(function() {}).toThrowError(, )' ); @@ -7552,7 +7561,7 @@ getJasmineRequireObj().toThrowError = function(j$) { thrown = e; } - if (!j$.private.isError(thrown)) { + if (!private$.isError(thrown)) { return fail(function() { return ( 'Expected function to throw an Error, but it threw ' + @@ -7595,7 +7604,7 @@ getJasmineRequireObj().toThrowError = function(j$) { match: function(error) { return pass( 'Expected function not to throw an Error, but it threw ' + - j$.private.fnNameFor(error) + + private$.fnNameFor(error) + '.' ); } @@ -7624,12 +7633,12 @@ getJasmineRequireObj().toThrowError = function(j$) { } const errorTypeDescription = errorType - ? j$.private.fnNameFor(errorType) + ? private$.fnNameFor(errorType) : 'an exception'; function thrownDescription(thrown) { const thrownName = errorType - ? j$.private.fnNameFor(thrown.constructor) + ? private$.fnNameFor(thrown.constructor) : 'an exception'; let thrownMessage = ''; @@ -7695,7 +7704,7 @@ getJasmineRequireObj().toThrowError = function(j$) { const Surrogate = function() {}; Surrogate.prototype = type.prototype; - return j$.private.isError(new Surrogate()); + return private$.isError(new Surrogate()); } } @@ -7716,10 +7725,10 @@ getJasmineRequireObj().toThrowError = function(j$) { return toThrowError; }; -getJasmineRequireObj().toThrowMatching = function(j$) { +getJasmineRequireObj().toThrowMatching = function(j$, private$) { 'use strict'; - const usageError = j$.private.formatErrorMsg( + const usageError = private$.formatErrorMsg( '', 'expect(function() {}).toThrowMatching()' ); @@ -7773,7 +7782,7 @@ getJasmineRequireObj().toThrowMatching = function(j$) { function thrownDescription(thrown) { if (thrown && thrown.constructor) { return ( - j$.private.fnNameFor(thrown.constructor) + + private$.fnNameFor(thrown.constructor) + ' with message ' + matchersUtil.pp(thrown.message) ); @@ -7800,7 +7809,7 @@ getJasmineRequireObj().toThrowMatching = function(j$) { return toThrowMatching; }; -getJasmineRequireObj().MockDate = function(j$) { +getJasmineRequireObj().MockDate = function(j$, private$) { 'use strict'; function MockDate(global) { @@ -7910,7 +7919,7 @@ getJasmineRequireObj().MockDate = function(j$) { return MockDate; }; -getJasmineRequireObj().NeverSkipPolicy = function(j$) { +getJasmineRequireObj().NeverSkipPolicy = function(j$, private$) { 'use strict'; function NeverSkipPolicy(queueableFns) {} @@ -7924,7 +7933,7 @@ getJasmineRequireObj().NeverSkipPolicy = function(j$) { return NeverSkipPolicy; }; -getJasmineRequireObj().ParallelReportDispatcher = function(j$) { +getJasmineRequireObj().ParallelReportDispatcher = function(j$, private$) { 'use strict'; /** @@ -7942,12 +7951,11 @@ getJasmineRequireObj().ParallelReportDispatcher = function(j$) { * @param onError {function} Function called when an unhandled exception, unhandled promise rejection, or explicit reporter failure occurs */ function ParallelReportDispatcher(onError, deps = {}) { - const ReportDispatcher = - deps.ReportDispatcher || j$.private.ReportDispatcher; - const QueueRunner = deps.QueueRunner || j$.private.QueueRunner; - const globalErrors = deps.globalErrors || new j$.private.GlobalErrors(); + const ReportDispatcher = deps.ReportDispatcher || private$.ReportDispatcher; + const QueueRunner = deps.QueueRunner || private$.QueueRunner; + const globalErrors = deps.globalErrors || new private$.GlobalErrors(); const dispatcher = new ReportDispatcher( - j$.private.reporterEvents, + private$.reporterEvents, function(queueRunnerOptions) { queueRunnerOptions = { ...queueRunnerOptions, @@ -8011,7 +8019,7 @@ getJasmineRequireObj().ParallelReportDispatcher = function(j$) { } }; - for (const eventName of j$.private.reporterEvents) { + for (const eventName of private$.reporterEvents) { self[eventName] = dispatcher[eventName].bind(dispatcher); } @@ -8021,7 +8029,7 @@ getJasmineRequireObj().ParallelReportDispatcher = function(j$) { return ParallelReportDispatcher; }; -getJasmineRequireObj().makePrettyPrinter = function(j$) { +getJasmineRequireObj().makePrettyPrinter = function(j$, private$) { 'use strict'; class SinglePrettyPrintRun { @@ -8051,7 +8059,7 @@ getJasmineRequireObj().makePrettyPrinter = function(j$) { this.emitScalar(''); } else if (value.jasmineToString) { this.emitScalar(value.jasmineToString(this.pp_)); - } else if (j$.private.isString(value)) { + } else if (private$.isString(value)) { this.emitString(value); } else if (j$.isSpy(value)) { this.emitScalar('spy on ' + value.and.identity); @@ -8065,7 +8073,7 @@ getJasmineRequireObj().makePrettyPrinter = function(j$) { } else { this.emitScalar('Function'); } - } else if (j$.private.isDomNode(value)) { + } else if (private$.isDomNode(value)) { if (value.tagName) { this.emitDomElement(value); } else { @@ -8073,11 +8081,11 @@ getJasmineRequireObj().makePrettyPrinter = function(j$) { } } else if (value instanceof Date) { this.emitScalar('Date(' + value + ')'); - } else if (j$.private.isSet(value)) { + } else if (private$.isSet(value)) { this.emitSet(value); - } else if (j$.private.isMap(value)) { + } else if (private$.isMap(value)) { this.emitMap(value); - } else if (j$.private.isTypedArray(value)) { + } else if (private$.isTypedArray(value)) { this.emitTypedArray(value); } else if ( value.toString && @@ -8097,7 +8105,7 @@ getJasmineRequireObj().makePrettyPrinter = function(j$) { (Array.isArray(value) ? 'Array' : 'Object') + '>' ); - } else if (Array.isArray(value) || j$.private.isA('Object', value)) { + } else if (Array.isArray(value) || private$.isA('Object', value)) { this.seen.push(value); if (Array.isArray(value)) { this.emitArray(value); @@ -8122,7 +8130,7 @@ getJasmineRequireObj().makePrettyPrinter = function(j$) { } iterateObject(obj, fn) { - const objKeys = j$.private.MatchersUtil.keys(obj, Array.isArray(obj)); + const objKeys = private$.MatchersUtil.keys(obj, Array.isArray(obj)); const length = Math.min(objKeys.length, j$.MAX_PRETTY_PRINT_ARRAY_LENGTH); for (let i = 0; i < length; i++) { @@ -8231,7 +8239,7 @@ getJasmineRequireObj().makePrettyPrinter = function(j$) { const ctor = obj.constructor; const constructorName = typeof ctor === 'function' && obj instanceof ctor - ? j$.private.fnNameFor(obj.constructor) + ? private$.fnNameFor(obj.constructor) : 'null'; this.append(constructorName); @@ -8261,7 +8269,7 @@ getJasmineRequireObj().makePrettyPrinter = function(j$) { } emitTypedArray(arr) { - const constructorName = j$.private.fnNameFor(arr.constructor); + const constructorName = private$.fnNameFor(arr.constructor); const limitedArray = Array.prototype.slice.call( arr, 0, @@ -8330,7 +8338,7 @@ getJasmineRequireObj().makePrettyPrinter = function(j$) { // iframe, web worker) try { return ( - j$.private.isFunction(value.toString) && + private$.isFunction(value.toString) && value.toString !== Object.prototype.toString && value.toString() !== Object.prototype.toString.call(value) ); @@ -8389,14 +8397,14 @@ getJasmineRequireObj().makePrettyPrinter = function(j$) { }; }; -getJasmineRequireObj().QueueRunner = function(j$) { +getJasmineRequireObj().QueueRunner = function(j$, private$) { 'use strict'; let nextid = 1; function StopExecutionError() {} StopExecutionError.prototype = new Error(); - j$.private.StopExecutionError = StopExecutionError; + private$.StopExecutionError = StopExecutionError; function once(fn, onTwice) { let called = false; @@ -8449,7 +8457,7 @@ getJasmineRequireObj().QueueRunner = function(j$) { }; this.onException = attrs.onException || emptyFn; this.onMultipleDone = attrs.onMultipleDone || fallbackOnMultipleDone; - this.userContext = attrs.userContext || new j$.private.UserContext(); + this.userContext = attrs.userContext || new private$.UserContext(); this.timeout = attrs.timeout || { setTimeout: setTimeout, clearTimeout: clearTimeout @@ -8460,7 +8468,7 @@ getJasmineRequireObj().QueueRunner = function(j$) { popListener: emptyFn }; - const SkipPolicy = attrs.SkipPolicy || j$.private.NeverSkipPolicy; + const SkipPolicy = attrs.SkipPolicy || private$.NeverSkipPolicy; this.skipPolicy_ = new SkipPolicy(this.queueableFns); this.errored_ = false; @@ -8583,7 +8591,7 @@ getJasmineRequireObj().QueueRunner = function(j$) { if (queueableFn.fn.length === 0) { maybeThenable = queueableFn.fn.call(this.userContext); - if (maybeThenable && j$.private.isFunction(maybeThenable.then)) { + if (maybeThenable && private$.isFunction(maybeThenable.then)) { maybeThenable.then( wrapInPromiseResolutionHandler(next), onPromiseRejection @@ -8653,11 +8661,11 @@ getJasmineRequireObj().QueueRunner = function(j$) { }; QueueRunner.prototype.diagnoseConflictingAsync_ = function(fn, retval) { - if (retval && j$.private.isFunction(retval.then)) { + if (retval && private$.isFunction(retval.then)) { // Issue a warning that matches the user's code. // Omit the stack trace because there's almost certainly no user code // on the stack at this point. - if (j$.private.isAsyncFunction(fn)) { + if (private$.isAsyncFunction(fn)) { this.onException( new Error( 'An asynchronous before/it/after ' + @@ -8681,7 +8689,7 @@ getJasmineRequireObj().QueueRunner = function(j$) { function wrapInPromiseResolutionHandler(fn) { return function(maybeArg) { - if (j$.private.isError(maybeArg)) { + if (private$.isError(maybeArg)) { fn(maybeArg); } else { fn(); @@ -8692,7 +8700,7 @@ getJasmineRequireObj().QueueRunner = function(j$) { return QueueRunner; }; -getJasmineRequireObj().ReportDispatcher = function(j$) { +getJasmineRequireObj().ReportDispatcher = function(j$, private$) { 'use strict'; function ReportDispatcher(methods, runQueue, onLateError) { @@ -8775,7 +8783,7 @@ getJasmineRequireObj().ReportDispatcher = function(j$) { return ReportDispatcher; }; -getJasmineRequireObj().reporterEvents = function(j$) { +getJasmineRequireObj().reporterEvents = function(j$, private$) { 'use strict'; /** @@ -9412,7 +9420,7 @@ getJasmineRequireObj().interface = function(jasmine, env) { return jasmineInterface; }; -getJasmineRequireObj().RunableResources = function(j$) { +getJasmineRequireObj().RunableResources = function(j$, private$) { 'use strict'; class RunableResources { @@ -9421,7 +9429,7 @@ getJasmineRequireObj().RunableResources = function(j$) { this.getCurrentRunableId_ = options.getCurrentRunableId; this.globalErrors_ = options.globalErrors; - this.spyFactory = new j$.private.SpyFactory( + this.spyFactory = new private$.SpyFactory( () => { if (this.getCurrentRunableId_()) { return this.customSpyStrategies(); @@ -9433,7 +9441,7 @@ getJasmineRequireObj().RunableResources = function(j$) { () => this.makeMatchersUtil() ); - this.spyRegistry = new j$.private.SpyRegistry({ + this.spyRegistry = new private$.SpyRegistry({ currentSpies: () => this.spies(), createSpy: (name, originalFn) => this.spyFactory.createSpy(name, originalFn) @@ -9464,7 +9472,7 @@ getJasmineRequireObj().RunableResources = function(j$) { ]; for (const k of toClone) { - newRes[k] = j$.private.util.clone(parentRes[k]); + newRes[k] = private$.util.clone(parentRes[k]); } } } @@ -9542,18 +9550,18 @@ getJasmineRequireObj().RunableResources = function(j$) { } makePrettyPrinter() { - return j$.private.makePrettyPrinter(this.customObjectFormatters()); + return private$.makePrettyPrinter(this.customObjectFormatters()); } makeMatchersUtil() { if (this.getCurrentRunableId_()) { - return new j$.private.MatchersUtil({ + return new private$.MatchersUtil({ customTesters: this.customEqualityTesters(), pp: this.makePrettyPrinter() }); } else { - return new j$.private.MatchersUtil({ - pp: j$.private.basicPrettyPrinter + return new private$.MatchersUtil({ + pp: private$.basicPrettyPrinter }); } } @@ -9572,7 +9580,7 @@ getJasmineRequireObj().RunableResources = function(j$) { return RunableResources; }; -getJasmineRequireObj().Runner = function(j$) { +getJasmineRequireObj().Runner = function(j$, private$) { 'use strict'; class Runner { @@ -9600,7 +9608,7 @@ getJasmineRequireObj().Runner = function(j$) { this.#reportDispatcher = options.reportDispatcher; this.#getConfig = options.getConfig; this.#executedBefore = false; - this.#currentRunableTracker = new j$.private.CurrentRunableTracker(); + this.#currentRunableTracker = new private$.CurrentRunableTracker(); } currentSpec() { @@ -9640,9 +9648,9 @@ getJasmineRequireObj().Runner = function(j$) { } } - const order = new j$.private.Order({ + const order = new private$.Order({ random: config.random, - seed: j$.private.isNumber(config.seed) ? config.seed + '' : config.seed + seed: private$.isNumber(config.seed) ? config.seed + '' : config.seed }); const treeProcessor = new this.#TreeProcessor({ @@ -9686,7 +9694,7 @@ getJasmineRequireObj().Runner = function(j$) { }); this.#currentRunableTracker.pushSuite(this.#topSuite); - const treeRunner = new j$.private.TreeRunner({ + const treeRunner = new private$.TreeRunner({ executionTree: this.#executionTree, globalErrors: this.#globalErrors, runableResources: this.#runableResources, @@ -9763,7 +9771,7 @@ getJasmineRequireObj().Runner = function(j$) { return Runner; }; -getJasmineRequireObj().SkipAfterBeforeAllErrorPolicy = function(j$) { +getJasmineRequireObj().SkipAfterBeforeAllErrorPolicy = function(j$, private$) { 'use strict'; function SkipAfterBeforeAllErrorPolicy(queueableFns) { @@ -9804,7 +9812,7 @@ getJasmineRequireObj().SkipAfterBeforeAllErrorPolicy = function(j$) { return SkipAfterBeforeAllErrorPolicy; }; -getJasmineRequireObj().Spy = function(j$) { +getJasmineRequireObj().Spy = function(j$, private$) { 'use strict'; const nextOrder = (function() { @@ -9861,7 +9869,7 @@ getJasmineRequireObj().Spy = function(j$) { }, matchersUtil ), - callTracker = new j$.private.CallTracker(); + callTracker = new private$.CallTracker(); function makeFunc(length, fn) { switch (length) { @@ -9953,9 +9961,9 @@ getJasmineRequireObj().Spy = function(j$) { } function SpyStrategyDispatcher(strategyArgs, matchersUtil) { - const baseStrategy = new j$.private.SpyStrategy(strategyArgs); + const baseStrategy = new private$.SpyStrategy(strategyArgs); const argsStrategies = new StrategyDict(function() { - return new j$.private.SpyStrategy(strategyArgs); + return new private$.SpyStrategy(strategyArgs); }, matchersUtil); this.and = baseStrategy; @@ -10020,7 +10028,7 @@ getJasmineRequireObj().Spy = function(j$) { return Spy; }; -getJasmineRequireObj().SpyFactory = function(j$) { +getJasmineRequireObj().SpyFactory = function(j$, private$) { 'use strict'; function SpyFactory( @@ -10029,12 +10037,12 @@ getJasmineRequireObj().SpyFactory = function(j$) { getMatchersUtil ) { this.createSpy = function(name, originalFn) { - if (j$.private.isFunction(name) && originalFn === undefined) { + if (private$.isFunction(name) && originalFn === undefined) { originalFn = name; name = originalFn.name; } - return j$.private.Spy(name, getMatchersUtil(), { + return private$.Spy(name, getMatchersUtil(), { originalFn, customStrategies: getCustomStrategies(), defaultStrategyFn: getDefaultStrategyFn() @@ -10043,7 +10051,7 @@ getJasmineRequireObj().SpyFactory = function(j$) { this.createSpyObj = function(baseName, methodNames, propertyNames) { const baseNameIsCollection = - j$.private.isObject(baseName) || Array.isArray(baseName); + private$.isObject(baseName) || Array.isArray(baseName); if (baseNameIsCollection) { propertyNames = methodNames; @@ -10093,7 +10101,7 @@ getJasmineRequireObj().SpyFactory = function(j$) { for (let i = 0; i < object.length; i++) { result.push([object[i]]); } - } else if (j$.private.isObject(object)) { + } else if (private$.isObject(object)) { for (const key in object) { if (object.hasOwnProperty(key)) { result.push([key, object[key]]); @@ -10106,14 +10114,14 @@ getJasmineRequireObj().SpyFactory = function(j$) { return SpyFactory; }; -getJasmineRequireObj().SpyRegistry = function(j$) { +getJasmineRequireObj().SpyRegistry = function(j$, private$) { 'use strict'; - const spyOnMsg = j$.private.formatErrorMsg( + const spyOnMsg = private$.formatErrorMsg( '', 'spyOn(, )' ); - const spyOnPropertyMsg = j$.private.formatErrorMsg( + const spyOnPropertyMsg = private$.formatErrorMsg( '', 'spyOnProperty(, , [accessType])' ); @@ -10155,7 +10163,7 @@ getJasmineRequireObj().SpyRegistry = function(j$) { // restored. if ( obj[methodName] && - obj[methodName][j$.private.Clock.IsMockClockTimingFn] + obj[methodName][private$.Clock.IsMockClockTimingFn] ) { throw new Error("Mock clock timing functions can't be spied on"); } @@ -10210,7 +10218,7 @@ getJasmineRequireObj().SpyRegistry = function(j$) { // localStorage in Firefox and later Safari versions, have no-op setters. if (obj[methodName] !== spiedMethod) { throw new Error( - j$.private.formatErrorMsg('')( + private$.formatErrorMsg('')( `Can't spy on ${methodName} because assigning to it had no effect` ) ); @@ -10238,10 +10246,7 @@ getJasmineRequireObj().SpyRegistry = function(j$) { throw new Error(getErrorMsg('No property name supplied')); } - const descriptor = j$.private.util.getPropertyDescriptor( - obj, - propertyName - ); + const descriptor = private$.util.getPropertyDescriptor(obj, propertyName); if (!descriptor) { throw new Error(getErrorMsg(propertyName + ' property does not exist')); @@ -10276,7 +10281,7 @@ getJasmineRequireObj().SpyRegistry = function(j$) { } } - const originalDescriptor = j$.private.util.clone(descriptor); + const originalDescriptor = private$.util.clone(descriptor); const spy = createSpy(propertyName, descriptor[accessType]); let restoreStrategy; @@ -10392,7 +10397,7 @@ getJasmineRequireObj().SpyRegistry = function(j$) { return SpyRegistry; }; -getJasmineRequireObj().SpyStrategy = function(j$) { +getJasmineRequireObj().SpyStrategy = function(j$, private$) { 'use strict'; /** @@ -10415,7 +10420,7 @@ getJasmineRequireObj().SpyStrategy = function(j$) { const cs = options.customStrategies || {}; for (const k in cs) { - if (j$.private.util.has(cs, k) && !this[k]) { + if (private$.util.has(cs, k) && !this[k]) { this[k] = createCustomPlan(cs[k]); } } @@ -10453,7 +10458,7 @@ getJasmineRequireObj().SpyStrategy = function(j$) { return function() { const plan = factory.apply(null, arguments); - if (!j$.private.isFunction(plan)) { + if (!private$.isFunction(plan)) { throw new Error('Spy strategy must return a function'); } @@ -10525,7 +10530,7 @@ getJasmineRequireObj().SpyStrategy = function(j$) { * @param {Error|Object|String} something Thing to throw */ SpyStrategy.prototype.throwError = function(something) { - const error = j$.private.isString(something) + const error = private$.isString(something) ? new Error(something) : something; this.plan = function() { @@ -10544,9 +10549,9 @@ getJasmineRequireObj().SpyStrategy = function(j$) { SpyStrategy.prototype.callFake = function(fn) { if ( !( - j$.private.isFunction(fn) || - j$.private.isAsyncFunction(fn) || - j$.private.isGeneratorFunction(fn) + private$.isFunction(fn) || + private$.isAsyncFunction(fn) || + private$.isGeneratorFunction(fn) ) ) { throw new Error( @@ -10575,7 +10580,7 @@ getJasmineRequireObj().SpyStrategy = function(j$) { return SpyStrategy; }; -getJasmineRequireObj().StackClearer = function(j$) { +getJasmineRequireObj().StackClearer = function(j$, private$) { 'use strict'; const maxInlineCallCount = 10; @@ -10733,7 +10738,7 @@ getJasmineRequireObj().StackClearer = function(j$) { return getStackClearer; }; -getJasmineRequireObj().StackTrace = function(j$) { +getJasmineRequireObj().StackTrace = function(j$, private$) { 'use strict'; function StackTrace(error) { @@ -10867,7 +10872,7 @@ getJasmineRequireObj().StackTrace = function(j$) { return StackTrace; }; -getJasmineRequireObj().Suite = function(j$) { +getJasmineRequireObj().Suite = function(j$, private$) { 'use strict'; class Suite { @@ -10906,10 +10911,10 @@ getJasmineRequireObj().Suite = function(j$) { // Key and value will eventually be cloned during reporting. The error // thrown at that point if they aren't cloneable isn't very helpful. // Throw a better one now. - if (!j$.private.isString(key)) { + if (!private$.isString(key)) { throw new Error('Key must be a string'); } - j$.private.util.assertReporterCloneable(value, 'Value'); + private$.util.assertReporterCloneable(value, 'Value'); this.#result.properties = this.#result.properties || {}; this.#result.properties[key] = value; @@ -11086,18 +11091,18 @@ getJasmineRequireObj().Suite = function(j$) { if (!this.sharedContext) { this.sharedContext = this.parentSuite ? this.parentSuite.clonedSharedUserContext() - : new j$.private.UserContext(); + : new private$.UserContext(); } return this.sharedContext; } clonedSharedUserContext() { - return j$.private.UserContext.fromExisting(this.sharedUserContext()); + return private$.UserContext.fromExisting(this.sharedUserContext()); } handleException() { - if (arguments[0] instanceof j$.private.errors.ExpectationFailed) { + if (arguments[0] instanceof private$.errors.ExpectationFailed) { return; } @@ -11106,7 +11111,7 @@ getJasmineRequireObj().Suite = function(j$) { passed: false, error: arguments[0] }; - const failedExpectation = j$.private.buildExpectationResult(data); + const failedExpectation = private$.buildExpectationResult(data); if (!this.parentSuite) { failedExpectation.globalErrorType = 'afterAll'; @@ -11148,7 +11153,7 @@ getJasmineRequireObj().Suite = function(j$) { return; } - const expectationResult = j$.private.buildExpectationResult(data); + const expectationResult = private$.buildExpectationResult(data); if (this.reportedDone) { this.onLateError(expectationResult); @@ -11157,7 +11162,7 @@ getJasmineRequireObj().Suite = function(j$) { } if (this.#throwOnExpectationFailure) { - throw new j$.private.errors.ExpectationFailed(); + throw new private$.errors.ExpectationFailed(); } } @@ -11166,7 +11171,7 @@ getJasmineRequireObj().Suite = function(j$) { deprecation = { message: deprecation }; } this.#result.deprecationWarnings.push( - j$.private.buildExpectationResult(deprecation) + private$.buildExpectationResult(deprecation) ); } @@ -11270,7 +11275,7 @@ getJasmineRequireObj().Suite = function(j$) { return Suite; }; -getJasmineRequireObj().SuiteBuilder = function(j$) { +getJasmineRequireObj().SuiteBuilder = function(j$, private$) { 'use strict'; class SuiteBuilder { @@ -11366,7 +11371,7 @@ getJasmineRequireObj().SuiteBuilder = function(j$) { ensureIsFunctionOrAsync(fn, 'fit'); if (timeout) { - j$.private.util.validateTimeout(timeout); + private$.util.validateTimeout(timeout); } const spec = this.specFactory_(description, fn, timeout, filename); this.currentDeclarationSuite_.addChild(spec); @@ -11379,7 +11384,7 @@ getJasmineRequireObj().SuiteBuilder = function(j$) { ensureIsFunctionOrAsync(beforeEachFunction, 'beforeEach'); if (timeout) { - j$.private.util.validateTimeout(timeout); + private$.util.validateTimeout(timeout); } this.currentDeclarationSuite_.beforeEach({ @@ -11392,7 +11397,7 @@ getJasmineRequireObj().SuiteBuilder = function(j$) { ensureIsFunctionOrAsync(beforeAllFunction, 'beforeAll'); if (timeout) { - j$.private.util.validateTimeout(timeout); + private$.util.validateTimeout(timeout); } this.currentDeclarationSuite_.beforeAll({ @@ -11405,7 +11410,7 @@ getJasmineRequireObj().SuiteBuilder = function(j$) { ensureIsFunctionOrAsync(afterEachFunction, 'afterEach'); if (timeout) { - j$.private.util.validateTimeout(timeout); + private$.util.validateTimeout(timeout); } afterEachFunction.isCleanup = true; @@ -11419,7 +11424,7 @@ getJasmineRequireObj().SuiteBuilder = function(j$) { ensureIsFunctionOrAsync(afterAllFunction, 'afterAll'); if (timeout) { - j$.private.util.validateTimeout(timeout); + private$.util.validateTimeout(timeout); } this.currentDeclarationSuite_.afterAll({ @@ -11430,7 +11435,7 @@ getJasmineRequireObj().SuiteBuilder = function(j$) { it_(description, fn, timeout, filename) { if (timeout) { - j$.private.util.validateTimeout(timeout); + private$.util.validateTimeout(timeout); } this.checkDuplicate_(description, 'spec'); @@ -11469,7 +11474,7 @@ getJasmineRequireObj().SuiteBuilder = function(j$) { const parentSuite = this.currentDeclarationSuite_; const reportedParentSuiteId = parentSuite === this.topSuite ? null : parentSuite.id; - return new j$.private.Suite({ + return new private$.Suite({ id: 'suite' + this.nextSuiteId_++, description, filename, @@ -11511,7 +11516,7 @@ getJasmineRequireObj().SuiteBuilder = function(j$) { const config = this.env_.configuration(); const suite = this.currentDeclarationSuite_; const parentSuiteId = suite === this.topSuite ? null : suite.id; - const spec = new j$.private.Spec({ + const spec = new private$.Spec({ id: 'spec' + this.nextSpecId_++, filename, parentSuiteId, @@ -11574,21 +11579,21 @@ getJasmineRequireObj().SuiteBuilder = function(j$) { } function ensureIsFunction(fn, caller) { - if (!j$.private.isFunction(fn)) { + if (!private$.isFunction(fn)) { throw new Error( caller + ' expects a function argument; received ' + - j$.private.getType(fn) + private$.getType(fn) ); } } function ensureIsFunctionOrAsync(fn, caller) { - if (!j$.private.isFunction(fn) && !j$.private.isAsyncFunction(fn)) { + if (!private$.isFunction(fn) && !private$.isAsyncFunction(fn)) { throw new Error( caller + ' expects a function argument; received ' + - j$.private.getType(fn) + private$.getType(fn) ); } } @@ -11662,7 +11667,7 @@ getJasmineRequireObj().Timer = function() { return Timer; }; -getJasmineRequireObj().TreeProcessor = function(j$) { +getJasmineRequireObj().TreeProcessor = function(j$, private$) { 'use strict'; const defaultMin = Infinity; @@ -11888,7 +11893,7 @@ getJasmineRequireObj().TreeProcessor = function(j$) { return TreeProcessor; }; -getJasmineRequireObj().TreeRunner = function(j$) { +getJasmineRequireObj().TreeRunner = function(j$, private$) { 'use strict'; class TreeRunner { @@ -11973,14 +11978,14 @@ getJasmineRequireObj().TreeRunner = function(j$) { }, onComplete: () => { if (spec.status() === 'failed') { - specOverallDone(new j$.private.StopExecutionError('spec failed')); + specOverallDone(new private$.StopExecutionError('spec failed')); } else { specOverallDone(); } }, userContext: spec.userContext(), runnableName: spec.getFullName.bind(spec), - SkipPolicy: j$.private.CompleteOnFirstErrorSkipPolicy + SkipPolicy: private$.CompleteOnFirstErrorSkipPolicy }); } @@ -12155,7 +12160,7 @@ getJasmineRequireObj().TreeRunner = function(j$) { async #reportChildrenOfBeforeAllFailure(suite) { for (const child of suite.children) { - if (child instanceof j$.private.Suite) { + if (child instanceof private$.Suite) { await this.#reportDispatcher.suiteStarted(child.startedEvent()); await this.#reportChildrenOfBeforeAllFailure(child); await this.#reportDispatcher.suiteDone(child.doneEvent()); @@ -12170,9 +12175,9 @@ getJasmineRequireObj().TreeRunner = function(j$) { #suiteSkipPolicy() { if (this.#getConfig().stopOnSpecFailure) { - return j$.private.CompleteOnFirstErrorSkipPolicy; + return private$.CompleteOnFirstErrorSkipPolicy; } else { - return j$.private.SkipAfterBeforeAllErrorPolicy; + return private$.SkipAfterBeforeAllErrorPolicy; } } } @@ -12180,7 +12185,7 @@ getJasmineRequireObj().TreeRunner = function(j$) { return TreeRunner; }; -getJasmineRequireObj().UserContext = function(j$) { +getJasmineRequireObj().UserContext = function(j$, private$) { 'use strict'; function UserContext() {} @@ -12203,3 +12208,41 @@ getJasmineRequireObj().UserContext = function(j$) { getJasmineRequireObj().version = function() { return '6.0.0-alpha.2'; }; + +(function() { + 'use strict'; + + const isNode = typeof module !== 'undefined' && module.exports; + const jasmineRequire = getJasmineRequireObj(); + + function bootJasmine(options) { + const jasmine = jasmineRequire.core(jasmineRequire).jasmine; + const env = jasmine.getEnv(options); + const jasmineInterface = jasmineRequire.interface(jasmine, env); + const globals = { + jasmine, + ...jasmineInterface + }; + + return { + jasmine, + globals, + installGlobals(dest) { + dest = dest ?? globalThis; + + for (const [k, v] of Object.entries(globals)) { + dest[k] = v; + } + } + }; + } + + if (isNode) { + module.exports = bootJasmine({ suppressLoadErrors: true }); + } else { + // Browser + bootJasmine().installGlobals(); + } +})(); + +})() \ No newline at end of file diff --git a/package.json b/package.json index 6950dbf1..69a35110 100644 --- a/package.json +++ b/package.json @@ -28,6 +28,9 @@ "description": "Simple JavaScript testing framework for browsers and node.js", "homepage": "https://jasmine.github.io", "main": "./lib/jasmine-core.js", + "exports": { + ".": "./lib/jasmine-core.js" + }, "files": [ "LICENSE", "README.md", @@ -45,7 +48,7 @@ "eslint-plugin-compat": "^6.0.2", "glob": "^10.2.3", "globals": "^16.0.0", - "jasmine": "github:jasmine/jasmine-npm#6.0", + "jasmine": "file:../jasmine-npm", "jasmine-browser-runner": "github:jasmine/jasmine-browser-runner#4.0", "jsdom": "^26.0.0", "prettier": "1.17.1", diff --git a/scripts/buildStandaloneDist.js b/scripts/buildStandaloneDist.js index 2623700a..7f582642 100644 --- a/scripts/buildStandaloneDist.js +++ b/scripts/buildStandaloneDist.js @@ -42,8 +42,7 @@ async function zipStandaloneDist(jasmineVersion) { 'lib/jasmine-core/jasmine.js', 'lib/jasmine-core/jasmine-html.js', 'lib/jasmine-core/jasmine.css', - 'lib/jasmine-core/boot0.js', - 'lib/jasmine-core/boot1.js', + 'lib/jasmine-core/boot.js', ], destDir: 'lib/jasmine-' + jasmineVersion }, diff --git a/scripts/lib/buildDistribution.js b/scripts/lib/buildDistribution.js index 7142f9be..b80f03ff 100644 --- a/scripts/lib/buildDistribution.js +++ b/scripts/lib/buildDistribution.js @@ -34,16 +34,20 @@ function concatFiles() { const configs = [ { src: [ + { literal: '(function() {' }, 'src/html/requireHtml.js', 'src/html/ResultsNode.js', 'src/html/QueryString.js', - 'src/html/**/*.js' + { glob: 'src/html/**/*.js', exclude: 'src/html/requireSuffix.js' }, + 'src/html/requireSuffix.js', + { literal: '})()' }, ], dest: 'lib/jasmine-core/jasmine-html.js', }, { dest: 'lib/jasmine-core/jasmine.js', src: [ + { literal: '(function() {' }, 'src/core/requireCore.js', 'src/core/matchers/requireMatchers.js', 'src/core/base.js', @@ -53,20 +57,18 @@ function concatFiles() { 'src/core/Env.js', 'src/core/PrettyPrinter', 'src/core/Suite', - 'src/core/**/*.js', + { glob: 'src/core/**/*.js', exclude: 'src/core/requireSuffix.js'}, { template: 'src/version.js', data: {version: pkg.version} }, + 'src/core/requireSuffix.js', + { literal: '})()' }, ], }, { - dest: 'lib/jasmine-core/boot0.js', - src: ['src/boot/boot0.js'], - }, - { - dest: 'lib/jasmine-core/boot1.js', - src: ['src/boot/boot1.js'], + dest: 'lib/jasmine-core/boot.js', + src: ['src/boot/boot.js'], }, { dest: 'lib/jasmine-core.js', @@ -82,25 +84,28 @@ function concatFiles() { src.unshift(licenseBanner); function expand(srcListEntry) { - if (typeof srcListEntry === 'object') { + if (typeof srcListEntry === 'object' && !srcListEntry.glob) { return srcListEntry; } - return glob.sync(srcListEntry) - .sort(function (a, b) { - // Match the sort order of previous build tools, so that the - // output is the same. - a = a.toLowerCase(); - b = b.toLowerCase(); + const matches = glob.sync( + srcListEntry.glob ?? srcListEntry, + {ignore: srcListEntry.exclude} + ); + return matches.sort(function (a, b) { + // Match the sort order of previous build tools, so that the + // output is the same. + a = a.toLowerCase(); + b = b.toLowerCase(); - if (a < b) { - return -1; - } else if (a === b) { - return 0; - } else { - return 1; - } - }); + if (a < b) { + return -1; + } else if (a === b) { + return 0; + } else { + return 1; + } + }); } const srcs = src.flatMap(expand); @@ -114,6 +119,8 @@ function concatFiles() { if (s.template) { const template = fs.readFileSync(s.template, {encoding: 'utf8'}); content = ejs.render(template, s.data); + } else if (s.literal) { + content = s.literal; } else { content = fs.readFileSync(s, {encoding: 'utf8'}); } diff --git a/scripts/runSpecsInNode.js b/scripts/runSpecsInNode.js index 08e772f3..960af11e 100644 --- a/scripts/runSpecsInNode.js +++ b/scripts/runSpecsInNode.js @@ -1,8 +1,9 @@ -verifyNoGlobals(() => require('../lib/jasmine-core.js').noGlobals()); +let jasmineCore; +verifyNoGlobals(() => { jasmineCore = require('../lib/jasmine-core.js'); }); +jasmineCore.installGlobals(); const Jasmine = require('jasmine'); -const jasmineCore = require('../lib/jasmine-core.js'); -const runner = new Jasmine({jasmineCore: jasmineCore}); +const runner = new Jasmine({jasmineCore}); runner.loadConfigFile('./spec/support/jasmine.json'); runner.exitOnCompletion = false; diff --git a/spec/core/ExceptionFormatterSpec.js b/spec/core/ExceptionFormatterSpec.js index 47217fd6..636589d7 100644 --- a/spec/core/ExceptionFormatterSpec.js +++ b/spec/core/ExceptionFormatterSpec.js @@ -173,10 +173,13 @@ describe('ExceptionFormatter', function() { }); it('filters Jasmine stack frames in this environment', function() { + const jasmineFile = (function() { + const trace = new privateUnderTest.StackTrace(new Error()); + return trace.frames[2].file; + })(); + expect(jasmineFile).toMatch(/\/jasmine.js$/); const error = new Error('an error'); - const subject = new privateUnderTest.ExceptionFormatter({ - jasmineFile: jasmine.private.util.jasmineFile() - }); + const subject = new privateUnderTest.ExceptionFormatter({ jasmineFile }); const result = subject.stack(error); jasmine.debugLog('Original stack trace: ' + error.stack); jasmine.debugLog('Filtered stack trace: ' + result); @@ -196,15 +199,18 @@ describe('ExceptionFormatter', function() { }); it('handles multiline error messages in this environment', function() { + const jasmineFile = (function() { + const trace = new privateUnderTest.StackTrace(new Error()); + return trace.frames[2].file; + })(); + expect(jasmineFile).toMatch(/\/jasmine.js$/); const msg = 'an error\nwith two lines'; const error = new Error(msg); if (error.stack.indexOf(msg) === -1) { pending("Stack traces don't have messages in this environment"); } - const subject = new privateUnderTest.ExceptionFormatter({ - jasmineFile: jasmine.private.util.jasmineFile() - }); + const subject = new privateUnderTest.ExceptionFormatter({ jasmineFile }); const result = subject.stack(error); const lines = result.split('\n'); @@ -284,7 +290,7 @@ describe('ExceptionFormatter', function() { it('ensures that stack traces do not include the message in this environment', function() { const error = new Error('an error'); const subject = new privateUnderTest.ExceptionFormatter({ - jasmineFile: jasmine.private.util.jasmineFile() + jasmineFile: "doesn't matter" }); const result = subject.stack(error, { omitMessage: true }); expect(result).not.toContain('an error'); diff --git a/spec/core/SpecSpec.js b/spec/core/SpecSpec.js index 48b2ecef..da2b47cd 100644 --- a/spec/core/SpecSpec.js +++ b/spec/core/SpecSpec.js @@ -278,7 +278,7 @@ describe('Spec', function() { spec.addExpectationResult(true, { message: 'passed' }); expect(function() { spec.addExpectationResult(false, { message: 'failed' }); - }).toThrowError(jasmineUnderTest.private.errors.ExpectationFailed); + }).toThrowError(privateUnderTest.errors.ExpectationFailed); expect(spec.doneEvent().failedExpectations).toEqual([ jasmine.objectContaining({ message: 'failed' }) @@ -453,9 +453,7 @@ describe('Spec', function() { queueableFn: {} }); - spec.handleException( - new jasmineUnderTest.private.errors.ExpectationFailed() - ); + spec.handleException(new privateUnderTest.errors.ExpectationFailed()); expect(spec.doneEvent().failedExpectations).toEqual([]); }); diff --git a/spec/core/SuiteSpec.js b/spec/core/SuiteSpec.js index dc771bde..c1649141 100644 --- a/spec/core/SuiteSpec.js +++ b/spec/core/SuiteSpec.js @@ -138,7 +138,7 @@ describe('Suite', function() { expect(function() { suite.addExpectationResult(false, { message: 'failed' }); - }).toThrowError(jasmineUnderTest.private.errors.ExpectationFailed); + }).toThrowError(privateUnderTest.errors.ExpectationFailed); expect(suite.doneEvent().status).toBe('failed'); expect(suite.doneEvent().failedExpectations).toEqual([ @@ -149,9 +149,7 @@ describe('Suite', function() { it('does not add an additional failure when an expectation fails', function() { const suite = new privateUnderTest.Suite({}); - suite.handleException( - new jasmineUnderTest.private.errors.ExpectationFailed() - ); + suite.handleException(new privateUnderTest.errors.ExpectationFailed()); expect(suite.doneEvent().failedExpectations).toEqual([]); }); diff --git a/spec/core/UtilSpec.js b/spec/core/UtilSpec.js index 0ab7d919..96bab359 100644 --- a/spec/core/UtilSpec.js +++ b/spec/core/UtilSpec.js @@ -163,7 +163,6 @@ describe('util', function() { // Chrome sometimes reports foo.js as foo.js/, so tolerate // a trailing slash if present. expect(privateUnderTest.util.jasmineFile()).toMatch(/util.js\/?$/); - expect(jasmine.private.util.jasmineFile()).toMatch(/jasmine.js\/?$/); }); }); }); diff --git a/spec/core/integration/EnvSpec.js b/spec/core/integration/EnvSpec.js index c1886772..df8c4635 100644 --- a/spec/core/integration/EnvSpec.js +++ b/spec/core/integration/EnvSpec.js @@ -1289,9 +1289,7 @@ describe('Env integration', function() { await env.execute(); expect(reporter.specDone).toHaveBeenCalledTimes(1); const event = reporter.specDone.calls.argsFor(0)[0]; - jasmine.debugLog( - 'Spec result: ' + jasmine.private.basicPrettyPrinter(event) - ); + jasmine.debugLog('Spec result: ' + jasmine.pp(event)); expect(event).toEqual(jasmine.objectContaining({ status: 'passed' })); jasmine.clock().tick(1); diff --git a/spec/core/jasmineNamespaceSpec.js b/spec/core/jasmineNamespaceSpec.js index eb69c6be..93ae2c3b 100644 --- a/spec/core/jasmineNamespaceSpec.js +++ b/spec/core/jasmineNamespaceSpec.js @@ -24,7 +24,6 @@ describe('The jasmine namespace', function() { 'getEnv', 'isSpy', 'ParallelReportDispatcher', - 'private', 'spyOnGlobalErrorsAsync', 'Timer', 'version', diff --git a/spec/helpers/defineJasmineUnderTest.js b/spec/helpers/defineJasmineUnderTest.js index 15d35dc6..eadfdd33 100644 --- a/spec/helpers/defineJasmineUnderTest.js +++ b/spec/helpers/defineJasmineUnderTest.js @@ -1,9 +1,11 @@ (function() { - // By the time onload is called, jasmineRequire will be redefined to point - // to the Jasmine source files (and not jasmine.js). So re-require - window.jasmineUnderTest = jasmineRequire.core(jasmineRequire); - jasmineRequire.html(jasmineUnderTest); + // By the time onload is called, getJasmineRequireObj() and + // getJasmineHtmlRequireObj() will be redefined to point + // to the Jasmine source files (and not jasmine.js). So re-require. + const jasmineRequire = getJasmineRequireObj(); + const coreUnderTest = jasmineRequire.core(jasmineRequire); + window.jasmineUnderTest = coreUnderTest.jasmine; + window.privateUnderTest = coreUnderTest.private; - // Alias the private namespace so tests can be less verbose - window.privateUnderTest = window.jasmineUnderTest.private; + getJasmineHtmlRequireObj().html(jasmineUnderTest, privateUnderTest); })(); diff --git a/spec/helpers/integrationMatchers.js b/spec/helpers/integrationMatchers.js index 76254bf6..ca1fb693 100644 --- a/spec/helpers/integrationMatchers.js +++ b/spec/helpers/integrationMatchers.js @@ -42,9 +42,9 @@ : 'Expected runnable "' + fullName + '" to have failures ' + - jasmine.private.basicPrettyPrinter(expectedFailures) + + jasmine.pp(expectedFailures) + ' but it had ' + - jasmine.private.basicPrettyPrinter(foundFailures) + jasmine.pp(foundFailures) }; } }; diff --git a/spec/helpers/nodeDefineJasmineUnderTest.js b/spec/helpers/nodeDefineJasmineUnderTest.js index ca9382bf..17a27a51 100644 --- a/spec/helpers/nodeDefineJasmineUnderTest.js +++ b/spec/helpers/nodeDefineJasmineUnderTest.js @@ -7,24 +7,29 @@ '../../src/core/requireCore.js' )); + // Individual source files call getJasmineRequireObj. It's normally defined + // by requireCore.js which is concatenated into jasmine.js before other source + // files. Since we're bypassing that mechanism, we need to provide our own. global.getJasmineRequireObj = function() { return jasmineUnderTestRequire; }; - function getSourceFiles() { - const globs = ['../../src/core/**/*.js', '../../src/version.js']; - const srcFiles = globs.flatMap(g => glob.sync(g, { cwd: __dirname })); + const srcFiles = [ + ...glob.sync('../../src/core/**/*.js', { + ignore: '../../src/core/requireSuffix.js', + cwd: __dirname + }), + '../../src/version.js', + '../../src/core/requireCore.js' + ]; - for (const file of srcFiles) { - require(file); - } + for (const file of srcFiles) { + require(file); } - getSourceFiles(); - global.jasmineUnderTest = jasmineUnderTestRequire.core( - jasmineUnderTestRequire - ); + delete global.getJasmineRequireObj; - // Alias the private namespace so tests can be less verbose - global.privateUnderTest = global.jasmineUnderTest.private; + const built = jasmineUnderTestRequire.core(jasmineUnderTestRequire); + global.jasmineUnderTest = built.jasmine; + global.privateUnderTest = built.private; })(); diff --git a/spec/npmPackage/npmPackageSpec.js b/spec/npmPackage/npmPackageSpec.js index 86d3f126..bf3796bd 100644 --- a/spec/npmPackage/npmPackageSpec.js +++ b/spec/npmPackage/npmPackageSpec.js @@ -77,7 +77,7 @@ describe('npm package', function() { }); it('has bootFiles', function() { - expect(this.packagedCore.files.bootFiles).toEqual(['boot0.js', 'boot1.js']); + expect(this.packagedCore.files.bootFiles).toEqual(['boot.js']); for (const fileName of this.packagedCore.files.bootFiles) { expect(fileName).toExistInPath(this.packagedCore.files.bootDir); diff --git a/spec/support/jasmine-browser.js b/spec/support/jasmine-browser.js index 36b99cdc..e19d9f1a 100644 --- a/spec/support/jasmine-browser.js +++ b/spec/support/jasmine-browser.js @@ -12,7 +12,9 @@ module.exports = { 'core/**/*.js', 'html/**/*.js', '**/*.js', - '!boot/**.js' + '!boot/**.js', + '!core/requireSuffix.js', + '!html/requireSuffix.js' ], specDir: 'spec', specFiles: ['**/*[Ss]pec.js', '!npmPackage/**/*'], diff --git a/src/SpecRunner.html.ejs b/src/SpecRunner.html.ejs index 23c1d327..7ac05ac3 100644 --- a/src/SpecRunner.html.ejs +++ b/src/SpecRunner.html.ejs @@ -8,10 +8,10 @@ - + - + diff --git a/src/boot/boot1.js b/src/boot/boot.js similarity index 50% rename from src/boot/boot1.js rename to src/boot/boot.js index bf0d2891..7ab1ddbc 100644 --- a/src/boot/boot1.js +++ b/src/boot/boot.js @@ -1,18 +1,5 @@ 'use strict'; -/** - This file finishes 'booting' Jasmine, performing all of the necessary - initialization before executing the loaded environment and all of a project's - specs. This file should be loaded after `boot0.js` but before any project - source files or spec files are loaded. Thus this file can also be used to - customize Jasmine for a project. - - If a project is using Jasmine via the standalone distribution, this file can - be customized directly. If you only wish to configure the Jasmine env, you - can load another file that calls `jasmine.getEnv().configure({...})` - after `boot0.js` is loaded and before this file is loaded. - */ - (function() { const env = jasmine.getEnv(); const urls = new jasmine.HtmlReporterV2Urls(); @@ -25,11 +12,16 @@ */ env.configure(urls.configFromCurrentUrl()); - window.addEventListener('load', function() { + const currentWindowOnload = window.onload; + window.onload = function() { + if (currentWindowOnload) { + currentWindowOnload(); + } + // The HTML reporter needs to be set up here so it can access the DOM. Other // reporters can be added at any time before env.execute() is called. const htmlReporter = new jasmine.HtmlReporterV2({ env, urls }); env.addReporter(htmlReporter); env.execute(); - }); + }; })(); diff --git a/src/boot/boot0.js b/src/boot/boot0.js deleted file mode 100644 index 0bb9da86..00000000 --- a/src/boot/boot0.js +++ /dev/null @@ -1,44 +0,0 @@ -'use strict'; - -/** - This file starts the process of "booting" Jasmine. It initializes Jasmine, - makes its globals available, and creates the env. This file should be loaded - after `jasmine.js` and `jasmine_html.js`, but before `boot1.js` or any project - source files or spec files are loaded. - */ -(function() { - const jasmineRequire = window.jasmineRequire || require('./jasmine.js'); - - /** - * ## Require & Instantiate - * - * Require Jasmine's core files. Specifically, this requires and attaches all of Jasmine's code to the `jasmine` reference. - */ - const jasmine = jasmineRequire.core(jasmineRequire), - global = jasmine.getGlobal(); - global.jasmine = jasmine; - - /** - * Since this is being run in a browser and the results should populate to an HTML page, require the HTML-specific Jasmine code, injecting the same reference. - */ - jasmineRequire.html(jasmine); - - /** - * Create the Jasmine environment. This is used to run all specs in a project. - */ - const env = jasmine.getEnv(); - - /** - * ## The Global Interface - * - * Build up the functions that will be exposed as the Jasmine public interface. A project can customize, rename or alias any of these functions as desired, provided the implementation remains unchanged. - */ - const jasmineInterface = jasmineRequire.interface(jasmine, env); - - /** - * Add all of the Jasmine global/public interface to the global scope, so a project can use the public interface directly. For example, calling `describe` in specs instead of `jasmine.getEnv().describe`. - */ - for (const property in jasmineInterface) { - global[property] = jasmineInterface[property]; - } -})(); diff --git a/src/boot/jasmine-core.js b/src/boot/jasmine-core.js index 1ceab28c..f65f6a21 100644 --- a/src/boot/jasmine-core.js +++ b/src/boot/jasmine-core.js @@ -1,69 +1,24 @@ 'use strict'; -/** - * Note: Only available on Node. - * @module jasmine-core - */ +const path = require('path'); +const fs = require('fs'); +const { + globals, + installGlobals, + private$ +} = require('./jasmine-core/jasmine.js'); -const jasmineRequire = require('./jasmine-core/jasmine.js'); -module.exports = jasmineRequire; - -const bootWithoutGlobals = (function() { - let jasmine, jasmineInterface; - - return function bootWithoutGlobals(reinitialize) { - if (!jasmineInterface || reinitialize === true) { - jasmine = jasmineRequire.core(jasmineRequire); - const env = jasmine.getEnv({ suppressLoadErrors: true }); - jasmineInterface = jasmineRequire.interface(jasmine, env); - } - - return { jasmine, jasmineInterface }; - }; -})(); - -/** - * Boots a copy of Jasmine and returns an object as described in {@link jasmine}. - * @param {boolean} [reinitialize=true] Whether to create a new copy of Jasmine if one already exists - * @type {function} - * @return {jasmine} - */ -module.exports.boot = function(reinitialize) { - if (reinitialize === undefined) { - reinitialize = true; - } - - const { jasmine, jasmineInterface } = bootWithoutGlobals(reinitialize); - - for (const k in jasmineInterface) { - global[k] = jasmineInterface[k]; - } - - return jasmine; -}; - -/** - * Boots a copy of Jasmine and returns an object containing the properties - * that would normally be added to the global object. If noGlobals is called - * multiple times, the same object is returned every time. - * - * @example - * const {describe, beforeEach, it, expect, jasmine} = require('jasmine-core').noGlobals(); - */ -module.exports.noGlobals = function() { - const { jasmineInterface } = bootWithoutGlobals(false); - return jasmineInterface; -}; - -const path = require('path'), - fs = require('fs'); +function reset() { + private$.currentEnv_ = null; + const env = jasmine.getEnv({ suppressLoadErrors: true }); + rebindInterface(env); +} const rootPath = path.join(__dirname, 'jasmine-core'), - bootFiles = ['boot0.js', 'boot1.js'], - legacyBootFiles = ['boot.js'], + bootFiles = ['boot.js'], cssFiles = [], jsFiles = [], - jsFilesToSkip = ['jasmine.js'].concat(bootFiles, legacyBootFiles); + jsFilesToSkip = ['jasmine.js'].concat(bootFiles); fs.readdirSync(rootPath).forEach(function(file) { if (fs.statSync(path.join(rootPath, file)).isFile()) { @@ -80,12 +35,35 @@ fs.readdirSync(rootPath).forEach(function(file) { } }); -module.exports.files = { - self: __filename, - path: rootPath, - bootDir: rootPath, - bootFiles: bootFiles, - cssFiles: cssFiles, - jsFiles: ['jasmine.js'].concat(jsFiles), - imagesDir: path.join(__dirname, '../images') +/** + * Note: Only available on Node. + * + * In addition to the members documented here, this module's exports include all + * {@link globals}. + * @module jasmine-core + */ +module.exports = { + ...globals, + /** + * Copies Jasmine globals (jasmine, describe, it, etc) to the specified + * object or to globalThis. + * @function + * @param {object} [dest] - The object to copy globals to. + */ + installGlobals, + /** + * Resets all of jasmine-core's state, including removing specs, suites, and + * reporters, and resetting configuration to the default. + * @function + */ + reset, + files: { + self: __filename, + path: rootPath, + bootDir: rootPath, + bootFiles: bootFiles, + cssFiles: cssFiles, + jsFiles: ['jasmine.js'].concat(jsFiles), + imagesDir: path.join(__dirname, '../images') + } }; diff --git a/src/core/CallTracker.js b/src/core/CallTracker.js index 7eeee8ca..0b3a99dc 100644 --- a/src/core/CallTracker.js +++ b/src/core/CallTracker.js @@ -1,4 +1,4 @@ -getJasmineRequireObj().CallTracker = function(j$) { +getJasmineRequireObj().CallTracker = function(j$, private$) { 'use strict'; /** @@ -125,9 +125,7 @@ getJasmineRequireObj().CallTracker = function(j$) { * @param {Function} [argsCloner] A function to use to clone the arguments. Defaults to a shallow cloning function. * @function */ - this.saveArgumentsByValue = function( - argsCloner = j$.private.util.cloneArgs - ) { + this.saveArgumentsByValue = function(argsCloner = private$.util.cloneArgs) { opts.cloneArgs = true; opts.argsCloner = argsCloner; }; diff --git a/src/core/Clock.js b/src/core/Clock.js index da743cfc..883e84df 100644 --- a/src/core/Clock.js +++ b/src/core/Clock.js @@ -1,4 +1,4 @@ -getJasmineRequireObj().Clock = function(j$) { +getJasmineRequireObj().Clock = function(j$, private$) { 'use strict'; /* global process */ diff --git a/src/core/CompleteOnFirstErrorSkipPolicy.js b/src/core/CompleteOnFirstErrorSkipPolicy.js index 0d1bd9d0..50c5af63 100644 --- a/src/core/CompleteOnFirstErrorSkipPolicy.js +++ b/src/core/CompleteOnFirstErrorSkipPolicy.js @@ -1,4 +1,4 @@ -getJasmineRequireObj().CompleteOnFirstErrorSkipPolicy = function(j$) { +getJasmineRequireObj().CompleteOnFirstErrorSkipPolicy = function(j$, private$) { 'use strict'; function CompleteOnFirstErrorSkipPolicy(queueableFns) { diff --git a/src/core/Configuration.js b/src/core/Configuration.js index ca40749d..f6557747 100644 --- a/src/core/Configuration.js +++ b/src/core/Configuration.js @@ -1,4 +1,4 @@ -getJasmineRequireObj().Configuration = function(j$) { +getJasmineRequireObj().Configuration = function(j$, private$) { 'use strict'; /** diff --git a/src/core/DelayedFunctionScheduler.js b/src/core/DelayedFunctionScheduler.js index b59c88cf..75d43f60 100644 --- a/src/core/DelayedFunctionScheduler.js +++ b/src/core/DelayedFunctionScheduler.js @@ -1,4 +1,4 @@ -getJasmineRequireObj().DelayedFunctionScheduler = function(j$) { +getJasmineRequireObj().DelayedFunctionScheduler = function(j$, private$) { 'use strict'; function DelayedFunctionScheduler() { diff --git a/src/core/Deprecator.js b/src/core/Deprecator.js index 7686c70e..e1d1e883 100644 --- a/src/core/Deprecator.js +++ b/src/core/Deprecator.js @@ -1,4 +1,4 @@ -getJasmineRequireObj().Deprecator = function(j$) { +getJasmineRequireObj().Deprecator = function(j$, private$) { 'use strict'; function Deprecator(topSuite) { @@ -25,7 +25,7 @@ getJasmineRequireObj().Deprecator = function(j$) { ) { options = options || {}; - if (!this.verbose_ && !j$.private.isError(deprecation)) { + if (!this.verbose_ && !private$.isError(deprecation)) { if (this.toSuppress_.indexOf(deprecation) !== -1) { return; } @@ -37,7 +37,7 @@ getJasmineRequireObj().Deprecator = function(j$) { }; Deprecator.prototype.log_ = function(runnable, deprecation, options) { - if (j$.private.isError(deprecation)) { + if (private$.isError(deprecation)) { // eslint-disable-next-line no-console console.error(deprecation); return; @@ -66,7 +66,7 @@ getJasmineRequireObj().Deprecator = function(j$) { }; Deprecator.prototype.stackTrace_ = function() { - const formatter = new j$.private.ExceptionFormatter(); + const formatter = new private$.ExceptionFormatter(); return formatter.stack(new Error()).replace(/^Error\n/m, ''); }; @@ -75,7 +75,7 @@ getJasmineRequireObj().Deprecator = function(j$) { runnable = this.topSuite_; } - if (j$.private.isError(deprecation)) { + if (private$.isError(deprecation)) { runnable.addDeprecationWarning(deprecation); return; } diff --git a/src/core/Env.js b/src/core/Env.js index eb8cfaae..6e66a76d 100644 --- a/src/core/Env.js +++ b/src/core/Env.js @@ -1,4 +1,4 @@ -getJasmineRequireObj().Env = function(j$) { +getJasmineRequireObj().Env = function(j$, private$) { 'use strict'; const DEFAULT_IT_DESCRIBE_STACK_DEPTH = 3; @@ -15,18 +15,18 @@ getJasmineRequireObj().Env = function(j$) { envOptions = envOptions || {}; const self = this; - const GlobalErrors = envOptions.GlobalErrors || j$.private.GlobalErrors; + const GlobalErrors = envOptions.GlobalErrors || private$.GlobalErrors; const global = envOptions.global || j$.getGlobal(); const realSetTimeout = global.setTimeout; const realClearTimeout = global.clearTimeout; - const stackClearer = j$.private.getStackClearer(global); - this.clock = new j$.private.Clock( + const stackClearer = private$.getStackClearer(global); + this.clock = new private$.Clock( global, function() { - return new j$.private.DelayedFunctionScheduler(); + return new private$.DelayedFunctionScheduler(); }, - new j$.private.MockDate(global) + new private$.MockDate(global) ); const globalErrors = new GlobalErrors( @@ -54,7 +54,7 @@ getJasmineRequireObj().Env = function(j$) { }; })(); - const runableResources = new j$.private.RunableResources({ + const runableResources = new private$.RunableResources({ getCurrentRunableId: function() { const r = runner.currentRunable(); return r ? r.id : null; @@ -67,7 +67,7 @@ getJasmineRequireObj().Env = function(j$) { let runner; let parallelLoadingState = null; // 'specs', 'helpers', or null for non-parallel - const config = new j$.private.Configuration(); + const config = new private$.Configuration(); if (!envOptions.suppressLoadErrors) { installGlobalErrors(); @@ -137,11 +137,11 @@ getJasmineRequireObj().Env = function(j$) { runableResources.customObjectFormatters().push(formatter); }; - j$.private.Expectation.addCoreMatchers(j$.private.matchers); - j$.private.Expectation.addAsyncCoreMatchers(j$.private.asyncMatchers); + private$.Expectation.addCoreMatchers(private$.matchers); + private$.Expectation.addAsyncCoreMatchers(private$.asyncMatchers); const expectationFactory = function(actual, spec) { - return j$.private.Expectation.factory({ + return private$.Expectation.factory({ matchersUtil: runableResources.makeMatchersUtil(), customMatchers: runableResources.customMatchers(), actual: actual, @@ -174,7 +174,7 @@ getJasmineRequireObj().Env = function(j$) { }; const throwUnlessFactory = function(actual, spec) { - return j$.private.Expectation.factory({ + return private$.Expectation.factory({ matchersUtil: runableResources.makeMatchersUtil(), customMatchers: runableResources.customMatchers(), actual: actual, @@ -183,7 +183,7 @@ getJasmineRequireObj().Env = function(j$) { }; const throwUnlessAsyncFactory = function(actual, spec) { - return j$.private.Expectation.asyncFactory({ + return private$.Expectation.asyncFactory({ matchersUtil: runableResources.makeMatchersUtil(), customAsyncMatchers: runableResources.customAsyncMatchers(), actual: actual, @@ -198,7 +198,7 @@ getJasmineRequireObj().Env = function(j$) { error.matcherName !== undefined && error.passed !== undefined; const result = isExpectationResult ? error - : j$.private.buildExpectationResult({ + : private$.buildExpectationResult({ error, passed: false, matcherName: '', @@ -259,7 +259,7 @@ getJasmineRequireObj().Env = function(j$) { } const asyncExpectationFactory = function(actual, spec, runableType) { - return j$.private.Expectation.asyncFactory({ + return private$.Expectation.asyncFactory({ matchersUtil: runableResources.makeMatchersUtil(), customAsyncMatchers: runableResources.customAsyncMatchers(), actual: actual, @@ -318,10 +318,10 @@ getJasmineRequireObj().Env = function(j$) { (runner.currentRunable() || topSuite).handleException(e); }; - new j$.private.QueueRunner(options).execute(); + new private$.QueueRunner(options).execute(); } - const suiteBuilder = new j$.private.SuiteBuilder({ + const suiteBuilder = new private$.SuiteBuilder({ env: this, expectationFactory, asyncExpectationFactory, @@ -330,7 +330,7 @@ getJasmineRequireObj().Env = function(j$) { }); topSuite = suiteBuilder.topSuite; const deprecator = - envOptions?.deprecator ?? new j$.private.Deprecator(topSuite); + envOptions?.deprecator ?? new private$.Deprecator(topSuite); /** * Provides the root suite, through which all suites and specs can be @@ -350,23 +350,23 @@ getJasmineRequireObj().Env = function(j$) { * @interface Reporter * @see custom_reporter */ - reportDispatcher = new j$.private.ReportDispatcher( - j$.private.reporterEvents, + reportDispatcher = new private$.ReportDispatcher( + private$.reporterEvents, function(options) { - options.SkipPolicy = j$.private.NeverSkipPolicy; + options.SkipPolicy = private$.NeverSkipPolicy; return runQueue(options); }, recordLateError ); - runner = new j$.private.Runner({ + runner = new private$.Runner({ topSuite, totalSpecsDefined: () => suiteBuilder.totalSpecsDefined, focusedRunables: () => suiteBuilder.focusedRunables, runableResources, reportDispatcher, runQueue, - TreeProcessor: j$.private.TreeProcessor, + TreeProcessor: private$.TreeProcessor, globalErrors, getConfig: () => config }); @@ -411,7 +411,7 @@ getJasmineRequireObj().Env = function(j$) { // 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) { + if (private$.loadedAsBrowserEsm) { this.deprecated( "jasmine-core isn't an ES module but it was loaded as one. This is not a supported configuration." ); @@ -540,7 +540,7 @@ getJasmineRequireObj().Env = function(j$) { try { const maybePromise = fn(spy); - if (!j$.private.isPromiseLike(maybePromise)) { + if (!private$.isPromiseLike(maybePromise)) { throw new Error( 'The callback to spyOnGlobalErrorsAsync must be an async or promise-returning function' ); @@ -783,7 +783,7 @@ getJasmineRequireObj().Env = function(j$) { }; this.pending = function(message) { - let fullMessage = j$.private.Spec.pendingSpecExceptionMessage; + let fullMessage = private$.Spec.pendingSpecExceptionMessage; if (message) { fullMessage += message; } @@ -802,7 +802,7 @@ getJasmineRequireObj().Env = function(j$) { message += ': '; if (error.message) { message += error.message; - } else if (j$.private.isString(error)) { + } else if (private$.isString(error)) { message += error; } else { // pretty print all kind of objects. This includes arrays. @@ -828,7 +828,7 @@ getJasmineRequireObj().Env = function(j$) { this.pp = function(value) { const pp = runner.currentRunable() ? runableResources.makePrettyPrinter() - : j$.private.basicPrettyPrinter; + : private$.basicPrettyPrinter; return pp(value); }; @@ -838,7 +838,7 @@ getJasmineRequireObj().Env = function(j$) { } function indirectCallerFilename(depth) { - const frames = new j$.private.StackTrace(new Error()).frames; + const frames = new private$.StackTrace(new Error()).frames; // The specified frame should always exist except in Jasmine's own tests, // which bypass the global it/describe layer, but could be absent in case // of misconfiguration. Don't crash if it's absent. diff --git a/src/core/ExceptionFormatter.js b/src/core/ExceptionFormatter.js index 12d73645..7c6b8f01 100644 --- a/src/core/ExceptionFormatter.js +++ b/src/core/ExceptionFormatter.js @@ -1,4 +1,4 @@ -getJasmineRequireObj().ExceptionFormatter = function(j$) { +getJasmineRequireObj().ExceptionFormatter = function(j$, private$) { 'use strict'; const ignoredProperties = [ @@ -16,7 +16,7 @@ getJasmineRequireObj().ExceptionFormatter = function(j$) { function ExceptionFormatter(options) { const jasmineFile = - (options && options.jasmineFile) || j$.private.util.jasmineFile(); + (options && options.jasmineFile) || private$.util.jasmineFile(); this.message = function(error) { let message = ''; @@ -60,7 +60,7 @@ getJasmineRequireObj().ExceptionFormatter = function(j$) { lines.pop(); } - const stackTrace = new j$.private.StackTrace(error); + const stackTrace = new private$.StackTrace(error); lines = lines.concat(filterJasmine(stackTrace)); if (messageHandling === 'require') { @@ -114,7 +114,7 @@ getJasmineRequireObj().ExceptionFormatter = function(j$) { if (!empty) { return ( - 'error properties: ' + j$.private.basicPrettyPrinter(result) + '\n' + 'error properties: ' + private$.basicPrettyPrinter(result) + '\n' ); } diff --git a/src/core/Expectation.js b/src/core/Expectation.js index 4703ec6d..091606a7 100644 --- a/src/core/Expectation.js +++ b/src/core/Expectation.js @@ -1,4 +1,4 @@ -getJasmineRequireObj().Expectation = function(j$) { +getJasmineRequireObj().Expectation = function(j$, private$) { 'use strict'; /** @@ -6,7 +6,7 @@ getJasmineRequireObj().Expectation = function(j$) { * @namespace matchers */ function Expectation(options) { - this.expector = new j$.private.Expector(options); + this.expector = new private$.Expector(options); const customMatchers = options.customMatchers || {}; for (const matcherName in customMatchers) { @@ -82,7 +82,7 @@ getJasmineRequireObj().Expectation = function(j$) { * @namespace async-matchers */ function AsyncExpectation(options) { - this.expector = new j$.private.Expector(options); + this.expector = new private$.Expector(options); const customAsyncMatchers = options.customAsyncMatchers || {}; for (const matcherName in customAsyncMatchers) { @@ -175,7 +175,7 @@ getJasmineRequireObj().Expectation = function(j$) { function negatedFailureMessage(result, matcherName, args, matchersUtil) { if (result.message) { - if (j$.private.isFunction(result.message)) { + if (private$.isFunction(result.message)) { return result.message(); } else { return result.message; @@ -220,7 +220,7 @@ getJasmineRequireObj().Expectation = function(j$) { return function(actual) { const matcherArgs = arguments; - return j$.private.isPending(actual).then(function(isPending) { + return private$.isPending(actual).then(function(isPending) { if (isPending) { return { pass: false, diff --git a/src/core/Expector.js b/src/core/Expector.js index f833e2a1..df5ea405 100644 --- a/src/core/Expector.js +++ b/src/core/Expector.js @@ -1,4 +1,4 @@ -getJasmineRequireObj().Expector = function(j$) { +getJasmineRequireObj().Expector = function(j$, private$) { 'use strict'; function Expector(options) { @@ -7,7 +7,7 @@ getJasmineRequireObj().Expector = function(j$) { }; this.actual = options.actual; this.addExpectationResult = options.addExpectationResult || function() {}; - this.filters = new j$.private.ExpectationFilterChain(); + this.filters = new private$.ExpectationFilterChain(); } Expector.prototype.instantiateMatcher = function( @@ -41,7 +41,7 @@ getJasmineRequireObj().Expector = function(j$) { this.matchersUtil, args ); - } else if (j$.private.isFunction(result.message)) { + } else if (private$.isFunction(result.message)) { return result.message(); } else { return result.message; diff --git a/src/core/GlobalErrors.js b/src/core/GlobalErrors.js index a10c9a2b..fd5fefc0 100644 --- a/src/core/GlobalErrors.js +++ b/src/core/GlobalErrors.js @@ -1,4 +1,4 @@ -getJasmineRequireObj().GlobalErrors = function(j$) { +getJasmineRequireObj().GlobalErrors = function(j$, private$) { 'use strict'; class GlobalErrors { @@ -26,7 +26,7 @@ getJasmineRequireObj().GlobalErrors = function(j$) { if ( global.process && global.process.listeners && - j$.private.isFunction(global.process.on) + private$.isFunction(global.process.on) ) { this.#adapter = new NodeAdapter(global, dispatch); } else { @@ -183,7 +183,7 @@ getJasmineRequireObj().GlobalErrors = function(j$) { const jasmineMessage = 'Unhandled promise rejection: ' + event.reason; let reason; - if (j$.private.isError(event.reason)) { + if (private$.isError(event.reason)) { reason = event.reason; reason.jasmineMessage = jasmineMessage; } else { @@ -262,7 +262,7 @@ getJasmineRequireObj().GlobalErrors = function(j$) { jasmineMessagePrefix = 'Uncaught exception'; } - if (j$.private.isError(error)) { + if (private$.isError(error)) { error.jasmineMessage = jasmineMessagePrefix + ': ' + error; return error; } else { diff --git a/src/core/MockDate.js b/src/core/MockDate.js index ba6e9ca8..a18c1253 100644 --- a/src/core/MockDate.js +++ b/src/core/MockDate.js @@ -1,4 +1,4 @@ -getJasmineRequireObj().MockDate = function(j$) { +getJasmineRequireObj().MockDate = function(j$, private$) { 'use strict'; function MockDate(global) { diff --git a/src/core/NeverSkipPolicy.js b/src/core/NeverSkipPolicy.js index 8c76dff7..8a905ab9 100644 --- a/src/core/NeverSkipPolicy.js +++ b/src/core/NeverSkipPolicy.js @@ -1,4 +1,4 @@ -getJasmineRequireObj().NeverSkipPolicy = function(j$) { +getJasmineRequireObj().NeverSkipPolicy = function(j$, private$) { 'use strict'; function NeverSkipPolicy(queueableFns) {} diff --git a/src/core/ParallelReportDispatcher.js b/src/core/ParallelReportDispatcher.js index c6491d21..e47f3e2d 100644 --- a/src/core/ParallelReportDispatcher.js +++ b/src/core/ParallelReportDispatcher.js @@ -1,4 +1,4 @@ -getJasmineRequireObj().ParallelReportDispatcher = function(j$) { +getJasmineRequireObj().ParallelReportDispatcher = function(j$, private$) { 'use strict'; /** @@ -16,12 +16,11 @@ getJasmineRequireObj().ParallelReportDispatcher = function(j$) { * @param onError {function} Function called when an unhandled exception, unhandled promise rejection, or explicit reporter failure occurs */ function ParallelReportDispatcher(onError, deps = {}) { - const ReportDispatcher = - deps.ReportDispatcher || j$.private.ReportDispatcher; - const QueueRunner = deps.QueueRunner || j$.private.QueueRunner; - const globalErrors = deps.globalErrors || new j$.private.GlobalErrors(); + const ReportDispatcher = deps.ReportDispatcher || private$.ReportDispatcher; + const QueueRunner = deps.QueueRunner || private$.QueueRunner; + const globalErrors = deps.globalErrors || new private$.GlobalErrors(); const dispatcher = new ReportDispatcher( - j$.private.reporterEvents, + private$.reporterEvents, function(queueRunnerOptions) { queueRunnerOptions = { ...queueRunnerOptions, @@ -85,7 +84,7 @@ getJasmineRequireObj().ParallelReportDispatcher = function(j$) { } }; - for (const eventName of j$.private.reporterEvents) { + for (const eventName of private$.reporterEvents) { self[eventName] = dispatcher[eventName].bind(dispatcher); } diff --git a/src/core/PrettyPrinter.js b/src/core/PrettyPrinter.js index 9e506bce..85df0446 100644 --- a/src/core/PrettyPrinter.js +++ b/src/core/PrettyPrinter.js @@ -1,4 +1,4 @@ -getJasmineRequireObj().makePrettyPrinter = function(j$) { +getJasmineRequireObj().makePrettyPrinter = function(j$, private$) { 'use strict'; class SinglePrettyPrintRun { @@ -28,7 +28,7 @@ getJasmineRequireObj().makePrettyPrinter = function(j$) { this.emitScalar(''); } else if (value.jasmineToString) { this.emitScalar(value.jasmineToString(this.pp_)); - } else if (j$.private.isString(value)) { + } else if (private$.isString(value)) { this.emitString(value); } else if (j$.isSpy(value)) { this.emitScalar('spy on ' + value.and.identity); @@ -42,7 +42,7 @@ getJasmineRequireObj().makePrettyPrinter = function(j$) { } else { this.emitScalar('Function'); } - } else if (j$.private.isDomNode(value)) { + } else if (private$.isDomNode(value)) { if (value.tagName) { this.emitDomElement(value); } else { @@ -50,11 +50,11 @@ getJasmineRequireObj().makePrettyPrinter = function(j$) { } } else if (value instanceof Date) { this.emitScalar('Date(' + value + ')'); - } else if (j$.private.isSet(value)) { + } else if (private$.isSet(value)) { this.emitSet(value); - } else if (j$.private.isMap(value)) { + } else if (private$.isMap(value)) { this.emitMap(value); - } else if (j$.private.isTypedArray(value)) { + } else if (private$.isTypedArray(value)) { this.emitTypedArray(value); } else if ( value.toString && @@ -74,7 +74,7 @@ getJasmineRequireObj().makePrettyPrinter = function(j$) { (Array.isArray(value) ? 'Array' : 'Object') + '>' ); - } else if (Array.isArray(value) || j$.private.isA('Object', value)) { + } else if (Array.isArray(value) || private$.isA('Object', value)) { this.seen.push(value); if (Array.isArray(value)) { this.emitArray(value); @@ -99,7 +99,7 @@ getJasmineRequireObj().makePrettyPrinter = function(j$) { } iterateObject(obj, fn) { - const objKeys = j$.private.MatchersUtil.keys(obj, Array.isArray(obj)); + const objKeys = private$.MatchersUtil.keys(obj, Array.isArray(obj)); const length = Math.min(objKeys.length, j$.MAX_PRETTY_PRINT_ARRAY_LENGTH); for (let i = 0; i < length; i++) { @@ -208,7 +208,7 @@ getJasmineRequireObj().makePrettyPrinter = function(j$) { const ctor = obj.constructor; const constructorName = typeof ctor === 'function' && obj instanceof ctor - ? j$.private.fnNameFor(obj.constructor) + ? private$.fnNameFor(obj.constructor) : 'null'; this.append(constructorName); @@ -238,7 +238,7 @@ getJasmineRequireObj().makePrettyPrinter = function(j$) { } emitTypedArray(arr) { - const constructorName = j$.private.fnNameFor(arr.constructor); + const constructorName = private$.fnNameFor(arr.constructor); const limitedArray = Array.prototype.slice.call( arr, 0, @@ -307,7 +307,7 @@ getJasmineRequireObj().makePrettyPrinter = function(j$) { // iframe, web worker) try { return ( - j$.private.isFunction(value.toString) && + private$.isFunction(value.toString) && value.toString !== Object.prototype.toString && value.toString() !== Object.prototype.toString.call(value) ); diff --git a/src/core/QueueRunner.js b/src/core/QueueRunner.js index c9aa3240..f9665936 100644 --- a/src/core/QueueRunner.js +++ b/src/core/QueueRunner.js @@ -1,11 +1,11 @@ -getJasmineRequireObj().QueueRunner = function(j$) { +getJasmineRequireObj().QueueRunner = function(j$, private$) { 'use strict'; let nextid = 1; function StopExecutionError() {} StopExecutionError.prototype = new Error(); - j$.private.StopExecutionError = StopExecutionError; + private$.StopExecutionError = StopExecutionError; function once(fn, onTwice) { let called = false; @@ -58,7 +58,7 @@ getJasmineRequireObj().QueueRunner = function(j$) { }; this.onException = attrs.onException || emptyFn; this.onMultipleDone = attrs.onMultipleDone || fallbackOnMultipleDone; - this.userContext = attrs.userContext || new j$.private.UserContext(); + this.userContext = attrs.userContext || new private$.UserContext(); this.timeout = attrs.timeout || { setTimeout: setTimeout, clearTimeout: clearTimeout @@ -69,7 +69,7 @@ getJasmineRequireObj().QueueRunner = function(j$) { popListener: emptyFn }; - const SkipPolicy = attrs.SkipPolicy || j$.private.NeverSkipPolicy; + const SkipPolicy = attrs.SkipPolicy || private$.NeverSkipPolicy; this.skipPolicy_ = new SkipPolicy(this.queueableFns); this.errored_ = false; @@ -192,7 +192,7 @@ getJasmineRequireObj().QueueRunner = function(j$) { if (queueableFn.fn.length === 0) { maybeThenable = queueableFn.fn.call(this.userContext); - if (maybeThenable && j$.private.isFunction(maybeThenable.then)) { + if (maybeThenable && private$.isFunction(maybeThenable.then)) { maybeThenable.then( wrapInPromiseResolutionHandler(next), onPromiseRejection @@ -262,11 +262,11 @@ getJasmineRequireObj().QueueRunner = function(j$) { }; QueueRunner.prototype.diagnoseConflictingAsync_ = function(fn, retval) { - if (retval && j$.private.isFunction(retval.then)) { + if (retval && private$.isFunction(retval.then)) { // Issue a warning that matches the user's code. // Omit the stack trace because there's almost certainly no user code // on the stack at this point. - if (j$.private.isAsyncFunction(fn)) { + if (private$.isAsyncFunction(fn)) { this.onException( new Error( 'An asynchronous before/it/after ' + @@ -290,7 +290,7 @@ getJasmineRequireObj().QueueRunner = function(j$) { function wrapInPromiseResolutionHandler(fn) { return function(maybeArg) { - if (j$.private.isError(maybeArg)) { + if (private$.isError(maybeArg)) { fn(maybeArg); } else { fn(); diff --git a/src/core/ReportDispatcher.js b/src/core/ReportDispatcher.js index 22f7255e..51a7afee 100644 --- a/src/core/ReportDispatcher.js +++ b/src/core/ReportDispatcher.js @@ -1,4 +1,4 @@ -getJasmineRequireObj().ReportDispatcher = function(j$) { +getJasmineRequireObj().ReportDispatcher = function(j$, private$) { 'use strict'; function ReportDispatcher(methods, runQueue, onLateError) { diff --git a/src/core/RunableResources.js b/src/core/RunableResources.js index eb14a86b..b173e7fc 100644 --- a/src/core/RunableResources.js +++ b/src/core/RunableResources.js @@ -1,4 +1,4 @@ -getJasmineRequireObj().RunableResources = function(j$) { +getJasmineRequireObj().RunableResources = function(j$, private$) { 'use strict'; class RunableResources { @@ -7,7 +7,7 @@ getJasmineRequireObj().RunableResources = function(j$) { this.getCurrentRunableId_ = options.getCurrentRunableId; this.globalErrors_ = options.globalErrors; - this.spyFactory = new j$.private.SpyFactory( + this.spyFactory = new private$.SpyFactory( () => { if (this.getCurrentRunableId_()) { return this.customSpyStrategies(); @@ -19,7 +19,7 @@ getJasmineRequireObj().RunableResources = function(j$) { () => this.makeMatchersUtil() ); - this.spyRegistry = new j$.private.SpyRegistry({ + this.spyRegistry = new private$.SpyRegistry({ currentSpies: () => this.spies(), createSpy: (name, originalFn) => this.spyFactory.createSpy(name, originalFn) @@ -50,7 +50,7 @@ getJasmineRequireObj().RunableResources = function(j$) { ]; for (const k of toClone) { - newRes[k] = j$.private.util.clone(parentRes[k]); + newRes[k] = private$.util.clone(parentRes[k]); } } } @@ -128,18 +128,18 @@ getJasmineRequireObj().RunableResources = function(j$) { } makePrettyPrinter() { - return j$.private.makePrettyPrinter(this.customObjectFormatters()); + return private$.makePrettyPrinter(this.customObjectFormatters()); } makeMatchersUtil() { if (this.getCurrentRunableId_()) { - return new j$.private.MatchersUtil({ + return new private$.MatchersUtil({ customTesters: this.customEqualityTesters(), pp: this.makePrettyPrinter() }); } else { - return new j$.private.MatchersUtil({ - pp: j$.private.basicPrettyPrinter + return new private$.MatchersUtil({ + pp: private$.basicPrettyPrinter }); } } diff --git a/src/core/Runner.js b/src/core/Runner.js index 15162da5..2124a523 100644 --- a/src/core/Runner.js +++ b/src/core/Runner.js @@ -1,4 +1,4 @@ -getJasmineRequireObj().Runner = function(j$) { +getJasmineRequireObj().Runner = function(j$, private$) { 'use strict'; class Runner { @@ -26,7 +26,7 @@ getJasmineRequireObj().Runner = function(j$) { this.#reportDispatcher = options.reportDispatcher; this.#getConfig = options.getConfig; this.#executedBefore = false; - this.#currentRunableTracker = new j$.private.CurrentRunableTracker(); + this.#currentRunableTracker = new private$.CurrentRunableTracker(); } currentSpec() { @@ -66,9 +66,9 @@ getJasmineRequireObj().Runner = function(j$) { } } - const order = new j$.private.Order({ + const order = new private$.Order({ random: config.random, - seed: j$.private.isNumber(config.seed) ? config.seed + '' : config.seed + seed: private$.isNumber(config.seed) ? config.seed + '' : config.seed }); const treeProcessor = new this.#TreeProcessor({ @@ -112,7 +112,7 @@ getJasmineRequireObj().Runner = function(j$) { }); this.#currentRunableTracker.pushSuite(this.#topSuite); - const treeRunner = new j$.private.TreeRunner({ + const treeRunner = new private$.TreeRunner({ executionTree: this.#executionTree, globalErrors: this.#globalErrors, runableResources: this.#runableResources, diff --git a/src/core/SkipAfterBeforeAllErrorPolicy.js b/src/core/SkipAfterBeforeAllErrorPolicy.js index c1b71a9d..a1942263 100644 --- a/src/core/SkipAfterBeforeAllErrorPolicy.js +++ b/src/core/SkipAfterBeforeAllErrorPolicy.js @@ -1,4 +1,4 @@ -getJasmineRequireObj().SkipAfterBeforeAllErrorPolicy = function(j$) { +getJasmineRequireObj().SkipAfterBeforeAllErrorPolicy = function(j$, private$) { 'use strict'; function SkipAfterBeforeAllErrorPolicy(queueableFns) { diff --git a/src/core/Spec.js b/src/core/Spec.js index 254b50fc..d2778fd7 100644 --- a/src/core/Spec.js +++ b/src/core/Spec.js @@ -1,4 +1,4 @@ -getJasmineRequireObj().Spec = function(j$) { +getJasmineRequireObj().Spec = function(j$, private$) { 'use strict'; class Spec { @@ -46,7 +46,7 @@ getJasmineRequireObj().Spec = function(j$) { } addExpectationResult(passed, data, isError) { - const expectationResult = j$.private.buildExpectationResult(data); + const expectationResult = private$.buildExpectationResult(data); if (passed) { this.#executionState.passedExpectations.push(expectationResult); @@ -58,7 +58,7 @@ getJasmineRequireObj().Spec = function(j$) { } if (this.#throwOnExpectationFailure && !isError) { - throw new j$.private.errors.ExpectationFailed(); + throw new private$.errors.ExpectationFailed(); } } } @@ -72,10 +72,10 @@ getJasmineRequireObj().Spec = function(j$) { // Key and value will eventually be cloned during reporting. The error // thrown at that point if they aren't cloneable isn't very helpful. // Throw a better one now. - if (!j$.private.isString(key)) { + if (!private$.isString(key)) { throw new Error('Key must be a string'); } - j$.private.util.assertReporterCloneable(value, 'Value'); + private$.util.assertReporterCloneable(value, 'Value'); this.#executionState.properties = this.#executionState.properties || {}; this.#executionState.properties[key] = value; @@ -208,7 +208,7 @@ getJasmineRequireObj().Spec = function(j$) { return; } - if (e instanceof j$.private.errors.ExpectationFailed) { + if (e instanceof private$.errors.ExpectationFailed) { return; } @@ -275,7 +275,7 @@ getJasmineRequireObj().Spec = function(j$) { deprecation = { message: deprecation }; } this.#executionState.deprecationWarnings.push( - j$.private.buildExpectationResult(deprecation) + private$.buildExpectationResult(deprecation) ); } diff --git a/src/core/Spy.js b/src/core/Spy.js index 5e84d19b..98156ff8 100644 --- a/src/core/Spy.js +++ b/src/core/Spy.js @@ -1,4 +1,4 @@ -getJasmineRequireObj().Spy = function(j$) { +getJasmineRequireObj().Spy = function(j$, private$) { 'use strict'; const nextOrder = (function() { @@ -55,7 +55,7 @@ getJasmineRequireObj().Spy = function(j$) { }, matchersUtil ), - callTracker = new j$.private.CallTracker(); + callTracker = new private$.CallTracker(); function makeFunc(length, fn) { switch (length) { @@ -147,9 +147,9 @@ getJasmineRequireObj().Spy = function(j$) { } function SpyStrategyDispatcher(strategyArgs, matchersUtil) { - const baseStrategy = new j$.private.SpyStrategy(strategyArgs); + const baseStrategy = new private$.SpyStrategy(strategyArgs); const argsStrategies = new StrategyDict(function() { - return new j$.private.SpyStrategy(strategyArgs); + return new private$.SpyStrategy(strategyArgs); }, matchersUtil); this.and = baseStrategy; diff --git a/src/core/SpyFactory.js b/src/core/SpyFactory.js index dfb669d9..6fb26a0f 100644 --- a/src/core/SpyFactory.js +++ b/src/core/SpyFactory.js @@ -1,4 +1,4 @@ -getJasmineRequireObj().SpyFactory = function(j$) { +getJasmineRequireObj().SpyFactory = function(j$, private$) { 'use strict'; function SpyFactory( @@ -7,12 +7,12 @@ getJasmineRequireObj().SpyFactory = function(j$) { getMatchersUtil ) { this.createSpy = function(name, originalFn) { - if (j$.private.isFunction(name) && originalFn === undefined) { + if (private$.isFunction(name) && originalFn === undefined) { originalFn = name; name = originalFn.name; } - return j$.private.Spy(name, getMatchersUtil(), { + return private$.Spy(name, getMatchersUtil(), { originalFn, customStrategies: getCustomStrategies(), defaultStrategyFn: getDefaultStrategyFn() @@ -21,7 +21,7 @@ getJasmineRequireObj().SpyFactory = function(j$) { this.createSpyObj = function(baseName, methodNames, propertyNames) { const baseNameIsCollection = - j$.private.isObject(baseName) || Array.isArray(baseName); + private$.isObject(baseName) || Array.isArray(baseName); if (baseNameIsCollection) { propertyNames = methodNames; @@ -71,7 +71,7 @@ getJasmineRequireObj().SpyFactory = function(j$) { for (let i = 0; i < object.length; i++) { result.push([object[i]]); } - } else if (j$.private.isObject(object)) { + } else if (private$.isObject(object)) { for (const key in object) { if (object.hasOwnProperty(key)) { result.push([key, object[key]]); diff --git a/src/core/SpyRegistry.js b/src/core/SpyRegistry.js index 85723f33..143b9a6f 100644 --- a/src/core/SpyRegistry.js +++ b/src/core/SpyRegistry.js @@ -1,11 +1,11 @@ -getJasmineRequireObj().SpyRegistry = function(j$) { +getJasmineRequireObj().SpyRegistry = function(j$, private$) { 'use strict'; - const spyOnMsg = j$.private.formatErrorMsg( + const spyOnMsg = private$.formatErrorMsg( '', 'spyOn(, )' ); - const spyOnPropertyMsg = j$.private.formatErrorMsg( + const spyOnPropertyMsg = private$.formatErrorMsg( '', 'spyOnProperty(, , [accessType])' ); @@ -47,7 +47,7 @@ getJasmineRequireObj().SpyRegistry = function(j$) { // restored. if ( obj[methodName] && - obj[methodName][j$.private.Clock.IsMockClockTimingFn] + obj[methodName][private$.Clock.IsMockClockTimingFn] ) { throw new Error("Mock clock timing functions can't be spied on"); } @@ -102,7 +102,7 @@ getJasmineRequireObj().SpyRegistry = function(j$) { // localStorage in Firefox and later Safari versions, have no-op setters. if (obj[methodName] !== spiedMethod) { throw new Error( - j$.private.formatErrorMsg('')( + private$.formatErrorMsg('')( `Can't spy on ${methodName} because assigning to it had no effect` ) ); @@ -130,10 +130,7 @@ getJasmineRequireObj().SpyRegistry = function(j$) { throw new Error(getErrorMsg('No property name supplied')); } - const descriptor = j$.private.util.getPropertyDescriptor( - obj, - propertyName - ); + const descriptor = private$.util.getPropertyDescriptor(obj, propertyName); if (!descriptor) { throw new Error(getErrorMsg(propertyName + ' property does not exist')); @@ -168,7 +165,7 @@ getJasmineRequireObj().SpyRegistry = function(j$) { } } - const originalDescriptor = j$.private.util.clone(descriptor); + const originalDescriptor = private$.util.clone(descriptor); const spy = createSpy(propertyName, descriptor[accessType]); let restoreStrategy; diff --git a/src/core/SpyStrategy.js b/src/core/SpyStrategy.js index 483cfc51..80ec5a65 100644 --- a/src/core/SpyStrategy.js +++ b/src/core/SpyStrategy.js @@ -1,4 +1,4 @@ -getJasmineRequireObj().SpyStrategy = function(j$) { +getJasmineRequireObj().SpyStrategy = function(j$, private$) { 'use strict'; /** @@ -21,7 +21,7 @@ getJasmineRequireObj().SpyStrategy = function(j$) { const cs = options.customStrategies || {}; for (const k in cs) { - if (j$.private.util.has(cs, k) && !this[k]) { + if (private$.util.has(cs, k) && !this[k]) { this[k] = createCustomPlan(cs[k]); } } @@ -59,7 +59,7 @@ getJasmineRequireObj().SpyStrategy = function(j$) { return function() { const plan = factory.apply(null, arguments); - if (!j$.private.isFunction(plan)) { + if (!private$.isFunction(plan)) { throw new Error('Spy strategy must return a function'); } @@ -131,7 +131,7 @@ getJasmineRequireObj().SpyStrategy = function(j$) { * @param {Error|Object|String} something Thing to throw */ SpyStrategy.prototype.throwError = function(something) { - const error = j$.private.isString(something) + const error = private$.isString(something) ? new Error(something) : something; this.plan = function() { @@ -150,9 +150,9 @@ getJasmineRequireObj().SpyStrategy = function(j$) { SpyStrategy.prototype.callFake = function(fn) { if ( !( - j$.private.isFunction(fn) || - j$.private.isAsyncFunction(fn) || - j$.private.isGeneratorFunction(fn) + private$.isFunction(fn) || + private$.isAsyncFunction(fn) || + private$.isGeneratorFunction(fn) ) ) { throw new Error( diff --git a/src/core/StackClearer.js b/src/core/StackClearer.js index 0af66f91..d885b10c 100644 --- a/src/core/StackClearer.js +++ b/src/core/StackClearer.js @@ -1,4 +1,4 @@ -getJasmineRequireObj().StackClearer = function(j$) { +getJasmineRequireObj().StackClearer = function(j$, private$) { 'use strict'; const maxInlineCallCount = 10; diff --git a/src/core/StackTrace.js b/src/core/StackTrace.js index 18efd720..fb8d615c 100644 --- a/src/core/StackTrace.js +++ b/src/core/StackTrace.js @@ -1,4 +1,4 @@ -getJasmineRequireObj().StackTrace = function(j$) { +getJasmineRequireObj().StackTrace = function(j$, private$) { 'use strict'; function StackTrace(error) { diff --git a/src/core/Suite.js b/src/core/Suite.js index 63fe3fbc..486c1f41 100644 --- a/src/core/Suite.js +++ b/src/core/Suite.js @@ -1,4 +1,4 @@ -getJasmineRequireObj().Suite = function(j$) { +getJasmineRequireObj().Suite = function(j$, private$) { 'use strict'; class Suite { @@ -37,10 +37,10 @@ getJasmineRequireObj().Suite = function(j$) { // Key and value will eventually be cloned during reporting. The error // thrown at that point if they aren't cloneable isn't very helpful. // Throw a better one now. - if (!j$.private.isString(key)) { + if (!private$.isString(key)) { throw new Error('Key must be a string'); } - j$.private.util.assertReporterCloneable(value, 'Value'); + private$.util.assertReporterCloneable(value, 'Value'); this.#result.properties = this.#result.properties || {}; this.#result.properties[key] = value; @@ -217,18 +217,18 @@ getJasmineRequireObj().Suite = function(j$) { if (!this.sharedContext) { this.sharedContext = this.parentSuite ? this.parentSuite.clonedSharedUserContext() - : new j$.private.UserContext(); + : new private$.UserContext(); } return this.sharedContext; } clonedSharedUserContext() { - return j$.private.UserContext.fromExisting(this.sharedUserContext()); + return private$.UserContext.fromExisting(this.sharedUserContext()); } handleException() { - if (arguments[0] instanceof j$.private.errors.ExpectationFailed) { + if (arguments[0] instanceof private$.errors.ExpectationFailed) { return; } @@ -237,7 +237,7 @@ getJasmineRequireObj().Suite = function(j$) { passed: false, error: arguments[0] }; - const failedExpectation = j$.private.buildExpectationResult(data); + const failedExpectation = private$.buildExpectationResult(data); if (!this.parentSuite) { failedExpectation.globalErrorType = 'afterAll'; @@ -279,7 +279,7 @@ getJasmineRequireObj().Suite = function(j$) { return; } - const expectationResult = j$.private.buildExpectationResult(data); + const expectationResult = private$.buildExpectationResult(data); if (this.reportedDone) { this.onLateError(expectationResult); @@ -288,7 +288,7 @@ getJasmineRequireObj().Suite = function(j$) { } if (this.#throwOnExpectationFailure) { - throw new j$.private.errors.ExpectationFailed(); + throw new private$.errors.ExpectationFailed(); } } @@ -297,7 +297,7 @@ getJasmineRequireObj().Suite = function(j$) { deprecation = { message: deprecation }; } this.#result.deprecationWarnings.push( - j$.private.buildExpectationResult(deprecation) + private$.buildExpectationResult(deprecation) ); } diff --git a/src/core/SuiteBuilder.js b/src/core/SuiteBuilder.js index f809d841..66e5fe84 100644 --- a/src/core/SuiteBuilder.js +++ b/src/core/SuiteBuilder.js @@ -1,4 +1,4 @@ -getJasmineRequireObj().SuiteBuilder = function(j$) { +getJasmineRequireObj().SuiteBuilder = function(j$, private$) { 'use strict'; class SuiteBuilder { @@ -94,7 +94,7 @@ getJasmineRequireObj().SuiteBuilder = function(j$) { ensureIsFunctionOrAsync(fn, 'fit'); if (timeout) { - j$.private.util.validateTimeout(timeout); + private$.util.validateTimeout(timeout); } const spec = this.specFactory_(description, fn, timeout, filename); this.currentDeclarationSuite_.addChild(spec); @@ -107,7 +107,7 @@ getJasmineRequireObj().SuiteBuilder = function(j$) { ensureIsFunctionOrAsync(beforeEachFunction, 'beforeEach'); if (timeout) { - j$.private.util.validateTimeout(timeout); + private$.util.validateTimeout(timeout); } this.currentDeclarationSuite_.beforeEach({ @@ -120,7 +120,7 @@ getJasmineRequireObj().SuiteBuilder = function(j$) { ensureIsFunctionOrAsync(beforeAllFunction, 'beforeAll'); if (timeout) { - j$.private.util.validateTimeout(timeout); + private$.util.validateTimeout(timeout); } this.currentDeclarationSuite_.beforeAll({ @@ -133,7 +133,7 @@ getJasmineRequireObj().SuiteBuilder = function(j$) { ensureIsFunctionOrAsync(afterEachFunction, 'afterEach'); if (timeout) { - j$.private.util.validateTimeout(timeout); + private$.util.validateTimeout(timeout); } afterEachFunction.isCleanup = true; @@ -147,7 +147,7 @@ getJasmineRequireObj().SuiteBuilder = function(j$) { ensureIsFunctionOrAsync(afterAllFunction, 'afterAll'); if (timeout) { - j$.private.util.validateTimeout(timeout); + private$.util.validateTimeout(timeout); } this.currentDeclarationSuite_.afterAll({ @@ -158,7 +158,7 @@ getJasmineRequireObj().SuiteBuilder = function(j$) { it_(description, fn, timeout, filename) { if (timeout) { - j$.private.util.validateTimeout(timeout); + private$.util.validateTimeout(timeout); } this.checkDuplicate_(description, 'spec'); @@ -197,7 +197,7 @@ getJasmineRequireObj().SuiteBuilder = function(j$) { const parentSuite = this.currentDeclarationSuite_; const reportedParentSuiteId = parentSuite === this.topSuite ? null : parentSuite.id; - return new j$.private.Suite({ + return new private$.Suite({ id: 'suite' + this.nextSuiteId_++, description, filename, @@ -239,7 +239,7 @@ getJasmineRequireObj().SuiteBuilder = function(j$) { const config = this.env_.configuration(); const suite = this.currentDeclarationSuite_; const parentSuiteId = suite === this.topSuite ? null : suite.id; - const spec = new j$.private.Spec({ + const spec = new private$.Spec({ id: 'spec' + this.nextSpecId_++, filename, parentSuiteId, @@ -302,21 +302,21 @@ getJasmineRequireObj().SuiteBuilder = function(j$) { } function ensureIsFunction(fn, caller) { - if (!j$.private.isFunction(fn)) { + if (!private$.isFunction(fn)) { throw new Error( caller + ' expects a function argument; received ' + - j$.private.getType(fn) + private$.getType(fn) ); } } function ensureIsFunctionOrAsync(fn, caller) { - if (!j$.private.isFunction(fn) && !j$.private.isAsyncFunction(fn)) { + if (!private$.isFunction(fn) && !private$.isAsyncFunction(fn)) { throw new Error( caller + ' expects a function argument; received ' + - j$.private.getType(fn) + private$.getType(fn) ); } } diff --git a/src/core/TreeProcessor.js b/src/core/TreeProcessor.js index 04feb514..200d893f 100644 --- a/src/core/TreeProcessor.js +++ b/src/core/TreeProcessor.js @@ -1,4 +1,4 @@ -getJasmineRequireObj().TreeProcessor = function(j$) { +getJasmineRequireObj().TreeProcessor = function(j$, private$) { 'use strict'; const defaultMin = Infinity; diff --git a/src/core/TreeRunner.js b/src/core/TreeRunner.js index 2bc878ba..cdebfc67 100644 --- a/src/core/TreeRunner.js +++ b/src/core/TreeRunner.js @@ -1,4 +1,4 @@ -getJasmineRequireObj().TreeRunner = function(j$) { +getJasmineRequireObj().TreeRunner = function(j$, private$) { 'use strict'; class TreeRunner { @@ -83,14 +83,14 @@ getJasmineRequireObj().TreeRunner = function(j$) { }, onComplete: () => { if (spec.status() === 'failed') { - specOverallDone(new j$.private.StopExecutionError('spec failed')); + specOverallDone(new private$.StopExecutionError('spec failed')); } else { specOverallDone(); } }, userContext: spec.userContext(), runnableName: spec.getFullName.bind(spec), - SkipPolicy: j$.private.CompleteOnFirstErrorSkipPolicy + SkipPolicy: private$.CompleteOnFirstErrorSkipPolicy }); } @@ -265,7 +265,7 @@ getJasmineRequireObj().TreeRunner = function(j$) { async #reportChildrenOfBeforeAllFailure(suite) { for (const child of suite.children) { - if (child instanceof j$.private.Suite) { + if (child instanceof private$.Suite) { await this.#reportDispatcher.suiteStarted(child.startedEvent()); await this.#reportChildrenOfBeforeAllFailure(child); await this.#reportDispatcher.suiteDone(child.doneEvent()); @@ -280,9 +280,9 @@ getJasmineRequireObj().TreeRunner = function(j$) { #suiteSkipPolicy() { if (this.#getConfig().stopOnSpecFailure) { - return j$.private.CompleteOnFirstErrorSkipPolicy; + return private$.CompleteOnFirstErrorSkipPolicy; } else { - return j$.private.SkipAfterBeforeAllErrorPolicy; + return private$.SkipAfterBeforeAllErrorPolicy; } } } diff --git a/src/core/UserContext.js b/src/core/UserContext.js index ae7978e8..a3cf71ba 100644 --- a/src/core/UserContext.js +++ b/src/core/UserContext.js @@ -1,4 +1,4 @@ -getJasmineRequireObj().UserContext = function(j$) { +getJasmineRequireObj().UserContext = function(j$, private$) { 'use strict'; function UserContext() {} diff --git a/src/core/asymmetric_equality/AllOf.js b/src/core/asymmetric_equality/AllOf.js index 7a6bb3e7..8157582a 100644 --- a/src/core/asymmetric_equality/AllOf.js +++ b/src/core/asymmetric_equality/AllOf.js @@ -1,4 +1,4 @@ -getJasmineRequireObj().AllOf = function(j$) { +getJasmineRequireObj().AllOf = function(j$, private$) { 'use strict'; function AllOf() { diff --git a/src/core/asymmetric_equality/Any.js b/src/core/asymmetric_equality/Any.js index 62d4210f..aa5726f0 100644 --- a/src/core/asymmetric_equality/Any.js +++ b/src/core/asymmetric_equality/Any.js @@ -1,4 +1,4 @@ -getJasmineRequireObj().Any = function(j$) { +getJasmineRequireObj().Any = function(j$, private$) { 'use strict'; function Any(expectedObject) { @@ -40,7 +40,7 @@ getJasmineRequireObj().Any = function(j$) { }; Any.prototype.jasmineToString = function() { - return ''; + return ''; }; return Any; diff --git a/src/core/asymmetric_equality/Anything.js b/src/core/asymmetric_equality/Anything.js index caca5af6..981e5372 100644 --- a/src/core/asymmetric_equality/Anything.js +++ b/src/core/asymmetric_equality/Anything.js @@ -1,4 +1,4 @@ -getJasmineRequireObj().Anything = function(j$) { +getJasmineRequireObj().Anything = function(j$, private$) { 'use strict'; function Anything() {} diff --git a/src/core/asymmetric_equality/ArrayContaining.js b/src/core/asymmetric_equality/ArrayContaining.js index e2408e19..075fd15c 100644 --- a/src/core/asymmetric_equality/ArrayContaining.js +++ b/src/core/asymmetric_equality/ArrayContaining.js @@ -1,4 +1,4 @@ -getJasmineRequireObj().ArrayContaining = function(j$) { +getJasmineRequireObj().ArrayContaining = function(j$, private$) { 'use strict'; function ArrayContaining(sample) { @@ -9,7 +9,7 @@ getJasmineRequireObj().ArrayContaining = function(j$) { if (!Array.isArray(this.sample)) { throw new Error( 'You must provide an array to arrayContaining, not ' + - j$.private.basicPrettyPrinter(this.sample) + + private$.basicPrettyPrinter(this.sample) + '.' ); } diff --git a/src/core/asymmetric_equality/ArrayWithExactContents.js b/src/core/asymmetric_equality/ArrayWithExactContents.js index 104049b2..b5a7bcc1 100644 --- a/src/core/asymmetric_equality/ArrayWithExactContents.js +++ b/src/core/asymmetric_equality/ArrayWithExactContents.js @@ -1,4 +1,4 @@ -getJasmineRequireObj().ArrayWithExactContents = function(j$) { +getJasmineRequireObj().ArrayWithExactContents = function(j$, private$) { 'use strict'; function ArrayWithExactContents(sample) { @@ -12,7 +12,7 @@ getJasmineRequireObj().ArrayWithExactContents = function(j$) { if (!Array.isArray(this.sample)) { throw new Error( 'You must provide an array to arrayWithExactContents, not ' + - j$.private.basicPrettyPrinter(this.sample) + + private$.basicPrettyPrinter(this.sample) + '.' ); } diff --git a/src/core/asymmetric_equality/Empty.js b/src/core/asymmetric_equality/Empty.js index 7cab0544..8f735f80 100644 --- a/src/core/asymmetric_equality/Empty.js +++ b/src/core/asymmetric_equality/Empty.js @@ -1,22 +1,22 @@ -getJasmineRequireObj().Empty = function(j$) { +getJasmineRequireObj().Empty = function(j$, private$) { 'use strict'; function Empty() {} Empty.prototype.asymmetricMatch = function(other) { if ( - j$.private.isString(other) || + private$.isString(other) || Array.isArray(other) || - j$.private.isTypedArray(other) + private$.isTypedArray(other) ) { return other.length === 0; } - if (j$.private.isMap(other) || j$.private.isSet(other)) { + if (private$.isMap(other) || private$.isSet(other)) { return other.size === 0; } - if (j$.private.isObject(other)) { + if (private$.isObject(other)) { return Object.keys(other).length === 0; } return false; diff --git a/src/core/asymmetric_equality/Falsy.js b/src/core/asymmetric_equality/Falsy.js index 5f28722e..a9cbe4de 100644 --- a/src/core/asymmetric_equality/Falsy.js +++ b/src/core/asymmetric_equality/Falsy.js @@ -1,4 +1,4 @@ -getJasmineRequireObj().Falsy = function(j$) { +getJasmineRequireObj().Falsy = function(j$, private$) { 'use strict'; function Falsy() {} diff --git a/src/core/asymmetric_equality/Is.js b/src/core/asymmetric_equality/Is.js index 67150877..0eb0bc65 100644 --- a/src/core/asymmetric_equality/Is.js +++ b/src/core/asymmetric_equality/Is.js @@ -1,4 +1,4 @@ -getJasmineRequireObj().Is = function(j$) { +getJasmineRequireObj().Is = function(j$, private$) { 'use strict'; class Is { diff --git a/src/core/asymmetric_equality/MapContaining.js b/src/core/asymmetric_equality/MapContaining.js index e3a68131..425d2e4a 100644 --- a/src/core/asymmetric_equality/MapContaining.js +++ b/src/core/asymmetric_equality/MapContaining.js @@ -1,11 +1,11 @@ -getJasmineRequireObj().MapContaining = function(j$) { +getJasmineRequireObj().MapContaining = function(j$, private$) { 'use strict'; function MapContaining(sample) { - if (!j$.private.isMap(sample)) { + if (!private$.isMap(sample)) { throw new Error( 'You must provide a map to `mapContaining`, not ' + - j$.private.basicPrettyPrinter(sample) + private$.basicPrettyPrinter(sample) ); } @@ -13,7 +13,7 @@ getJasmineRequireObj().MapContaining = function(j$) { } MapContaining.prototype.asymmetricMatch = function(other, matchersUtil) { - if (!j$.private.isMap(other)) { + if (!private$.isMap(other)) { return false; } diff --git a/src/core/asymmetric_equality/NotEmpty.js b/src/core/asymmetric_equality/NotEmpty.js index b4c8660b..e498750f 100644 --- a/src/core/asymmetric_equality/NotEmpty.js +++ b/src/core/asymmetric_equality/NotEmpty.js @@ -1,22 +1,22 @@ -getJasmineRequireObj().NotEmpty = function(j$) { +getJasmineRequireObj().NotEmpty = function(j$, private$) { 'use strict'; function NotEmpty() {} NotEmpty.prototype.asymmetricMatch = function(other) { if ( - j$.private.isString(other) || + private$.isString(other) || Array.isArray(other) || - j$.private.isTypedArray(other) + private$.isTypedArray(other) ) { return other.length !== 0; } - if (j$.private.isMap(other) || j$.private.isSet(other)) { + if (private$.isMap(other) || private$.isSet(other)) { return other.size !== 0; } - if (j$.private.isObject(other)) { + if (private$.isObject(other)) { return Object.keys(other).length !== 0; } diff --git a/src/core/asymmetric_equality/ObjectContaining.js b/src/core/asymmetric_equality/ObjectContaining.js index 8b775050..fa044c0d 100644 --- a/src/core/asymmetric_equality/ObjectContaining.js +++ b/src/core/asymmetric_equality/ObjectContaining.js @@ -1,4 +1,4 @@ -getJasmineRequireObj().ObjectContaining = function(j$) { +getJasmineRequireObj().ObjectContaining = function(j$, private$) { 'use strict'; function ObjectContaining(sample) { @@ -42,7 +42,7 @@ getJasmineRequireObj().ObjectContaining = function(j$) { }; ObjectContaining.prototype.valuesForDiff_ = function(other, pp) { - if (!j$.private.isObject(other)) { + if (!private$.isObject(other)) { return { self: this.jasmineToString(pp), other: other diff --git a/src/core/asymmetric_equality/SetContaining.js b/src/core/asymmetric_equality/SetContaining.js index a42215a1..0327658e 100644 --- a/src/core/asymmetric_equality/SetContaining.js +++ b/src/core/asymmetric_equality/SetContaining.js @@ -1,11 +1,11 @@ -getJasmineRequireObj().SetContaining = function(j$) { +getJasmineRequireObj().SetContaining = function(j$, private$) { 'use strict'; function SetContaining(sample) { - if (!j$.private.isSet(sample)) { + if (!private$.isSet(sample)) { throw new Error( 'You must provide a set to `setContaining`, not ' + - j$.private.basicPrettyPrinter(sample) + private$.basicPrettyPrinter(sample) ); } @@ -13,7 +13,7 @@ getJasmineRequireObj().SetContaining = function(j$) { } SetContaining.prototype.asymmetricMatch = function(other, matchersUtil) { - if (!j$.private.isSet(other)) { + if (!private$.isSet(other)) { return false; } diff --git a/src/core/asymmetric_equality/StringContaining.js b/src/core/asymmetric_equality/StringContaining.js index 98302048..489d2303 100644 --- a/src/core/asymmetric_equality/StringContaining.js +++ b/src/core/asymmetric_equality/StringContaining.js @@ -1,8 +1,8 @@ -getJasmineRequireObj().StringContaining = function(j$) { +getJasmineRequireObj().StringContaining = function(j$, private$) { 'use strict'; function StringContaining(expected) { - if (!j$.private.isString(expected)) { + if (!private$.isString(expected)) { throw new Error('Expected is not a String'); } @@ -10,7 +10,7 @@ getJasmineRequireObj().StringContaining = function(j$) { } StringContaining.prototype.asymmetricMatch = function(other) { - if (!j$.private.isString(other)) { + if (!private$.isString(other)) { // Arrays, etc. don't match no matter what their indexOf returns. return false; } diff --git a/src/core/asymmetric_equality/StringMatching.js b/src/core/asymmetric_equality/StringMatching.js index 44cebaf1..dee9db22 100644 --- a/src/core/asymmetric_equality/StringMatching.js +++ b/src/core/asymmetric_equality/StringMatching.js @@ -1,8 +1,8 @@ -getJasmineRequireObj().StringMatching = function(j$) { +getJasmineRequireObj().StringMatching = function(j$, private$) { 'use strict'; function StringMatching(expected) { - if (!j$.private.isString(expected) && !j$.private.isA('RegExp', expected)) { + if (!private$.isString(expected) && !private$.isA('RegExp', expected)) { throw new Error('Expected is not a String or a RegExp'); } diff --git a/src/core/asymmetric_equality/Truthy.js b/src/core/asymmetric_equality/Truthy.js index 5e17caa7..dd813d82 100644 --- a/src/core/asymmetric_equality/Truthy.js +++ b/src/core/asymmetric_equality/Truthy.js @@ -1,4 +1,4 @@ -getJasmineRequireObj().Truthy = function(j$) { +getJasmineRequireObj().Truthy = function(j$, private$) { 'use strict'; function Truthy() {} diff --git a/src/core/base.js b/src/core/base.js index 95d5bdef..2e7dad0b 100644 --- a/src/core/base.js +++ b/src/core/base.js @@ -1,4 +1,4 @@ -getJasmineRequireObj().base = function(j$, jasmineGlobal) { +getJasmineRequireObj().base = function(j$, private$, jasmineGlobal) { 'use strict'; /** @@ -47,7 +47,7 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) { return DEFAULT_TIMEOUT_INTERVAL; }, set: function(newValue) { - j$.private.util.validateTimeout( + private$.util.validateTimeout( newValue, 'jasmine.DEFAULT_TIMEOUT_INTERVAL' ); @@ -70,58 +70,58 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) { Object.defineProperty(j$, 'getEnv', { enumerable: true, value: function(options) { - const env = (j$.private.currentEnv_ = - j$.private.currentEnv_ || new j$.private.Env(options)); + const env = (private$.currentEnv_ = + private$.currentEnv_ || new private$.Env(options)); //jasmine. singletons in here (setTimeout blah blah). return env; } }); - j$.private.isObject = function(value) { + private$.isObject = function(value) { return ( - value !== undefined && value !== null && j$.private.isA('Object', value) + value !== undefined && value !== null && private$.isA('Object', value) ); }; - j$.private.isString = function(value) { - return j$.private.isA('String', value); + private$.isString = function(value) { + return private$.isA('String', value); }; - j$.private.isNumber = function(value) { - return j$.private.isA('Number', value); + private$.isNumber = function(value) { + return private$.isA('Number', value); }; - j$.private.isFunction = function(value) { - return j$.private.isA('Function', value); + private$.isFunction = function(value) { + return private$.isA('Function', value); }; - j$.private.isAsyncFunction = function(value) { - return j$.private.isA('AsyncFunction', value); + private$.isAsyncFunction = function(value) { + return private$.isA('AsyncFunction', value); }; - j$.private.isGeneratorFunction = function(value) { - return j$.private.isA('GeneratorFunction', value); + private$.isGeneratorFunction = function(value) { + return private$.isA('GeneratorFunction', value); }; - j$.private.isTypedArray = function(value) { + private$.isTypedArray = function(value) { return ( - j$.private.isA('Float32Array', value) || - j$.private.isA('Float64Array', value) || - j$.private.isA('Int16Array', value) || - j$.private.isA('Int32Array', value) || - j$.private.isA('Int8Array', value) || - j$.private.isA('Uint16Array', value) || - j$.private.isA('Uint32Array', value) || - j$.private.isA('Uint8Array', value) || - j$.private.isA('Uint8ClampedArray', value) + private$.isA('Float32Array', value) || + private$.isA('Float64Array', value) || + private$.isA('Int16Array', value) || + private$.isA('Int32Array', value) || + private$.isA('Int8Array', value) || + private$.isA('Uint16Array', value) || + private$.isA('Uint32Array', value) || + private$.isA('Uint8Array', value) || + private$.isA('Uint8ClampedArray', value) ); }; - j$.private.isA = function(typeName, value) { - return j$.private.getType(value) === '[object ' + typeName + ']'; + private$.isA = function(typeName, value) { + return private$.getType(value) === '[object ' + typeName + ']'; }; - j$.private.isError = function(value) { + private$.isError = function(value) { if (!value) { return false; } @@ -133,15 +133,15 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) { return typeof value.stack === 'string' && typeof value.message === 'string'; }; - j$.private.isAsymmetricEqualityTester = function(obj) { - return obj ? j$.private.isA('Function', obj.asymmetricMatch) : false; + private$.isAsymmetricEqualityTester = function(obj) { + return obj ? private$.isA('Function', obj.asymmetricMatch) : false; }; - j$.private.getType = function(value) { + private$.getType = function(value) { return Object.prototype.toString.apply(value); }; - j$.private.isDomNode = function(obj) { + private$.isDomNode = function(obj) { // Node is a function, because constructors return typeof jasmineGlobal.Node !== 'undefined' ? obj instanceof jasmineGlobal.Node @@ -152,7 +152,7 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) { // return obj.nodeType > 0; }; - j$.private.isMap = function(obj) { + private$.isMap = function(obj) { return ( obj !== null && typeof obj !== 'undefined' && @@ -160,7 +160,7 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) { ); }; - j$.private.isSet = function(obj) { + private$.isSet = function(obj) { return ( obj !== null && typeof obj !== 'undefined' && @@ -168,7 +168,7 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) { ); }; - j$.private.isWeakMap = function(obj) { + private$.isWeakMap = function(obj) { return ( obj !== null && typeof obj !== 'undefined' && @@ -176,7 +176,7 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) { ); }; - j$.private.isURL = function(obj) { + private$.isURL = function(obj) { return ( obj !== null && typeof obj !== 'undefined' && @@ -184,11 +184,11 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) { ); }; - j$.private.isIterable = function(value) { + private$.isIterable = function(value) { return value && !!value[Symbol.iterator]; }; - j$.private.isDataView = function(obj) { + private$.isDataView = function(obj) { return ( obj !== null && typeof obj !== 'undefined' && @@ -196,15 +196,15 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) { ); }; - j$.private.isPromise = function(obj) { + private$.isPromise = function(obj) { return !!obj && obj.constructor === jasmineGlobal.Promise; }; - j$.private.isPromiseLike = function(obj) { - return !!obj && j$.private.isFunction(obj.then); + private$.isPromiseLike = function(obj) { + return !!obj && private$.isFunction(obj.then); }; - j$.private.fnNameFor = function(func) { + private$.fnNameFor = function(func) { if (func.name) { return func.name; } @@ -216,7 +216,7 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) { return matches ? matches[1] : ''; }; - j$.private.isPending = function(promise) { + private$.isPending = function(promise) { const sentinel = {}; return Promise.race([promise, Promise.resolve(sentinel)]).then( function(result) { @@ -251,7 +251,7 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) { * @param {Constructor} clazz - The constructor to check against. */ j$.any = function(clazz) { - return new j$.private.Any(clazz); + return new private$.Any(clazz); }; /** @@ -263,7 +263,7 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) { * @function */ j$.anything = function() { - return new j$.private.Anything(); + return new private$.Anything(); }; /** @@ -275,7 +275,7 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) { * @function */ j$.truthy = function() { - return new j$.private.Truthy(); + return new private$.Truthy(); }; /** @@ -288,7 +288,7 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) { * @function */ j$.falsy = function() { - return new j$.private.Falsy(); + return new private$.Falsy(); }; /** @@ -300,7 +300,7 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) { * @function */ j$.empty = function() { - return new j$.private.Empty(); + return new private$.Empty(); }; /** @@ -312,7 +312,7 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) { * @param {Object} sample - The value to compare the actual to. */ j$.is = function(sample) { - return new j$.private.Is(sample); + return new private$.Is(sample); }; /** @@ -324,7 +324,7 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) { * @function */ j$.notEmpty = function() { - return new j$.private.NotEmpty(); + return new private$.NotEmpty(); }; /** @@ -337,7 +337,7 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) { * @param {Object} sample - The subset of properties that _must_ be in the actual. */ j$.objectContaining = function(sample) { - return new j$.private.ObjectContaining(sample); + return new private$.ObjectContaining(sample); }; /** @@ -350,7 +350,7 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) { * @param {RegExp|String} expected */ j$.stringMatching = function(expected) { - return new j$.private.StringMatching(expected); + return new private$.StringMatching(expected); }; /** @@ -363,7 +363,7 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) { * @param {String} expected */ j$.stringContaining = function(expected) { - return new j$.private.StringContaining(expected); + return new private$.StringContaining(expected); }; /** @@ -376,7 +376,7 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) { * @param {Array} sample */ j$.arrayContaining = function(sample) { - return new j$.private.ArrayContaining(sample); + return new private$.ArrayContaining(sample); }; /** @@ -390,7 +390,7 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) { * @param {Array} sample */ j$.arrayWithExactContents = function(sample) { - return new j$.private.ArrayWithExactContents(sample); + return new private$.ArrayWithExactContents(sample); }; /** @@ -404,7 +404,7 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) { * @param {Map} sample - The subset of items that _must_ be in the actual. */ j$.mapContaining = function(sample) { - return new j$.private.MapContaining(sample); + return new private$.MapContaining(sample); }; /** @@ -418,7 +418,7 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) { * @param {Set} sample - The subset of items that _must_ be in the actual. */ j$.setContaining = function(sample) { - return new j$.private.SetContaining(sample); + return new private$.SetContaining(sample); }; /** @@ -434,8 +434,8 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) { return false; } return ( - putativeSpy.and instanceof j$.private.SpyStrategy && - putativeSpy.calls instanceof j$.private.CallTracker + putativeSpy.and instanceof private$.SpyStrategy && + putativeSpy.calls instanceof private$.CallTracker ); }; diff --git a/src/core/buildExpectationResult.js b/src/core/buildExpectationResult.js index 7a052878..175d1697 100644 --- a/src/core/buildExpectationResult.js +++ b/src/core/buildExpectationResult.js @@ -1,9 +1,9 @@ //TODO: expectation result may make more sense as a presentation of an expectation. -getJasmineRequireObj().buildExpectationResult = function(j$) { +getJasmineRequireObj().buildExpectationResult = function(j$, private$) { 'use strict'; function buildExpectationResult(options) { - const exceptionFormatter = new j$.private.ExceptionFormatter(); + const exceptionFormatter = new private$.ExceptionFormatter(); /** * Describes the result of evaluating an expectation @@ -33,7 +33,7 @@ getJasmineRequireObj().buildExpectationResult = function(j$) { } if (!result.passed) { - if (options.error && !j$.private.isString(options.error)) { + if (options.error && !private$.isString(options.error)) { if ('code' in options.error) { result.code = options.error.code; } diff --git a/src/core/matchers/DiffBuilder.js b/src/core/matchers/DiffBuilder.js index d06bf7e2..d6749cc9 100644 --- a/src/core/matchers/DiffBuilder.js +++ b/src/core/matchers/DiffBuilder.js @@ -1,12 +1,12 @@ -getJasmineRequireObj().DiffBuilder = function(j$) { +getJasmineRequireObj().DiffBuilder = function(j$, private$) { 'use strict'; class DiffBuilder { constructor(config) { this.prettyPrinter_ = - (config || {}).prettyPrinter || j$.private.makePrettyPrinter(); - this.mismatches_ = new j$.private.MismatchTree(); - this.path_ = new j$.private.ObjectPath(); + (config || {}).prettyPrinter || private$.makePrettyPrinter(); + this.mismatches_ = new private$.MismatchTree(); + this.path_ = new private$.ObjectPath(); this.actualRoot_ = undefined; this.expectedRoot_ = undefined; } @@ -67,8 +67,8 @@ getJasmineRequireObj().DiffBuilder = function(j$) { const handleAsymmetricExpected = () => { if ( - j$.private.isAsymmetricEqualityTester(expected) && - j$.private.isFunction(expected.valuesForDiff_) + private$.isAsymmetricEqualityTester(expected) && + private$.isFunction(expected.valuesForDiff_) ) { const asymmetricResult = expected.valuesForDiff_( actual, diff --git a/src/core/matchers/MismatchTree.js b/src/core/matchers/MismatchTree.js index 5d4da678..117746ee 100644 --- a/src/core/matchers/MismatchTree.js +++ b/src/core/matchers/MismatchTree.js @@ -1,4 +1,4 @@ -getJasmineRequireObj().MismatchTree = function(j$) { +getJasmineRequireObj().MismatchTree = function(j$, private$) { 'use strict'; /* @@ -10,7 +10,7 @@ getJasmineRequireObj().MismatchTree = function(j$) { */ class MismatchTree { constructor(path) { - this.path = path || new j$.private.ObjectPath([]); + this.path = path || new private$.ObjectPath([]); this.formatter = undefined; this.children = []; this.isMismatch = false; diff --git a/src/core/matchers/NullDiffBuilder.js b/src/core/matchers/NullDiffBuilder.js index 43d8362e..99111caa 100644 --- a/src/core/matchers/NullDiffBuilder.js +++ b/src/core/matchers/NullDiffBuilder.js @@ -1,4 +1,4 @@ -getJasmineRequireObj().NullDiffBuilder = function(j$) { +getJasmineRequireObj().NullDiffBuilder = function(j$, private$) { 'use strict'; return function() { diff --git a/src/core/matchers/ObjectPath.js b/src/core/matchers/ObjectPath.js index 7493d79d..cd904bc3 100644 --- a/src/core/matchers/ObjectPath.js +++ b/src/core/matchers/ObjectPath.js @@ -1,4 +1,4 @@ -getJasmineRequireObj().ObjectPath = function(j$) { +getJasmineRequireObj().ObjectPath = function(j$, private$) { 'use strict'; class ObjectPath { diff --git a/src/core/matchers/async/toBePending.js b/src/core/matchers/async/toBePending.js index 06ec4a8c..4e36b1ed 100644 --- a/src/core/matchers/async/toBePending.js +++ b/src/core/matchers/async/toBePending.js @@ -1,4 +1,4 @@ -getJasmineRequireObj().toBePending = function(j$) { +getJasmineRequireObj().toBePending = function(j$, private$) { 'use strict'; /** @@ -13,7 +13,7 @@ getJasmineRequireObj().toBePending = function(j$) { return function toBePending() { return { compare: function(actual) { - if (!j$.private.isPromiseLike(actual)) { + if (!private$.isPromiseLike(actual)) { throw new Error( `Expected toBePending to be called on a promise but was on a ${typeof actual}.` ); diff --git a/src/core/matchers/async/toBeRejected.js b/src/core/matchers/async/toBeRejected.js index 84f83b96..fb29bbb9 100644 --- a/src/core/matchers/async/toBeRejected.js +++ b/src/core/matchers/async/toBeRejected.js @@ -1,4 +1,4 @@ -getJasmineRequireObj().toBeRejected = function(j$) { +getJasmineRequireObj().toBeRejected = function(j$, private$) { 'use strict'; /** @@ -15,7 +15,7 @@ getJasmineRequireObj().toBeRejected = function(j$) { return function toBeRejected() { return { compare: function(actual) { - if (!j$.private.isPromiseLike(actual)) { + if (!private$.isPromiseLike(actual)) { throw new Error( `Expected toBeRejected to be called on a promise but was on a ${typeof actual}.` ); diff --git a/src/core/matchers/async/toBeRejectedWith.js b/src/core/matchers/async/toBeRejectedWith.js index 61cce961..d24f5c78 100644 --- a/src/core/matchers/async/toBeRejectedWith.js +++ b/src/core/matchers/async/toBeRejectedWith.js @@ -1,4 +1,4 @@ -getJasmineRequireObj().toBeRejectedWith = function(j$) { +getJasmineRequireObj().toBeRejectedWith = function(j$, private$) { 'use strict'; /** @@ -16,7 +16,7 @@ getJasmineRequireObj().toBeRejectedWith = function(j$) { return function toBeRejectedWith(matchersUtil) { return { compare: function(actualPromise, expectedValue) { - if (!j$.private.isPromiseLike(actualPromise)) { + if (!private$.isPromiseLike(actualPromise)) { throw new Error( `Expected toBeRejectedWith to be called on a promise but was on a ${typeof actualPromise}.` ); diff --git a/src/core/matchers/async/toBeRejectedWithError.js b/src/core/matchers/async/toBeRejectedWithError.js index 24bd5391..0dc65614 100644 --- a/src/core/matchers/async/toBeRejectedWithError.js +++ b/src/core/matchers/async/toBeRejectedWithError.js @@ -1,4 +1,4 @@ -getJasmineRequireObj().toBeRejectedWithError = function(j$) { +getJasmineRequireObj().toBeRejectedWithError = function(j$, private$) { 'use strict'; /** @@ -19,7 +19,7 @@ getJasmineRequireObj().toBeRejectedWithError = function(j$) { return function toBeRejectedWithError(matchersUtil) { return { compare: function(actualPromise, arg1, arg2) { - if (!j$.private.isPromiseLike(actualPromise)) { + if (!private$.isPromiseLike(actualPromise)) { throw new Error( `Expected toBeRejectedWithError to be called on a promise but was on a ${typeof actualPromise}.` ); @@ -43,14 +43,14 @@ getJasmineRequireObj().toBeRejectedWithError = function(j$) { }; function matchError(actual, expected, matchersUtil) { - if (!j$.private.isError(actual)) { + if (!private$.isError(actual)) { return fail(expected, 'rejected with ' + matchersUtil.pp(actual)); } if (!(actual instanceof expected.error)) { return fail( expected, - 'rejected with type ' + j$.private.fnNameFor(actual.constructor) + 'rejected with type ' + private$.fnNameFor(actual.constructor) ); } @@ -110,7 +110,7 @@ getJasmineRequireObj().toBeRejectedWithError = function(j$) { error: error, message: message, printValue: - j$.private.fnNameFor(error) + + private$.fnNameFor(error) + (typeof message === 'undefined' ? '' : ': ' + matchersUtil.pp(message)) }; } @@ -118,7 +118,7 @@ getJasmineRequireObj().toBeRejectedWithError = function(j$) { function isErrorConstructor(value) { return ( typeof value === 'function' && - (value === Error || j$.private.isError(value.prototype)) + (value === Error || private$.isError(value.prototype)) ); } }; diff --git a/src/core/matchers/async/toBeResolved.js b/src/core/matchers/async/toBeResolved.js index c9ff0c04..0d404fbf 100644 --- a/src/core/matchers/async/toBeResolved.js +++ b/src/core/matchers/async/toBeResolved.js @@ -1,4 +1,4 @@ -getJasmineRequireObj().toBeResolved = function(j$) { +getJasmineRequireObj().toBeResolved = function(j$, private$) { 'use strict'; /** @@ -15,7 +15,7 @@ getJasmineRequireObj().toBeResolved = function(j$) { return function toBeResolved(matchersUtil) { return { compare: function(actual) { - if (!j$.private.isPromiseLike(actual)) { + if (!private$.isPromiseLike(actual)) { throw new Error( `Expected toBeResolved to be called on a promise but was on a ${typeof actual}.` ); diff --git a/src/core/matchers/async/toBeResolvedTo.js b/src/core/matchers/async/toBeResolvedTo.js index 59e7a01f..621af2ac 100644 --- a/src/core/matchers/async/toBeResolvedTo.js +++ b/src/core/matchers/async/toBeResolvedTo.js @@ -1,4 +1,4 @@ -getJasmineRequireObj().toBeResolvedTo = function(j$) { +getJasmineRequireObj().toBeResolvedTo = function(j$, private$) { 'use strict'; /** @@ -16,7 +16,7 @@ getJasmineRequireObj().toBeResolvedTo = function(j$) { return function toBeResolvedTo(matchersUtil) { return { compare: function(actualPromise, expectedValue) { - if (!j$.private.isPromiseLike(actualPromise)) { + if (!private$.isPromiseLike(actualPromise)) { throw new Error( `Expected toBeResolvedTo to be called on a promise but was on a ${typeof actualPromise}.` ); diff --git a/src/core/matchers/matchersUtil.js b/src/core/matchers/matchersUtil.js index 0ad6f61c..41052094 100644 --- a/src/core/matchers/matchersUtil.js +++ b/src/core/matchers/matchersUtil.js @@ -1,4 +1,4 @@ -getJasmineRequireObj().MatchersUtil = function(j$) { +getJasmineRequireObj().MatchersUtil = function(j$, private$) { 'use strict'; /** @@ -38,7 +38,7 @@ getJasmineRequireObj().MatchersUtil = function(j$) { return false; } - if (j$.private.isSet(haystack)) { + if (private$.isSet(haystack)) { // Try .has() first. It should be faster in cases where // needle === something in haystack. Fall back to .equals() comparison // if that fails. @@ -47,7 +47,7 @@ getJasmineRequireObj().MatchersUtil = function(j$) { } } - if (j$.private.isIterable(haystack) && !j$.private.isString(haystack)) { + if (private$.isIterable(haystack) && !private$.isString(haystack)) { // Arrays, Sets, etc. for (const candidate of haystack) { if (this.equals(candidate, needle)) { @@ -63,7 +63,7 @@ getJasmineRequireObj().MatchersUtil = function(j$) { return haystack.indexOf(needle) >= 0; } - if (j$.private.isNumber(haystack.length)) { + if (private$.isNumber(haystack.length)) { // Objects that are shaped like arrays but aren't iterable for (let i = 0; i < haystack.length; i++) { if (this.equals(haystack[i], needle)) { @@ -110,7 +110,7 @@ getJasmineRequireObj().MatchersUtil = function(j$) { bStack, diffBuilder ) { - if (j$.private.isFunction(b.valuesForDiff_)) { + if (private$.isFunction(b.valuesForDiff_)) { const values = b.valuesForDiff_(a, this.pp); this.eq_(values.other, values.self, aStack, bStack, diffBuilder); } else { @@ -125,8 +125,8 @@ getJasmineRequireObj().MatchersUtil = function(j$) { bStack, diffBuilder ) { - const asymmetricA = j$.private.isAsymmetricEqualityTester(a); - const asymmetricB = j$.private.isAsymmetricEqualityTester(b); + const asymmetricA = private$.isAsymmetricEqualityTester(a); + const asymmetricB = private$.isAsymmetricEqualityTester(b); if (asymmetricA === asymmetricB) { return undefined; @@ -161,7 +161,7 @@ getJasmineRequireObj().MatchersUtil = function(j$) { * @returns {boolean} True if the values are equal */ MatchersUtil.prototype.equals = function(a, b, diffBuilder) { - diffBuilder = diffBuilder || j$.private.NullDiffBuilder(); + diffBuilder = diffBuilder || private$.NullDiffBuilder(); diffBuilder.setRoots(a, b); return this.eq_(a, b, [], [], diffBuilder); @@ -276,8 +276,8 @@ getJasmineRequireObj().MatchersUtil = function(j$) { return false; } - const aIsDomNode = j$.private.isDomNode(a); - const bIsDomNode = j$.private.isDomNode(b); + const aIsDomNode = private$.isDomNode(a); + const bIsDomNode = private$.isDomNode(b); if (aIsDomNode && bIsDomNode) { // At first try to use DOM3 method isEqualNode result = a.isEqualNode(b); @@ -291,8 +291,8 @@ getJasmineRequireObj().MatchersUtil = function(j$) { return false; } - const aIsPromise = j$.private.isPromise(a); - const bIsPromise = j$.private.isPromise(b); + const aIsPromise = private$.isPromise(a); + const bIsPromise = private$.isPromise(b); if (aIsPromise && bIsPromise) { return a === b; } @@ -346,7 +346,7 @@ getJasmineRequireObj().MatchersUtil = function(j$) { if (!result) { return false; } - } else if (j$.private.isMap(a) && j$.private.isMap(b)) { + } else if (private$.isMap(a) && private$.isMap(b)) { if (a.size != b.size) { diffBuilder.recordMismatch(); return false; @@ -379,14 +379,14 @@ getJasmineRequireObj().MatchersUtil = function(j$) { // otherwise explicitly look up the mapKey in the other Map since we want keys with unique // obj identity (that are otherwise equal) to not match. if ( - j$.private.isAsymmetricEqualityTester(mapKey) || - (j$.private.isAsymmetricEqualityTester(cmpKey) && + private$.isAsymmetricEqualityTester(mapKey) || + (private$.isAsymmetricEqualityTester(cmpKey) && this.eq_( mapKey, cmpKey, aStack, bStack, - j$.private.NullDiffBuilder() + private$.NullDiffBuilder() )) ) { mapValueB = b.get(cmpKey); @@ -398,7 +398,7 @@ getJasmineRequireObj().MatchersUtil = function(j$) { mapValueB, aStack, bStack, - j$.private.NullDiffBuilder() + private$.NullDiffBuilder() ); } } @@ -407,7 +407,7 @@ getJasmineRequireObj().MatchersUtil = function(j$) { diffBuilder.recordMismatch(); return false; } - } else if (j$.private.isSet(a) && j$.private.isSet(b)) { + } else if (private$.isSet(a) && private$.isSet(b)) { if (a.size != b.size) { diffBuilder.recordMismatch(); return false; @@ -443,7 +443,7 @@ getJasmineRequireObj().MatchersUtil = function(j$) { otherValue, baseStack, otherStack, - j$.private.NullDiffBuilder() + private$.NullDiffBuilder() ); if (!found && prevStackSize !== baseStack.length) { baseStack.splice(prevStackSize); @@ -458,7 +458,7 @@ getJasmineRequireObj().MatchersUtil = function(j$) { diffBuilder.recordMismatch(); return false; } - } else if (j$.private.isURL(a) && j$.private.isURL(b)) { + } else if (private$.isURL(a) && private$.isURL(b)) { // URLs have no enumrable properties, so the default object comparison // would consider any two URLs to be equal. return a.toString() === b.toString(); @@ -496,7 +496,7 @@ getJasmineRequireObj().MatchersUtil = function(j$) { for (const key of aKeys) { // Deep compare each member - if (!j$.private.util.has(b, key)) { + if (!private$.util.has(b, key)) { diffBuilder.recordMismatch( objectKeysAreDifferentFormatter.bind(null, this.pp) ); @@ -526,7 +526,7 @@ getJasmineRequireObj().MatchersUtil = function(j$) { const allKeys = (function(o) { const keys = []; for (const key in o) { - if (j$.private.util.has(o, key)) { + if (private$.util.has(o, key)) { keys.push(key); } } @@ -567,7 +567,7 @@ getJasmineRequireObj().MatchersUtil = function(j$) { // and not in objB. function extraKeysAndValues(objA, objB) { return MatchersUtil.keys(objA) - .filter(key => !j$.private.util.has(objB, key)) + .filter(key => !private$.util.has(objB, key)) .map(key => [key, objA[key]]); } @@ -606,7 +606,7 @@ getJasmineRequireObj().MatchersUtil = function(j$) { 'Expected ' + path + ' to be a kind of ' + - j$.private.fnNameFor(expected.constructor) + + private$.fnNameFor(expected.constructor) + ', but was ' + pp(actual) + '.' diff --git a/src/core/matchers/requireAsyncMatchers.js b/src/core/matchers/requireAsyncMatchers.js index b24717db..b739ec35 100644 --- a/src/core/matchers/requireAsyncMatchers.js +++ b/src/core/matchers/requireAsyncMatchers.js @@ -1,4 +1,4 @@ -getJasmineRequireObj().requireAsyncMatchers = function(jRequire, j$) { +getJasmineRequireObj().requireAsyncMatchers = function(jRequire, j$, private$) { 'use strict'; const availableMatchers = [ @@ -12,7 +12,7 @@ getJasmineRequireObj().requireAsyncMatchers = function(jRequire, j$) { matchers = {}; for (const name of availableMatchers) { - matchers[name] = jRequire[name](j$); + matchers[name] = jRequire[name](j$, private$); } return matchers; diff --git a/src/core/matchers/requireMatchers.js b/src/core/matchers/requireMatchers.js index d0567a1e..552f311a 100755 --- a/src/core/matchers/requireMatchers.js +++ b/src/core/matchers/requireMatchers.js @@ -1,4 +1,4 @@ -getJasmineRequireObj().requireMatchers = function(jRequire, j$) { +getJasmineRequireObj().requireMatchers = function(jRequire, j$, private$) { 'use strict'; const availableMatchers = [ @@ -41,7 +41,7 @@ getJasmineRequireObj().requireMatchers = function(jRequire, j$) { matchers = {}; for (const name of availableMatchers) { - matchers[name] = jRequire[name](j$); + matchers[name] = jRequire[name](j$, private$); } return matchers; diff --git a/src/core/matchers/toBe.js b/src/core/matchers/toBe.js index bd997ff1..ae294853 100644 --- a/src/core/matchers/toBe.js +++ b/src/core/matchers/toBe.js @@ -1,4 +1,4 @@ -getJasmineRequireObj().toBe = function(j$) { +getJasmineRequireObj().toBe = function(j$, private$) { 'use strict'; /** diff --git a/src/core/matchers/toBeInstanceOf.js b/src/core/matchers/toBeInstanceOf.js index d759bca9..68810513 100644 --- a/src/core/matchers/toBeInstanceOf.js +++ b/src/core/matchers/toBeInstanceOf.js @@ -1,7 +1,7 @@ -getJasmineRequireObj().toBeInstanceOf = function(j$) { +getJasmineRequireObj().toBeInstanceOf = function(j$, private$) { 'use strict'; - const usageError = j$.private.formatErrorMsg( + const usageError = private$.formatErrorMsg( '', 'expect(value).toBeInstanceOf()' ); @@ -22,16 +22,16 @@ getJasmineRequireObj().toBeInstanceOf = function(j$) { compare: function(actual, expected) { const actualType = actual && actual.constructor - ? j$.private.fnNameFor(actual.constructor) + ? private$.fnNameFor(actual.constructor) : matchersUtil.pp(actual); const expectedType = expected - ? j$.private.fnNameFor(expected) + ? private$.fnNameFor(expected) : matchersUtil.pp(expected); let expectedMatcher; let pass; try { - expectedMatcher = new j$.private.Any(expected); + expectedMatcher = new private$.Any(expected); pass = expectedMatcher.asymmetricMatch(actual); // eslint-disable-next-line no-unused-vars } catch (error) { diff --git a/src/core/matchers/toBeNaN.js b/src/core/matchers/toBeNaN.js index 6140b50e..fe1e13b7 100644 --- a/src/core/matchers/toBeNaN.js +++ b/src/core/matchers/toBeNaN.js @@ -1,4 +1,4 @@ -getJasmineRequireObj().toBeNaN = function(j$) { +getJasmineRequireObj().toBeNaN = function(j$, private$) { 'use strict'; /** diff --git a/src/core/matchers/toBeNegativeInfinity.js b/src/core/matchers/toBeNegativeInfinity.js index ca306812..01ef5cf6 100644 --- a/src/core/matchers/toBeNegativeInfinity.js +++ b/src/core/matchers/toBeNegativeInfinity.js @@ -1,4 +1,4 @@ -getJasmineRequireObj().toBeNegativeInfinity = function(j$) { +getJasmineRequireObj().toBeNegativeInfinity = function(j$, private$) { 'use strict'; /** diff --git a/src/core/matchers/toBePositiveInfinity.js b/src/core/matchers/toBePositiveInfinity.js index 4bb1988e..3c32f975 100644 --- a/src/core/matchers/toBePositiveInfinity.js +++ b/src/core/matchers/toBePositiveInfinity.js @@ -1,4 +1,4 @@ -getJasmineRequireObj().toBePositiveInfinity = function(j$) { +getJasmineRequireObj().toBePositiveInfinity = function(j$, private$) { 'use strict'; /** diff --git a/src/core/matchers/toEqual.js b/src/core/matchers/toEqual.js index 9a8ad1c0..345797c7 100644 --- a/src/core/matchers/toEqual.js +++ b/src/core/matchers/toEqual.js @@ -1,4 +1,4 @@ -getJasmineRequireObj().toEqual = function(j$) { +getJasmineRequireObj().toEqual = function(j$, private$) { 'use strict'; /** @@ -16,7 +16,7 @@ getJasmineRequireObj().toEqual = function(j$) { const result = { pass: false }, - diffBuilder = new j$.private.DiffBuilder({ + diffBuilder = new private$.DiffBuilder({ prettyPrinter: matchersUtil.pp }); diff --git a/src/core/matchers/toHaveBeenCalled.js b/src/core/matchers/toHaveBeenCalled.js index 6da4c407..fdcfc373 100644 --- a/src/core/matchers/toHaveBeenCalled.js +++ b/src/core/matchers/toHaveBeenCalled.js @@ -1,7 +1,7 @@ -getJasmineRequireObj().toHaveBeenCalled = function(j$) { +getJasmineRequireObj().toHaveBeenCalled = function(j$, private$) { 'use strict'; - const getErrorMsg = j$.private.formatErrorMsg( + const getErrorMsg = private$.formatErrorMsg( '', 'expect().toHaveBeenCalled()' ); diff --git a/src/core/matchers/toHaveBeenCalledBefore.js b/src/core/matchers/toHaveBeenCalledBefore.js index 8f95fc74..d5816b40 100644 --- a/src/core/matchers/toHaveBeenCalledBefore.js +++ b/src/core/matchers/toHaveBeenCalledBefore.js @@ -1,7 +1,7 @@ -getJasmineRequireObj().toHaveBeenCalledBefore = function(j$) { +getJasmineRequireObj().toHaveBeenCalledBefore = function(j$, private$) { 'use strict'; - const getErrorMsg = j$.private.formatErrorMsg( + const getErrorMsg = private$.formatErrorMsg( '', 'expect().toHaveBeenCalledBefore()' ); diff --git a/src/core/matchers/toHaveBeenCalledOnceWith.js b/src/core/matchers/toHaveBeenCalledOnceWith.js index 1b241ab0..68e73515 100644 --- a/src/core/matchers/toHaveBeenCalledOnceWith.js +++ b/src/core/matchers/toHaveBeenCalledOnceWith.js @@ -1,7 +1,7 @@ -getJasmineRequireObj().toHaveBeenCalledOnceWith = function(j$) { +getJasmineRequireObj().toHaveBeenCalledOnceWith = function(j$, private$) { 'use strict'; - const getErrorMsg = j$.private.formatErrorMsg( + const getErrorMsg = private$.formatErrorMsg( '', 'expect().toHaveBeenCalledOnceWith(...arguments)' ); @@ -64,7 +64,7 @@ getJasmineRequireObj().toHaveBeenCalledOnceWith = function(j$) { function getDiffs() { return actual.calls.allArgs().map(function(argsForCall, callIx) { - const diffBuilder = new j$.private.DiffBuilder(); + const diffBuilder = new private$.DiffBuilder(); matchersUtil.equals(argsForCall, expectedArgs, diffBuilder); return diffBuilder.getMessage(); }); diff --git a/src/core/matchers/toHaveBeenCalledTimes.js b/src/core/matchers/toHaveBeenCalledTimes.js index 68023ac0..7a5cbb56 100644 --- a/src/core/matchers/toHaveBeenCalledTimes.js +++ b/src/core/matchers/toHaveBeenCalledTimes.js @@ -1,7 +1,7 @@ -getJasmineRequireObj().toHaveBeenCalledTimes = function(j$) { +getJasmineRequireObj().toHaveBeenCalledTimes = function(j$, private$) { 'use strict'; - const getErrorMsg = j$.private.formatErrorMsg( + const getErrorMsg = private$.formatErrorMsg( '', 'expect().toHaveBeenCalledTimes()' ); @@ -29,7 +29,7 @@ getJasmineRequireObj().toHaveBeenCalledTimes = function(j$) { const args = Array.prototype.slice.call(arguments, 0), result = { pass: false }; - if (!j$.private.isNumber(expected)) { + if (!private$.isNumber(expected)) { throw new Error( getErrorMsg( 'The expected times failed is a required argument and must be a number.' diff --git a/src/core/matchers/toHaveBeenCalledWith.js b/src/core/matchers/toHaveBeenCalledWith.js index ebdc8492..3d02fb63 100644 --- a/src/core/matchers/toHaveBeenCalledWith.js +++ b/src/core/matchers/toHaveBeenCalledWith.js @@ -1,7 +1,7 @@ -getJasmineRequireObj().toHaveBeenCalledWith = function(j$) { +getJasmineRequireObj().toHaveBeenCalledWith = function(j$, private$) { 'use strict'; - const getErrorMsg = j$.private.formatErrorMsg( + const getErrorMsg = private$.formatErrorMsg( '', 'expect().toHaveBeenCalledWith(...arguments)' ); @@ -73,7 +73,7 @@ getJasmineRequireObj().toHaveBeenCalledWith = function(j$) { const diffs = actual.calls .allArgs() .map(function(argsForCall, callIx) { - const diffBuilder = new j$.private.DiffBuilder(); + const diffBuilder = new private$.DiffBuilder(); matchersUtil.equals(argsForCall, expectedArgs, diffBuilder); return ( 'Call ' + diff --git a/src/core/matchers/toHaveClass.js b/src/core/matchers/toHaveClass.js index 63591a6e..9212315e 100644 --- a/src/core/matchers/toHaveClass.js +++ b/src/core/matchers/toHaveClass.js @@ -1,4 +1,4 @@ -getJasmineRequireObj().toHaveClass = function(j$) { +getJasmineRequireObj().toHaveClass = function(j$, private$) { 'use strict'; /** @@ -30,7 +30,7 @@ getJasmineRequireObj().toHaveClass = function(j$) { return ( maybeEl && maybeEl.classList && - j$.private.isFunction(maybeEl.classList.contains) + private$.isFunction(maybeEl.classList.contains) ); } diff --git a/src/core/matchers/toHaveClasses.js b/src/core/matchers/toHaveClasses.js index 145ec29d..25639d51 100644 --- a/src/core/matchers/toHaveClasses.js +++ b/src/core/matchers/toHaveClasses.js @@ -1,4 +1,4 @@ -getJasmineRequireObj().toHaveClasses = function(j$) { +getJasmineRequireObj().toHaveClasses = function(j$, private$) { 'use strict'; /** @@ -30,7 +30,7 @@ getJasmineRequireObj().toHaveClasses = function(j$) { return ( maybeEl && maybeEl.classList && - j$.private.isFunction(maybeEl.classList.contains) + private$.isFunction(maybeEl.classList.contains) ); } diff --git a/src/core/matchers/toHaveNoOtherSpyInteractions.js b/src/core/matchers/toHaveNoOtherSpyInteractions.js index a358828a..dae1c56a 100644 --- a/src/core/matchers/toHaveNoOtherSpyInteractions.js +++ b/src/core/matchers/toHaveNoOtherSpyInteractions.js @@ -1,7 +1,7 @@ -getJasmineRequireObj().toHaveNoOtherSpyInteractions = function(j$) { +getJasmineRequireObj().toHaveNoOtherSpyInteractions = function(j$, private$) { 'use strict'; - const getErrorMsg = j$.private.formatErrorMsg( + const getErrorMsg = private$.formatErrorMsg( '', 'expect().toHaveNoOtherSpyInteractions()' ); @@ -19,7 +19,7 @@ getJasmineRequireObj().toHaveNoOtherSpyInteractions = function(j$) { compare: function(actual) { const result = {}; - if (!j$.private.isObject(actual)) { + if (!private$.isObject(actual)) { throw new Error( getErrorMsg('Expected an object, but got ' + typeof actual + '.') ); diff --git a/src/core/matchers/toHaveSize.js b/src/core/matchers/toHaveSize.js index d393a2e4..b59de392 100644 --- a/src/core/matchers/toHaveSize.js +++ b/src/core/matchers/toHaveSize.js @@ -1,4 +1,4 @@ -getJasmineRequireObj().toHaveSize = function(j$) { +getJasmineRequireObj().toHaveSize = function(j$, private$) { 'use strict'; /** @@ -19,15 +19,15 @@ getJasmineRequireObj().toHaveSize = function(j$) { }; if ( - j$.private.isA('WeakSet', actual) || - j$.private.isWeakMap(actual) || - j$.private.isDataView(actual) + private$.isA('WeakSet', actual) || + private$.isWeakMap(actual) || + private$.isDataView(actual) ) { throw new Error('Cannot get size of ' + actual + '.'); } let actualSize; - if (j$.private.isSet(actual) || j$.private.isMap(actual)) { + if (private$.isSet(actual) || private$.isMap(actual)) { actualSize = actual.size; } else if (isLength(actual.length)) { actualSize = actual.length; diff --git a/src/core/matchers/toHaveSpyInteractions.js b/src/core/matchers/toHaveSpyInteractions.js index 9851200d..f9ba9458 100755 --- a/src/core/matchers/toHaveSpyInteractions.js +++ b/src/core/matchers/toHaveSpyInteractions.js @@ -1,7 +1,7 @@ -getJasmineRequireObj().toHaveSpyInteractions = function(j$) { +getJasmineRequireObj().toHaveSpyInteractions = function(j$, private$) { 'use strict'; - const getErrorMsg = j$.private.formatErrorMsg( + const getErrorMsg = private$.formatErrorMsg( '', 'expect().toHaveSpyInteractions()' ); @@ -20,7 +20,7 @@ getJasmineRequireObj().toHaveSpyInteractions = function(j$) { compare: function(actual) { const result = {}; - if (!j$.private.isObject(actual)) { + if (!private$.isObject(actual)) { throw new Error( getErrorMsg('Expected a spy object, but got ' + typeof actual + '.') ); diff --git a/src/core/matchers/toMatch.js b/src/core/matchers/toMatch.js index dd07f713..a509debb 100644 --- a/src/core/matchers/toMatch.js +++ b/src/core/matchers/toMatch.js @@ -1,7 +1,7 @@ -getJasmineRequireObj().toMatch = function(j$) { +getJasmineRequireObj().toMatch = function(j$, private$) { 'use strict'; - const getErrorMsg = j$.private.formatErrorMsg( + const getErrorMsg = private$.formatErrorMsg( '', 'expect().toMatch( || )' ); @@ -19,10 +19,7 @@ getJasmineRequireObj().toMatch = function(j$) { function toMatch() { return { compare: function(actual, expected) { - if ( - !j$.private.isString(expected) && - !j$.private.isA('RegExp', expected) - ) { + if (!private$.isString(expected) && !private$.isA('RegExp', expected)) { throw new Error(getErrorMsg('Expected is not a String or a RegExp')); } diff --git a/src/core/matchers/toThrow.js b/src/core/matchers/toThrow.js index 00c6415c..91e4a0c2 100644 --- a/src/core/matchers/toThrow.js +++ b/src/core/matchers/toThrow.js @@ -1,7 +1,7 @@ -getJasmineRequireObj().toThrow = function(j$) { +getJasmineRequireObj().toThrow = function(j$, private$) { 'use strict'; - const getErrorMsg = j$.private.formatErrorMsg( + const getErrorMsg = private$.formatErrorMsg( '', 'expect(function() {}).toThrow()' ); diff --git a/src/core/matchers/toThrowError.js b/src/core/matchers/toThrowError.js index 7fb729b6..27d34e0b 100644 --- a/src/core/matchers/toThrowError.js +++ b/src/core/matchers/toThrowError.js @@ -1,7 +1,7 @@ -getJasmineRequireObj().toThrowError = function(j$) { +getJasmineRequireObj().toThrowError = function(j$, private$) { 'use strict'; - const getErrorMsg = j$.private.formatErrorMsg( + const getErrorMsg = private$.formatErrorMsg( '', 'expect(function() {}).toThrowError(, )' ); @@ -38,7 +38,7 @@ getJasmineRequireObj().toThrowError = function(j$) { thrown = e; } - if (!j$.private.isError(thrown)) { + if (!private$.isError(thrown)) { return fail(function() { return ( 'Expected function to throw an Error, but it threw ' + @@ -81,7 +81,7 @@ getJasmineRequireObj().toThrowError = function(j$) { match: function(error) { return pass( 'Expected function not to throw an Error, but it threw ' + - j$.private.fnNameFor(error) + + private$.fnNameFor(error) + '.' ); } @@ -110,12 +110,12 @@ getJasmineRequireObj().toThrowError = function(j$) { } const errorTypeDescription = errorType - ? j$.private.fnNameFor(errorType) + ? private$.fnNameFor(errorType) : 'an exception'; function thrownDescription(thrown) { const thrownName = errorType - ? j$.private.fnNameFor(thrown.constructor) + ? private$.fnNameFor(thrown.constructor) : 'an exception'; let thrownMessage = ''; @@ -181,7 +181,7 @@ getJasmineRequireObj().toThrowError = function(j$) { const Surrogate = function() {}; Surrogate.prototype = type.prototype; - return j$.private.isError(new Surrogate()); + return private$.isError(new Surrogate()); } } diff --git a/src/core/matchers/toThrowMatching.js b/src/core/matchers/toThrowMatching.js index d684ab36..8fa763dd 100644 --- a/src/core/matchers/toThrowMatching.js +++ b/src/core/matchers/toThrowMatching.js @@ -1,7 +1,7 @@ -getJasmineRequireObj().toThrowMatching = function(j$) { +getJasmineRequireObj().toThrowMatching = function(j$, private$) { 'use strict'; - const usageError = j$.private.formatErrorMsg( + const usageError = private$.formatErrorMsg( '', 'expect(function() {}).toThrowMatching()' ); @@ -55,7 +55,7 @@ getJasmineRequireObj().toThrowMatching = function(j$) { function thrownDescription(thrown) { if (thrown && thrown.constructor) { return ( - j$.private.fnNameFor(thrown.constructor) + + private$.fnNameFor(thrown.constructor) + ' with message ' + matchersUtil.pp(thrown.message) ); diff --git a/src/core/reporterEvents.js b/src/core/reporterEvents.js index 55243039..638c6c49 100644 --- a/src/core/reporterEvents.js +++ b/src/core/reporterEvents.js @@ -1,4 +1,4 @@ -getJasmineRequireObj().reporterEvents = function(j$) { +getJasmineRequireObj().reporterEvents = function(j$, private$) { 'use strict'; /** diff --git a/src/core/requireCore.js b/src/core/requireCore.js index 387a560f..48e91cc6 100644 --- a/src/core/requireCore.js +++ b/src/core/requireCore.js @@ -1,5 +1,5 @@ -// eslint-disable-next-line no-unused-vars,no-var -var getJasmineRequireObj = (function() { +// eslint-disable-next-line no-unused-vars +const getJasmineRequireObj = (function() { 'use strict'; let jasmineRequire; @@ -12,7 +12,7 @@ var getJasmineRequireObj = (function() { jasmineRequire = exports; } else { // Browser - jasmineRequire = globalThis.jasmineRequire = {}; + jasmineRequire = {}; } function getJasmineRequire() { @@ -20,88 +20,101 @@ var getJasmineRequireObj = (function() { } getJasmineRequire().core = function(jRequire) { + const private$ = {}; const j$ = {}; - Object.defineProperty(j$, 'private', { - enumerable: true, - value: {} - }); - jRequire.base(j$, globalThis); - j$.private.util = jRequire.util(j$); - j$.private.errors = jRequire.errors(); - j$.private.formatErrorMsg = jRequire.formatErrorMsg(j$); - j$.private.AllOf = jRequire.AllOf(j$); - j$.private.Any = jRequire.Any(j$); - j$.private.Anything = jRequire.Anything(j$); - j$.private.CallTracker = jRequire.CallTracker(j$); - j$.private.MockDate = jRequire.MockDate(j$); - j$.private.getStackClearer = jRequire.StackClearer(j$); - j$.private.Clock = jRequire.Clock(j$); - j$.private.DelayedFunctionScheduler = jRequire.DelayedFunctionScheduler(j$); - j$.private.Deprecator = jRequire.Deprecator(j$); - j$.private.Configuration = jRequire.Configuration(j$); - j$.private.Env = jRequire.Env(j$); - j$.private.StackTrace = jRequire.StackTrace(j$); - j$.private.ExceptionFormatter = jRequire.ExceptionFormatter(j$); - j$.private.ExpectationFilterChain = jRequire.ExpectationFilterChain(); - j$.private.Expector = jRequire.Expector(j$); - j$.private.Expectation = jRequire.Expectation(j$); - j$.private.buildExpectationResult = jRequire.buildExpectationResult(j$); - j$.private.makePrettyPrinter = jRequire.makePrettyPrinter(j$); - j$.private.basicPrettyPrinter = j$.private.makePrettyPrinter(); - j$.private.MatchersUtil = jRequire.MatchersUtil(j$); - j$.private.ObjectContaining = jRequire.ObjectContaining(j$); - j$.private.ArrayContaining = jRequire.ArrayContaining(j$); - j$.private.ArrayWithExactContents = jRequire.ArrayWithExactContents(j$); - j$.private.MapContaining = jRequire.MapContaining(j$); - j$.private.SetContaining = jRequire.SetContaining(j$); - j$.private.QueueRunner = jRequire.QueueRunner(j$); - j$.private.NeverSkipPolicy = jRequire.NeverSkipPolicy(j$); - j$.private.SkipAfterBeforeAllErrorPolicy = jRequire.SkipAfterBeforeAllErrorPolicy( + jRequire.base(j$, private$, globalThis); + private$.util = jRequire.util(j$, private$); + private$.errors = jRequire.errors(); + private$.formatErrorMsg = jRequire.formatErrorMsg(j$, private$); + private$.AllOf = jRequire.AllOf(j$, private$); + private$.Any = jRequire.Any(j$, private$); + private$.Anything = jRequire.Anything(j$, private$); + private$.CallTracker = jRequire.CallTracker(j$, private$); + private$.MockDate = jRequire.MockDate(j$, private$); + private$.getStackClearer = jRequire.StackClearer(j$, private$); + private$.Clock = jRequire.Clock(j$, private$); + private$.DelayedFunctionScheduler = jRequire.DelayedFunctionScheduler( + j$, + private$ + ); + private$.Deprecator = jRequire.Deprecator(j$, private$); + private$.Configuration = jRequire.Configuration(j$, private$); + private$.Env = jRequire.Env(j$, private$); + private$.StackTrace = jRequire.StackTrace(j$, private$); + private$.ExceptionFormatter = jRequire.ExceptionFormatter(j$, private$); + private$.ExpectationFilterChain = jRequire.ExpectationFilterChain(); + private$.Expector = jRequire.Expector(j$, private$); + private$.Expectation = jRequire.Expectation(j$, private$); + private$.buildExpectationResult = jRequire.buildExpectationResult( + j$, + private$ + ); + private$.makePrettyPrinter = jRequire.makePrettyPrinter(j$, private$); + private$.basicPrettyPrinter = private$.makePrettyPrinter(); + private$.MatchersUtil = jRequire.MatchersUtil(j$, private$); + private$.ObjectContaining = jRequire.ObjectContaining(j$, private$); + private$.ArrayContaining = jRequire.ArrayContaining(j$, private$); + private$.ArrayWithExactContents = jRequire.ArrayWithExactContents( + j$, + private$ + ); + private$.MapContaining = jRequire.MapContaining(j$, private$); + private$.SetContaining = jRequire.SetContaining(j$, private$); + private$.QueueRunner = jRequire.QueueRunner(j$, private$); + private$.NeverSkipPolicy = jRequire.NeverSkipPolicy(j$, private$); + private$.SkipAfterBeforeAllErrorPolicy = jRequire.SkipAfterBeforeAllErrorPolicy( j$ ); - j$.private.CompleteOnFirstErrorSkipPolicy = jRequire.CompleteOnFirstErrorSkipPolicy( + private$.CompleteOnFirstErrorSkipPolicy = jRequire.CompleteOnFirstErrorSkipPolicy( j$ ); - j$.private.reporterEvents = jRequire.reporterEvents(j$); - j$.private.ReportDispatcher = jRequire.ReportDispatcher(j$); - j$.ParallelReportDispatcher = jRequire.ParallelReportDispatcher(j$); - j$.private.CurrentRunableTracker = jRequire.CurrentRunableTracker(); - j$.private.RunableResources = jRequire.RunableResources(j$); - j$.private.Runner = jRequire.Runner(j$); - j$.private.Spec = jRequire.Spec(j$); - j$.private.Spy = jRequire.Spy(j$); - j$.private.SpyFactory = jRequire.SpyFactory(j$); - j$.private.SpyRegistry = jRequire.SpyRegistry(j$); - j$.private.SpyStrategy = jRequire.SpyStrategy(j$); - j$.private.StringMatching = jRequire.StringMatching(j$); - j$.private.StringContaining = jRequire.StringContaining(j$); - j$.private.UserContext = jRequire.UserContext(j$); - j$.private.Suite = jRequire.Suite(j$); - j$.private.SuiteBuilder = jRequire.SuiteBuilder(j$); + private$.reporterEvents = jRequire.reporterEvents(j$, private$); + private$.ReportDispatcher = jRequire.ReportDispatcher(j$, private$); + j$.ParallelReportDispatcher = jRequire.ParallelReportDispatcher( + j$, + private$ + ); + private$.CurrentRunableTracker = jRequire.CurrentRunableTracker(); + private$.RunableResources = jRequire.RunableResources(j$, private$); + private$.Runner = jRequire.Runner(j$, private$); + private$.Spec = jRequire.Spec(j$, private$); + private$.Spy = jRequire.Spy(j$, private$); + private$.SpyFactory = jRequire.SpyFactory(j$, private$); + private$.SpyRegistry = jRequire.SpyRegistry(j$, private$); + private$.SpyStrategy = jRequire.SpyStrategy(j$, private$); + private$.StringMatching = jRequire.StringMatching(j$, private$); + private$.StringContaining = jRequire.StringContaining(j$, private$); + private$.UserContext = jRequire.UserContext(j$, private$); + private$.Suite = jRequire.Suite(j$, private$); + private$.SuiteBuilder = jRequire.SuiteBuilder(j$, private$); j$.Timer = jRequire.Timer(); - j$.private.TreeProcessor = jRequire.TreeProcessor(j$); - j$.private.TreeRunner = jRequire.TreeRunner(j$); + private$.TreeProcessor = jRequire.TreeProcessor(j$, private$); + private$.TreeRunner = jRequire.TreeRunner(j$, private$); j$.version = jRequire.version(); - j$.private.Order = jRequire.Order(); - j$.private.DiffBuilder = jRequire.DiffBuilder(j$); - j$.private.NullDiffBuilder = jRequire.NullDiffBuilder(j$); - j$.private.ObjectPath = jRequire.ObjectPath(j$); - j$.private.MismatchTree = jRequire.MismatchTree(j$); - j$.private.GlobalErrors = jRequire.GlobalErrors(j$); - j$.private.Truthy = jRequire.Truthy(j$); - j$.private.Falsy = jRequire.Falsy(j$); - j$.private.Empty = jRequire.Empty(j$); - j$.private.NotEmpty = jRequire.NotEmpty(j$); - j$.private.Is = jRequire.Is(j$); + private$.Order = jRequire.Order(); + private$.DiffBuilder = jRequire.DiffBuilder(j$, private$); + private$.NullDiffBuilder = jRequire.NullDiffBuilder(j$, private$); + private$.ObjectPath = jRequire.ObjectPath(j$, private$); + private$.MismatchTree = jRequire.MismatchTree(j$, private$); + private$.GlobalErrors = jRequire.GlobalErrors(j$, private$); + private$.Truthy = jRequire.Truthy(j$, private$); + private$.Falsy = jRequire.Falsy(j$, private$); + private$.Empty = jRequire.Empty(j$, private$); + private$.NotEmpty = jRequire.NotEmpty(j$, private$); + private$.Is = jRequire.Is(j$, private$); - j$.private.matchers = jRequire.requireMatchers(jRequire, j$); - j$.private.asyncMatchers = jRequire.requireAsyncMatchers(jRequire, j$); + private$.matchers = jRequire.requireMatchers(jRequire, j$, private$); + private$.asyncMatchers = jRequire.requireAsyncMatchers( + jRequire, + j$, + private$ + ); - j$.private.loadedAsBrowserEsm = + private$.loadedAsBrowserEsm = globalThis.document && !globalThis.document.currentScript; - return j$; + return { jasmine: j$, private: private$ }; }; return getJasmineRequire; diff --git a/src/core/requireSuffix.js b/src/core/requireSuffix.js new file mode 100644 index 00000000..170d60da --- /dev/null +++ b/src/core/requireSuffix.js @@ -0,0 +1,35 @@ +(function() { + 'use strict'; + + const isNode = typeof module !== 'undefined' && module.exports; + const jasmineRequire = getJasmineRequireObj(); + + function bootJasmine(options) { + const jasmine = jasmineRequire.core(jasmineRequire).jasmine; + const env = jasmine.getEnv(options); + const jasmineInterface = jasmineRequire.interface(jasmine, env); + const globals = { + jasmine, + ...jasmineInterface + }; + + return { + jasmine, + globals, + installGlobals(dest) { + dest = dest ?? globalThis; + + for (const [k, v] of Object.entries(globals)) { + dest[k] = v; + } + } + }; + } + + if (isNode) { + module.exports = bootJasmine({ suppressLoadErrors: true }); + } else { + // Browser + bootJasmine().installGlobals(); + } +})(); diff --git a/src/core/util.js b/src/core/util.js index a39defae..1d6efc30 100644 --- a/src/core/util.js +++ b/src/core/util.js @@ -1,4 +1,4 @@ -getJasmineRequireObj().util = function(j$) { +getJasmineRequireObj().util = function(j$, private$) { 'use strict'; const util = {}; @@ -29,7 +29,7 @@ getJasmineRequireObj().util = function(j$) { } else if (str === '[object Date]') { return new Date(arg.valueOf()); } else { - return j$.private.util.clone(arg); + return private$.util.clone(arg); } }); }; @@ -51,7 +51,7 @@ getJasmineRequireObj().util = function(j$) { }; function callerFile() { - const trace = new j$.private.StackTrace(new Error()); + const trace = new private$.StackTrace(new Error()); return trace.frames[1].file; } diff --git a/src/html/AlertsView.js b/src/html/AlertsView.js index 8575a043..50db16a4 100644 --- a/src/html/AlertsView.js +++ b/src/html/AlertsView.js @@ -1,7 +1,7 @@ -jasmineRequire.AlertsView = function(j$) { +getJasmineHtmlRequireObj().AlertsView = function(j$, private$) { 'use strict'; - const { createDom } = j$.private.htmlReporterUtils; + const { createDom } = private$.htmlReporterUtils; const errorBarClassName = 'jasmine-bar jasmine-errored'; const afterAllMessagePrefix = 'AfterAll '; diff --git a/src/html/Banner.js b/src/html/Banner.js index f3e93377..44bf8f12 100644 --- a/src/html/Banner.js +++ b/src/html/Banner.js @@ -1,7 +1,7 @@ -jasmineRequire.Banner = function(j$) { +getJasmineHtmlRequireObj().Banner = function(j$, private$) { 'use strict'; - const { createDom } = j$.private.htmlReporterUtils; + const { createDom } = private$.htmlReporterUtils; class Banner { #navigateWithNewParam; diff --git a/src/html/FailuresView.js b/src/html/FailuresView.js index 55412144..6169b425 100644 --- a/src/html/FailuresView.js +++ b/src/html/FailuresView.js @@ -1,7 +1,7 @@ -jasmineRequire.FailuresView = function(j$) { +getJasmineHtmlRequireObj().FailuresView = function(j$, private$) { 'use strict'; - const { createDom } = j$.private.htmlReporterUtils; + const { createDom } = private$.htmlReporterUtils; class FailuresView { #urlBuilder; diff --git a/src/html/HtmlReporterV2.js b/src/html/HtmlReporterV2.js index b379d576..c0a0515d 100644 --- a/src/html/HtmlReporterV2.js +++ b/src/html/HtmlReporterV2.js @@ -1,7 +1,7 @@ -jasmineRequire.HtmlReporterV2 = function(j$) { +getJasmineHtmlRequireObj().HtmlReporterV2 = function(j$, private$) { 'use strict'; - const { createDom, noExpectations } = j$.private.htmlReporterUtils; + const { createDom, noExpectations } = private$.htmlReporterUtils; const specListTabId = 'jasmine-specListTab'; const failuresTabId = 'jasmine-failuresTab'; @@ -57,14 +57,14 @@ jasmineRequire.HtmlReporterV2 = function(j$) { this.#config = options.env ? options.env.configuration() : {}; - this.#stateBuilder = new j$.private.ResultsStateBuilder(); + this.#stateBuilder = new private$.ResultsStateBuilder(); - this.#alerts = new j$.private.AlertsView(this.#urlBuilder); - this.#statusBar = new j$.private.OverallStatusBar(this.#urlBuilder); + this.#alerts = new private$.AlertsView(this.#urlBuilder); + this.#statusBar = new private$.OverallStatusBar(this.#urlBuilder); this.#statusBar.showRunning(); this.#alerts.addBar(this.#statusBar.rootEl); - this.#tabBar = new j$.private.TabBar( + this.#tabBar = new private$.TabBar( [ { id: specListTabId, label: 'Spec List' }, { id: failuresTabId, label: 'Failures' }, @@ -83,11 +83,11 @@ jasmineRequire.HtmlReporterV2 = function(j$) { this.#alerts.addBar(this.#tabBar.rootEl); this.#progress = new ProgressView(); - this.#banner = new j$.private.Banner( + this.#banner = new private$.Banner( this.#queryString.navigateWithNewParam.bind(this.#queryString), true ); - this.#failures = new j$.private.FailuresView(this.#urlBuilder); + this.#failures = new private$.FailuresView(this.#urlBuilder); this.#htmlReporterMain = createDom( 'div', { className: 'jasmine_html-reporter' }, @@ -168,13 +168,13 @@ jasmineRequire.HtmlReporterV2 = function(j$) { } const results = this.#find('.jasmine-results'); - const summary = new j$.private.SummaryTreeView( + const summary = new private$.SummaryTreeView( this.#urlBuilder, this.#filterSpecs ); summary.addResults(this.#stateBuilder.topResults); results.appendChild(summary.rootEl); - const perf = new j$.private.PerformanceView(); + const perf = new private$.PerformanceView(); perf.addResults(this.#stateBuilder.topResults); results.appendChild(perf.rootEl); this.#tabBar.showTab(specListTabId); diff --git a/src/html/HtmlReporterV2Urls.js b/src/html/HtmlReporterV2Urls.js index cfa66db8..c6ef4825 100644 --- a/src/html/HtmlReporterV2Urls.js +++ b/src/html/HtmlReporterV2Urls.js @@ -1,4 +1,4 @@ -jasmineRequire.HtmlReporterV2Urls = function(j$) { +getJasmineHtmlRequireObj().HtmlReporterV2Urls = function(j$, private$) { 'use strict'; // TODO unify with V2 UrlBuilder? @@ -49,7 +49,7 @@ jasmineRequire.HtmlReporterV2Urls = function(j$) { config.seed = seed; } - const specFilter = new j$.private.HtmlSpecFilterV2({ + const specFilter = new private$.HtmlSpecFilterV2({ filterParams: () => ({ path: this.queryString.getParam('path'), spec: this.queryString.getParam('spec') diff --git a/src/html/HtmlSpecFilterv2.js b/src/html/HtmlSpecFilterv2.js index 5e93b3cc..02772963 100644 --- a/src/html/HtmlSpecFilterv2.js +++ b/src/html/HtmlSpecFilterv2.js @@ -1,4 +1,4 @@ -jasmineRequire.HtmlSpecFilterV2 = function() { +getJasmineHtmlRequireObj().HtmlSpecFilterV2 = function() { class HtmlSpecFilterV2 { #getFilterParams; diff --git a/src/html/OverallStatusBar.js b/src/html/OverallStatusBar.js index 7172ab55..84422b42 100644 --- a/src/html/OverallStatusBar.js +++ b/src/html/OverallStatusBar.js @@ -1,7 +1,7 @@ -jasmineRequire.OverallStatusBar = function(j$) { +getJasmineHtmlRequireObj().OverallStatusBar = function(j$, private$) { 'use strict'; - const { createDom } = j$.private.htmlReporterUtils; + const { createDom } = private$.htmlReporterUtils; const staticClassNames = 'jasmine-overall-result jasmine-bar'; class OverallStatusBar { diff --git a/src/html/PerformanceView.js b/src/html/PerformanceView.js index 5f1f2948..13826cca 100644 --- a/src/html/PerformanceView.js +++ b/src/html/PerformanceView.js @@ -1,5 +1,5 @@ -jasmineRequire.PerformanceView = function(j$) { - const createDom = j$.private.htmlReporterUtils.createDom; +getJasmineHtmlRequireObj().PerformanceView = function(j$, private$) { + const createDom = private$.htmlReporterUtils.createDom; const MAX_SLOW_SPECS = 20; class PerformanceView { diff --git a/src/html/QueryString.js b/src/html/QueryString.js index 9e380f54..9946c19a 100644 --- a/src/html/QueryString.js +++ b/src/html/QueryString.js @@ -1,4 +1,4 @@ -jasmineRequire.QueryString = function() { +getJasmineHtmlRequireObj().QueryString = function() { 'use strict'; /** diff --git a/src/html/ResultsNode.js b/src/html/ResultsNode.js index d9331a40..52835c21 100644 --- a/src/html/ResultsNode.js +++ b/src/html/ResultsNode.js @@ -1,4 +1,4 @@ -jasmineRequire.ResultsNode = function() { +getJasmineHtmlRequireObj().ResultsNode = function() { 'use strict'; function ResultsNode(result, type, parent) { diff --git a/src/html/ResultsStateBuilder.js b/src/html/ResultsStateBuilder.js index 0613152a..16dde476 100644 --- a/src/html/ResultsStateBuilder.js +++ b/src/html/ResultsStateBuilder.js @@ -1,9 +1,9 @@ -jasmineRequire.ResultsStateBuilder = function(j$) { +getJasmineHtmlRequireObj().ResultsStateBuilder = function(j$, private$) { 'use strict'; class ResultsStateBuilder { constructor() { - this.topResults = new j$.private.ResultsNode({}, '', null); + this.topResults = new private$.ResultsNode({}, '', null); this.currentParent = this.topResults; this.suitesById = {}; this.totalSpecsDefined = 0; diff --git a/src/html/SummaryTreeView.js b/src/html/SummaryTreeView.js index 560641e7..97d42815 100644 --- a/src/html/SummaryTreeView.js +++ b/src/html/SummaryTreeView.js @@ -1,7 +1,7 @@ -jasmineRequire.SummaryTreeView = function(j$) { +getJasmineHtmlRequireObj().SummaryTreeView = function(j$, private$) { 'use strict'; - const { createDom, noExpectations } = j$.private.htmlReporterUtils; + const { createDom, noExpectations } = private$.htmlReporterUtils; class SummaryTreeView { #urlBuilder; diff --git a/src/html/TabBar.js b/src/html/TabBar.js index 0f4742ff..6ae00d76 100644 --- a/src/html/TabBar.js +++ b/src/html/TabBar.js @@ -1,5 +1,5 @@ -jasmineRequire.TabBar = function(j$) { - const createDom = j$.private.htmlReporterUtils.createDom; +getJasmineHtmlRequireObj().TabBar = function(j$, private$) { + const createDom = private$.htmlReporterUtils.createDom; class TabBar { #tabs; diff --git a/src/html/htmlReporterUtils.js b/src/html/htmlReporterUtils.js index 6a4e407d..dccd465b 100644 --- a/src/html/htmlReporterUtils.js +++ b/src/html/htmlReporterUtils.js @@ -1,4 +1,4 @@ -jasmineRequire.htmlReporterUtils = function(j$) { +getJasmineHtmlRequireObj().htmlReporterUtils = function(j$, private$) { 'use strict'; function createDom(type, attrs, childrenArrayOrVarArgs) { diff --git a/src/html/requireHtml.js b/src/html/requireHtml.js index df196937..13ee40a2 100644 --- a/src/html/requireHtml.js +++ b/src/html/requireHtml.js @@ -1,19 +1,35 @@ -// eslint-disable-next-line no-var -var jasmineRequire = window.jasmineRequire || require('./jasmine.js'); +// eslint-disable-next-line no-unused-vars +const getJasmineHtmlRequireObj = (function() { + 'use strict'; + const htmlRequire = {}; -jasmineRequire.html = function(j$) { - j$.private.ResultsNode = jasmineRequire.ResultsNode(); - j$.private.ResultsStateBuilder = jasmineRequire.ResultsStateBuilder(j$); - j$.private.htmlReporterUtils = jasmineRequire.htmlReporterUtils(j$); - j$.private.AlertsView = jasmineRequire.AlertsView(j$); - j$.private.OverallStatusBar = jasmineRequire.OverallStatusBar(j$); - j$.private.Banner = jasmineRequire.Banner(j$); - j$.private.SummaryTreeView = jasmineRequire.SummaryTreeView(j$); - j$.private.FailuresView = jasmineRequire.FailuresView(j$); - j$.private.PerformanceView = jasmineRequire.PerformanceView(j$); - j$.private.TabBar = jasmineRequire.TabBar(j$); - j$.HtmlReporterV2Urls = jasmineRequire.HtmlReporterV2Urls(j$); - j$.HtmlReporterV2 = jasmineRequire.HtmlReporterV2(j$); - j$.QueryString = jasmineRequire.QueryString(); - j$.private.HtmlSpecFilterV2 = jasmineRequire.HtmlSpecFilterV2(); -}; + function getJasmineHtmlRequire() { + return htmlRequire; + } + + htmlRequire.html = function(j$, private$) { + if (!private$) { + private$ = {}; + } + + private$.ResultsNode = htmlRequire.ResultsNode(); + private$.ResultsStateBuilder = htmlRequire.ResultsStateBuilder( + j$, + private$ + ); + private$.htmlReporterUtils = htmlRequire.htmlReporterUtils(j$, private$); + private$.AlertsView = htmlRequire.AlertsView(j$, private$); + private$.OverallStatusBar = htmlRequire.OverallStatusBar(j$, private$); + private$.Banner = htmlRequire.Banner(j$, private$); + private$.SummaryTreeView = htmlRequire.SummaryTreeView(j$, private$); + private$.FailuresView = htmlRequire.FailuresView(j$, private$); + private$.PerformanceView = htmlRequire.PerformanceView(j$, private$); + private$.TabBar = htmlRequire.TabBar(j$, private$); + j$.HtmlReporterV2Urls = htmlRequire.HtmlReporterV2Urls(j$, private$); + j$.HtmlReporterV2 = htmlRequire.HtmlReporterV2(j$, private$); + j$.QueryString = htmlRequire.QueryString(); + private$.HtmlSpecFilterV2 = htmlRequire.HtmlSpecFilterV2(); + }; + + return getJasmineHtmlRequire; +})(); diff --git a/src/html/requireSuffix.js b/src/html/requireSuffix.js new file mode 100644 index 00000000..53709580 --- /dev/null +++ b/src/html/requireSuffix.js @@ -0,0 +1,4 @@ +(function() { + 'use strict'; + getJasmineHtmlRequireObj().html(jasmine); +})();