From 6d77f3e7f00a7240ea12ac848beebd4a91361785 Mon Sep 17 00:00:00 2001 From: Steve Gravrock Date: Sun, 14 Sep 2025 09:17:17 -0700 Subject: [PATCH 01/95] Deprecate the eval forms of setTimeout and setInterval --- lib/jasmine-core/jasmine.js | 3 +++ spec/core/DelayedFunctionSchedulerSpec.js | 6 ++++++ src/core/DelayedFunctionScheduler.js | 3 +++ 3 files changed, 12 insertions(+) diff --git a/lib/jasmine-core/jasmine.js b/lib/jasmine-core/jasmine.js index 8ab0ec67..b97e13f8 100644 --- a/lib/jasmine-core/jasmine.js +++ b/lib/jasmine-core/jasmine.js @@ -3521,6 +3521,9 @@ getJasmineRequireObj().DelayedFunctionScheduler = function(j$) { // setTimeout("some code") and setInterval("some code") are legal, if // not recommended. We don't do that ourselves, but user code might. // This allows such code to work when the mock clock is installed. + j$.getEnv().deprecated( + "The eval form of setTimeout and setInterval is deprecated and will stop working in a future version of Jasmine's mock clock. Pass a function instead of a string." + ); f = function() { // eslint-disable-next-line no-eval return eval(funcToCall); diff --git a/spec/core/DelayedFunctionSchedulerSpec.js b/spec/core/DelayedFunctionSchedulerSpec.js index 09cf84c2..9ff98c74 100644 --- a/spec/core/DelayedFunctionSchedulerSpec.js +++ b/spec/core/DelayedFunctionSchedulerSpec.js @@ -15,8 +15,14 @@ describe('DelayedFunctionScheduler', function() { it('schedules a string for later execution', function() { const scheduler = new jasmineUnderTest.DelayedFunctionScheduler(), strfn = 'horrible = true;'; + spyOn(jasmineUnderTest.getEnv(), 'deprecated'); scheduler.scheduleFunction(strfn, 0); + expect(jasmineUnderTest.getEnv().deprecated).toHaveBeenCalledWith( + 'The eval form of setTimeout and setInterval is deprecated and will ' + + "stop working in a future version of Jasmine's mock clock. Pass a " + + 'function instead of a string.' + ); scheduler.tick(0); diff --git a/src/core/DelayedFunctionScheduler.js b/src/core/DelayedFunctionScheduler.js index 8933866e..abe157aa 100644 --- a/src/core/DelayedFunctionScheduler.js +++ b/src/core/DelayedFunctionScheduler.js @@ -29,6 +29,9 @@ getJasmineRequireObj().DelayedFunctionScheduler = function(j$) { // setTimeout("some code") and setInterval("some code") are legal, if // not recommended. We don't do that ourselves, but user code might. // This allows such code to work when the mock clock is installed. + j$.getEnv().deprecated( + "The eval form of setTimeout and setInterval is deprecated and will stop working in a future version of Jasmine's mock clock. Pass a function instead of a string." + ); f = function() { // eslint-disable-next-line no-eval return eval(funcToCall); From 3cbf4dc27bad91c92b7463dfaf720baed3cb5848 Mon Sep 17 00:00:00 2001 From: Steve Gravrock Date: Sun, 14 Sep 2025 11:34:06 -0700 Subject: [PATCH 02/95] Deprecate access to non-public Spec properties in spec filters --- lib/jasmine-core/jasmine.js | 48 ++++++++++++++++++++++++++++++-- spec/core/integration/EnvSpec.js | 40 +++++++++++++++++++++++--- src/core/Env.js | 3 +- src/core/Runner.js | 7 +++-- src/core/deprecatingSpecProxy.js | 36 ++++++++++++++++++++++++ src/core/requireCore.js | 1 + 6 files changed, 125 insertions(+), 10 deletions(-) create mode 100644 src/core/deprecatingSpecProxy.js diff --git a/lib/jasmine-core/jasmine.js b/lib/jasmine-core/jasmine.js index b97e13f8..a15ad5ee 100644 --- a/lib/jasmine-core/jasmine.js +++ b/lib/jasmine-core/jasmine.js @@ -66,6 +66,7 @@ var getJasmineRequireObj = (function(jasmineGlobal) { j$.getClearStack = jRequire.clearStack(j$); j$.Clock = jRequire.Clock(); j$.DelayedFunctionScheduler = jRequire.DelayedFunctionScheduler(j$); + j$.deprecatingSpecProxy = jRequire.deprecatingSpecProxy(j$); j$.Deprecator = jRequire.Deprecator(j$); j$.Configuration = jRequire.Configuration(j$); j$.Env = jRequire.Env(j$); @@ -1498,7 +1499,8 @@ getJasmineRequireObj().Env = function(j$) { runQueue, TreeProcessor: j$.TreeProcessor, globalErrors, - getConfig: () => config + getConfig: () => config, + deprecated: this.deprecated }); this.setParallelLoadingState = function(state) { @@ -3711,6 +3713,43 @@ getJasmineRequireObj().DelayedFunctionScheduler = function(j$) { return DelayedFunctionScheduler; }; +// TODO: Remove this in the next major release. +getJasmineRequireObj().deprecatingSpecProxy = function(j$) { + const allowedMembers = ['id', 'description', 'getFullName', 'getPath']; + + function isMember(target, prop) { + return ( + Object.keys(target).indexOf(prop) !== -1 || + Object.keys(j$.Spec.prototype).indexOf(prop) !== -1 + ); + } + + function msg(member) { + const memberName = member.toString().replace(/^Symbol\((.+)\)$/, '$1'); + return ( + 'Access to private Spec members (in this case `' + + memberName + + '`) via spec filters is not supported and will break in ' + + 'a future release. See ' + + 'for correct usage.' + ); + } + + function deprecatingSpecProxy(spec, deprecated) { + return new Proxy(spec, { + get(target, prop, receiver) { + if (isMember(target, prop) && !allowedMembers.includes(prop)) { + deprecated(msg(prop)); + } + + return target[prop]; + } + }); + } + + return deprecatingSpecProxy; +}; + getJasmineRequireObj().Deprecator = function(j$) { function Deprecator(topSuite) { this.topSuite_ = topSuite; @@ -9440,6 +9479,7 @@ getJasmineRequireObj().Runner = function(j$) { #globalErrors; #reportDispatcher; #getConfig; + #deprecated; #executedBefore; #currentRunableTracker; @@ -9453,6 +9493,7 @@ getJasmineRequireObj().Runner = function(j$) { this.#globalErrors = options.globalErrors; this.#reportDispatcher = options.reportDispatcher; this.#getConfig = options.getConfig; + this.#deprecated = options.deprecated; this.#executedBefore = false; this.#currentRunableTracker = new j$.CurrentRunableTracker(); } @@ -9505,8 +9546,9 @@ getJasmineRequireObj().Runner = function(j$) { orderChildren: function(node) { return order.sort(node.children); }, - excludeNode: function(spec) { - return !config.specFilter(spec); + excludeNode: spec => { + const proxy = j$.deprecatingSpecProxy(spec, this.#deprecated); + return !config.specFilter(proxy); } }); this.#executionTree = treeProcessor.processTree(); diff --git a/spec/core/integration/EnvSpec.js b/spec/core/integration/EnvSpec.js index d9224d40..f1b8504d 100644 --- a/spec/core/integration/EnvSpec.js +++ b/spec/core/integration/EnvSpec.js @@ -913,6 +913,7 @@ describe('Env integration', function() { }); env.configure({ + random: false, specFilter: function(spec) { return /^first suite/.test(spec.getFullName()); } @@ -920,13 +921,44 @@ describe('Env integration', function() { await env.execute(); - expect(calls.length).toEqual(2); - expect(calls).toEqual( - jasmine.arrayContaining(['first spec', 'second spec']) - ); + expect(calls).toEqual(['first spec', 'second spec']); expect(suiteCallback).toHaveBeenCalled(); }); + it('reports a deprecation warning when a spec filter accesses private properties', async function() { + env.it('a spec', function() {}); + + const reporter = jasmine.createSpyObj('reporter', ['jasmineDone']); + env.addReporter(reporter); + + env.configure({ + random: false, + specFilter: function(spec) { + spec.result; // deprecated + spec.id; // not deprecated + spec.description; // not deprecated + spec.getPath(); // not deprecated + spec.getFullName(); // not deprecated + return true; + } + }); + + spyOn(console, 'error'); + await env.execute(); + + expect(reporter.jasmineDone).toHaveBeenCalledWith( + jasmine.objectContaining({ + deprecationWarnings: [ + jasmine.objectContaining({ + message: jasmine.stringContaining( + 'Access to private Spec members (in this case `result`)' + ) + }) + ] + }) + ); + }); + it('Functions can be spied on and have their calls tracked', async function() { let originalFunctionWasCalled = false; const subject = { diff --git a/src/core/Env.js b/src/core/Env.js index 701b4586..3e4fb741 100644 --- a/src/core/Env.js +++ b/src/core/Env.js @@ -371,7 +371,8 @@ getJasmineRequireObj().Env = function(j$) { runQueue, TreeProcessor: j$.TreeProcessor, globalErrors, - getConfig: () => config + getConfig: () => config, + deprecated: this.deprecated }); this.setParallelLoadingState = function(state) { diff --git a/src/core/Runner.js b/src/core/Runner.js index db44c639..c6d69a7a 100644 --- a/src/core/Runner.js +++ b/src/core/Runner.js @@ -10,6 +10,7 @@ getJasmineRequireObj().Runner = function(j$) { #globalErrors; #reportDispatcher; #getConfig; + #deprecated; #executedBefore; #currentRunableTracker; @@ -23,6 +24,7 @@ getJasmineRequireObj().Runner = function(j$) { this.#globalErrors = options.globalErrors; this.#reportDispatcher = options.reportDispatcher; this.#getConfig = options.getConfig; + this.#deprecated = options.deprecated; this.#executedBefore = false; this.#currentRunableTracker = new j$.CurrentRunableTracker(); } @@ -75,8 +77,9 @@ getJasmineRequireObj().Runner = function(j$) { orderChildren: function(node) { return order.sort(node.children); }, - excludeNode: function(spec) { - return !config.specFilter(spec); + excludeNode: spec => { + const proxy = j$.deprecatingSpecProxy(spec, this.#deprecated); + return !config.specFilter(proxy); } }); this.#executionTree = treeProcessor.processTree(); diff --git a/src/core/deprecatingSpecProxy.js b/src/core/deprecatingSpecProxy.js new file mode 100644 index 00000000..eb1b583e --- /dev/null +++ b/src/core/deprecatingSpecProxy.js @@ -0,0 +1,36 @@ +// TODO: Remove this in the next major release. +getJasmineRequireObj().deprecatingSpecProxy = function(j$) { + const allowedMembers = ['id', 'description', 'getFullName', 'getPath']; + + function isMember(target, prop) { + return ( + Object.keys(target).indexOf(prop) !== -1 || + Object.keys(j$.Spec.prototype).indexOf(prop) !== -1 + ); + } + + function msg(member) { + const memberName = member.toString().replace(/^Symbol\((.+)\)$/, '$1'); + return ( + 'Access to private Spec members (in this case `' + + memberName + + '`) via spec filters is not supported and will break in ' + + 'a future release. See ' + + 'for correct usage.' + ); + } + + function deprecatingSpecProxy(spec, deprecated) { + return new Proxy(spec, { + get(target, prop, receiver) { + if (isMember(target, prop) && !allowedMembers.includes(prop)) { + deprecated(msg(prop)); + } + + return target[prop]; + } + }); + } + + return deprecatingSpecProxy; +}; diff --git a/src/core/requireCore.js b/src/core/requireCore.js index 669bd244..9ce8aed3 100644 --- a/src/core/requireCore.js +++ b/src/core/requireCore.js @@ -42,6 +42,7 @@ var getJasmineRequireObj = (function(jasmineGlobal) { j$.getClearStack = jRequire.clearStack(j$); j$.Clock = jRequire.Clock(); j$.DelayedFunctionScheduler = jRequire.DelayedFunctionScheduler(j$); + j$.deprecatingSpecProxy = jRequire.deprecatingSpecProxy(j$); j$.Deprecator = jRequire.Deprecator(j$); j$.Configuration = jRequire.Configuration(j$); j$.Env = jRequire.Env(j$); From 27297de3b85657dcac70892688f458a118ac0a78 Mon Sep 17 00:00:00 2001 From: Steve Gravrock Date: Sun, 14 Sep 2025 09:21:37 -0700 Subject: [PATCH 03/95] Drop support for the eval form of setTimeout and setInterval in the mock clock --- lib/jasmine-core/jasmine.js | 21 +++++---------------- spec/core/DelayedFunctionSchedulerSpec.js | 21 ++++++++------------- src/core/DelayedFunctionScheduler.js | 21 +++++---------------- 3 files changed, 18 insertions(+), 45 deletions(-) diff --git a/lib/jasmine-core/jasmine.js b/lib/jasmine-core/jasmine.js index a15ad5ee..ac72688e 100644 --- a/lib/jasmine-core/jasmine.js +++ b/lib/jasmine-core/jasmine.js @@ -3492,10 +3492,9 @@ getJasmineRequireObj().CurrentRunableTracker = function() { return CurrentRunableTracker; }; -// Warning: don't add "use strict" to this file. Doing so potentially changes -// the behavior of user code that does things like setTimeout("var x = 1;") -// while the mock clock is installed. getJasmineRequireObj().DelayedFunctionScheduler = function(j$) { + 'use strict'; + function DelayedFunctionScheduler() { this.scheduledLookup_ = []; this.scheduledFunctions_ = {}; @@ -3518,20 +3517,10 @@ getJasmineRequireObj().DelayedFunctionScheduler = function(j$) { timeoutKey, runAtMillis ) { - let f; if (typeof funcToCall === 'string') { - // setTimeout("some code") and setInterval("some code") are legal, if - // not recommended. We don't do that ourselves, but user code might. - // This allows such code to work when the mock clock is installed. - j$.getEnv().deprecated( - "The eval form of setTimeout and setInterval is deprecated and will stop working in a future version of Jasmine's mock clock. Pass a function instead of a string." + throw new Error( + 'The mock clock does not support the eval form of setTimeout and setInterval. Pass a function instead of a string.' ); - f = function() { - // eslint-disable-next-line no-eval - return eval(funcToCall); - }; - } else { - f = funcToCall; } millis = millis || 0; @@ -3540,7 +3529,7 @@ getJasmineRequireObj().DelayedFunctionScheduler = function(j$) { const funcToSchedule = { runAtMillis: runAtMillis, - funcToCall: f, + funcToCall, recurring: recurring, params: params, timeoutKey: timeoutKey, diff --git a/spec/core/DelayedFunctionSchedulerSpec.js b/spec/core/DelayedFunctionSchedulerSpec.js index 9ff98c74..c7ea4a7c 100644 --- a/spec/core/DelayedFunctionSchedulerSpec.js +++ b/spec/core/DelayedFunctionSchedulerSpec.js @@ -1,4 +1,6 @@ describe('DelayedFunctionScheduler', function() { + 'use strict'; + it('schedules a function for later execution', function() { const scheduler = new jasmineUnderTest.DelayedFunctionScheduler(), fn = jasmine.createSpy('fn'); @@ -12,21 +14,14 @@ describe('DelayedFunctionScheduler', function() { expect(fn).toHaveBeenCalled(); }); - it('schedules a string for later execution', function() { - const scheduler = new jasmineUnderTest.DelayedFunctionScheduler(), - strfn = 'horrible = true;'; - spyOn(jasmineUnderTest.getEnv(), 'deprecated'); + it('throws if a string is passed', function() { + const scheduler = new jasmineUnderTest.DelayedFunctionScheduler(); - scheduler.scheduleFunction(strfn, 0); - expect(jasmineUnderTest.getEnv().deprecated).toHaveBeenCalledWith( - 'The eval form of setTimeout and setInterval is deprecated and will ' + - "stop working in a future version of Jasmine's mock clock. Pass a " + - 'function instead of a string.' + expect(function() { + scheduler.scheduleFunction('horrible = true;', 0); + }).toThrowError( + 'The mock clock does not support the eval form of setTimeout and setInterval. Pass a function instead of a string.' ); - - scheduler.tick(0); - - expect(horrible).toEqual(true); }); it('#tick defaults to 0', function() { diff --git a/src/core/DelayedFunctionScheduler.js b/src/core/DelayedFunctionScheduler.js index abe157aa..b59c88cf 100644 --- a/src/core/DelayedFunctionScheduler.js +++ b/src/core/DelayedFunctionScheduler.js @@ -1,7 +1,6 @@ -// Warning: don't add "use strict" to this file. Doing so potentially changes -// the behavior of user code that does things like setTimeout("var x = 1;") -// while the mock clock is installed. getJasmineRequireObj().DelayedFunctionScheduler = function(j$) { + 'use strict'; + function DelayedFunctionScheduler() { this.scheduledLookup_ = []; this.scheduledFunctions_ = {}; @@ -24,20 +23,10 @@ getJasmineRequireObj().DelayedFunctionScheduler = function(j$) { timeoutKey, runAtMillis ) { - let f; if (typeof funcToCall === 'string') { - // setTimeout("some code") and setInterval("some code") are legal, if - // not recommended. We don't do that ourselves, but user code might. - // This allows such code to work when the mock clock is installed. - j$.getEnv().deprecated( - "The eval form of setTimeout and setInterval is deprecated and will stop working in a future version of Jasmine's mock clock. Pass a function instead of a string." + throw new Error( + 'The mock clock does not support the eval form of setTimeout and setInterval. Pass a function instead of a string.' ); - f = function() { - // eslint-disable-next-line no-eval - return eval(funcToCall); - }; - } else { - f = funcToCall; } millis = millis || 0; @@ -46,7 +35,7 @@ getJasmineRequireObj().DelayedFunctionScheduler = function(j$) { const funcToSchedule = { runAtMillis: runAtMillis, - funcToCall: f, + funcToCall, recurring: recurring, params: params, timeoutKey: timeoutKey, From 6ab83e25d10cd2df31614327bb8c58c8d6f08ce9 Mon Sep 17 00:00:00 2001 From: Steve Gravrock Date: Sun, 14 Sep 2025 09:44:58 -0700 Subject: [PATCH 04/95] Don't expose Order instances to reporters --- lib/jasmine-core/jasmine.js | 26 ++++++++++++++++------- spec/core/DelayedFunctionSchedulerSpec.js | 2 +- spec/core/integration/EnvSpec.js | 14 ++++++------ src/core/Runner.js | 26 ++++++++++++++++------- 4 files changed, 43 insertions(+), 25 deletions(-) diff --git a/lib/jasmine-core/jasmine.js b/lib/jasmine-core/jasmine.js index ac72688e..3d254bae 100644 --- a/lib/jasmine-core/jasmine.js +++ b/lib/jasmine-core/jasmine.js @@ -9564,13 +9564,7 @@ getJasmineRequireObj().Runner = function(j$) { // In parallel mode, the jasmineStarted event is separately dispatched // by jasmine-npm. This event only reaches reporters in non-parallel. totalSpecsDefined, - /** - * Information about the ordering (random or not) of this execution of the suite. - * @typedef Order - * @property {boolean} random - Whether the suite is running in random order - * @property {string} seed - The random seed - */ - order: order, + order: orderForReporting(order), parallel: false }); @@ -9622,7 +9616,7 @@ getJasmineRequireObj().Runner = function(j$) { totalTime: jasmineTimer.elapsed(), incompleteReason: incompleteReason, incompleteCode: incompleteCode, - order: order, + order: orderForReporting(order), failedExpectations: this.#topSuite.result.failedExpectations, deprecationWarnings: this.#topSuite.result.deprecationWarnings }; @@ -9632,6 +9626,22 @@ getJasmineRequireObj().Runner = function(j$) { } } + /** + * Information about the ordering (random or not) of this execution of the suite. + * @typedef Order + * @property {boolean} random - Whether the suite is running in random order + * @property {string} seed - The random seed + */ + function orderForReporting(order) { + // Don't expose the actual Order object to reporters. That class is private + // and instances are not cloneable. + if (order.random) { + return { random: true, seed: order.seed }; + } else { + return { random: false }; + } + } + return Runner; }; diff --git a/spec/core/DelayedFunctionSchedulerSpec.js b/spec/core/DelayedFunctionSchedulerSpec.js index c7ea4a7c..20674c3d 100644 --- a/spec/core/DelayedFunctionSchedulerSpec.js +++ b/spec/core/DelayedFunctionSchedulerSpec.js @@ -1,6 +1,6 @@ describe('DelayedFunctionScheduler', function() { 'use strict'; - + it('schedules a function for later execution', function() { const scheduler = new jasmineUnderTest.DelayedFunctionScheduler(), fn = jasmine.createSpy('fn'); diff --git a/spec/core/integration/EnvSpec.js b/spec/core/integration/EnvSpec.js index f1b8504d..df431c65 100644 --- a/spec/core/integration/EnvSpec.js +++ b/spec/core/integration/EnvSpec.js @@ -1571,7 +1571,7 @@ describe('Env integration', function() { expect(reporter.jasmineStarted).toHaveBeenCalledWith({ totalSpecsDefined: 1, - order: jasmine.any(jasmineUnderTest.Order), + order: { random: true, seed: jasmine.any(String) }, parallel: false }); @@ -1606,7 +1606,7 @@ describe('Env integration', function() { expect(reporter.jasmineStarted).toHaveBeenCalledWith({ totalSpecsDefined: 1, - order: jasmine.any(jasmineUnderTest.Order), + order: { random: true, seed: jasmine.any(String) }, parallel: false }); @@ -1671,7 +1671,7 @@ describe('Env integration', function() { expect(reporter.jasmineStarted).toHaveBeenCalledWith({ totalSpecsDefined: 6, - order: jasmine.any(jasmineUnderTest.Order), + order: { random: false }, parallel: false }); @@ -1953,12 +1953,10 @@ describe('Env integration', function() { expect(reporter.jasmineStarted).toHaveBeenCalled(); const startedArg = reporter.jasmineStarted.calls.argsFor(0)[0]; - expect(startedArg.order.random).toEqual(true); - expect(startedArg.order.seed).toEqual('123456'); + expect(startedArg.order).toEqual({ random: true, seed: '123456' }); const doneArg = reporter.jasmineDone.calls.argsFor(0)[0]; - expect(doneArg.order.random).toEqual(true); - expect(doneArg.order.seed).toEqual('123456'); + expect(doneArg.order).toEqual({ random: true, seed: '123456' }); }); it('coerces the random seed to a string if it is a number', async function() { @@ -2078,7 +2076,7 @@ describe('Env integration', function() { expect(reporter.jasmineStarted).toHaveBeenCalledWith({ totalSpecsDefined: 1, - order: jasmine.any(jasmineUnderTest.Order), + order: { random: true, seed: jasmine.any(String) }, parallel: false }); diff --git a/src/core/Runner.js b/src/core/Runner.js index c6d69a7a..0a715a55 100644 --- a/src/core/Runner.js +++ b/src/core/Runner.js @@ -106,13 +106,7 @@ getJasmineRequireObj().Runner = function(j$) { // In parallel mode, the jasmineStarted event is separately dispatched // by jasmine-npm. This event only reaches reporters in non-parallel. totalSpecsDefined, - /** - * Information about the ordering (random or not) of this execution of the suite. - * @typedef Order - * @property {boolean} random - Whether the suite is running in random order - * @property {string} seed - The random seed - */ - order: order, + order: orderForReporting(order), parallel: false }); @@ -164,7 +158,7 @@ getJasmineRequireObj().Runner = function(j$) { totalTime: jasmineTimer.elapsed(), incompleteReason: incompleteReason, incompleteCode: incompleteCode, - order: order, + order: orderForReporting(order), failedExpectations: this.#topSuite.result.failedExpectations, deprecationWarnings: this.#topSuite.result.deprecationWarnings }; @@ -174,5 +168,21 @@ getJasmineRequireObj().Runner = function(j$) { } } + /** + * Information about the ordering (random or not) of this execution of the suite. + * @typedef Order + * @property {boolean} random - Whether the suite is running in random order + * @property {string} seed - The random seed + */ + function orderForReporting(order) { + // Don't expose the actual Order object to reporters. That class is private + // and instances are not cloneable. + if (order.random) { + return { random: true, seed: order.seed }; + } else { + return { random: false }; + } + } + return Runner; }; From 4d3f6b272a2b3975b7c40f8e0c3a4866259a878f Mon Sep 17 00:00:00 2001 From: Steve Gravrock Date: Sun, 14 Sep 2025 09:48:01 -0700 Subject: [PATCH 05/95] Remove expected and actual properties of expectation results --- lib/jasmine-core/jasmine.js | 20 +------------------- spec/core/SpecSpec.js | 2 -- spec/core/buildExpectationResultSpec.js | 24 +----------------------- src/core/buildExpectationResult.js | 20 +------------------- 4 files changed, 3 insertions(+), 63 deletions(-) diff --git a/lib/jasmine-core/jasmine.js b/lib/jasmine-core/jasmine.js index 3d254bae..7c847732 100644 --- a/lib/jasmine-core/jasmine.js +++ b/lib/jasmine-core/jasmine.js @@ -2529,20 +2529,11 @@ getJasmineRequireObj().buildExpectationResult = function(j$) { /** * Describes the result of evaluating an expectation * - * Note: The expected and actual properties are deprecated and may be removed - * in a future release. In many Jasmine configurations they are passed - * through JSON serialization and deserialization, which is inherently - * lossy. In such cases, the expected and actual values may be placeholders - * or approximations of the original objects. jasmine-browser-runner 3.0 and - * later omits them entirely. - * * @typedef ExpectationResult * @property {String} matcherName - The name of the matcher that was executed for this expectation. * @property {String} message - The failure message for the expectation. * @property {String} stack - The stack trace for the failure if available. * @property {Boolean} passed - Whether the expectation passed or failed. - * @property {Object} expected - Deprecated. If the expectation failed, what was the expected value. - * @property {Object} actual - Deprecated. If the expectation failed, what actual value was produced. * @property {String|undefined} globalErrorType - The type of an error that * is reported on the top suite. Valid values are undefined, "afterAll", * "load", "lateExpectation", and "lateError". @@ -2555,21 +2546,12 @@ getJasmineRequireObj().buildExpectationResult = function(j$) { }; if (!result.passed) { - result.expected = options.expected; - result.actual = options.actual; - if (options.error && !j$.isString_(options.error)) { if ('code' in options.error) { result.code = options.error.code; } - if ( - options.error.code === 'ERR_ASSERTION' && - options.expected === '' && - options.actual === '' - ) { - result.expected = options.error.expected; - result.actual = options.error.actual; + if (options.error.code === 'ERR_ASSERTION') { result.matcherName = 'assert ' + options.error.operator; } } diff --git a/spec/core/SpecSpec.js b/spec/core/SpecSpec.js index 3bc41ede..664cc092 100644 --- a/spec/core/SpecSpec.js +++ b/spec/core/SpecSpec.js @@ -337,8 +337,6 @@ describe('Spec', function() { message: 'foo thrown', matcherName: '', passed: false, - expected: '', - actual: '', stack: null } ]); diff --git a/spec/core/buildExpectationResultSpec.js b/spec/core/buildExpectationResultSpec.js index a47ff1cb..88b4cc19 100644 --- a/spec/core/buildExpectationResultSpec.js +++ b/spec/core/buildExpectationResultSpec.js @@ -63,50 +63,28 @@ describe('buildExpectationResult', function() { expect(result.matcherName).toBe('some-value'); }); - it('expected returns passed expected', function() { - const result = jasmineUnderTest.buildExpectationResult({ - expected: 'some-value' - }); - expect(result.expected).toBe('some-value'); - }); - - it('actual returns passed actual', function() { - const result = jasmineUnderTest.buildExpectationResult({ - actual: 'some-value' - }); - expect(result.actual).toBe('some-value'); - }); - it('handles nodejs assertions', function() { if (typeof require === 'undefined') { pending('This test only runs in Node'); } const assert = require('assert'); - const value = 8421; - const expectedValue = 'JasmineExpectationTestValue'; let error; try { - assert.equal(value, expectedValue); + assert.equal('a', 'b'); } catch (e) { error = e; } expect(error.code).toEqual('ERR_ASSERTION'); - expect(error.actual).toEqual(value); - expect(error.expected).toEqual(expectedValue); expect(error.operator).toEqual('=='); const result = jasmineUnderTest.buildExpectationResult({ passed: false, matcherName: '', - expected: '', - actual: '', error: error }); expect(result.code).toEqual('ERR_ASSERTION'); - expect(result.actual).toEqual(value); - expect(result.expected).toEqual(expectedValue); expect(result.matcherName).toEqual('assert =='); }); }); diff --git a/src/core/buildExpectationResult.js b/src/core/buildExpectationResult.js index b62d1d8d..12f17b77 100644 --- a/src/core/buildExpectationResult.js +++ b/src/core/buildExpectationResult.js @@ -6,20 +6,11 @@ getJasmineRequireObj().buildExpectationResult = function(j$) { /** * Describes the result of evaluating an expectation * - * Note: The expected and actual properties are deprecated and may be removed - * in a future release. In many Jasmine configurations they are passed - * through JSON serialization and deserialization, which is inherently - * lossy. In such cases, the expected and actual values may be placeholders - * or approximations of the original objects. jasmine-browser-runner 3.0 and - * later omits them entirely. - * * @typedef ExpectationResult * @property {String} matcherName - The name of the matcher that was executed for this expectation. * @property {String} message - The failure message for the expectation. * @property {String} stack - The stack trace for the failure if available. * @property {Boolean} passed - Whether the expectation passed or failed. - * @property {Object} expected - Deprecated. If the expectation failed, what was the expected value. - * @property {Object} actual - Deprecated. If the expectation failed, what actual value was produced. * @property {String|undefined} globalErrorType - The type of an error that * is reported on the top suite. Valid values are undefined, "afterAll", * "load", "lateExpectation", and "lateError". @@ -32,21 +23,12 @@ getJasmineRequireObj().buildExpectationResult = function(j$) { }; if (!result.passed) { - result.expected = options.expected; - result.actual = options.actual; - if (options.error && !j$.isString_(options.error)) { if ('code' in options.error) { result.code = options.error.code; } - if ( - options.error.code === 'ERR_ASSERTION' && - options.expected === '' && - options.actual === '' - ) { - result.expected = options.error.expected; - result.actual = options.error.actual; + if (options.error.code === 'ERR_ASSERTION') { result.matcherName = 'assert ' + options.error.operator; } } From 3040abe23d2b65d4a1fa4c98981e1cff77c70935 Mon Sep 17 00:00:00 2001 From: Steve Gravrock Date: Sun, 14 Sep 2025 09:51:21 -0700 Subject: [PATCH 06/95] Treat {verboseDeprecations: undefined} as a no-op, like other boolean config props --- lib/jasmine-core/jasmine.js | 9 ++------- spec/core/ConfigurationSpec.js | 25 ++----------------------- src/core/Configuration.js | 9 ++------- 3 files changed, 6 insertions(+), 37 deletions(-) diff --git a/lib/jasmine-core/jasmine.js b/lib/jasmine-core/jasmine.js index 7c847732..14ab310e 100644 --- a/lib/jasmine-core/jasmine.js +++ b/lib/jasmine-core/jasmine.js @@ -3406,7 +3406,8 @@ getJasmineRequireObj().Configuration = function(j$) { 'stopSpecOnExpectationFailure', 'autoCleanClosures', 'forbidDuplicateNames', - 'detectLateRejectionHandling' + 'detectLateRejectionHandling', + 'verboseDeprecations' ]; for (const k of booleanProps) { @@ -3423,12 +3424,6 @@ getJasmineRequireObj().Configuration = function(j$) { if (typeof changes.seed !== 'undefined') { this.#values.seed = changes.seed; } - - // TODO: in the next major release, make verboseDeprecations work like - // other boolean properties. - if (changes.hasOwnProperty('verboseDeprecations')) { - this.#values.verboseDeprecations = changes.verboseDeprecations; - } } } diff --git a/spec/core/ConfigurationSpec.js b/spec/core/ConfigurationSpec.js index bc548380..849dbf90 100644 --- a/spec/core/ConfigurationSpec.js +++ b/spec/core/ConfigurationSpec.js @@ -7,14 +7,10 @@ describe('Configuration', function() { 'hideDisabled', 'autoCleanClosures', 'forbidDuplicateNames', - 'detectLateRejectionHandling' - ]; - const allKeys = [ - ...standardBooleanKeys, - 'seed', - 'specFilter', + 'detectLateRejectionHandling', 'verboseDeprecations' ]; + const allKeys = [...standardBooleanKeys, 'seed', 'specFilter']; Object.freeze(standardBooleanKeys); Object.freeze(allKeys); @@ -86,23 +82,6 @@ describe('Configuration', function() { }); } - // TODO: in the next major release, treat verboseDeprecations like other booleans - it('sets verboseDeprecations when present', function() { - const subject = new jasmineUnderTest.Configuration(); - const orig = subject.verboseDeprecations; - - subject.update({ verboseDeprecations: !orig }); - expect(subject.verboseDeprecations).toEqual(!orig); - - subject.update({ verboseDeprecations: orig }); - expect(subject.verboseDeprecations).toEqual(orig); - - // For backwards compatibility, explicitly setting to undefined should - // work. Undefined isn't officially valid but gets treated like false. - subject.update({ verboseDeprecations: undefined }); - expect(subject.verboseDeprecations).toBeUndefined(); - }); - it('sets specFilter when truthy', function() { const subject = new jasmineUnderTest.Configuration(); const orig = subject.specFilter; diff --git a/src/core/Configuration.js b/src/core/Configuration.js index 4d32d5ce..82e30327 100644 --- a/src/core/Configuration.js +++ b/src/core/Configuration.js @@ -156,7 +156,8 @@ getJasmineRequireObj().Configuration = function(j$) { 'stopSpecOnExpectationFailure', 'autoCleanClosures', 'forbidDuplicateNames', - 'detectLateRejectionHandling' + 'detectLateRejectionHandling', + 'verboseDeprecations' ]; for (const k of booleanProps) { @@ -173,12 +174,6 @@ getJasmineRequireObj().Configuration = function(j$) { if (typeof changes.seed !== 'undefined') { this.#values.seed = changes.seed; } - - // TODO: in the next major release, make verboseDeprecations work like - // other boolean properties. - if (changes.hasOwnProperty('verboseDeprecations')) { - this.#values.verboseDeprecations = changes.verboseDeprecations; - } } } From 7c34b43607b029fe761162292abb1205b7022b66 Mon Sep 17 00:00:00 2001 From: Steve Gravrock Date: Sun, 14 Sep 2025 10:06:47 -0700 Subject: [PATCH 07/95] Default forbidDuplicateNames to true --- lib/jasmine-core/jasmine.js | 4 ++-- spec/core/ConfigurationSpec.js | 2 +- spec/core/EnvSpec.js | 16 ++++++++-------- spec/core/integration/SpecRunningSpec.js | 2 +- src/core/Configuration.js | 4 ++-- 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/lib/jasmine-core/jasmine.js b/lib/jasmine-core/jasmine.js index 14ab310e..0dc988b7 100644 --- a/lib/jasmine-core/jasmine.js +++ b/lib/jasmine-core/jasmine.js @@ -3345,9 +3345,9 @@ getJasmineRequireObj().Configuration = function(j$) { * error. * @name Configuration#forbidDuplicateNames * @type boolean - * @default false + * @default true */ - forbidDuplicateNames: false, + forbidDuplicateNames: true, /** * Whether to issue warnings for certain deprecated functionality * every time it's used. If not set or set to false, deprecation warnings diff --git a/spec/core/ConfigurationSpec.js b/spec/core/ConfigurationSpec.js index 849dbf90..b90ec59c 100644 --- a/spec/core/ConfigurationSpec.js +++ b/spec/core/ConfigurationSpec.js @@ -25,7 +25,7 @@ describe('Configuration', function() { expect(subject.specFilter()).toEqual(true); expect(subject.hideDisabled).toEqual(false); expect(subject.autoCleanClosures).toEqual(true); - expect(subject.forbidDuplicateNames).toEqual(false); + expect(subject.forbidDuplicateNames).toEqual(true); expect(subject.verboseDeprecations).toEqual(false); expect(subject.detectLateRejectionHandling).toEqual(false); }); diff --git a/spec/core/EnvSpec.js b/spec/core/EnvSpec.js index db258a00..353ab285 100644 --- a/spec/core/EnvSpec.js +++ b/spec/core/EnvSpec.js @@ -487,14 +487,14 @@ describe('Env', function() { it('does not throw an error when called in a describe', function() { env.setParallelLoadingState('helpers'); - check(); + check(1); env.setParallelLoadingState('specs'); - check(); + check(2); - function check() { + function check(disambiguator) { let done = false; - env.describe('a suite', function() { + env.describe('a suite ' + disambiguator, function() { expect(function() { env.it('a spec'); env.beforeAll(function() {}); @@ -594,14 +594,14 @@ describe('Env', function() { it('does not throw an error when called in a describe', function() { env.setParallelLoadingState('helpers'); - check(); + check(1); env.setParallelLoadingState('specs'); - check(); + check(2); - function check() { + function check(disambiguator) { let done = false; - env.describe('a suite', function() { + env.describe('a suite ' + disambiguator, function() { expect(function() { env.it('a spec'); env.afterAll(function() {}); diff --git a/spec/core/integration/SpecRunningSpec.js b/spec/core/integration/SpecRunningSpec.js index a1975876..06ae0552 100644 --- a/spec/core/integration/SpecRunningSpec.js +++ b/spec/core/integration/SpecRunningSpec.js @@ -40,7 +40,7 @@ describe('spec running', function() { env.it('should run nested suites', function() { foo++; }); - env.it('should run nested suites', function() { + env.it('should run nested suites 2', function() { bar++; }); }); diff --git a/src/core/Configuration.js b/src/core/Configuration.js index 82e30327..1d3a509c 100644 --- a/src/core/Configuration.js +++ b/src/core/Configuration.js @@ -95,9 +95,9 @@ getJasmineRequireObj().Configuration = function(j$) { * error. * @name Configuration#forbidDuplicateNames * @type boolean - * @default false + * @default true */ - forbidDuplicateNames: false, + forbidDuplicateNames: true, /** * Whether to issue warnings for certain deprecated functionality * every time it's used. If not set or set to false, deprecation warnings From 2c6ce35ccc3174f42d5c3610a7839db5a2a91560 Mon Sep 17 00:00:00 2001 From: Steve Gravrock Date: Sun, 14 Sep 2025 10:44:50 -0700 Subject: [PATCH 08/95] Pass spec metadata to filters, not internal Spec instance --- lib/jasmine-core/jasmine.js | 10 +++------- spec/core/integration/EnvSpec.js | 34 -------------------------------- src/core/Env.js | 3 +-- src/core/Runner.js | 7 ++----- 4 files changed, 6 insertions(+), 48 deletions(-) diff --git a/lib/jasmine-core/jasmine.js b/lib/jasmine-core/jasmine.js index 0dc988b7..37135702 100644 --- a/lib/jasmine-core/jasmine.js +++ b/lib/jasmine-core/jasmine.js @@ -1499,8 +1499,7 @@ getJasmineRequireObj().Env = function(j$) { runQueue, TreeProcessor: j$.TreeProcessor, globalErrors, - getConfig: () => config, - deprecated: this.deprecated + getConfig: () => config }); this.setParallelLoadingState = function(state) { @@ -9445,7 +9444,6 @@ getJasmineRequireObj().Runner = function(j$) { #globalErrors; #reportDispatcher; #getConfig; - #deprecated; #executedBefore; #currentRunableTracker; @@ -9459,7 +9457,6 @@ getJasmineRequireObj().Runner = function(j$) { this.#globalErrors = options.globalErrors; this.#reportDispatcher = options.reportDispatcher; this.#getConfig = options.getConfig; - this.#deprecated = options.deprecated; this.#executedBefore = false; this.#currentRunableTracker = new j$.CurrentRunableTracker(); } @@ -9512,9 +9509,8 @@ getJasmineRequireObj().Runner = function(j$) { orderChildren: function(node) { return order.sort(node.children); }, - excludeNode: spec => { - const proxy = j$.deprecatingSpecProxy(spec, this.#deprecated); - return !config.specFilter(proxy); + excludeNode: function(spec) { + return !config.specFilter(spec.metadata); } }); this.#executionTree = treeProcessor.processTree(); diff --git a/spec/core/integration/EnvSpec.js b/spec/core/integration/EnvSpec.js index df431c65..542fd7e2 100644 --- a/spec/core/integration/EnvSpec.js +++ b/spec/core/integration/EnvSpec.js @@ -925,40 +925,6 @@ describe('Env integration', function() { expect(suiteCallback).toHaveBeenCalled(); }); - it('reports a deprecation warning when a spec filter accesses private properties', async function() { - env.it('a spec', function() {}); - - const reporter = jasmine.createSpyObj('reporter', ['jasmineDone']); - env.addReporter(reporter); - - env.configure({ - random: false, - specFilter: function(spec) { - spec.result; // deprecated - spec.id; // not deprecated - spec.description; // not deprecated - spec.getPath(); // not deprecated - spec.getFullName(); // not deprecated - return true; - } - }); - - spyOn(console, 'error'); - await env.execute(); - - expect(reporter.jasmineDone).toHaveBeenCalledWith( - jasmine.objectContaining({ - deprecationWarnings: [ - jasmine.objectContaining({ - message: jasmine.stringContaining( - 'Access to private Spec members (in this case `result`)' - ) - }) - ] - }) - ); - }); - it('Functions can be spied on and have their calls tracked', async function() { let originalFunctionWasCalled = false; const subject = { diff --git a/src/core/Env.js b/src/core/Env.js index 3e4fb741..701b4586 100644 --- a/src/core/Env.js +++ b/src/core/Env.js @@ -371,8 +371,7 @@ getJasmineRequireObj().Env = function(j$) { runQueue, TreeProcessor: j$.TreeProcessor, globalErrors, - getConfig: () => config, - deprecated: this.deprecated + getConfig: () => config }); this.setParallelLoadingState = function(state) { diff --git a/src/core/Runner.js b/src/core/Runner.js index 0a715a55..8e06e8b6 100644 --- a/src/core/Runner.js +++ b/src/core/Runner.js @@ -10,7 +10,6 @@ getJasmineRequireObj().Runner = function(j$) { #globalErrors; #reportDispatcher; #getConfig; - #deprecated; #executedBefore; #currentRunableTracker; @@ -24,7 +23,6 @@ getJasmineRequireObj().Runner = function(j$) { this.#globalErrors = options.globalErrors; this.#reportDispatcher = options.reportDispatcher; this.#getConfig = options.getConfig; - this.#deprecated = options.deprecated; this.#executedBefore = false; this.#currentRunableTracker = new j$.CurrentRunableTracker(); } @@ -77,9 +75,8 @@ getJasmineRequireObj().Runner = function(j$) { orderChildren: function(node) { return order.sort(node.children); }, - excludeNode: spec => { - const proxy = j$.deprecatingSpecProxy(spec, this.#deprecated); - return !config.specFilter(proxy); + excludeNode: function(spec) { + return !config.specFilter(spec.metadata); } }); this.#executionTree = treeProcessor.processTree(); From 5439c8c9cd8450128ca0714a2411e3793bd9cef3 Mon Sep 17 00:00:00 2001 From: Steve Gravrock Date: Sun, 14 Sep 2025 14:49:55 -0700 Subject: [PATCH 09/95] Don't remove existing unhandled exception and promise rejection handlers in Node --- lib/jasmine-core/jasmine.js | 44 +++++++++-------------------------- spec/core/GlobalErrorsSpec.js | 12 +++------- src/core/GlobalErrors.js | 44 +++++++++-------------------------- 3 files changed, 25 insertions(+), 75 deletions(-) diff --git a/lib/jasmine-core/jasmine.js b/lib/jasmine-core/jasmine.js index 37135702..94b74490 100644 --- a/lib/jasmine-core/jasmine.js +++ b/lib/jasmine-core/jasmine.js @@ -4559,56 +4559,34 @@ getJasmineRequireObj().GlobalErrors = function(j$) { class NodeAdapter { #global; #dispatch; - #originalHandlers; - #jasmineHandlers; constructor(global, dispatch) { this.#global = global; this.#dispatch = dispatch; - this.#jasmineHandlers = {}; - this.#originalHandlers = {}; - this.onError = this.onError.bind(this); this.onUnhandledRejection = this.onUnhandledRejection.bind(this); } install() { - this.#installHandler('uncaughtException', this.onError); - this.#installHandler('unhandledRejection', this.onUnhandledRejection); - this.#installHandler( + this.#global.process.on('uncaughtException', this.onError); + this.#global.process.on('unhandledRejection', this.onUnhandledRejection); + this.#global.process.on( 'rejectionHandled', this.#dispatch.onRejectionHandled ); } uninstall() { - const errorTypes = Object.keys(this.#originalHandlers); - for (const errorType of errorTypes) { - this.#global.process.removeListener( - errorType, - this.#jasmineHandlers[errorType] - ); - - for (let i = 0; i < this.#originalHandlers[errorType].length; i++) { - this.#global.process.on( - errorType, - this.#originalHandlers[errorType][i] - ); - } - delete this.#originalHandlers[errorType]; - delete this.#jasmineHandlers[errorType]; - } - } - - #installHandler(errorType, handler) { - this.#originalHandlers[errorType] = this.#global.process.listeners( - errorType + this.#global.process.removeListener('uncaughtException', this.onError); + this.#global.process.removeListener( + 'unhandledRejection', + this.onUnhandledRejection + ); + this.#global.process.removeListener( + 'rejectionHandled', + this.#dispatch.onRejectionHandled ); - this.#jasmineHandlers[errorType] = handler; - - this.#global.process.removeAllListeners(errorType); - this.#global.process.on(errorType, handler); } #augmentError(error, isUnhandledRejection) { diff --git a/spec/core/GlobalErrorsSpec.js b/spec/core/GlobalErrorsSpec.js index 959bb340..799814f9 100644 --- a/spec/core/GlobalErrorsSpec.js +++ b/spec/core/GlobalErrorsSpec.js @@ -142,11 +142,9 @@ describe('GlobalErrors', function() { errors.install(); expect(globals.listeners.uncaughtException).toEqual([ + originalHandler, jasmine.any(Function) ]); - expect(globals.listeners.uncaughtException).not.toEqual([ - originalHandler() - ]); errors.pushListener(handler); @@ -175,11 +173,9 @@ describe('GlobalErrors', function() { errors.install(); expect(globals.listeners.unhandledRejection).toEqual([ + originalHandler, jasmine.any(Function) ]); - expect(globals.listeners.unhandledRejection).not.toEqual([ - originalHandler() - ]); errors.pushListener(handler); @@ -257,11 +253,9 @@ describe('GlobalErrors', function() { errors.install(); expect(globals.listeners.rejectionHandled).toEqual([ + originalHandler, jasmine.any(Function) ]); - expect(globals.listeners.rejectionHandled).not.toEqual([ - originalHandler - ]); errors.uninstall(); expect(globals.listeners.rejectionHandled).toEqual([originalHandler]); diff --git a/src/core/GlobalErrors.js b/src/core/GlobalErrors.js index 27af0128..7fd5d3b1 100644 --- a/src/core/GlobalErrors.js +++ b/src/core/GlobalErrors.js @@ -191,56 +191,34 @@ getJasmineRequireObj().GlobalErrors = function(j$) { class NodeAdapter { #global; #dispatch; - #originalHandlers; - #jasmineHandlers; constructor(global, dispatch) { this.#global = global; this.#dispatch = dispatch; - this.#jasmineHandlers = {}; - this.#originalHandlers = {}; - this.onError = this.onError.bind(this); this.onUnhandledRejection = this.onUnhandledRejection.bind(this); } install() { - this.#installHandler('uncaughtException', this.onError); - this.#installHandler('unhandledRejection', this.onUnhandledRejection); - this.#installHandler( + this.#global.process.on('uncaughtException', this.onError); + this.#global.process.on('unhandledRejection', this.onUnhandledRejection); + this.#global.process.on( 'rejectionHandled', this.#dispatch.onRejectionHandled ); } uninstall() { - const errorTypes = Object.keys(this.#originalHandlers); - for (const errorType of errorTypes) { - this.#global.process.removeListener( - errorType, - this.#jasmineHandlers[errorType] - ); - - for (let i = 0; i < this.#originalHandlers[errorType].length; i++) { - this.#global.process.on( - errorType, - this.#originalHandlers[errorType][i] - ); - } - delete this.#originalHandlers[errorType]; - delete this.#jasmineHandlers[errorType]; - } - } - - #installHandler(errorType, handler) { - this.#originalHandlers[errorType] = this.#global.process.listeners( - errorType + this.#global.process.removeListener('uncaughtException', this.onError); + this.#global.process.removeListener( + 'unhandledRejection', + this.onUnhandledRejection + ); + this.#global.process.removeListener( + 'rejectionHandled', + this.#dispatch.onRejectionHandled ); - this.#jasmineHandlers[errorType] = handler; - - this.#global.process.removeAllListeners(errorType); - this.#global.process.on(errorType, handler); } #augmentError(error, isUnhandledRejection) { From 4166ea791ce7ab078baa348c8d20605ac67e8482 Mon Sep 17 00:00:00 2001 From: Steve Gravrock Date: Sun, 14 Sep 2025 17:27:58 -0700 Subject: [PATCH 10/95] Clean up global error listener leaks in Jasmine's own tests --- spec/helpers/resetEnv.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/spec/helpers/resetEnv.js b/spec/helpers/resetEnv.js index cf12a0a9..af90b4b4 100644 --- a/spec/helpers/resetEnv.js +++ b/spec/helpers/resetEnv.js @@ -1,4 +1,8 @@ beforeEach(function() { - // env is stateful. Ensure that it does not leak between tests. - jasmineUnderTest.currentEnv_ = null; + // env is stateful. Ensure that it, and its global error event listeners, + // do not leak between tests. + if (jasmineUnderTest.currentEnv_) { + jasmineUnderTest.currentEnv_.cleanup_(); + jasmineUnderTest.currentEnv_ = null; + } }); From 70fbdc98b5c3021e14b06fbed90db1747a7afadc Mon Sep 17 00:00:00 2001 From: Steve Gravrock Date: Sat, 20 Sep 2025 06:08:56 -0700 Subject: [PATCH 11/95] Revert to pre-5.0 default of creating a new core instance in each call to Node boot() --- lib/jasmine-core.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/lib/jasmine-core.js b/lib/jasmine-core.js index e20680c4..30b95b2e 100644 --- a/lib/jasmine-core.js +++ b/lib/jasmine-core.js @@ -6,7 +6,7 @@ const jasmineRequire = require('./jasmine-core/jasmine.js'); module.exports = jasmineRequire; -const boot = (function() { +const bootWithoutGlobals = (function() { let jasmine, jasmineInterface; return function bootWithoutGlobals(reinitialize) { @@ -22,14 +22,16 @@ const boot = (function() { /** * Boots a copy of Jasmine and returns an object as described in {@link jasmine}. - * If boot is called multiple times, the same object is returned every time - * unless true is passed. - * @param {boolean} [reinitialize=false] Whether to create a new copy of Jasmine if one already exists + * @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) { - const {jasmine, jasmineInterface} = boot(reinitialize); + if (reinitialize === undefined) { + reinitialize = true; + } + + const {jasmine, jasmineInterface} = bootWithoutGlobals(reinitialize); for (const k in jasmineInterface) { global[k] = jasmineInterface[k]; @@ -48,7 +50,7 @@ module.exports.boot = function(reinitialize) { * const {describe, beforeEach, it, expect, jasmine} = require('jasmine-core').noGlobals(); */ module.exports.noGlobals = function(reinitialize) { - const {jasmineInterface} = boot(reinitialize); + const {jasmineInterface} = bootWithoutGlobals(reinitialize); return jasmineInterface; }; From f86f8c3331e79dd2a9926abd89bfd6a5a266a7b7 Mon Sep 17 00:00:00 2001 From: Steve Gravrock Date: Sat, 20 Sep 2025 06:16:34 -0700 Subject: [PATCH 12/95] Remove useless reinitialize option from noGlobals() --- lib/jasmine-core.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/jasmine-core.js b/lib/jasmine-core.js index 30b95b2e..868874bc 100644 --- a/lib/jasmine-core.js +++ b/lib/jasmine-core.js @@ -43,14 +43,13 @@ module.exports.boot = function(reinitialize) { /** * 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 unless true is passed. + * multiple times, the same object is returned every time. * - * @param {boolean} [reinitialize=false] Whether to create a new copy of Jasmine if one already exists * @example * const {describe, beforeEach, it, expect, jasmine} = require('jasmine-core').noGlobals(); */ -module.exports.noGlobals = function(reinitialize) { - const {jasmineInterface} = bootWithoutGlobals(reinitialize); +module.exports.noGlobals = function() { + const {jasmineInterface} = bootWithoutGlobals(false); return jasmineInterface; }; From 72ecc70c5d7d1493887cce730d2f465d7fb43667 Mon Sep 17 00:00:00 2001 From: Steve Gravrock Date: Sat, 20 Sep 2025 06:35:48 -0700 Subject: [PATCH 13/95] Move jasmine-core.js source from lib to src --- lib/jasmine-core.js | 40 +++++++++++--- scripts/lib/buildDistribution.js | 4 ++ src/boot/jasmine-core.js | 89 ++++++++++++++++++++++++++++++++ 3 files changed, 125 insertions(+), 8 deletions(-) create mode 100644 src/boot/jasmine-core.js diff --git a/lib/jasmine-core.js b/lib/jasmine-core.js index 868874bc..326ccab1 100644 --- a/lib/jasmine-core.js +++ b/lib/jasmine-core.js @@ -1,3 +1,27 @@ +/* +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. +*/ + /** * Note: Only available on Node. * @module jasmine-core @@ -16,9 +40,9 @@ const bootWithoutGlobals = (function() { jasmineInterface = jasmineRequire.interface(jasmine, env); } - return {jasmine, jasmineInterface}; + return { jasmine, jasmineInterface }; }; -}()); +})(); /** * Boots a copy of Jasmine and returns an object as described in {@link jasmine}. @@ -31,7 +55,7 @@ module.exports.boot = function(reinitialize) { reinitialize = true; } - const {jasmine, jasmineInterface} = bootWithoutGlobals(reinitialize); + const { jasmine, jasmineInterface } = bootWithoutGlobals(reinitialize); for (const k in jasmineInterface) { global[k] = jasmineInterface[k]; @@ -49,7 +73,7 @@ module.exports.boot = function(reinitialize) { * const {describe, beforeEach, it, expect, jasmine} = require('jasmine-core').noGlobals(); */ module.exports.noGlobals = function() { - const {jasmineInterface} = bootWithoutGlobals(false); + const { jasmineInterface } = bootWithoutGlobals(false); return jasmineInterface; }; @@ -64,16 +88,16 @@ const rootPath = path.join(__dirname, 'jasmine-core'), jsFilesToSkip = ['jasmine.js'].concat(bootFiles, legacyBootFiles); fs.readdirSync(rootPath).forEach(function(file) { - if(fs.statSync(path.join(rootPath, file)).isFile()) { - switch(path.extname(file)) { + if (fs.statSync(path.join(rootPath, file)).isFile()) { + switch (path.extname(file)) { case '.css': cssFiles.push(file); - break; + break; case '.js': if (jsFilesToSkip.indexOf(file) < 0) { jsFiles.push(file); } - break; + break; } } }); diff --git a/scripts/lib/buildDistribution.js b/scripts/lib/buildDistribution.js index f92587ac..5832a3d0 100644 --- a/scripts/lib/buildDistribution.js +++ b/scripts/lib/buildDistribution.js @@ -70,6 +70,10 @@ function concatFiles() { { dest: 'lib/jasmine-core/boot1.js', src: ['src/boot/boot1.js'], + }, + { + dest: 'lib/jasmine-core.js', + src: ['src/boot/jasmine-core.js'], } ]; const licenseBanner = { diff --git a/src/boot/jasmine-core.js b/src/boot/jasmine-core.js new file mode 100644 index 00000000..6d8878fc --- /dev/null +++ b/src/boot/jasmine-core.js @@ -0,0 +1,89 @@ +/** + * Note: Only available on Node. + * @module jasmine-core + */ + +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'); + +const rootPath = path.join(__dirname, 'jasmine-core'), + bootFiles = ['boot0.js', 'boot1.js'], + legacyBootFiles = ['boot.js'], + cssFiles = [], + jsFiles = [], + jsFilesToSkip = ['jasmine.js'].concat(bootFiles, legacyBootFiles); + +fs.readdirSync(rootPath).forEach(function(file) { + if (fs.statSync(path.join(rootPath, file)).isFile()) { + switch (path.extname(file)) { + case '.css': + cssFiles.push(file); + break; + case '.js': + if (jsFilesToSkip.indexOf(file) < 0) { + jsFiles.push(file); + } + break; + } + } +}); + +module.exports.files = { + self: __filename, + path: rootPath, + bootDir: rootPath, + bootFiles: bootFiles, + cssFiles: cssFiles, + jsFiles: ['jasmine.js'].concat(jsFiles), + imagesDir: path.join(__dirname, '../images') +}; From 0462500c316c213b3d4d93908fe04e17cbc5480c Mon Sep 17 00:00:00 2001 From: Steve Gravrock Date: Sat, 20 Sep 2025 10:25:32 -0700 Subject: [PATCH 14/95] Drop support for Node 18, to match jasmine-browser-runner Selenium-webdriver 4.34 and later don't support it. --- .circleci/config.yml | 22 +++++----------------- README.md | 2 +- 2 files changed, 6 insertions(+), 18 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index fe0b2b31..e8dc4ac8 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -16,10 +16,6 @@ executors: docker: - image: cimg/node:20.0.0 working_directory: ~/workspace - node18: - docker: - - image: cimg/node:18.20.5 - working_directory: ~/workspace jobs: build: @@ -68,7 +64,7 @@ jobs: command: npm run test:parallel test_browsers: &test_browsers - executor: node18 + executor: node20 steps: - attach_workspace: at: . @@ -113,9 +109,6 @@ workflows: - build: executor: node20 name: build_node_20 - - build: - executor: node18 - name: build_node_18 - test_node: executor: node22 name: test_node_22 @@ -126,11 +119,6 @@ workflows: name: test_node_20 requires: - build_node_20 - - test_node: - executor: node18 - name: test_node_18 - requires: - - build_node_18 - test_parallel: executor: node24 name: test_parallel_node_24 @@ -147,13 +135,13 @@ workflows: requires: - build_node_20 - test_parallel: - executor: node18 - name: test_parallel_node_18 + executor: node20 + name: test_parallel_node_20 requires: - - build_node_18 + - build_node_20 - test_browsers: requires: - - build_node_18 + - build_node_20 filters: branches: ignore: /pull\/.*/ # Don't run on pull requests. diff --git a/README.md b/README.md index d61e6b74..d809d61c 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,7 @@ Microsoft Edge) as well as Node. | Environment | Supported versions | |-------------------|----------------------------------| -| Node | 18.20.5+*, 20, 22, 24 | +| Node | 20, 22, 24 | | Safari | 16*, 17* | | Chrome | Evergreen | | Firefox | Evergreen, 102*, 115*, 128*, 140 | From 88289f592e0675b558d6a5f1e180583b6336de0b Mon Sep 17 00:00:00 2001 From: Steve Gravrock Date: Sat, 20 Sep 2025 10:26:49 -0700 Subject: [PATCH 15/95] Revert "Don't remove existing unhandled exception and promise rejection handlers in Node" This reverts commit 6da88ec19eea2780c030dc95fcc55d059fed69e5. Removing existing handlers turns out to be load-bearing for Jasmine's parallel mode. ParallelWorker (in the jasmine package) installs a pair of handlers before booting core so that it can catch late async errors that happen after one spec file has finished executing and before the next starts. If those aren't uninstalled, errors that get routed through jasmine-core's normal error handling mechanism will also be reported via ParallelWorker's handlers. It might be possible for ParallelWorker to uninstall and install its handlers at the right time, but it's likely that there would be gaps in between when core uninstalls its handlers and when ParallelWorker installs. And in any case, the old behavior of GlobalErrors was a perfect match for what ParallelWorker needs, so let's keep it. --- lib/jasmine-core/jasmine.js | 44 ++++++++++++++++++++++++++--------- spec/core/GlobalErrorsSpec.js | 12 +++++++--- src/core/GlobalErrors.js | 44 ++++++++++++++++++++++++++--------- 3 files changed, 75 insertions(+), 25 deletions(-) diff --git a/lib/jasmine-core/jasmine.js b/lib/jasmine-core/jasmine.js index 94b74490..37135702 100644 --- a/lib/jasmine-core/jasmine.js +++ b/lib/jasmine-core/jasmine.js @@ -4559,34 +4559,56 @@ getJasmineRequireObj().GlobalErrors = function(j$) { class NodeAdapter { #global; #dispatch; + #originalHandlers; + #jasmineHandlers; constructor(global, dispatch) { this.#global = global; this.#dispatch = dispatch; + this.#jasmineHandlers = {}; + this.#originalHandlers = {}; + this.onError = this.onError.bind(this); this.onUnhandledRejection = this.onUnhandledRejection.bind(this); } install() { - this.#global.process.on('uncaughtException', this.onError); - this.#global.process.on('unhandledRejection', this.onUnhandledRejection); - this.#global.process.on( + this.#installHandler('uncaughtException', this.onError); + this.#installHandler('unhandledRejection', this.onUnhandledRejection); + this.#installHandler( 'rejectionHandled', this.#dispatch.onRejectionHandled ); } uninstall() { - this.#global.process.removeListener('uncaughtException', this.onError); - this.#global.process.removeListener( - 'unhandledRejection', - this.onUnhandledRejection - ); - this.#global.process.removeListener( - 'rejectionHandled', - this.#dispatch.onRejectionHandled + const errorTypes = Object.keys(this.#originalHandlers); + for (const errorType of errorTypes) { + this.#global.process.removeListener( + errorType, + this.#jasmineHandlers[errorType] + ); + + for (let i = 0; i < this.#originalHandlers[errorType].length; i++) { + this.#global.process.on( + errorType, + this.#originalHandlers[errorType][i] + ); + } + delete this.#originalHandlers[errorType]; + delete this.#jasmineHandlers[errorType]; + } + } + + #installHandler(errorType, handler) { + this.#originalHandlers[errorType] = this.#global.process.listeners( + errorType ); + this.#jasmineHandlers[errorType] = handler; + + this.#global.process.removeAllListeners(errorType); + this.#global.process.on(errorType, handler); } #augmentError(error, isUnhandledRejection) { diff --git a/spec/core/GlobalErrorsSpec.js b/spec/core/GlobalErrorsSpec.js index 799814f9..959bb340 100644 --- a/spec/core/GlobalErrorsSpec.js +++ b/spec/core/GlobalErrorsSpec.js @@ -142,9 +142,11 @@ describe('GlobalErrors', function() { errors.install(); expect(globals.listeners.uncaughtException).toEqual([ - originalHandler, jasmine.any(Function) ]); + expect(globals.listeners.uncaughtException).not.toEqual([ + originalHandler() + ]); errors.pushListener(handler); @@ -173,9 +175,11 @@ describe('GlobalErrors', function() { errors.install(); expect(globals.listeners.unhandledRejection).toEqual([ - originalHandler, jasmine.any(Function) ]); + expect(globals.listeners.unhandledRejection).not.toEqual([ + originalHandler() + ]); errors.pushListener(handler); @@ -253,9 +257,11 @@ describe('GlobalErrors', function() { errors.install(); expect(globals.listeners.rejectionHandled).toEqual([ - originalHandler, jasmine.any(Function) ]); + expect(globals.listeners.rejectionHandled).not.toEqual([ + originalHandler + ]); errors.uninstall(); expect(globals.listeners.rejectionHandled).toEqual([originalHandler]); diff --git a/src/core/GlobalErrors.js b/src/core/GlobalErrors.js index 7fd5d3b1..27af0128 100644 --- a/src/core/GlobalErrors.js +++ b/src/core/GlobalErrors.js @@ -191,34 +191,56 @@ getJasmineRequireObj().GlobalErrors = function(j$) { class NodeAdapter { #global; #dispatch; + #originalHandlers; + #jasmineHandlers; constructor(global, dispatch) { this.#global = global; this.#dispatch = dispatch; + this.#jasmineHandlers = {}; + this.#originalHandlers = {}; + this.onError = this.onError.bind(this); this.onUnhandledRejection = this.onUnhandledRejection.bind(this); } install() { - this.#global.process.on('uncaughtException', this.onError); - this.#global.process.on('unhandledRejection', this.onUnhandledRejection); - this.#global.process.on( + this.#installHandler('uncaughtException', this.onError); + this.#installHandler('unhandledRejection', this.onUnhandledRejection); + this.#installHandler( 'rejectionHandled', this.#dispatch.onRejectionHandled ); } uninstall() { - this.#global.process.removeListener('uncaughtException', this.onError); - this.#global.process.removeListener( - 'unhandledRejection', - this.onUnhandledRejection - ); - this.#global.process.removeListener( - 'rejectionHandled', - this.#dispatch.onRejectionHandled + const errorTypes = Object.keys(this.#originalHandlers); + for (const errorType of errorTypes) { + this.#global.process.removeListener( + errorType, + this.#jasmineHandlers[errorType] + ); + + for (let i = 0; i < this.#originalHandlers[errorType].length; i++) { + this.#global.process.on( + errorType, + this.#originalHandlers[errorType][i] + ); + } + delete this.#originalHandlers[errorType]; + delete this.#jasmineHandlers[errorType]; + } + } + + #installHandler(errorType, handler) { + this.#originalHandlers[errorType] = this.#global.process.listeners( + errorType ); + this.#jasmineHandlers[errorType] = handler; + + this.#global.process.removeAllListeners(errorType); + this.#global.process.on(errorType, handler); } #augmentError(error, isUnhandledRejection) { From ee696cbbf6ed3d70b5cdd2947ed5896f7067ecb4 Mon Sep 17 00:00:00 2001 From: Steve Gravrock Date: Sat, 20 Sep 2025 10:41:50 -0700 Subject: [PATCH 16/95] Depend on the 4.0 branch of jasmine-browser-runner --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index de14c60d..caa42e98 100644 --- a/package.json +++ b/package.json @@ -46,7 +46,7 @@ "glob": "^10.2.3", "globals": "^16.0.0", "jasmine": "^5.0.0", - "jasmine-browser-runner": "github:jasmine/jasmine-browser-runner", + "jasmine-browser-runner": "github:jasmine/jasmine-browser-runner#4.0", "jsdom": "^26.0.0", "prettier": "1.17.1", "sass": "^1.58.3" From 7aaa16f576e2ea0b146a141a266fd571a07983e6 Mon Sep 17 00:00:00 2001 From: Steve Gravrock Date: Sat, 20 Sep 2025 15:52:42 -0700 Subject: [PATCH 17/95] Removed ReportDispatcher support for multiple args and non-object args All reporter calls take a single argument of object type, and always have. --- lib/jasmine-core/jasmine.js | 16 ++++++++-------- spec/core/ReportDispatcherSpec.js | 30 +++++++++++++++--------------- src/core/ReportDispatcher.js | 16 ++++++++-------- 3 files changed, 31 insertions(+), 31 deletions(-) diff --git a/lib/jasmine-core/jasmine.js b/lib/jasmine-core/jasmine.js index 37135702..f074d174 100644 --- a/lib/jasmine-core/jasmine.js +++ b/lib/jasmine-core/jasmine.js @@ -8581,8 +8581,8 @@ getJasmineRequireObj().ReportDispatcher = function(j$) { for (const method of dispatchedMethods) { this[method] = (function(m) { - return function() { - return dispatch(m, arguments); + return function(event) { + return dispatch(m, event); }; })(method); } @@ -8604,13 +8604,13 @@ getJasmineRequireObj().ReportDispatcher = function(j$) { return this; - function dispatch(method, args) { + function dispatch(method, event) { if (reporters.length === 0 && fallbackReporter !== null) { reporters.push(fallbackReporter); } const fns = []; for (const reporter of reporters) { - addFn(fns, reporter, method, args); + addFn(fns, reporter, method, event); } return new Promise(function(resolve) { @@ -8630,23 +8630,23 @@ getJasmineRequireObj().ReportDispatcher = function(j$) { }); } - function addFn(fns, reporter, method, args) { + function addFn(fns, reporter, method, event) { const fn = reporter[method]; if (!fn) { return; } - const thisArgs = j$.util.cloneArgs(args); + const thisEvent = j$.util.clone(event); if (fn.length <= 1) { fns.push({ fn: function() { - return fn.apply(reporter, thisArgs); + return fn.call(reporter, thisEvent); } }); } else { fns.push({ fn: function(done) { - return fn.apply(reporter, thisArgs.concat([done])); + return fn.call(reporter, thisEvent, done); } }); } diff --git a/spec/core/ReportDispatcherSpec.js b/spec/core/ReportDispatcherSpec.js index 83649a9c..5c9fe06c 100644 --- a/spec/core/ReportDispatcherSpec.js +++ b/spec/core/ReportDispatcherSpec.js @@ -23,7 +23,7 @@ describe('ReportDispatcher', function() { dispatcher.addReporter(reporter); dispatcher.addReporter(anotherReporter); - dispatcher.foo(123, 456); + dispatcher.foo({ an: 'event' }); expect(runQueue).toHaveBeenCalledWith( jasmine.objectContaining({ @@ -37,16 +37,16 @@ describe('ReportDispatcher', function() { let fns = runQueue.calls.mostRecent().args[0].queueableFns; fns[0].fn(); - expect(reporter.foo).toHaveBeenCalledWith(123, 456); + expect(reporter.foo).toHaveBeenCalledWith({ an: 'event' }); expect(reporter.foo.calls.mostRecent().object).toBe(reporter); fns[1].fn(); - expect(anotherReporter.foo).toHaveBeenCalledWith(123, 456); + expect(anotherReporter.foo).toHaveBeenCalledWith({ an: 'event' }); expect(anotherReporter.foo.calls.mostRecent().object).toBe(anotherReporter); runQueue.calls.reset(); - dispatcher.bar('a', 'b'); + dispatcher.bar({ another: 'event' }); expect(runQueue).toHaveBeenCalledWith( jasmine.objectContaining({ @@ -60,10 +60,10 @@ describe('ReportDispatcher', function() { fns = runQueue.calls.mostRecent().args[0].queueableFns; fns[0].fn(); - expect(reporter.bar).toHaveBeenCalledWith('a', 'b'); + expect(reporter.bar).toHaveBeenCalledWith({ another: 'event' }); fns[1].fn(); - expect(anotherReporter.bar).toHaveBeenCalledWith('a', 'b'); + expect(anotherReporter.bar).toHaveBeenCalledWith({ another: 'event' }); }); it("does not dispatch to a reporter if the reporter doesn't accept the method", function() { @@ -90,7 +90,7 @@ describe('ReportDispatcher', function() { reporter = jasmine.createSpyObj('reporter', ['foo', 'bar']); dispatcher.provideFallbackReporter(reporter); - dispatcher.foo(123, 456); + dispatcher.foo({ an: 'event' }); expect(runQueue).toHaveBeenCalledWith( jasmine.objectContaining({ @@ -101,7 +101,7 @@ describe('ReportDispatcher', function() { const fns = runQueue.calls.mostRecent().args[0].queueableFns; fns[0].fn(); - expect(reporter.foo).toHaveBeenCalledWith(123, 456); + expect(reporter.foo).toHaveBeenCalledWith({ an: 'event' }); }); it('does not call fallback reporting methods when another reporter is provided', function() { @@ -115,7 +115,7 @@ describe('ReportDispatcher', function() { dispatcher.provideFallbackReporter(fallbackReporter); dispatcher.addReporter(reporter); - dispatcher.foo(123, 456); + dispatcher.foo({ an: 'event' }); expect(runQueue).toHaveBeenCalledWith( jasmine.objectContaining({ @@ -126,8 +126,8 @@ describe('ReportDispatcher', function() { const fns = runQueue.calls.mostRecent().args[0].queueableFns; fns[0].fn(); - expect(reporter.foo).toHaveBeenCalledWith(123, 456); - expect(fallbackReporter.foo).not.toHaveBeenCalledWith(123, 456); + expect(reporter.foo).toHaveBeenCalledWith({ an: 'event' }); + expect(fallbackReporter.foo).not.toHaveBeenCalled(); }); it('allows registered reporters to be cleared', function() { @@ -140,7 +140,7 @@ describe('ReportDispatcher', function() { reporter2 = jasmine.createSpyObj('reporter2', ['foo', 'bar']); dispatcher.addReporter(reporter1); - dispatcher.foo(123); + dispatcher.foo({ an: 'event' }); expect(runQueue).toHaveBeenCalledWith( jasmine.objectContaining({ queueableFns: [{ fn: jasmine.any(Function) }], @@ -150,11 +150,11 @@ describe('ReportDispatcher', function() { let fns = runQueue.calls.mostRecent().args[0].queueableFns; fns[0].fn(); - expect(reporter1.foo).toHaveBeenCalledWith(123); + expect(reporter1.foo).toHaveBeenCalledWith({ an: 'event' }); dispatcher.clearReporters(); dispatcher.addReporter(reporter2); - dispatcher.bar(456); + dispatcher.bar({ another: 'event' }); expect(runQueue).toHaveBeenCalledWith( jasmine.objectContaining({ @@ -166,6 +166,6 @@ describe('ReportDispatcher', function() { fns = runQueue.calls.mostRecent().args[0].queueableFns; fns[0].fn(); expect(reporter1.bar).not.toHaveBeenCalled(); - expect(reporter2.bar).toHaveBeenCalledWith(456); + expect(reporter2.bar).toHaveBeenCalledWith({ another: 'event' }); }); }); diff --git a/src/core/ReportDispatcher.js b/src/core/ReportDispatcher.js index a20c62ed..266ed899 100644 --- a/src/core/ReportDispatcher.js +++ b/src/core/ReportDispatcher.js @@ -6,8 +6,8 @@ getJasmineRequireObj().ReportDispatcher = function(j$) { for (const method of dispatchedMethods) { this[method] = (function(m) { - return function() { - return dispatch(m, arguments); + return function(event) { + return dispatch(m, event); }; })(method); } @@ -29,13 +29,13 @@ getJasmineRequireObj().ReportDispatcher = function(j$) { return this; - function dispatch(method, args) { + function dispatch(method, event) { if (reporters.length === 0 && fallbackReporter !== null) { reporters.push(fallbackReporter); } const fns = []; for (const reporter of reporters) { - addFn(fns, reporter, method, args); + addFn(fns, reporter, method, event); } return new Promise(function(resolve) { @@ -55,23 +55,23 @@ getJasmineRequireObj().ReportDispatcher = function(j$) { }); } - function addFn(fns, reporter, method, args) { + function addFn(fns, reporter, method, event) { const fn = reporter[method]; if (!fn) { return; } - const thisArgs = j$.util.cloneArgs(args); + const thisEvent = j$.util.clone(event); if (fn.length <= 1) { fns.push({ fn: function() { - return fn.apply(reporter, thisArgs); + return fn.call(reporter, thisEvent); } }); } else { fns.push({ fn: function(done) { - return fn.apply(reporter, thisArgs.concat([done])); + return fn.call(reporter, thisEvent, done); } }); } From 1e98a4b61be7d6a89aa9bedc19988fe40e4adbb3 Mon Sep 17 00:00:00 2001 From: Steve Gravrock Date: Sat, 20 Sep 2025 16:14:54 -0700 Subject: [PATCH 18/95] Removed remaining paths that pass expected and actual of expectations to reporters --- lib/jasmine-core/jasmine.js | 18 +------------- spec/core/AsyncExpectationSpec.js | 29 ----------------------- spec/core/ExpectationSpec.js | 39 ++++--------------------------- spec/core/integration/EnvSpec.js | 4 ---- src/core/Env.js | 10 -------- src/core/Expector.js | 4 +--- src/core/Spec.js | 2 -- src/core/Suite.js | 2 -- 8 files changed, 7 insertions(+), 101 deletions(-) diff --git a/lib/jasmine-core/jasmine.js b/lib/jasmine-core/jasmine.js index f074d174..8e46df32 100644 --- a/lib/jasmine-core/jasmine.js +++ b/lib/jasmine-core/jasmine.js @@ -922,8 +922,6 @@ getJasmineRequireObj().Spec = function(j$) { { matcherName: '', passed: false, - expected: '', - actual: '', error: e }, true @@ -1286,23 +1284,13 @@ getJasmineRequireObj().Env = function(j$) { * {@link throwUnless}. Properties of this error are a subset of the * properties of {@link ExpectationResult} and have the same values. * - * Note: The expected and actual properties are deprecated and may be removed - * in a future release. In many Jasmine configurations they are passed - * through JSON serialization and deserialization, which is inherently - * lossy. In such cases, the expected and actual values may be placeholders - * or approximations of the original objects. - * * @property {String} matcherName - The name of the matcher that was executed for this expectation. * @property {String} message - The failure message for the expectation. * @property {Boolean} passed - Whether the expectation passed or failed. - * @property {Object} expected - Deprecated. If the expectation failed, what was the expected value. - * @property {Object} actual - Deprecated. If the expectation failed, what actual value was produced. */ const error = new Error(result.message); error.passed = result.passed; error.message = result.message; - error.expected = result.expected; - error.actual = result.actual; error.matcherName = result.matcherName; throw error; } @@ -4345,9 +4333,7 @@ getJasmineRequireObj().Expector = function(j$) { passed: result.pass, message: message, error: errorForStack ? undefined : result.error, - errorForStack: errorForStack || undefined, - actual: this.actual, - expected: this.expected // TODO: this may need to be arrayified/sliced + errorForStack: errorForStack || undefined }); }; @@ -10720,8 +10706,6 @@ getJasmineRequireObj().Suite = function(j$) { const data = { matcherName: '', passed: false, - expected: '', - actual: '', error: arguments[0] }; const failedExpectation = j$.buildExpectationResult(data); diff --git a/spec/core/AsyncExpectationSpec.js b/spec/core/AsyncExpectationSpec.js index e4393e9c..dc687f53 100644 --- a/spec/core/AsyncExpectationSpec.js +++ b/spec/core/AsyncExpectationSpec.js @@ -303,8 +303,6 @@ describe('AsyncExpectation', function() { passed: true, message: '', error: undefined, - expected: 'hello', - actual: 'an actual', errorForStack: jasmine.any(Error) }); }); @@ -338,8 +336,6 @@ describe('AsyncExpectation', function() { expect(addExpectationResult).toHaveBeenCalledWith(false, { matcherName: 'toFoo', passed: false, - expected: 'hello', - actual: 'an actual', message: '', error: undefined, errorForStack: jasmine.any(Error) @@ -372,8 +368,6 @@ describe('AsyncExpectation', function() { expect(addExpectationResult).toHaveBeenCalledWith(false, { matcherName: 'toFoo', passed: false, - expected: 'hello', - actual: 'an actual', message: 'I am a custom message', error: undefined, errorForStack: jasmine.any(Error) @@ -408,8 +402,6 @@ describe('AsyncExpectation', function() { expect(addExpectationResult).toHaveBeenCalledWith(false, { matcherName: 'toFoo', passed: false, - expected: 'hello', - actual: 'an actual', message: 'I am a custom message', error: undefined, errorForStack: jasmine.any(Error) @@ -428,7 +420,6 @@ describe('AsyncExpectation', function() { } }; const addExpectationResult = jasmine.createSpy('addExpectationResult'); - const actual = 'an actual'; const expectation = jasmineUnderTest.Expectation.asyncFactory({ customAsyncMatchers: matchers, @@ -442,8 +433,6 @@ describe('AsyncExpectation', function() { passed: true, message: '', error: undefined, - expected: 'hello', - actual: actual, errorForStack: jasmine.any(Error) }); }); @@ -465,7 +454,6 @@ describe('AsyncExpectation', function() { } }; const addExpectationResult = jasmine.createSpy('addExpectationResult'); - const actual = 'an actual'; const expectation = jasmineUnderTest.Expectation.asyncFactory({ customAsyncMatchers: matchers, @@ -478,8 +466,6 @@ describe('AsyncExpectation', function() { expect(addExpectationResult).toHaveBeenCalledWith(false, { matcherName: 'toFoo', passed: false, - expected: 'hello', - actual: actual, message: 'default message', error: undefined, errorForStack: jasmine.any(Error) @@ -501,7 +487,6 @@ describe('AsyncExpectation', function() { } }; const addExpectationResult = jasmine.createSpy('addExpectationResult'); - const actual = 'an actual'; const expectation = jasmineUnderTest.Expectation.asyncFactory({ customAsyncMatchers: matchers, @@ -513,8 +498,6 @@ describe('AsyncExpectation', function() { expect(addExpectationResult).toHaveBeenCalledWith(false, { matcherName: 'toFoo', passed: false, - expected: 'hello', - actual: actual, message: 'I am a custom message', error: undefined, errorForStack: jasmine.any(Error) @@ -536,7 +519,6 @@ describe('AsyncExpectation', function() { } }; const addExpectationResult = jasmine.createSpy('addExpectationResult'); - const actual = 'an actual'; const expectation = jasmineUnderTest.Expectation.asyncFactory({ customAsyncMatchers: matchers, @@ -548,8 +530,6 @@ describe('AsyncExpectation', function() { expect(addExpectationResult).toHaveBeenCalledWith(true, { matcherName: 'toFoo', passed: true, - expected: 'hello', - actual: actual, message: '', error: undefined, errorForStack: jasmine.any(Error) @@ -574,7 +554,6 @@ describe('AsyncExpectation', function() { } }; const addExpectationResult = jasmine.createSpy('addExpectationResult'); - const actual = 'an actual'; const expectation = jasmineUnderTest.Expectation.asyncFactory({ customAsyncMatchers: matchers, @@ -586,8 +565,6 @@ describe('AsyncExpectation', function() { expect(addExpectationResult).toHaveBeenCalledWith(false, { matcherName: 'toFoo', passed: false, - expected: 'hello', - actual: actual, message: "I'm a custom message", error: undefined, errorForStack: jasmine.any(Error) @@ -622,8 +599,6 @@ describe('AsyncExpectation', function() { expect(addExpectationResult).toHaveBeenCalledWith(false, { matcherName: 'toFoo', passed: false, - expected: 'hello', - actual: 'an actual', message: 'I am a custom message', error: undefined, errorForStack: jasmine.any(Error) @@ -656,8 +631,6 @@ describe('AsyncExpectation', function() { expect(addExpectationResult).toHaveBeenCalledWith(false, { matcherName: 'toFoo', passed: false, - expected: 'hello', - actual: 'an actual', message: 'I am a custom message', error: undefined, errorForStack: jasmine.any(Error) @@ -692,8 +665,6 @@ describe('AsyncExpectation', function() { expect(addExpectationResult).toHaveBeenCalledWith(false, { matcherName: 'toFoo', passed: false, - expected: 'hello', - actual: 'an actual', message: 'I am a custom message', error: undefined, errorForStack: jasmine.any(Error) diff --git a/spec/core/ExpectationSpec.js b/spec/core/ExpectationSpec.js index c127e1de..06964b40 100644 --- a/spec/core/ExpectationSpec.js +++ b/spec/core/ExpectationSpec.js @@ -108,8 +108,6 @@ describe('Expectation', function() { passed: true, message: '', error: undefined, - expected: 'hello', - actual: 'an actual', errorForStack: undefined }); }); @@ -143,8 +141,6 @@ describe('Expectation', function() { expect(addExpectationResult).toHaveBeenCalledWith(false, { matcherName: 'toFoo', passed: false, - expected: 'hello', - actual: 'an actual', message: '', error: undefined, errorForStack: undefined @@ -177,8 +173,6 @@ describe('Expectation', function() { expect(addExpectationResult).toHaveBeenCalledWith(false, { matcherName: 'toFoo', passed: false, - expected: 'hello', - actual: 'an actual', message: 'I am a custom message', error: undefined, errorForStack: undefined @@ -213,8 +207,6 @@ describe('Expectation', function() { expect(addExpectationResult).toHaveBeenCalledWith(false, { matcherName: 'toFoo', passed: false, - expected: 'hello', - actual: 'an actual', message: 'I am a custom message', error: undefined, errorForStack: undefined @@ -231,8 +223,7 @@ describe('Expectation', function() { }; } }, - addExpectationResult = jasmine.createSpy('addExpectationResult'), - actual = 'an actual'; + addExpectationResult = jasmine.createSpy('addExpectationResult'); const expectation = jasmineUnderTest.Expectation.factory({ customMatchers: matchers, @@ -247,8 +238,6 @@ describe('Expectation', function() { passed: true, message: '', error: undefined, - expected: 'hello', - actual: actual, errorForStack: undefined }); }); @@ -268,8 +257,7 @@ describe('Expectation', function() { return 'default message'; } }, - addExpectationResult = jasmine.createSpy('addExpectationResult'), - actual = 'an actual'; + addExpectationResult = jasmine.createSpy('addExpectationResult'); const expectation = jasmineUnderTest.Expectation.factory({ customMatchers: matchers, @@ -283,8 +271,6 @@ describe('Expectation', function() { expect(addExpectationResult).toHaveBeenCalledWith(false, { matcherName: 'toFoo', passed: false, - expected: 'hello', - actual: actual, message: 'default message', error: undefined, errorForStack: undefined @@ -304,8 +290,7 @@ describe('Expectation', function() { }; } }, - addExpectationResult = jasmine.createSpy('addExpectationResult'), - actual = 'an actual'; + addExpectationResult = jasmine.createSpy('addExpectationResult'); const expectation = jasmineUnderTest.Expectation.factory({ customMatchers: matchers, @@ -318,8 +303,6 @@ describe('Expectation', function() { expect(addExpectationResult).toHaveBeenCalledWith(false, { matcherName: 'toFoo', passed: false, - expected: 'hello', - actual: actual, message: 'I am a custom message', error: undefined, errorForStack: undefined @@ -339,8 +322,7 @@ describe('Expectation', function() { }; } }, - addExpectationResult = jasmine.createSpy('addExpectationResult'), - actual = 'an actual'; + addExpectationResult = jasmine.createSpy('addExpectationResult'); const expectation = jasmineUnderTest.Expectation.factory({ customMatchers: matchers, @@ -353,8 +335,6 @@ describe('Expectation', function() { expect(addExpectationResult).toHaveBeenCalledWith(true, { matcherName: 'toFoo', passed: true, - expected: 'hello', - actual: actual, message: '', error: undefined, errorForStack: undefined @@ -377,8 +357,7 @@ describe('Expectation', function() { }; } }, - addExpectationResult = jasmine.createSpy('addExpectationResult'), - actual = 'an actual'; + addExpectationResult = jasmine.createSpy('addExpectationResult'); const expectation = jasmineUnderTest.Expectation.factory({ customMatchers: matchers, @@ -391,8 +370,6 @@ describe('Expectation', function() { expect(addExpectationResult).toHaveBeenCalledWith(false, { matcherName: 'toFoo', passed: false, - expected: 'hello', - actual: actual, message: "I'm a custom message", error: undefined, errorForStack: undefined @@ -427,8 +404,6 @@ describe('Expectation', function() { expect(addExpectationResult).toHaveBeenCalledWith(false, { matcherName: 'toFoo', passed: false, - expected: 'hello', - actual: 'an actual', message: 'I am a custom message', error: customError, errorForStack: undefined @@ -463,8 +438,6 @@ describe('Expectation', function() { expect(addExpectationResult).toHaveBeenCalledWith(false, { matcherName: 'toFoo', passed: false, - expected: 'hello', - actual: 'an actual', message: 'I am a custom message', error: customError, errorForStack: undefined @@ -501,8 +474,6 @@ describe('Expectation', function() { expect(addExpectationResult).toHaveBeenCalledWith(false, { matcherName: 'toFoo', passed: false, - expected: 'hello', - actual: 'an actual', message: 'I am a custom message', error: customError, errorForStack: undefined diff --git a/spec/core/integration/EnvSpec.js b/spec/core/integration/EnvSpec.js index 542fd7e2..ec74fc16 100644 --- a/spec/core/integration/EnvSpec.js +++ b/spec/core/integration/EnvSpec.js @@ -3702,8 +3702,6 @@ describe('Env integration', function() { expect(thrown.passed).toEqual(false); expect(thrown.matcherName).toEqual('toEqual'); expect(thrown.message).toEqual('Expected 1 to equal 2.'); - expect(thrown.actual).toEqual(1); - expect(thrown.expected).toEqual(2); }); it('does not throw when the matcher passes', async function() { @@ -3760,8 +3758,6 @@ describe('Env integration', function() { expect(thrown.message).toEqual( "Expected a promise to be resolved to 'b' but it was resolved to 'a'." ); - expect(thrown.actual).toBe(promise); - expect(thrown.expected).toEqual('b'); }); it('does not throw when the matcher passes', async function() { diff --git a/src/core/Env.js b/src/core/Env.js index 701b4586..6f3db478 100644 --- a/src/core/Env.js +++ b/src/core/Env.js @@ -158,23 +158,13 @@ getJasmineRequireObj().Env = function(j$) { * {@link throwUnless}. Properties of this error are a subset of the * properties of {@link ExpectationResult} and have the same values. * - * Note: The expected and actual properties are deprecated and may be removed - * in a future release. In many Jasmine configurations they are passed - * through JSON serialization and deserialization, which is inherently - * lossy. In such cases, the expected and actual values may be placeholders - * or approximations of the original objects. - * * @property {String} matcherName - The name of the matcher that was executed for this expectation. * @property {String} message - The failure message for the expectation. * @property {Boolean} passed - Whether the expectation passed or failed. - * @property {Object} expected - Deprecated. If the expectation failed, what was the expected value. - * @property {Object} actual - Deprecated. If the expectation failed, what actual value was produced. */ const error = new Error(result.message); error.passed = result.passed; error.message = result.message; - error.expected = result.expected; - error.actual = result.actual; error.matcherName = result.matcherName; throw error; } diff --git a/src/core/Expector.js b/src/core/Expector.js index c840841b..01802f24 100644 --- a/src/core/Expector.js +++ b/src/core/Expector.js @@ -83,9 +83,7 @@ getJasmineRequireObj().Expector = function(j$) { passed: result.pass, message: message, error: errorForStack ? undefined : result.error, - errorForStack: errorForStack || undefined, - actual: this.actual, - expected: this.expected // TODO: this may need to be arrayified/sliced + errorForStack: errorForStack || undefined }); }; diff --git a/src/core/Spec.js b/src/core/Spec.js index 9d13d757..defa642c 100644 --- a/src/core/Spec.js +++ b/src/core/Spec.js @@ -148,8 +148,6 @@ getJasmineRequireObj().Spec = function(j$) { { matcherName: '', passed: false, - expected: '', - actual: '', error: e }, true diff --git a/src/core/Suite.js b/src/core/Suite.js index e8cc044c..fbbeca1a 100644 --- a/src/core/Suite.js +++ b/src/core/Suite.js @@ -183,8 +183,6 @@ getJasmineRequireObj().Suite = function(j$) { const data = { matcherName: '', passed: false, - expected: '', - actual: '', error: arguments[0] }; const failedExpectation = j$.buildExpectationResult(data); From d333ecb5b130a6a41fff3a1b3e5c7575abce6ba5 Mon Sep 17 00:00:00 2001 From: Steve Gravrock Date: Sat, 20 Sep 2025 16:17:02 -0700 Subject: [PATCH 19/95] Removed useless passed property from ThrowUnlessFailure --- lib/jasmine-core/jasmine.js | 2 -- spec/core/integration/EnvSpec.js | 2 -- src/core/Env.js | 2 -- 3 files changed, 6 deletions(-) diff --git a/lib/jasmine-core/jasmine.js b/lib/jasmine-core/jasmine.js index 8e46df32..c32bccf8 100644 --- a/lib/jasmine-core/jasmine.js +++ b/lib/jasmine-core/jasmine.js @@ -1286,10 +1286,8 @@ getJasmineRequireObj().Env = function(j$) { * * @property {String} matcherName - The name of the matcher that was executed for this expectation. * @property {String} message - The failure message for the expectation. - * @property {Boolean} passed - Whether the expectation passed or failed. */ const error = new Error(result.message); - error.passed = result.passed; error.message = result.message; error.matcherName = result.matcherName; throw error; diff --git a/spec/core/integration/EnvSpec.js b/spec/core/integration/EnvSpec.js index ec74fc16..b9536680 100644 --- a/spec/core/integration/EnvSpec.js +++ b/spec/core/integration/EnvSpec.js @@ -3699,7 +3699,6 @@ describe('Env integration', function() { await env.execute(); expect(thrown).toBeInstanceOf(Error); - expect(thrown.passed).toEqual(false); expect(thrown.matcherName).toEqual('toEqual'); expect(thrown.message).toEqual('Expected 1 to equal 2.'); }); @@ -3753,7 +3752,6 @@ describe('Env integration', function() { await env.execute(); expect(thrown).toBeInstanceOf(Error); - expect(thrown.passed).toEqual(false); expect(thrown.matcherName).toEqual('toBeResolvedTo'); expect(thrown.message).toEqual( "Expected a promise to be resolved to 'b' but it was resolved to 'a'." diff --git a/src/core/Env.js b/src/core/Env.js index 6f3db478..ae38aca1 100644 --- a/src/core/Env.js +++ b/src/core/Env.js @@ -160,10 +160,8 @@ getJasmineRequireObj().Env = function(j$) { * * @property {String} matcherName - The name of the matcher that was executed for this expectation. * @property {String} message - The failure message for the expectation. - * @property {Boolean} passed - Whether the expectation passed or failed. */ const error = new Error(result.message); - error.passed = result.passed; error.message = result.message; error.matcherName = result.matcherName; throw error; From 6e0342fc8eb5a8f0e474e0cc3d99cfeb175f6ccc Mon Sep 17 00:00:00 2001 From: Steve Gravrock Date: Sat, 20 Sep 2025 16:18:56 -0700 Subject: [PATCH 20/95] Deep clone reporter events --- spec/core/ReportDispatcherSpec.js | 33 +++++++++++++++++++++++++++++++ spec/core/integration/EnvSpec.js | 9 --------- src/core/ReportDispatcher.js | 2 +- 3 files changed, 34 insertions(+), 10 deletions(-) diff --git a/spec/core/ReportDispatcherSpec.js b/spec/core/ReportDispatcherSpec.js index 5c9fe06c..c1234e65 100644 --- a/spec/core/ReportDispatcherSpec.js +++ b/spec/core/ReportDispatcherSpec.js @@ -66,6 +66,39 @@ describe('ReportDispatcher', function() { expect(anotherReporter.bar).toHaveBeenCalledWith({ another: 'event' }); }); + it('passes each reporter a separate deep copy of the event', function() { + const runQueue = jasmine.createSpy('runQueue'); + const dispatcher = new jasmineUnderTest.ReportDispatcher( + ['foo', 'bar'], + runQueue + ); + const reporter = jasmine.createSpyObj('reporter', ['foo']); + const anotherReporter = jasmine.createSpyObj('anotherReporter', ['foo']); + const event = { + child: { + grandchild: 'something' + } + }; + dispatcher.addReporter(reporter); + dispatcher.addReporter(anotherReporter); + + dispatcher.foo(event); + + for (const fn of runQueue.calls.mostRecent().args[0].queueableFns) { + fn.fn(); + } + + expect(reporter.foo).toHaveBeenCalledWith(event); + expect(anotherReporter.foo).toHaveBeenCalledWith(event); + const receivedEvents = [reporter, anotherReporter].map(function(reporter) { + return reporter.foo.calls.mostRecent().args[0]; + }); + expect(receivedEvents[0]).not.toBe(event); + expect(receivedEvents[0]).not.toBe(receivedEvents[1]); + expect(receivedEvents[0].child).not.toBe(event.child); + expect(receivedEvents[0].child).not.toBe(receivedEvents[1].child); + }); + it("does not dispatch to a reporter if the reporter doesn't accept the method", function() { const runQueue = jasmine.createSpy('runQueue'), dispatcher = new jasmineUnderTest.ReportDispatcher(['foo'], runQueue), diff --git a/spec/core/integration/EnvSpec.js b/spec/core/integration/EnvSpec.js index b9536680..9a39db2e 100644 --- a/spec/core/integration/EnvSpec.js +++ b/spec/core/integration/EnvSpec.js @@ -1598,15 +1598,6 @@ describe('Env integration', function() { suiteFullNameToId[e.fullName] = e.id; }); - // Clone args to work around Jasmine mutating the result after passing it - // to the reporter event. - // TODO: remove this once Jasmine no longer does that - const clone = structuredClone.bind(globalThis); - reporter.specStarted.calls.saveArgumentsByValue(clone); - reporter.specDone.calls.saveArgumentsByValue(clone); - reporter.specStarted.calls.saveArgumentsByValue(clone); - reporter.suiteDone.calls.saveArgumentsByValue(clone); - env.configure({ random: false }); env.addReporter(reporter); diff --git a/src/core/ReportDispatcher.js b/src/core/ReportDispatcher.js index 266ed899..22f7255e 100644 --- a/src/core/ReportDispatcher.js +++ b/src/core/ReportDispatcher.js @@ -61,7 +61,7 @@ getJasmineRequireObj().ReportDispatcher = function(j$) { return; } - const thisEvent = j$.util.clone(event); + const thisEvent = structuredClone(event); if (fn.length <= 1) { fns.push({ fn: function() { From e2a7740322d2366c56f7538d7c50ee702b655613 Mon Sep 17 00:00:00 2001 From: Steve Gravrock Date: Sat, 20 Sep 2025 17:16:39 -0700 Subject: [PATCH 21/95] Drop support for Safari 16 and Firefox 102 Neither of these browsers has sufficient structuredClone support. FF 102 is well past EOL and Safari 16 only runs on past-EOL OS versions. --- README.md | 4 ++-- scripts/run-all-browsers | 4 +--- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index d809d61c..4734dc2a 100644 --- a/README.md +++ b/README.md @@ -30,9 +30,9 @@ Microsoft Edge) as well as Node. | Environment | Supported versions | |-------------------|----------------------------------| | Node | 20, 22, 24 | -| Safari | 16*, 17* | +| Safari | 17* | | Chrome | Evergreen | -| Firefox | Evergreen, 102*, 115*, 128*, 140 | +| Firefox | Evergreen, 115*, 128*, 140 | | Edge | Evergreen | For evergreen browsers, each version of Jasmine is tested against the version of the browser that is available to us diff --git a/scripts/run-all-browsers b/scripts/run-all-browsers index f28619a0..7d3db73c 100755 --- a/scripts/run-all-browsers +++ b/scripts/run-all-browsers @@ -35,12 +35,10 @@ if [ "$1" = "--not-actually-all" ]; then else run_browser firefox 140 run_browser firefox 128 - run_browser firefox 115 fi -run_browser firefox 102 + run_browser firefox 115 run_browser safari 17 -run_browser safari 16 run_browser MicrosoftEdge latest From 17c0567baebd8bcbfa555aa6784b745821b679a9 Mon Sep 17 00:00:00 2001 From: Steve Gravrock Date: Sun, 21 Sep 2025 08:34:59 -0700 Subject: [PATCH 22/95] Don't leak errorWithStack in late async expectation failures --- lib/jasmine-core/jasmine.js | 7 ++++--- spec/core/SpecSpec.js | 3 ++- spec/core/integration/EnvSpec.js | 15 +++++++++++---- src/core/Env.js | 2 +- src/core/buildExpectationResult.js | 3 ++- 5 files changed, 20 insertions(+), 10 deletions(-) diff --git a/lib/jasmine-core/jasmine.js b/lib/jasmine-core/jasmine.js index c32bccf8..b518aa8a 100644 --- a/lib/jasmine-core/jasmine.js +++ b/lib/jasmine-core/jasmine.js @@ -1354,7 +1354,7 @@ getJasmineRequireObj().Env = function(j$) { '2. Was done() invoked before an async operation completed?\n' + '3. Did an expectation follow a call to done()?'; - topSuite.result.failedExpectations.push(delayedExpectationResult); + topSuite.addExpectationResult(false, delayedExpectationResult); } function routeLateFailure(expectationResult) { @@ -2527,7 +2527,8 @@ getJasmineRequireObj().buildExpectationResult = function(j$) { matcherName: options.matcherName, message: message(), stack: options.omitStackTrace ? '' : stack(), - passed: options.passed + passed: options.passed, + globalErrorType: options.globalErrorType }; if (!result.passed) { @@ -8620,7 +8621,7 @@ getJasmineRequireObj().ReportDispatcher = function(j$) { return; } - const thisEvent = j$.util.clone(event); + const thisEvent = structuredClone(event); if (fn.length <= 1) { fns.push({ fn: function() { diff --git a/spec/core/SpecSpec.js b/spec/core/SpecSpec.js index 664cc092..88f55543 100644 --- a/spec/core/SpecSpec.js +++ b/spec/core/SpecSpec.js @@ -337,7 +337,8 @@ describe('Spec', function() { message: 'foo thrown', matcherName: '', passed: false, - stack: null + stack: null, + globalErrorType: undefined } ]); }); diff --git a/spec/core/integration/EnvSpec.js b/spec/core/integration/EnvSpec.js index 9a39db2e..a62731a3 100644 --- a/spec/core/integration/EnvSpec.js +++ b/spec/core/integration/EnvSpec.js @@ -1674,7 +1674,13 @@ describe('Env integration', function() { status: 'passed', parentSuiteId: suiteFullNameToId['A Suite'], passedExpectations: [ - { matcherName: 'toBe', message: 'Passed.', stack: '', passed: true } + { + matcherName: 'toBe', + message: 'Passed.', + stack: '', + passed: true, + globalErrorType: undefined + } ], duration: jasmine.any(Number) }); @@ -3145,7 +3151,7 @@ describe('Env integration', function() { const result = jasmineDone.calls.argsFor(0)[0]; expect(result.failedExpectations).toEqual([ - jasmine.objectContaining({ + { passed: false, globalErrorType: 'lateExpectation', message: @@ -3154,8 +3160,9 @@ describe('Env integration', function() { '1. Did you forget to return or await the result of expectAsync?\n' + '2. Was done() invoked before an async operation completed?\n' + '3. Did an expectation follow a call to done()?', - matcherName: 'toBeResolved' - }) + matcherName: 'toBeResolved', + stack: jasmine.any(String) + } ]); }); diff --git a/src/core/Env.js b/src/core/Env.js index ae38aca1..e0ed30f3 100644 --- a/src/core/Env.js +++ b/src/core/Env.js @@ -228,7 +228,7 @@ getJasmineRequireObj().Env = function(j$) { '2. Was done() invoked before an async operation completed?\n' + '3. Did an expectation follow a call to done()?'; - topSuite.result.failedExpectations.push(delayedExpectationResult); + topSuite.addExpectationResult(false, delayedExpectationResult); } function routeLateFailure(expectationResult) { diff --git a/src/core/buildExpectationResult.js b/src/core/buildExpectationResult.js index 12f17b77..513741af 100644 --- a/src/core/buildExpectationResult.js +++ b/src/core/buildExpectationResult.js @@ -19,7 +19,8 @@ getJasmineRequireObj().buildExpectationResult = function(j$) { matcherName: options.matcherName, message: message(), stack: options.omitStackTrace ? '' : stack(), - passed: options.passed + passed: options.passed, + globalErrorType: options.globalErrorType }; if (!result.passed) { From 4a36ece65b4857367fddb9d368c9d8f47354a849 Mon Sep 17 00:00:00 2001 From: Steve Gravrock Date: Sun, 21 Sep 2025 08:41:15 -0700 Subject: [PATCH 23/95] Revert "Drop support for Safari 16 and Firefox 102" This reverts commit e2a7740322d2366c56f7538d7c50ee702b655613. structuredClone errors in these browsers were a symptom of inavertently including Error objects in reporter events. In newer browsers, structuredClone can copy those objects, but it's lossy: if an instance of an Error subclass is cloned, the result is an instance of Error. With that fixed, Jasmine is compatible with Safari 16 and FF 102. At least for now. And keeping them around may provide a way to detect similar bugs. --- README.md | 4 ++-- scripts/run-all-browsers | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 4734dc2a..d809d61c 100644 --- a/README.md +++ b/README.md @@ -30,9 +30,9 @@ Microsoft Edge) as well as Node. | Environment | Supported versions | |-------------------|----------------------------------| | Node | 20, 22, 24 | -| Safari | 17* | +| Safari | 16*, 17* | | Chrome | Evergreen | -| Firefox | Evergreen, 115*, 128*, 140 | +| Firefox | Evergreen, 102*, 115*, 128*, 140 | | Edge | Evergreen | For evergreen browsers, each version of Jasmine is tested against the version of the browser that is available to us diff --git a/scripts/run-all-browsers b/scripts/run-all-browsers index 7d3db73c..f28619a0 100755 --- a/scripts/run-all-browsers +++ b/scripts/run-all-browsers @@ -35,10 +35,12 @@ if [ "$1" = "--not-actually-all" ]; then else run_browser firefox 140 run_browser firefox 128 -fi run_browser firefox 115 +fi +run_browser firefox 102 run_browser safari 17 +run_browser safari 16 run_browser MicrosoftEdge latest From 4020da25a4ca7562d111c902b60d5108c80a4923 Mon Sep 17 00:00:00 2001 From: Steve Gravrock Date: Sun, 21 Sep 2025 09:05:00 -0700 Subject: [PATCH 24/95] Refactor Suite#addExpectationResult to use named arguments --- lib/jasmine-core/jasmine.js | 37 ++++++++++++++++++------------------- src/core/Suite.js | 37 ++++++++++++++++++------------------- 2 files changed, 36 insertions(+), 38 deletions(-) diff --git a/lib/jasmine-core/jasmine.js b/lib/jasmine-core/jasmine.js index b518aa8a..d02dd1be 100644 --- a/lib/jasmine-core/jasmine.js +++ b/lib/jasmine-core/jasmine.js @@ -10742,25 +10742,28 @@ getJasmineRequireObj().Suite = function(j$) { this.onLateError(new Error(msg)); } - addExpectationResult() { - if (isFailure(arguments)) { - const data = arguments[1]; - const expectationResult = j$.buildExpectationResult(data); + addExpectationResult(passed, data) { + if (passed) { + // Passed expectations are accepted for compatibility with + // Spec#addExpectationResult, but aren't recorded. + return; + } - if (this.reportedDone) { - this.onLateError(expectationResult); - } else { - this.result.failedExpectations.push(expectationResult); + const expectationResult = j$.buildExpectationResult(data); - // TODO: refactor so that we don't need to override cached status - if (this.result.status) { - this.result.status = 'failed'; - } + if (this.reportedDone) { + this.onLateError(expectationResult); + } else { + this.result.failedExpectations.push(expectationResult); + + // TODO: refactor so that we don't need to override cached status + if (this.result.status) { + this.result.status = 'failed'; } + } - if (this.#throwOnExpectationFailure) { - throw new j$.errors.ExpectationFailed(); - } + if (this.#throwOnExpectationFailure) { + throw new j$.errors.ExpectationFailed(); } } @@ -10857,10 +10860,6 @@ getJasmineRequireObj().Suite = function(j$) { } } - function isFailure(args) { - return !args[0]; - } - return Suite; }; diff --git a/src/core/Suite.js b/src/core/Suite.js index fbbeca1a..58e226f4 100644 --- a/src/core/Suite.js +++ b/src/core/Suite.js @@ -220,25 +220,28 @@ getJasmineRequireObj().Suite = function(j$) { this.onLateError(new Error(msg)); } - addExpectationResult() { - if (isFailure(arguments)) { - const data = arguments[1]; - const expectationResult = j$.buildExpectationResult(data); + addExpectationResult(passed, data) { + if (passed) { + // Passed expectations are accepted for compatibility with + // Spec#addExpectationResult, but aren't recorded. + return; + } - if (this.reportedDone) { - this.onLateError(expectationResult); - } else { - this.result.failedExpectations.push(expectationResult); + const expectationResult = j$.buildExpectationResult(data); - // TODO: refactor so that we don't need to override cached status - if (this.result.status) { - this.result.status = 'failed'; - } + if (this.reportedDone) { + this.onLateError(expectationResult); + } else { + this.result.failedExpectations.push(expectationResult); + + // TODO: refactor so that we don't need to override cached status + if (this.result.status) { + this.result.status = 'failed'; } + } - if (this.#throwOnExpectationFailure) { - throw new j$.errors.ExpectationFailed(); - } + if (this.#throwOnExpectationFailure) { + throw new j$.errors.ExpectationFailed(); } } @@ -335,9 +338,5 @@ getJasmineRequireObj().Suite = function(j$) { } } - function isFailure(args) { - return !args[0]; - } - return Suite; }; From 970cbdc69cfe8d5bf3cf8ae1ff4c5394a2967a65 Mon Sep 17 00:00:00 2001 From: Steve Gravrock Date: Sun, 21 Sep 2025 13:58:02 -0700 Subject: [PATCH 25/95] Omit irrelevant properties from specStarted --- lib/jasmine-core/jasmine.js | 95 +++++++++--- spec/core/SpecSpec.js | 242 +++++++++++++++++++++++++++++++ spec/core/TreeRunnerSpec.js | 6 +- spec/core/integration/EnvSpec.js | 28 ++-- src/core/Env.js | 2 +- src/core/JsApiReporter.js | 4 +- src/core/Spec.js | 77 ++++++++-- src/core/TreeRunner.js | 6 +- src/core/base.js | 2 +- src/core/reporterEvents.js | 4 +- 10 files changed, 406 insertions(+), 60 deletions(-) diff --git a/lib/jasmine-core/jasmine.js b/lib/jasmine-core/jasmine.js index d02dd1be..e55f611f 100644 --- a/lib/jasmine-core/jasmine.js +++ b/lib/jasmine-core/jasmine.js @@ -617,7 +617,7 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) { /** * Logs a message for use in debugging. If the spec fails, trace messages - * will be included in the {@link SpecResult|result} passed to the + * will be included in the {@link SpecDoneEvent|result} passed to the * reporter's specDone method. * * This method should be called only when a spec (including any associated @@ -844,6 +844,7 @@ getJasmineRequireObj().Spec = function(j$) { return this.result.properties[key]; } + // TODO: throw if the key or value is not structred cloneable setSpecProperty(key, value) { this.result.properties = this.result.properties || {}; this.result.properties[key] = value; @@ -867,8 +868,45 @@ getJasmineRequireObj().Spec = function(j$) { } reset() { + this.result = { + id: this.id, + description: this.description, + fullName: this.getFullName(), + parentSuiteId: this.parentSuiteId, + filename: this.filename, + failedExpectations: [], + passedExpectations: [], + deprecationWarnings: [], + pendingReason: this.excludeMessage || '', + duration: null, + properties: null, + debugLogs: null + }; + this.markedPending = this.markedExcluding; + this.reportedDone = false; + } + + startedEvent() { /** - * @typedef SpecResult + * @typedef SpecStartedEvent + * @property {String} id - The unique id of this spec. + * @property {String} description - The description passed to the {@link it} that created this spec. + * @property {String} fullName - The full description including all ancestors of this spec. + * @property {String|null} parentSuiteId - The ID of the suite containing this spec, or null if this spec is not in a describe(). + * @property {String} filename - Deprecated. The name of the file the spec was defined in. + * Note: The value may be incorrect if zone.js is installed or + * `it`/`fit`/`xit` have been replaced with versions that don't maintain the + * same call stack height as the originals. This property may be removed in + * a future version unless there is enough user interest in keeping it. + * See {@link https://github.com/jasmine/jasmine/issues/2065}. + * @since 6.0.0 + */ + return this.#commonEventFields(); + } + + doneEvent() { + /** + * @typedef SpecDoneEvent * @property {String} id - The unique id of this spec. * @property {String} description - The description passed to the {@link it} that created this spec. * @property {String} fullName - The full description including all ancestors of this spec. @@ -887,24 +925,37 @@ getJasmineRequireObj().Spec = function(j$) { * @property {number} duration - The time in ms used by the spec execution, including any before/afterEach. * @property {Object} properties - User-supplied properties, if any, that were set using {@link Env#setSpecProperty} * @property {DebugLogEntry[]|null} debugLogs - Messages, if any, that were logged using {@link jasmine.debugLog} during a failing spec. - * @since 2.0.0 + * @since 6.0.0 */ - this.result = { + const event = { + ...this.#commonEventFields() + }; + const toCopy = [ + 'failedExpectations', + 'passedExpectations', + 'deprecationWarnings', + 'pendingReason', + 'status', + 'duration', + 'properties', + 'debugLogs' + ]; + + for (const k of toCopy) { + event[k] = this.result[k]; + } + + return event; + } + + #commonEventFields() { + return { id: this.id, description: this.description, fullName: this.getFullName(), parentSuiteId: this.parentSuiteId, - filename: this.filename, - failedExpectations: [], - passedExpectations: [], - deprecationWarnings: [], - pendingReason: this.excludeMessage || '', - duration: null, - properties: null, - debugLogs: null + filename: this.filename }; - this.markedPending = this.markedExcluding; - this.reportedDone = false; } handleException(e) { @@ -1747,7 +1798,7 @@ getJasmineRequireObj().Env = function(j$) { }; /** - * Get a user-defined property as part of the properties field of {@link SpecResult} + * Get a user-defined property as part of the properties field of {@link SpecDoneEvent} * @name Env#getSpecProperty * @since 5.10.0 * @function @@ -2039,7 +2090,7 @@ getJasmineRequireObj().JsApiReporter = function(j$) { * @function * @param {Number} index - The position in the specs list to start from. * @param {Number} length - Maximum number of specs results to return. - * @return {SpecResult[]} + * @return {SpecDoneEvent[]} */ this.specResults = function(index, length) { return specs.slice(index, index + length); @@ -2050,7 +2101,7 @@ getJasmineRequireObj().JsApiReporter = function(j$) { * @name jsApiReporter#specs * @since 2.0.0 * @function - * @return {SpecResult[]} + * @return {SpecDoneEvent[]} */ this.specs = function() { return specs; @@ -8715,7 +8766,7 @@ getJasmineRequireObj().reporterEvents = function() { * `specStarted` is invoked when an `it` starts to run (including associated `beforeEach` functions) * @function * @name Reporter#specStarted - * @param {SpecResult} result Information about the individual {@link it} being run + * @param {SpecStartedEvent} result Information about the individual {@link it} being run * @param {Function} [done] Used to specify to Jasmine that this callback is asynchronous and Jasmine should wait until it has been called before moving on. * @returns {} Optionally return a Promise instead of using `done` to cause Jasmine to wait for completion. * @see async @@ -8727,7 +8778,7 @@ getJasmineRequireObj().reporterEvents = function() { * While jasmine doesn't require any specific functions, not defining a `specDone` will make it impossible for a reporter to know when a spec has failed. * @function * @name Reporter#specDone - * @param {SpecResult} result + * @param {SpecDoneEvent} result * @param {Function} [done] Used to specify to Jasmine that this callback is asynchronous and Jasmine should wait until it has been called before moving on. * @returns {} Optionally return a Promise instead of using `done` to cause Jasmine to wait for completion. * @see async @@ -11514,7 +11565,7 @@ getJasmineRequireObj().TreeRunner = function(j$) { const onStart = next => { this.#currentRunableTracker.setCurrentSpec(spec); this.#runableResources.initForRunable(spec.id, spec.parentSuiteId); - this.#reportDispatcher.specStarted(spec.result).then(next); + this.#reportDispatcher.specStarted(spec.startedEvent()).then(next); }; const resultCallback = (result, next) => { this.#specComplete(spec).then(next); @@ -11721,7 +11772,7 @@ getJasmineRequireObj().TreeRunner = function(j$) { async #reportSpecDone(spec) { spec.reportedDone = true; - await this.#reportDispatcher.specDone(spec.result); + await this.#reportDispatcher.specDone(spec.doneEvent()); } async #reportChildrenOfBeforeAllFailure(suite) { @@ -11737,7 +11788,7 @@ getJasmineRequireObj().TreeRunner = function(j$) { await this.#reportDispatcher.suiteDone(child.result); } else { /* a spec */ - await this.#reportDispatcher.specStarted(child.result); + await this.#reportDispatcher.specStarted(child.startedEvent()); child.addExpectationResult( false, diff --git a/spec/core/SpecSpec.js b/spec/core/SpecSpec.js index 88f55543..5d727729 100644 --- a/spec/core/SpecSpec.js +++ b/spec/core/SpecSpec.js @@ -412,4 +412,246 @@ describe('Spec', function() { }); }); }); + + describe('#startedEvent', function() { + it('includes only properties that are known before execution', function() { + const spec = new jasmineUnderTest.Spec({ + id: 'spec1', + parentSuiteId: 'suite1', + description: 'a spec', + filename: 'somefile.js', + getPath() { + return ['a suite', 'a spec']; + }, + queueableFn: { fn: () => {} } + }); + + expect(spec.startedEvent()).toEqual({ + id: 'spec1', + parentSuiteId: 'suite1', + description: 'a spec', + fullName: 'a suite a spec', + filename: 'somefile.js' + }); + }); + }); + + describe('#doneEvent', function() { + it('returns the event for a passed spec', function() { + const timer = { + start() {}, + elapsed() { + return 123; + } + }; + const spec = new jasmineUnderTest.Spec({ + id: 'spec1', + parentSuiteId: 'suite1', + description: 'a spec', + filename: 'somefile.js', + getPath() { + return ['a suite', 'a spec']; + }, + queueableFn: { fn: () => {} }, + timer: timer + }); + + spec.addExpectationResult(true, { + matcherName: 'a passing expectation', + passed: true + }); + spec.executionFinished(false, false); + + expect(spec.doneEvent()).toEqual({ + id: 'spec1', + parentSuiteId: 'suite1', + description: 'a spec', + fullName: 'a suite a spec', + filename: 'somefile.js', + status: 'passed', + passedExpectations: [ + { + matcherName: 'a passing expectation', + passed: true, + message: 'Passed.', + stack: '', + globalErrorType: undefined + } + ], + failedExpectations: [], + deprecationWarnings: [], + debugLogs: null, // TODO change to [] + properties: null, // TODO change to {} + pendingReason: '', + duration: 123 + }); + }); + + it('returns the event for a failed spec', function() { + const timer = { + start() {}, + elapsed() { + return 123; + } + }; + const spec = new jasmineUnderTest.Spec({ + id: 'spec1', + parentSuiteId: 'suite1', + description: 'a spec', + filename: 'somefile.js', + getPath() { + return ['a suite', 'a spec']; + }, + queueableFn: { fn: () => {} }, + timer: timer + }); + + spec.addExpectationResult(true, { + matcherName: 'a passing expectation', + passed: true + }); + spec.addExpectationResult(false, { + matcherName: 'a failing expectation', + passed: false, + error: new Error('failed') + }); + spec.executionFinished(false, false); + + expect(spec.doneEvent()).toEqual({ + id: 'spec1', + parentSuiteId: 'suite1', + description: 'a spec', + fullName: 'a suite a spec', + filename: 'somefile.js', + status: 'failed', + passedExpectations: [ + { + matcherName: 'a passing expectation', + passed: true, + message: 'Passed.', + stack: '', + globalErrorType: undefined + } + ], + failedExpectations: [ + { + matcherName: 'a failing expectation', + passed: false, + message: jasmine.stringMatching(/^Error: failed/), + stack: jasmine.stringContaining('SpecSpec.js'), + globalErrorType: undefined + } + ], + deprecationWarnings: [], + debugLogs: null, // TODO change to [] + properties: null, // TODO change to {} + pendingReason: '', + duration: 123 + }); + }); + + it("reports a status of 'pending' for a declaratively pended spec", function() { + const spec = new jasmineUnderTest.Spec({ + queueableFn: {} + }); + + spec.executionFinished(false, false); + + const result = spec.doneEvent(); + expect(result.status).toEqual('pending'); + expect(result.pendingReason).toEqual(''); + }); + + it("reports a status of 'pending' for a spec pended by #pend", function() { + const spec = new jasmineUnderTest.Spec({ + queueableFn: { fn: () => {} } + }); + + spec.pend('nope'); + spec.executionFinished(false, false); + + const result = spec.doneEvent(); + expect(result.status).toEqual('pending'); + expect(result.pendingReason).toEqual('nope'); + }); + + it("reports a status of 'excluded' for an excluded spec", function() { + const spec = new jasmineUnderTest.Spec({ + queueableFn: { fn: () => {} } + }); + + spec.executionFinished(true, false); + + expect(spec.doneEvent().status).toEqual('excluded'); + }); + + describe('When failSpecWithNoExpectations is true', function() { + it("reports a status of 'failed' for a spec with no expectations", function() { + const spec = new jasmineUnderTest.Spec({ + queueableFn: { fn: () => {} } + }); + + spec.executionFinished(false, true); + + expect(spec.doneEvent().status).toEqual('failed'); + }); + }); + + it('includes deprecation warnings', function() { + const spec = new jasmineUnderTest.Spec({ + queueableFn: { fn: () => {} } + }); + + spec.addDeprecationWarning('stop that'); + + expect(spec.doneEvent().deprecationWarnings).toEqual([ + { + // TODO: remove irrelevant properties + message: 'stop that', + stack: jasmine.stringContaining('SpecSpec.js'), + matcherName: undefined, + passed: undefined, + globalErrorType: undefined + } + ]); + }); + + it('includes debug logs', function() { + const timer = { + start() {}, + elapsed() { + return 123; + } + }; + const spec = new jasmineUnderTest.Spec({ + timer, + queueableFn: { fn: () => {} } + }); + + spec.debugLog('maybe this will help'); + + expect(spec.doneEvent().debugLogs).toEqual([ + { + message: 'maybe this will help', + timestamp: 123 + } + ]); + }); + + it('includes spec properties', function() { + const spec = new jasmineUnderTest.Spec({ + queueableFn: { fn: () => {} } + }); + + spec.setSpecProperty('foo', 'bar'); + spec.setSpecProperty('baz', { grault: ['wombat'] }); + + expect(spec.doneEvent().properties).toEqual({ + foo: 'bar', + baz: { grault: ['wombat'] } + }); + }); + + // it("excludes properties that aren't in the public API"); + }); }); diff --git a/spec/core/TreeRunnerSpec.js b/spec/core/TreeRunnerSpec.js index 93eab8c0..ee53c123 100644 --- a/spec/core/TreeRunnerSpec.js +++ b/spec/core/TreeRunnerSpec.js @@ -28,7 +28,9 @@ describe('TreeRunner', function() { spec.id, spec.parentSuiteId ); - expect(reportDispatcher.specStarted).toHaveBeenCalledWith(spec.result); + expect(reportDispatcher.specStarted).toHaveBeenCalledWith( + spec.startedEvent() + ); await Promise.resolve(); expect(reportDispatcher.specStarted).toHaveBeenCalledBefore(next); await expectAsync(executePromise).toBePending(); @@ -61,7 +63,7 @@ describe('TreeRunner', function() { expect(currentRunableTracker.currentSpec()).toBeFalsy(); expect(runableResources.clearForRunable).toHaveBeenCalledWith(spec.id); - expect(reportDispatcher.specDone).toHaveBeenCalledWith(spec.result); + expect(reportDispatcher.specDone).toHaveBeenCalledWith(spec.doneEvent()); expect(spec.result.duration).toEqual('the elapsed time'); expect(spec.reportedDone).toEqual(true); await Promise.resolve(); diff --git a/spec/core/integration/EnvSpec.js b/spec/core/integration/EnvSpec.js index a62731a3..688ab1c0 100644 --- a/spec/core/integration/EnvSpec.js +++ b/spec/core/integration/EnvSpec.js @@ -1636,15 +1636,18 @@ describe('Env integration', function() { expect(reporter.specDone.calls.count()).toBe(6); const baseSpecEvent = { + id: jasmine.any(String), + filename: jasmine.any(String) + }; + const baseSpecDoneEvent = { + ...baseSpecEvent, passedExpectations: [], failedExpectations: [], deprecationWarnings: [], pendingReason: '', duration: null, properties: null, - debugLogs: null, - id: jasmine.any(String), - filename: jasmine.any(String) + debugLogs: null }; expect(reporter.specStarted.calls.argsFor(0)[0]).toEqual({ @@ -1654,7 +1657,7 @@ describe('Env integration', function() { parentSuiteId: null }); expect(reporter.specDone.calls.argsFor(0)[0]).toEqual({ - ...baseSpecEvent, + ...baseSpecDoneEvent, description: 'a top level spec', fullName: 'a top level spec', status: 'passed', @@ -1668,7 +1671,7 @@ describe('Env integration', function() { parentSuiteId: suiteFullNameToId['A Suite'] }); expect(reporter.specDone.calls.argsFor(1)[0]).toEqual({ - ...baseSpecEvent, + ...baseSpecDoneEvent, description: 'with a spec', fullName: 'A Suite with a spec', status: 'passed', @@ -1689,11 +1692,10 @@ describe('Env integration', function() { ...baseSpecEvent, description: "with an x'ed spec", fullName: "A Suite with a nested suite with an x'ed spec", - parentSuiteId: suiteFullNameToId['A Suite with a nested suite'], - pendingReason: 'Temporarily disabled with xit' + parentSuiteId: suiteFullNameToId['A Suite with a nested suite'] }); expect(reporter.specDone.calls.argsFor(2)[0]).toEqual({ - ...baseSpecEvent, + ...baseSpecDoneEvent, description: "with an x'ed spec", fullName: "A Suite with a nested suite with an x'ed spec", status: 'pending', @@ -1709,7 +1711,7 @@ describe('Env integration', function() { parentSuiteId: suiteFullNameToId['A Suite with a nested suite'] }); expect(reporter.specDone.calls.argsFor(3)[0]).toEqual({ - ...baseSpecEvent, + ...baseSpecDoneEvent, description: 'with a spec', fullName: 'A Suite with a nested suite with a spec', status: 'failed', @@ -1730,7 +1732,7 @@ describe('Env integration', function() { parentSuiteId: suiteFullNameToId['A Suite with only non-executable specs'] }); expect(reporter.specDone.calls.argsFor(4)[0]).toEqual({ - ...baseSpecEvent, + ...baseSpecDoneEvent, description: 'is pending', status: 'pending', fullName: 'A Suite with only non-executable specs is pending', @@ -1743,12 +1745,10 @@ describe('Env integration', function() { ...baseSpecEvent, description: 'is xed', fullName: 'A Suite with only non-executable specs is xed', - parentSuiteId: - suiteFullNameToId['A Suite with only non-executable specs'], - pendingReason: 'Temporarily disabled with xit' + parentSuiteId: suiteFullNameToId['A Suite with only non-executable specs'] }); expect(reporter.specDone.calls.argsFor(5)[0]).toEqual({ - ...baseSpecEvent, + ...baseSpecDoneEvent, description: 'is xed', status: 'pending', fullName: 'A Suite with only non-executable specs is xed', diff --git a/src/core/Env.js b/src/core/Env.js index e0ed30f3..7cbc61fd 100644 --- a/src/core/Env.js +++ b/src/core/Env.js @@ -621,7 +621,7 @@ getJasmineRequireObj().Env = function(j$) { }; /** - * Get a user-defined property as part of the properties field of {@link SpecResult} + * Get a user-defined property as part of the properties field of {@link SpecDoneEvent} * @name Env#getSpecProperty * @since 5.10.0 * @function diff --git a/src/core/JsApiReporter.js b/src/core/JsApiReporter.js index 8ee3ecc5..6ab524af 100644 --- a/src/core/JsApiReporter.js +++ b/src/core/JsApiReporter.js @@ -96,7 +96,7 @@ getJasmineRequireObj().JsApiReporter = function(j$) { * @function * @param {Number} index - The position in the specs list to start from. * @param {Number} length - Maximum number of specs results to return. - * @return {SpecResult[]} + * @return {SpecDoneEvent[]} */ this.specResults = function(index, length) { return specs.slice(index, index + length); @@ -107,7 +107,7 @@ getJasmineRequireObj().JsApiReporter = function(j$) { * @name jsApiReporter#specs * @since 2.0.0 * @function - * @return {SpecResult[]} + * @return {SpecDoneEvent[]} */ this.specs = function() { return specs; diff --git a/src/core/Spec.js b/src/core/Spec.js index defa642c..05383d93 100644 --- a/src/core/Spec.js +++ b/src/core/Spec.js @@ -70,6 +70,7 @@ getJasmineRequireObj().Spec = function(j$) { return this.result.properties[key]; } + // TODO: throw if the key or value is not structred cloneable setSpecProperty(key, value) { this.result.properties = this.result.properties || {}; this.result.properties[key] = value; @@ -93,8 +94,45 @@ getJasmineRequireObj().Spec = function(j$) { } reset() { + this.result = { + id: this.id, + description: this.description, + fullName: this.getFullName(), + parentSuiteId: this.parentSuiteId, + filename: this.filename, + failedExpectations: [], + passedExpectations: [], + deprecationWarnings: [], + pendingReason: this.excludeMessage || '', + duration: null, + properties: null, + debugLogs: null + }; + this.markedPending = this.markedExcluding; + this.reportedDone = false; + } + + startedEvent() { /** - * @typedef SpecResult + * @typedef SpecStartedEvent + * @property {String} id - The unique id of this spec. + * @property {String} description - The description passed to the {@link it} that created this spec. + * @property {String} fullName - The full description including all ancestors of this spec. + * @property {String|null} parentSuiteId - The ID of the suite containing this spec, or null if this spec is not in a describe(). + * @property {String} filename - Deprecated. The name of the file the spec was defined in. + * Note: The value may be incorrect if zone.js is installed or + * `it`/`fit`/`xit` have been replaced with versions that don't maintain the + * same call stack height as the originals. This property may be removed in + * a future version unless there is enough user interest in keeping it. + * See {@link https://github.com/jasmine/jasmine/issues/2065}. + * @since 6.0.0 + */ + return this.#commonEventFields(); + } + + doneEvent() { + /** + * @typedef SpecDoneEvent * @property {String} id - The unique id of this spec. * @property {String} description - The description passed to the {@link it} that created this spec. * @property {String} fullName - The full description including all ancestors of this spec. @@ -113,24 +151,37 @@ getJasmineRequireObj().Spec = function(j$) { * @property {number} duration - The time in ms used by the spec execution, including any before/afterEach. * @property {Object} properties - User-supplied properties, if any, that were set using {@link Env#setSpecProperty} * @property {DebugLogEntry[]|null} debugLogs - Messages, if any, that were logged using {@link jasmine.debugLog} during a failing spec. - * @since 2.0.0 + * @since 6.0.0 */ - this.result = { + const event = { + ...this.#commonEventFields() + }; + const toCopy = [ + 'failedExpectations', + 'passedExpectations', + 'deprecationWarnings', + 'pendingReason', + 'status', + 'duration', + 'properties', + 'debugLogs' + ]; + + for (const k of toCopy) { + event[k] = this.result[k]; + } + + return event; + } + + #commonEventFields() { + return { id: this.id, description: this.description, fullName: this.getFullName(), parentSuiteId: this.parentSuiteId, - filename: this.filename, - failedExpectations: [], - passedExpectations: [], - deprecationWarnings: [], - pendingReason: this.excludeMessage || '', - duration: null, - properties: null, - debugLogs: null + filename: this.filename }; - this.markedPending = this.markedExcluding; - this.reportedDone = false; } handleException(e) { diff --git a/src/core/TreeRunner.js b/src/core/TreeRunner.js index 8b7c5703..1412a1c6 100644 --- a/src/core/TreeRunner.js +++ b/src/core/TreeRunner.js @@ -48,7 +48,7 @@ getJasmineRequireObj().TreeRunner = function(j$) { const onStart = next => { this.#currentRunableTracker.setCurrentSpec(spec); this.#runableResources.initForRunable(spec.id, spec.parentSuiteId); - this.#reportDispatcher.specStarted(spec.result).then(next); + this.#reportDispatcher.specStarted(spec.startedEvent()).then(next); }; const resultCallback = (result, next) => { this.#specComplete(spec).then(next); @@ -255,7 +255,7 @@ getJasmineRequireObj().TreeRunner = function(j$) { async #reportSpecDone(spec) { spec.reportedDone = true; - await this.#reportDispatcher.specDone(spec.result); + await this.#reportDispatcher.specDone(spec.doneEvent()); } async #reportChildrenOfBeforeAllFailure(suite) { @@ -271,7 +271,7 @@ getJasmineRequireObj().TreeRunner = function(j$) { await this.#reportDispatcher.suiteDone(child.result); } else { /* a spec */ - await this.#reportDispatcher.specStarted(child.result); + await this.#reportDispatcher.specStarted(child.startedEvent()); child.addExpectationResult( false, diff --git a/src/core/base.js b/src/core/base.js index 95ea4bba..2b32ffb2 100644 --- a/src/core/base.js +++ b/src/core/base.js @@ -421,7 +421,7 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) { /** * Logs a message for use in debugging. If the spec fails, trace messages - * will be included in the {@link SpecResult|result} passed to the + * will be included in the {@link SpecDoneEvent|result} passed to the * reporter's specDone method. * * This method should be called only when a spec (including any associated diff --git a/src/core/reporterEvents.js b/src/core/reporterEvents.js index 88efb9b3..e073494a 100644 --- a/src/core/reporterEvents.js +++ b/src/core/reporterEvents.js @@ -72,7 +72,7 @@ getJasmineRequireObj().reporterEvents = function() { * `specStarted` is invoked when an `it` starts to run (including associated `beforeEach` functions) * @function * @name Reporter#specStarted - * @param {SpecResult} result Information about the individual {@link it} being run + * @param {SpecStartedEvent} result Information about the individual {@link it} being run * @param {Function} [done] Used to specify to Jasmine that this callback is asynchronous and Jasmine should wait until it has been called before moving on. * @returns {} Optionally return a Promise instead of using `done` to cause Jasmine to wait for completion. * @see async @@ -84,7 +84,7 @@ getJasmineRequireObj().reporterEvents = function() { * While jasmine doesn't require any specific functions, not defining a `specDone` will make it impossible for a reporter to know when a spec has failed. * @function * @name Reporter#specDone - * @param {SpecResult} result + * @param {SpecDoneEvent} result * @param {Function} [done] Used to specify to Jasmine that this callback is asynchronous and Jasmine should wait until it has been called before moving on. * @returns {} Optionally return a Promise instead of using `done` to cause Jasmine to wait for completion. * @see async From 7214ccd3dc6969fe6895765f34a0031228cd199c Mon Sep 17 00:00:00 2001 From: Steve Gravrock Date: Sun, 21 Sep 2025 15:08:53 -0700 Subject: [PATCH 26/95] Validate that setSuiteProperty and setSpecProperty args are cloneable --- lib/jasmine-core/jasmine.js | 19 ++++++++++++++++++- spec/core/SpecSpec.js | 20 ++++++++++++++++++++ spec/core/SuiteSpec.js | 18 ++++++++++++++++++ src/core/Spec.js | 6 +++++- src/core/Suite.js | 5 +++++ src/core/util.js | 8 ++++++++ 6 files changed, 74 insertions(+), 2 deletions(-) diff --git a/lib/jasmine-core/jasmine.js b/lib/jasmine-core/jasmine.js index e55f611f..3c046ce9 100644 --- a/lib/jasmine-core/jasmine.js +++ b/lib/jasmine-core/jasmine.js @@ -769,6 +769,14 @@ getJasmineRequireObj().util = function(j$) { } }; + util.assertStructuredCloneable = function(v, msgPrefix) { + try { + structuredClone(v); + } catch (e) { + throw new Error(`${msgPrefix} can't be cloned`, { cause: e }); + } + }; + return util; }; @@ -844,8 +852,12 @@ getJasmineRequireObj().Spec = function(j$) { return this.result.properties[key]; } - // TODO: throw if the key or value is not structred cloneable setSpecProperty(key, value) { + // 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. + j$.util.assertStructuredCloneable(key, 'Key'); + j$.util.assertStructuredCloneable(value, 'Value'); this.result.properties = this.result.properties || {}; this.result.properties[key] = value; } @@ -10604,6 +10616,11 @@ getJasmineRequireObj().Suite = function(j$) { } setSuiteProperty(key, value) { + // 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. + j$.util.assertStructuredCloneable(key, 'Key'); + j$.util.assertStructuredCloneable(value, 'Value'); this.result.properties = this.result.properties || {}; this.result.properties[key] = value; } diff --git a/spec/core/SpecSpec.js b/spec/core/SpecSpec.js index 5d727729..18769efa 100644 --- a/spec/core/SpecSpec.js +++ b/spec/core/SpecSpec.js @@ -102,6 +102,26 @@ describe('Spec', function() { b: 'original-value' }); }); + + it('throws if the key is not structured-cloneable', function() { + const spec = new jasmineUnderTest.Spec({ + queueableFn: { fn: () => {} } + }); + + expect(function() { + spec.setSpecProperty(new Promise(() => {}), ''); + }).toThrowError("Key can't be cloned"); + }); + + it('throws if the value is not structured-cloneable', function() { + const spec = new jasmineUnderTest.Spec({ + queueableFn: { fn: () => {} } + }); + + expect(function() { + spec.setSpecProperty('k', new Promise(() => {})); + }).toThrowError("Value can't be cloned"); + }); }); describe('status', function() { diff --git a/spec/core/SuiteSpec.js b/spec/core/SuiteSpec.js index af2e4d64..e3961193 100644 --- a/spec/core/SuiteSpec.js +++ b/spec/core/SuiteSpec.js @@ -405,4 +405,22 @@ describe('Suite', function() { expect(subject.hasChildWithDescription('a spec')).toBeFalse(); }); }); + + describe('#setSuiteProperty', function() { + it('throws if the key is not structured-cloneable', function() { + const suite = new jasmineUnderTest.Suite({}); + + expect(function() { + suite.setSuiteProperty(new Promise(() => {}), ''); + }).toThrowError("Key can't be cloned"); + }); + + it('throws if the value is not structured-cloneable', function() { + const suite = new jasmineUnderTest.Suite({}); + + expect(function() { + suite.setSuiteProperty('k', new Promise(() => {})); + }).toThrowError("Value can't be cloned"); + }); + }); }); diff --git a/src/core/Spec.js b/src/core/Spec.js index 05383d93..56d572bf 100644 --- a/src/core/Spec.js +++ b/src/core/Spec.js @@ -70,8 +70,12 @@ getJasmineRequireObj().Spec = function(j$) { return this.result.properties[key]; } - // TODO: throw if the key or value is not structred cloneable setSpecProperty(key, value) { + // 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. + j$.util.assertStructuredCloneable(key, 'Key'); + j$.util.assertStructuredCloneable(value, 'Value'); this.result.properties = this.result.properties || {}; this.result.properties[key] = value; } diff --git a/src/core/Suite.js b/src/core/Suite.js index 58e226f4..4a75565f 100644 --- a/src/core/Suite.js +++ b/src/core/Suite.js @@ -31,6 +31,11 @@ getJasmineRequireObj().Suite = function(j$) { } setSuiteProperty(key, value) { + // 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. + j$.util.assertStructuredCloneable(key, 'Key'); + j$.util.assertStructuredCloneable(value, 'Value'); this.result.properties = this.result.properties || {}; this.result.properties[key] = value; } diff --git a/src/core/util.js b/src/core/util.js index e40d6a0e..f824df1d 100644 --- a/src/core/util.js +++ b/src/core/util.js @@ -80,5 +80,13 @@ getJasmineRequireObj().util = function(j$) { } }; + util.assertStructuredCloneable = function(v, msgPrefix) { + try { + structuredClone(v); + } catch (e) { + throw new Error(`${msgPrefix} can't be cloned`, { cause: e }); + } + }; + return util; }; From 8863643d5532a981060ca9bf64561edfd4b03bfb Mon Sep 17 00:00:00 2001 From: Steve Gravrock Date: Thu, 25 Sep 2025 20:40:31 -0700 Subject: [PATCH 27/95] Fixed broken SpyRegistry spec --- spec/core/SpyRegistrySpec.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/spec/core/SpyRegistrySpec.js b/spec/core/SpyRegistrySpec.js index 391a3d63..dabab075 100644 --- a/spec/core/SpyRegistrySpec.js +++ b/spec/core/SpyRegistrySpec.js @@ -119,15 +119,15 @@ describe('SpyRegistry', function() { }); it('overrides the method on the object and returns the spy', function() { - const originalFunctionWasCalled = false, - spyRegistry = new jasmineUnderTest.SpyRegistry({ - createSpy: createSpy - }), - subject = { - spiedFunc: function() { - originalFunctionWasCalled = true; - } - }; + let originalFunctionWasCalled = false; + const spyRegistry = new jasmineUnderTest.SpyRegistry({ + createSpy: createSpy + }); + const subject = { + spiedFunc: function() { + originalFunctionWasCalled = true; + } + }; const spy = spyRegistry.spyOn(subject, 'spiedFunc'); From 979e4a5d0f33664fbbb3206a3573cd791d234c83 Mon Sep 17 00:00:00 2001 From: Steve Gravrock Date: Thu, 25 Sep 2025 20:41:19 -0700 Subject: [PATCH 28/95] Fixed naming in SpyRegistry specs --- spec/core/SpyRegistrySpec.js | 262 +++++++++++++++++------------------ 1 file changed, 131 insertions(+), 131 deletions(-) diff --git a/spec/core/SpyRegistrySpec.js b/spec/core/SpyRegistrySpec.js index dabab075..5e72f90e 100644 --- a/spec/core/SpyRegistrySpec.js +++ b/spec/core/SpyRegistrySpec.js @@ -15,10 +15,10 @@ describe('SpyRegistry', function() { it('checks that a method name was passed', function() { const spyRegistry = new jasmineUnderTest.SpyRegistry(), - subject = {}; + target = {}; expect(function() { - spyRegistry.spyOn(subject); + spyRegistry.spyOn(target); }).toThrowError(/No method name supplied/); }); @@ -31,19 +31,19 @@ describe('SpyRegistry', function() { it('checks that the method name is not `null`', function() { const spyRegistry = new jasmineUnderTest.SpyRegistry(), - subject = {}; + target = {}; expect(function() { - spyRegistry.spyOn(subject, null); + spyRegistry.spyOn(target, null); }).toThrowError(/No method name supplied/); }); it('checks for the existence of the method', function() { const spyRegistry = new jasmineUnderTest.SpyRegistry(), - subject = {}; + target = {}; expect(function() { - spyRegistry.spyOn(subject, 'pants'); + spyRegistry.spyOn(target, 'pants'); }).toThrowError(/method does not exist/); }); @@ -55,12 +55,12 @@ describe('SpyRegistry', function() { }, createSpy: createSpy }), - subject = { spiedFunc: function() {} }; + target = { spiedFunc: function() {} }; - spyRegistry.spyOn(subject, 'spiedFunc'); + spyRegistry.spyOn(target, 'spiedFunc'); expect(function() { - spyRegistry.spyOn(subject, 'spiedFunc'); + spyRegistry.spyOn(target, 'spiedFunc'); }).toThrowError(/has already been spied upon/); }); @@ -83,14 +83,14 @@ describe('SpyRegistry', function() { return spies; } }), - subject = { spiedFunc: scope.myFunc }; + target = { spiedFunc: scope.myFunc }; expect(function() { spyRegistry.spyOn(scope, 'myFunc'); }).toThrowError(/is not declared writable or has no setter/); expect(function() { - spyRegistry.spyOn(subject, 'spiedFunc'); + spyRegistry.spyOn(target, 'spiedFunc'); }).not.toThrowError(/is not declared writable or has no setter/); }); @@ -123,16 +123,16 @@ describe('SpyRegistry', function() { const spyRegistry = new jasmineUnderTest.SpyRegistry({ createSpy: createSpy }); - const subject = { + const target = { spiedFunc: function() { originalFunctionWasCalled = true; } }; - const spy = spyRegistry.spyOn(subject, 'spiedFunc'); + const spy = spyRegistry.spyOn(target, 'spiedFunc'); - expect(subject.spiedFunc).toEqual(spy); - subject.spiedFunc(); + expect(target.spiedFunc).toEqual(spy); + target.spiedFunc(); expect(originalFunctionWasCalled).toBe(false); }); }); @@ -147,27 +147,27 @@ describe('SpyRegistry', function() { it('checks that a property name was passed', function() { const spyRegistry = new jasmineUnderTest.SpyRegistry(), - subject = {}; + target = {}; expect(function() { - spyRegistry.spyOnProperty(subject); + spyRegistry.spyOnProperty(target); }).toThrowError(/No property name supplied/); }); it('checks for the existence of the method', function() { const spyRegistry = new jasmineUnderTest.SpyRegistry(), - subject = {}; + target = {}; expect(function() { - spyRegistry.spyOnProperty(subject, 'pants'); + spyRegistry.spyOnProperty(target, 'pants'); }).toThrowError(/property does not exist/); }); it('checks for the existence of access type', function() { const spyRegistry = new jasmineUnderTest.SpyRegistry(), - subject = {}; + target = {}; - Object.defineProperty(subject, 'pants', { + Object.defineProperty(target, 'pants', { get: function() { return 1; }, @@ -175,18 +175,18 @@ describe('SpyRegistry', function() { }); expect(function() { - spyRegistry.spyOnProperty(subject, 'pants', 'set'); + spyRegistry.spyOnProperty(target, 'pants', 'set'); }).toThrowError(/does not have access type/); }); it('checks if it can be spied upon', function() { - const subject = {}; + const target = {}; - Object.defineProperty(subject, 'myProp', { + Object.defineProperty(target, 'myProp', { get: function() {} }); - Object.defineProperty(subject, 'spiedProp', { + Object.defineProperty(target, 'spiedProp', { get: function() {}, configurable: true }); @@ -194,11 +194,11 @@ describe('SpyRegistry', function() { const spyRegistry = new jasmineUnderTest.SpyRegistry(); expect(function() { - spyRegistry.spyOnProperty(subject, 'myProp'); + spyRegistry.spyOnProperty(target, 'myProp'); }).toThrowError(/is not declared configurable/); expect(function() { - spyRegistry.spyOnProperty(subject, 'spiedProp'); + spyRegistry.spyOnProperty(target, 'spiedProp'); }).not.toThrowError(/is not declared configurable/); }); @@ -206,34 +206,34 @@ describe('SpyRegistry', function() { const spyRegistry = new jasmineUnderTest.SpyRegistry({ createSpy: createSpy }), - subject = {}, + target = {}, returnValue = 1; - Object.defineProperty(subject, 'spiedProperty', { + Object.defineProperty(target, 'spiedProperty', { get: function() { return returnValue; }, configurable: true }); - expect(subject.spiedProperty).toEqual(returnValue); + expect(target.spiedProperty).toEqual(returnValue); - const spy = spyRegistry.spyOnProperty(subject, 'spiedProperty'); - const getter = Object.getOwnPropertyDescriptor(subject, 'spiedProperty') + const spy = spyRegistry.spyOnProperty(target, 'spiedProperty'); + const getter = Object.getOwnPropertyDescriptor(target, 'spiedProperty') .get; expect(getter).toEqual(spy); - expect(subject.spiedProperty).toBeUndefined(); + expect(target.spiedProperty).toBeUndefined(); }); it('overrides the property setter on the object and returns the spy', function() { const spyRegistry = new jasmineUnderTest.SpyRegistry({ createSpy: createSpy }), - subject = {}, + target = {}, returnValue = 1; - Object.defineProperty(subject, 'spiedProperty', { + Object.defineProperty(target, 'spiedProperty', { get: function() { return returnValue; }, @@ -241,11 +241,11 @@ describe('SpyRegistry', function() { configurable: true }); - const spy = spyRegistry.spyOnProperty(subject, 'spiedProperty', 'set'); - const setter = Object.getOwnPropertyDescriptor(subject, 'spiedProperty') + const spy = spyRegistry.spyOnProperty(target, 'spiedProperty', 'set'); + const setter = Object.getOwnPropertyDescriptor(target, 'spiedProperty') .set; - expect(subject.spiedProperty).toEqual(returnValue); + expect(target.spiedProperty).toEqual(returnValue); expect(setter).toEqual(spy); }); @@ -254,19 +254,19 @@ describe('SpyRegistry', function() { const spyRegistry = new jasmineUnderTest.SpyRegistry({ createSpy: createSpy }), - subject = {}; + target = {}; - Object.defineProperty(subject, 'spiedProp', { + Object.defineProperty(target, 'spiedProp', { get: function() { return 1; }, configurable: true }); - spyRegistry.spyOnProperty(subject, 'spiedProp'); + spyRegistry.spyOnProperty(target, 'spiedProp'); expect(function() { - spyRegistry.spyOnProperty(subject, 'spiedProp'); + spyRegistry.spyOnProperty(target, 'spiedProp'); }).toThrowError(/spiedProp#get has already been spied upon/); }); @@ -274,20 +274,20 @@ describe('SpyRegistry', function() { const spyRegistry = new jasmineUnderTest.SpyRegistry({ createSpy: createSpy }), - subject = {}; + target = {}; spyRegistry.allowRespy(true); - Object.defineProperty(subject, 'spiedProp', { + Object.defineProperty(target, 'spiedProp', { get: function() { return 1; }, configurable: true }); - const originalSpy = spyRegistry.spyOnProperty(subject, 'spiedProp'); + const originalSpy = spyRegistry.spyOnProperty(target, 'spiedProp'); - expect(spyRegistry.spyOnProperty(subject, 'spiedProp')).toBe( + expect(spyRegistry.spyOnProperty(target, 'spiedProp')).toBe( originalSpy ); }); @@ -322,21 +322,21 @@ describe('SpyRegistry', function() { const parent = { parentSpied1: noop1 }; - const subject = Object.create(parent); - Object.defineProperty(subject, 'spied1', { + const target = Object.create(parent); + Object.defineProperty(target, 'spied1', { value: noop1, writable: true, configurable: true, enumerable: true }); - Object.defineProperty(subject, 'spied2', { + Object.defineProperty(target, 'spied2', { value: noop2, writable: true, configurable: true, enumerable: true }); let _spied3 = noop3; - Object.defineProperty(subject, 'spied3', { + Object.defineProperty(target, 'spied3', { configurable: true, set: function(val) { _spied3 = val; @@ -346,20 +346,20 @@ describe('SpyRegistry', function() { }, enumerable: true }); - subject.spied4 = noop4; - Object.defineProperty(subject, 'notSpied2', { + target.spied4 = noop4; + Object.defineProperty(target, 'notSpied2', { value: noop2, writable: false, configurable: true, enumerable: true }); - Object.defineProperty(subject, 'notSpied3', { + Object.defineProperty(target, 'notSpied3', { value: noop3, writable: true, configurable: false, enumerable: true }); - Object.defineProperty(subject, 'notSpied4', { + Object.defineProperty(target, 'notSpied4', { configurable: false, set: function() { /**/ @@ -369,27 +369,27 @@ describe('SpyRegistry', function() { }, enumerable: true }); - Object.defineProperty(subject, 'notSpied5', { + Object.defineProperty(target, 'notSpied5', { value: noop5, writable: true, configurable: true, enumerable: false }); - subject.notSpied6 = 6; + target.notSpied6 = 6; - const spiedObject = spyRegistry.spyOnAllFunctions(subject); + const spiedObject = spyRegistry.spyOnAllFunctions(target); - expect(subject.parentSpied1).toBe('I am a spy'); - expect(subject.notSpied2).toBe(noop2); - expect(subject.notSpied3).toBe(noop3); - expect(subject.notSpied4).toBe(noop4); - expect(subject.notSpied5).toBe(noop5); - expect(subject.notSpied6).toBe(6); - expect(subject.spied1).toBe('I am a spy'); - expect(subject.spied2).toBe('I am a spy'); - expect(subject.spied3).toBe('I am a spy'); - expect(subject.spied4).toBe('I am a spy'); - expect(spiedObject).toBe(subject); + expect(target.parentSpied1).toBe('I am a spy'); + expect(target.notSpied2).toBe(noop2); + expect(target.notSpied3).toBe(noop3); + expect(target.notSpied4).toBe(noop4); + expect(target.notSpied5).toBe(noop5); + expect(target.notSpied6).toBe(6); + expect(target.spied1).toBe('I am a spy'); + expect(target.spied2).toBe('I am a spy'); + expect(target.spied3).toBe('I am a spy'); + expect(target.spied4).toBe('I am a spy'); + expect(spiedObject).toBe(target); }); it('overrides prototype methods on the object', function() { @@ -407,11 +407,11 @@ describe('SpyRegistry', function() { }; MyClass.prototype.spied2 = noop2; - const subject = new MyClass(); - spyRegistry.spyOnAllFunctions(subject); + const target = new MyClass(); + spyRegistry.spyOnAllFunctions(target); - expect(subject.spied1).toBe('I am a spy'); - expect(subject.spied2).toBe('I am a spy'); + expect(target.spied1).toBe('I am a spy'); + expect(target.spied2).toBe('I am a spy'); expect(MyClass.prototype.spied2).toBe(noop2); }); @@ -421,15 +421,15 @@ describe('SpyRegistry', function() { return 'I am a spy'; } }); - const subject = { + const target = { spied1: function() {} }; - spyRegistry.spyOnAllFunctions(subject); + spyRegistry.spyOnAllFunctions(target); - expect(subject.spied1).toBe('I am a spy'); - expect(subject.toString).not.toBe('I am a spy'); - expect(subject.hasOwnProperty).not.toBe('I am a spy'); + expect(target.spied1).toBe('I am a spy'); + expect(target.toString).not.toBe('I am a spy'); + expect(target.hasOwnProperty).not.toBe('I am a spy'); }); describe('when includeNonEnumerable is true', function() { it('does not override Object.prototype methods', function() { @@ -438,15 +438,15 @@ describe('SpyRegistry', function() { return 'I am a spy'; } }); - const subject = { + const target = { spied1: function() {} }; - spyRegistry.spyOnAllFunctions(subject, true); + spyRegistry.spyOnAllFunctions(target, true); - expect(subject.spied1).toBe('I am a spy'); - expect(subject.toString).not.toBe('I am a spy'); - expect(subject.hasOwnProperty).not.toBe('I am a spy'); + expect(target.spied1).toBe('I am a spy'); + expect(target.toString).not.toBe('I am a spy'); + expect(target.hasOwnProperty).not.toBe('I am a spy'); }); it('overrides non-enumerable properties', function() { @@ -455,21 +455,21 @@ describe('SpyRegistry', function() { return 'I am a spy'; } }); - const subject = { + const target = { spied1: function() {}, spied2: function() {} }; - Object.defineProperty(subject, 'spied2', { + Object.defineProperty(target, 'spied2', { enumerable: false, writable: true, configurable: true }); - spyRegistry.spyOnAllFunctions(subject, true); + spyRegistry.spyOnAllFunctions(target, true); - expect(subject.spied1).toBe('I am a spy'); - expect(subject.spied2).toBe('I am a spy'); + expect(target.spied1).toBe('I am a spy'); + expect(target.spied2).toBe('I am a spy'); }); it('should not spy on non-enumerable functions named constructor', function() { @@ -478,19 +478,19 @@ describe('SpyRegistry', function() { return 'I am a spy'; } }); - const subject = { + const target = { constructor: function() {} }; - Object.defineProperty(subject, 'constructor', { + Object.defineProperty(target, 'constructor', { enumerable: false, writable: true, configurable: true }); - spyRegistry.spyOnAllFunctions(subject, true); + spyRegistry.spyOnAllFunctions(target, true); - expect(subject.constructor).not.toBe('I am a spy'); + expect(target.constructor).not.toBe('I am a spy'); }); it('should spy on enumerable functions named constructor', function() { @@ -499,13 +499,13 @@ describe('SpyRegistry', function() { return 'I am a spy'; } }); - const subject = { + const target = { constructor: function() {} }; - spyRegistry.spyOnAllFunctions(subject, true); + spyRegistry.spyOnAllFunctions(target, true); - expect(subject.constructor).toBe('I am a spy'); + expect(target.constructor).toBe('I am a spy'); }); it('should not throw an exception if we try and access strict mode restricted properties', function() { @@ -514,9 +514,9 @@ describe('SpyRegistry', function() { return 'I am a spy'; } }); - const subject = function() {}; + const target = function() {}; const fn = function() { - spyRegistry.spyOnAllFunctions(subject, true); + spyRegistry.spyOnAllFunctions(target, true); }; expect(fn).not.toThrow(); @@ -528,24 +528,24 @@ describe('SpyRegistry', function() { return 'I am a spy'; } }); - const subjectParent = Object.defineProperty({}, 'sharedProp', { + const targetParent = Object.defineProperty({}, 'sharedProp', { value: function() {}, writable: true, configurable: true }); - const subject = Object.create(subjectParent); + const target = Object.create(targetParent); - Object.defineProperty(subject, 'sharedProp', { + Object.defineProperty(target, 'sharedProp', { value: function() {} }); const fn = function() { - spyRegistry.spyOnAllFunctions(subject, true); + spyRegistry.spyOnAllFunctions(target, true); }; expect(fn).not.toThrow(); - expect(subject).not.toBe('I am a spy'); + expect(target).not.toBe('I am a spy'); }); }); }); @@ -560,12 +560,12 @@ describe('SpyRegistry', function() { createSpy: createSpy }), originalFunction = function() {}, - subject = { spiedFunc: originalFunction }; + target = { spiedFunc: originalFunction }; - spyRegistry.spyOn(subject, 'spiedFunc'); + spyRegistry.spyOn(target, 'spiedFunc'); spyRegistry.clearSpies(); - expect(subject.spiedFunc).toBe(originalFunction); + expect(target.spiedFunc).toBe(originalFunction); }); it('restores the original functions, even when that spy has been replace and re-spied upon', function() { @@ -577,19 +577,19 @@ describe('SpyRegistry', function() { createSpy: createSpy }), originalFunction = function() {}, - subject = { spiedFunc: originalFunction }; + target = { spiedFunc: originalFunction }; - spyRegistry.spyOn(subject, 'spiedFunc'); + spyRegistry.spyOn(target, 'spiedFunc'); // replace the original spy with some other function - subject.spiedFunc = function() {}; + target.spiedFunc = function() {}; // spy on the function in that location again - spyRegistry.spyOn(subject, 'spiedFunc'); + spyRegistry.spyOn(target, 'spiedFunc'); spyRegistry.clearSpies(); - expect(subject.spiedFunc).toBe(originalFunction); + expect(target.spiedFunc).toBe(originalFunction); }); it("does not add a property that the spied-upon object didn't originally have", function() { @@ -601,17 +601,17 @@ describe('SpyRegistry', function() { createSpy: createSpy }), originalFunction = function() {}, - subjectParent = { spiedFunc: originalFunction }; + targetParent = { spiedFunc: originalFunction }; - const subject = Object.create(subjectParent); + const target = Object.create(targetParent); - expect(subject.hasOwnProperty('spiedFunc')).toBe(false); + expect(target.hasOwnProperty('spiedFunc')).toBe(false); - spyRegistry.spyOn(subject, 'spiedFunc'); + spyRegistry.spyOn(target, 'spiedFunc'); spyRegistry.clearSpies(); - expect(subject.hasOwnProperty('spiedFunc')).toBe(false); - expect(subject.spiedFunc).toBe(originalFunction); + expect(target.hasOwnProperty('spiedFunc')).toBe(false); + expect(target.spiedFunc).toBe(originalFunction); }); it("restores the original function when it's inherited and cannot be deleted", function() { @@ -623,20 +623,20 @@ describe('SpyRegistry', function() { createSpy: createSpy }), originalFunction = function() {}, - subjectParent = { spiedFunc: originalFunction }; + targetParent = { spiedFunc: originalFunction }; - const subject = Object.create(subjectParent); + const target = Object.create(targetParent); - spyRegistry.spyOn(subject, 'spiedFunc'); + spyRegistry.spyOn(target, 'spiedFunc'); // simulate a spy that cannot be deleted - Object.defineProperty(subject, 'spiedFunc', { + Object.defineProperty(target, 'spiedFunc', { configurable: false }); spyRegistry.clearSpies(); - expect(jasmineUnderTest.isSpy(subject.spiedFunc)).toBe(false); + expect(jasmineUnderTest.isSpy(target.spiedFunc)).toBe(false); }); it('restores window.onerror by overwriting, not deleting', function() { @@ -670,19 +670,19 @@ describe('SpyRegistry', function() { createSpy: createSpy }), originalReturn = 1, - subject = {}; + target = {}; - Object.defineProperty(subject, 'spiedProp', { + Object.defineProperty(target, 'spiedProp', { get: function() { return originalReturn; }, configurable: true }); - spyRegistry.spyOnProperty(subject, 'spiedProp'); + spyRegistry.spyOnProperty(target, 'spiedProp'); spyRegistry.clearSpies(); - expect(subject.spiedProp).toBe(originalReturn); + expect(target.spiedProp).toBe(originalReturn); }); it("does not add a property that the spied-upon object didn't originally have", function() { @@ -694,24 +694,24 @@ describe('SpyRegistry', function() { createSpy: createSpy }), originalReturn = 1, - subjectParent = {}; + targetParent = {}; - Object.defineProperty(subjectParent, 'spiedProp', { + Object.defineProperty(targetParent, 'spiedProp', { get: function() { return originalReturn; }, configurable: true }); - const subject = Object.create(subjectParent); + const target = Object.create(targetParent); - expect(subject.hasOwnProperty('spiedProp')).toBe(false); + expect(target.hasOwnProperty('spiedProp')).toBe(false); - spyRegistry.spyOnProperty(subject, 'spiedProp'); + spyRegistry.spyOnProperty(target, 'spiedProp'); spyRegistry.clearSpies(); - expect(subject.hasOwnProperty('spiedProp')).toBe(false); - expect(subject.spiedProp).toBe(originalReturn); + expect(target.hasOwnProperty('spiedProp')).toBe(false); + expect(target.spiedProp).toBe(originalReturn); }); }); }); From 190a13ed96c80818265c77a679ae5cedd62d5126 Mon Sep 17 00:00:00 2001 From: Steve Gravrock Date: Thu, 25 Sep 2025 20:56:19 -0700 Subject: [PATCH 29/95] Prevent mock clock timing fns from being spied on Fixes #826 --- lib/jasmine-core/jasmine.js | 13 +++++++++++++ spec/core/ClockSpec.js | 35 +++++++++++++++++++++++++++++++++++ spec/core/SpyRegistrySpec.js | 12 ++++++++++++ src/core/Clock.js | 7 +++++++ src/core/SpyRegistry.js | 6 ++++++ 5 files changed, 73 insertions(+) diff --git a/lib/jasmine-core/jasmine.js b/lib/jasmine-core/jasmine.js index 3c046ce9..cc9769ce 100644 --- a/lib/jasmine-core/jasmine.js +++ b/lib/jasmine-core/jasmine.js @@ -2912,6 +2912,8 @@ getJasmineRequireObj().Clock = function() { process.versions && typeof process.versions.node === 'string'; + const IsMockClockTimingFn = Symbol('IsMockClockTimingFn'); + /** * @class Clock * @since 1.3.0 @@ -3090,6 +3092,10 @@ callbacks to execute _before_ running the next one. advanceUntilModeChanges(); }; + setTimeout[IsMockClockTimingFn] = true; + clearTimeout[IsMockClockTimingFn] = true; + setInterval[IsMockClockTimingFn] = true; + clearInterval[IsMockClockTimingFn] = true; return this; // Advances the Clock's time until the mode changes. @@ -3242,6 +3248,7 @@ callbacks to execute _before_ running the next one. return this; }; + Clock.IsMockClockTimingFn = IsMockClockTimingFn; return Clock; }; @@ -10046,6 +10053,12 @@ getJasmineRequireObj().SpyRegistry = function(j$) { throw new Error(getErrorMsg(methodName + '() method does not exist')); } + // Spying on mock clock timing fns would prevent the real ones from being + // restored. + if (obj[methodName] && obj[methodName][j$.Clock.IsMockClockTimingFn]) { + throw new Error("Mock clock timing functions can't be spied on"); + } + if (obj[methodName] && j$.isSpy(obj[methodName])) { if (this.respy) { return obj[methodName]; diff --git a/spec/core/ClockSpec.js b/spec/core/ClockSpec.js index ad47f823..2fb48d65 100644 --- a/spec/core/ClockSpec.js +++ b/spec/core/ClockSpec.js @@ -408,6 +408,41 @@ describe('Clock', function() { expect(delayedFunctionScheduler.scheduleFunction).not.toHaveBeenCalled(); }); + it('identifies its timing functions', function() { + const fakeSetTimeout = jasmine.createSpy('global setTimeout'); + const fakeGlobal = { setTimeout: fakeSetTimeout }; + const delayedFunctionScheduler = jasmine.createSpyObj( + 'delayedFunctionScheduler', + ['scheduleFunction'] + ); + const mockDate = { + install: function() {}, + tick: function() {}, + uninstall: function() {} + }; + const clock = new jasmineUnderTest.Clock( + fakeGlobal, + function() { + return delayedFunctionScheduler; + }, + mockDate + ); + clock.install(); + + expect( + fakeGlobal.setTimeout[jasmineUnderTest.Clock.IsMockClockTimingFn] + ).toEqual(true); + expect( + fakeGlobal.clearTimeout[jasmineUnderTest.Clock.IsMockClockTimingFn] + ).toEqual(true); + expect( + fakeGlobal.setInterval[jasmineUnderTest.Clock.IsMockClockTimingFn] + ).toEqual(true); + expect( + fakeGlobal.clearInterval[jasmineUnderTest.Clock.IsMockClockTimingFn] + ).toEqual(true); + }); + describe('setTimeout', function() { it('schedules the delayed function with the fake timer', function() { const fakeSetTimeout = jasmine.createSpy('setTimeout'), diff --git a/spec/core/SpyRegistrySpec.js b/spec/core/SpyRegistrySpec.js index 5e72f90e..74ba4a2d 100644 --- a/spec/core/SpyRegistrySpec.js +++ b/spec/core/SpyRegistrySpec.js @@ -135,6 +135,18 @@ describe('SpyRegistry', function() { target.spiedFunc(); expect(originalFunctionWasCalled).toBe(false); }); + + it('throws if the method is a mock clock method', function() { + const spyRegistry = new jasmineUnderTest.SpyRegistry({ + createSpy: createSpy + }); + const target = { spiedFunc: function() {} }; + target.spiedFunc[jasmineUnderTest.Clock.IsMockClockTimingFn] = true; + + expect(function() { + spyRegistry.spyOn(target, 'spiedFunc'); + }).toThrowError("Mock clock timing functions can't be spied on"); + }); }); describe('#spyOnProperty', function() { diff --git a/src/core/Clock.js b/src/core/Clock.js index c537d069..4956fcac 100644 --- a/src/core/Clock.js +++ b/src/core/Clock.js @@ -5,6 +5,8 @@ getJasmineRequireObj().Clock = function() { process.versions && typeof process.versions.node === 'string'; + const IsMockClockTimingFn = Symbol('IsMockClockTimingFn'); + /** * @class Clock * @since 1.3.0 @@ -183,6 +185,10 @@ callbacks to execute _before_ running the next one. advanceUntilModeChanges(); }; + setTimeout[IsMockClockTimingFn] = true; + clearTimeout[IsMockClockTimingFn] = true; + setInterval[IsMockClockTimingFn] = true; + clearInterval[IsMockClockTimingFn] = true; return this; // Advances the Clock's time until the mode changes. @@ -335,5 +341,6 @@ callbacks to execute _before_ running the next one. return this; }; + Clock.IsMockClockTimingFn = IsMockClockTimingFn; return Clock; }; diff --git a/src/core/SpyRegistry.js b/src/core/SpyRegistry.js index 7042388b..b4a246da 100644 --- a/src/core/SpyRegistry.js +++ b/src/core/SpyRegistry.js @@ -41,6 +41,12 @@ getJasmineRequireObj().SpyRegistry = function(j$) { throw new Error(getErrorMsg(methodName + '() method does not exist')); } + // Spying on mock clock timing fns would prevent the real ones from being + // restored. + if (obj[methodName] && obj[methodName][j$.Clock.IsMockClockTimingFn]) { + throw new Error("Mock clock timing functions can't be spied on"); + } + if (obj[methodName] && j$.isSpy(obj[methodName])) { if (this.respy) { return obj[methodName]; From fbec066837fcc48113b231e27d73bd48b211bcd5 Mon Sep 17 00:00:00 2001 From: Steve Gravrock Date: Mon, 22 Sep 2025 21:53:27 -0700 Subject: [PATCH 30/95] rm unused deprecatingSpecProxy --- lib/jasmine-core/jasmine.js | 38 -------------------------------- src/core/deprecatingSpecProxy.js | 36 ------------------------------ src/core/requireCore.js | 1 - 3 files changed, 75 deletions(-) delete mode 100644 src/core/deprecatingSpecProxy.js diff --git a/lib/jasmine-core/jasmine.js b/lib/jasmine-core/jasmine.js index cc9769ce..e952ea2e 100644 --- a/lib/jasmine-core/jasmine.js +++ b/lib/jasmine-core/jasmine.js @@ -66,7 +66,6 @@ var getJasmineRequireObj = (function(jasmineGlobal) { j$.getClearStack = jRequire.clearStack(j$); j$.Clock = jRequire.Clock(); j$.DelayedFunctionScheduler = jRequire.DelayedFunctionScheduler(j$); - j$.deprecatingSpecProxy = jRequire.deprecatingSpecProxy(j$); j$.Deprecator = jRequire.Deprecator(j$); j$.Configuration = jRequire.Configuration(j$); j$.Env = jRequire.Env(j$); @@ -3735,43 +3734,6 @@ getJasmineRequireObj().DelayedFunctionScheduler = function(j$) { return DelayedFunctionScheduler; }; -// TODO: Remove this in the next major release. -getJasmineRequireObj().deprecatingSpecProxy = function(j$) { - const allowedMembers = ['id', 'description', 'getFullName', 'getPath']; - - function isMember(target, prop) { - return ( - Object.keys(target).indexOf(prop) !== -1 || - Object.keys(j$.Spec.prototype).indexOf(prop) !== -1 - ); - } - - function msg(member) { - const memberName = member.toString().replace(/^Symbol\((.+)\)$/, '$1'); - return ( - 'Access to private Spec members (in this case `' + - memberName + - '`) via spec filters is not supported and will break in ' + - 'a future release. See ' + - 'for correct usage.' - ); - } - - function deprecatingSpecProxy(spec, deprecated) { - return new Proxy(spec, { - get(target, prop, receiver) { - if (isMember(target, prop) && !allowedMembers.includes(prop)) { - deprecated(msg(prop)); - } - - return target[prop]; - } - }); - } - - return deprecatingSpecProxy; -}; - getJasmineRequireObj().Deprecator = function(j$) { function Deprecator(topSuite) { this.topSuite_ = topSuite; diff --git a/src/core/deprecatingSpecProxy.js b/src/core/deprecatingSpecProxy.js deleted file mode 100644 index eb1b583e..00000000 --- a/src/core/deprecatingSpecProxy.js +++ /dev/null @@ -1,36 +0,0 @@ -// TODO: Remove this in the next major release. -getJasmineRequireObj().deprecatingSpecProxy = function(j$) { - const allowedMembers = ['id', 'description', 'getFullName', 'getPath']; - - function isMember(target, prop) { - return ( - Object.keys(target).indexOf(prop) !== -1 || - Object.keys(j$.Spec.prototype).indexOf(prop) !== -1 - ); - } - - function msg(member) { - const memberName = member.toString().replace(/^Symbol\((.+)\)$/, '$1'); - return ( - 'Access to private Spec members (in this case `' + - memberName + - '`) via spec filters is not supported and will break in ' + - 'a future release. See ' + - 'for correct usage.' - ); - } - - function deprecatingSpecProxy(spec, deprecated) { - return new Proxy(spec, { - get(target, prop, receiver) { - if (isMember(target, prop) && !allowedMembers.includes(prop)) { - deprecated(msg(prop)); - } - - return target[prop]; - } - }); - } - - return deprecatingSpecProxy; -}; diff --git a/src/core/requireCore.js b/src/core/requireCore.js index 9ce8aed3..669bd244 100644 --- a/src/core/requireCore.js +++ b/src/core/requireCore.js @@ -42,7 +42,6 @@ var getJasmineRequireObj = (function(jasmineGlobal) { j$.getClearStack = jRequire.clearStack(j$); j$.Clock = jRequire.Clock(); j$.DelayedFunctionScheduler = jRequire.DelayedFunctionScheduler(j$); - j$.deprecatingSpecProxy = jRequire.deprecatingSpecProxy(j$); j$.Deprecator = jRequire.Deprecator(j$); j$.Configuration = jRequire.Configuration(j$); j$.Env = jRequire.Env(j$); From 168ff0a751b6280b170ce097410d77a4c7c1f449 Mon Sep 17 00:00:00 2001 From: Steve Gravrock Date: Sat, 27 Sep 2025 13:21:09 -0700 Subject: [PATCH 31/95] Move private APIs to private namespace Fixes #2078 --- lib/jasmine-core/jasmine-html.js | 6 +- lib/jasmine-core/jasmine.js | 799 +++++++++--------- release_notes/3.9.0.md | 2 +- spec/core/AsyncExpectationSpec.js | 66 +- spec/core/CallTrackerSpec.js | 32 +- spec/core/ClearStackSpec.js | 18 +- spec/core/ClockSpec.js | 120 +-- .../CompleteOnFirstErrorSkipPolicySpec.js | 12 +- spec/core/ConfigurationSpec.js | 14 +- spec/core/DelayedFunctionSchedulerSpec.js | 40 +- spec/core/DeprecatorSpec.js | 28 +- spec/core/EnvSpec.js | 76 +- spec/core/ExceptionFormatterSpec.js | 48 +- spec/core/ExceptionsSpec.js | 2 +- spec/core/ExpectationFilterChainSpec.js | 16 +- spec/core/ExpectationSpec.js | 50 +- spec/core/GlobalErrorsSpec.js | 50 +- spec/core/JsApiReporterSpec.js | 24 +- spec/core/MockDateSpec.js | 26 +- spec/core/PrettyPrintSpec.js | 106 +-- spec/core/QueueRunnerSpec.js | 102 +-- spec/core/ReportDispatcherSpec.js | 14 +- spec/core/RunableResourcesSpec.js | 90 +- spec/core/RunnerSpec.js | 70 +- .../core/SkipAfterBeforeAllErrorPolicySpec.js | 10 +- spec/core/SpecSpec.js | 98 +-- spec/core/SpyRegistrySpec.js | 76 +- spec/core/SpySpec.js | 10 +- spec/core/SpyStrategySpec.js | 61 +- spec/core/StackTraceSpec.js | 22 +- spec/core/SuiteBuilderSpec.js | 50 +- spec/core/SuiteSpec.js | 76 +- spec/core/TreeProcessorSpec.js | 28 +- spec/core/TreeRunnerSpec.js | 88 +- spec/core/UserContextSpec.js | 10 +- spec/core/UtilSpec.js | 98 +-- spec/core/asymmetric_equality/AnySpec.js | 26 +- spec/core/asymmetric_equality/AnythingSpec.js | 22 +- .../ArrayContainingSpec.js | 26 +- .../ArrayWithExactContentsSpec.js | 20 +- spec/core/asymmetric_equality/EmptySpec.js | 12 +- spec/core/asymmetric_equality/FalsySpec.js | 10 +- spec/core/asymmetric_equality/IsSpec.js | 12 +- .../asymmetric_equality/MapContainingSpec.js | 48 +- spec/core/asymmetric_equality/NotEmptySpec.js | 12 +- .../ObjectContainingSpec.js | 64 +- .../asymmetric_equality/SetContainingSpec.js | 38 +- .../StringContainingSpec.js | 8 +- .../asymmetric_equality/StringMatchingSpec.js | 8 +- spec/core/asymmetric_equality/TruthySpec.js | 18 +- spec/core/baseSpec.js | 50 +- spec/core/buildExpectationResultSpec.js | 16 +- spec/core/formatErrorMsgSpec.js | 4 +- .../AsymmetricEqualityTestersSpec.js | 4 +- .../integration/CustomAsyncMatchersSpec.js | 4 +- spec/core/integration/CustomMatchersSpec.js | 4 +- .../integration/CustomObjectFormatterSpec.js | 2 +- .../integration/CustomSpyStrategiesSpec.js | 2 +- .../integration/DefaultSpyStrategySpec.js | 2 +- spec/core/integration/DeprecationSpec.js | 2 +- spec/core/integration/EnvSpec.js | 46 +- .../integration/GlobalErrorHandlingSpec.js | 62 +- spec/core/integration/MatchersSpec.js | 4 +- spec/core/integration/ParallelSpec.js | 2 +- spec/core/integration/SpecRunningSpec.js | 2 +- spec/core/jasmineNamespaceSpec.js | 77 ++ spec/core/matchers/DiffBuilderSpec.js | 40 +- spec/core/matchers/MismatchTreeSpec.js | 66 +- spec/core/matchers/NullDiffBuilderSpec.js | 2 +- spec/core/matchers/ObjectPathSpec.js | 2 +- spec/core/matchers/async/toBePendingSpec.js | 16 +- spec/core/matchers/async/toBeRejectedSpec.js | 12 +- .../async/toBeRejectedWithErrorSpec.js | 72 +- .../matchers/async/toBeRejectedWithSpec.js | 30 +- spec/core/matchers/async/toBeResolvedSpec.js | 14 +- .../core/matchers/async/toBeResolvedToSpec.js | 34 +- spec/core/matchers/matchersUtilSpec.js | 228 ++--- spec/core/matchers/nothingSpec.js | 2 +- spec/core/matchers/toBeCloseToSpec.js | 24 +- spec/core/matchers/toBeDefinedSpec.js | 4 +- spec/core/matchers/toBeFalseSpec.js | 6 +- spec/core/matchers/toBeFalsySpec.js | 4 +- .../matchers/toBeGreaterThanOrEqualSpec.js | 4 +- spec/core/matchers/toBeGreaterThanSpec.js | 4 +- spec/core/matchers/toBeInstanceOfSpec.js | 48 +- spec/core/matchers/toBeLessThanOrEqualSpec.js | 4 +- spec/core/matchers/toBeLessThanSpec.js | 4 +- spec/core/matchers/toBeNaNSpec.js | 8 +- .../core/matchers/toBeNegativeInfinitySpec.js | 8 +- spec/core/matchers/toBeNullSpec.js | 4 +- spec/core/matchers/toBeNullishSpec.js | 18 +- .../core/matchers/toBePositiveInfinitySpec.js | 8 +- spec/core/matchers/toBeSpec.js | 38 +- spec/core/matchers/toBeTrueSpec.js | 4 +- spec/core/matchers/toBeTruthySpec.js | 4 +- spec/core/matchers/toBeUndefinedSpec.js | 4 +- spec/core/matchers/toContainSpec.js | 8 +- spec/core/matchers/toEqualSpec.js | 44 +- .../matchers/toHaveBeenCalledBeforeSpec.js | 54 +- .../matchers/toHaveBeenCalledOnceWithSpec.js | 60 +- spec/core/matchers/toHaveBeenCalledSpec.js | 24 +- .../matchers/toHaveBeenCalledTimesSpec.js | 36 +- .../core/matchers/toHaveBeenCalledWithSpec.js | 36 +- spec/core/matchers/toHaveClassSpec.js | 10 +- spec/core/matchers/toHaveClassesSpec.js | 10 +- .../toHaveNoOtherSpyInteractionsSpec.js | 34 +- spec/core/matchers/toHaveSizeSpec.js | 34 +- .../matchers/toHaveSpyInteractionsSpec.js | 16 +- spec/core/matchers/toMatchSpec.js | 10 +- spec/core/matchers/toThrowErrorSpec.js | 64 +- spec/core/matchers/toThrowMatchingSpec.js | 16 +- spec/core/matchers/toThrowSpec.js | 24 +- spec/helpers/defineJasmineUnderTest.js | 3 + spec/helpers/integrationMatchers.js | 4 +- spec/helpers/nodeDefineJasmineUnderTest.js | 3 + spec/helpers/resetEnv.js | 6 +- spec/html/HtmlReporterSpec.js | 2 +- spec/html/PrettyPrintHtmlSpec.js | 10 +- spec/html/ResultsNodeSpec.js | 8 +- spec/html/SpyRegistryHtmlSpec.js | 4 +- src/core/CallTracker.js | 4 +- src/core/Deprecator.js | 8 +- src/core/Env.js | 52 +- src/core/ExceptionFormatter.js | 8 +- src/core/Expectation.js | 8 +- src/core/Expector.js | 4 +- src/core/GlobalErrors.js | 6 +- src/core/ParallelReportDispatcher.js | 11 +- src/core/PrettyPrinter.js | 32 +- src/core/QueueRunner.js | 14 +- src/core/RunableResources.js | 14 +- src/core/Runner.js | 8 +- src/core/Spec.js | 12 +- src/core/Spy.js | 6 +- src/core/SpyFactory.js | 10 +- src/core/SpyRegistry.js | 18 +- src/core/SpyStrategy.js | 14 +- src/core/Suite.js | 18 +- src/core/SuiteBuilder.js | 28 +- src/core/TreeRunner.js | 10 +- src/core/asymmetric_equality/Any.js | 2 +- .../asymmetric_equality/ArrayContaining.js | 6 +- .../ArrayWithExactContents.js | 4 +- src/core/asymmetric_equality/Empty.js | 10 +- src/core/asymmetric_equality/MapContaining.js | 6 +- src/core/asymmetric_equality/NotEmpty.js | 10 +- .../asymmetric_equality/ObjectContaining.js | 2 +- src/core/asymmetric_equality/SetContaining.js | 6 +- .../asymmetric_equality/StringContaining.js | 4 +- .../asymmetric_equality/StringMatching.js | 2 +- src/core/base.js | 150 ++-- src/core/buildExpectationResult.js | 4 +- src/core/matchers/DiffBuilder.js | 10 +- src/core/matchers/MismatchTree.js | 2 +- src/core/matchers/async/toBePending.js | 2 +- src/core/matchers/async/toBeRejected.js | 2 +- src/core/matchers/async/toBeRejectedWith.js | 2 +- .../matchers/async/toBeRejectedWithError.js | 10 +- src/core/matchers/async/toBeResolved.js | 2 +- src/core/matchers/async/toBeResolvedTo.js | 2 +- src/core/matchers/matchersUtil.js | 52 +- src/core/matchers/toBeInstanceOf.js | 8 +- src/core/matchers/toEqual.js | 4 +- src/core/matchers/toHaveBeenCalled.js | 2 +- src/core/matchers/toHaveBeenCalledBefore.js | 2 +- src/core/matchers/toHaveBeenCalledOnceWith.js | 4 +- src/core/matchers/toHaveBeenCalledTimes.js | 4 +- src/core/matchers/toHaveBeenCalledWith.js | 4 +- src/core/matchers/toHaveClass.js | 4 +- src/core/matchers/toHaveClasses.js | 4 +- .../matchers/toHaveNoOtherSpyInteractions.js | 4 +- src/core/matchers/toHaveSize.js | 8 +- src/core/matchers/toHaveSpyInteractions.js | 4 +- src/core/matchers/toMatch.js | 7 +- src/core/matchers/toThrow.js | 2 +- src/core/matchers/toThrowError.js | 12 +- src/core/matchers/toThrowMatching.js | 4 +- src/core/reporterEvents.js | 2 +- src/core/requireCore.js | 139 ++- src/core/requireInterface.js | 2 +- src/core/util.js | 4 +- src/html/HtmlReporter.js | 4 +- src/html/requireHtml.js | 2 +- 183 files changed, 2627 insertions(+), 2459 deletions(-) create mode 100644 spec/core/jasmineNamespaceSpec.js diff --git a/lib/jasmine-core/jasmine-html.js b/lib/jasmine-core/jasmine-html.js index 61f389d1..767951a4 100644 --- a/lib/jasmine-core/jasmine-html.js +++ b/lib/jasmine-core/jasmine-html.js @@ -26,7 +26,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. var jasmineRequire = window.jasmineRequire || require('./jasmine.js'); jasmineRequire.html = function(j$) { - j$.ResultsNode = jasmineRequire.ResultsNode(); + j$.private.ResultsNode = jasmineRequire.ResultsNode(); j$.HtmlReporter = jasmineRequire.HtmlReporter(j$); j$.QueryString = jasmineRequire.QueryString(); j$.HtmlSpecFilter = jasmineRequire.HtmlSpecFilter(); @@ -35,7 +35,7 @@ jasmineRequire.html = function(j$) { jasmineRequire.HtmlReporter = function(j$) { function ResultsStateBuilder() { - this.topResults = new j$.ResultsNode({}, '', null); + this.topResults = new j$.private.ResultsNode({}, '', null); this.currentParent = this.topResults; this.specsExecuted = 0; this.failureCount = 0; @@ -793,7 +793,7 @@ jasmineRequire.HtmlReporter = function(j$) { const el = createElement(type); let children; - if (j$.isArray_(childrenArrayOrVarArgs)) { + if (j$.private.isArray(childrenArrayOrVarArgs)) { children = childrenArrayOrVarArgs; } else { children = []; diff --git a/lib/jasmine-core/jasmine.js b/lib/jasmine-core/jasmine.js index e952ea2e..3d927b00 100644 --- a/lib/jasmine-core/jasmine.js +++ b/lib/jasmine-core/jasmine.js @@ -53,92 +53,79 @@ var getJasmineRequireObj = (function(jasmineGlobal) { } getJasmineRequire().core = function(jRequire) { - const j$ = {}; + const j$ = { private: {} }; jRequire.base(j$, jasmineGlobal); - j$.util = jRequire.util(j$); - j$.errors = jRequire.errors(); - j$.formatErrorMsg = jRequire.formatErrorMsg(); - j$.Any = jRequire.Any(j$); - j$.Anything = jRequire.Anything(j$); - j$.CallTracker = jRequire.CallTracker(j$); - j$.MockDate = jRequire.MockDate(j$); - j$.getClearStack = jRequire.clearStack(j$); - j$.Clock = jRequire.Clock(); - j$.DelayedFunctionScheduler = jRequire.DelayedFunctionScheduler(j$); - j$.Deprecator = jRequire.Deprecator(j$); - j$.Configuration = jRequire.Configuration(j$); - j$.Env = jRequire.Env(j$); - j$.StackTrace = jRequire.StackTrace(j$); - j$.ExceptionFormatter = jRequire.ExceptionFormatter(j$); - j$.ExpectationFilterChain = jRequire.ExpectationFilterChain(); - j$.Expector = jRequire.Expector(j$); - j$.Expectation = jRequire.Expectation(j$); - j$.buildExpectationResult = jRequire.buildExpectationResult(j$); - j$.JsApiReporter = jRequire.JsApiReporter(j$); - j$.makePrettyPrinter = jRequire.makePrettyPrinter(j$); - j$.basicPrettyPrinter_ = j$.makePrettyPrinter(); - j$.MatchersUtil = jRequire.MatchersUtil(j$); - j$.ObjectContaining = jRequire.ObjectContaining(j$); - j$.ArrayContaining = jRequire.ArrayContaining(j$); - j$.ArrayWithExactContents = jRequire.ArrayWithExactContents(j$); - j$.MapContaining = jRequire.MapContaining(j$); - j$.SetContaining = jRequire.SetContaining(j$); - j$.QueueRunner = jRequire.QueueRunner(j$); - j$.NeverSkipPolicy = jRequire.NeverSkipPolicy(j$); - j$.SkipAfterBeforeAllErrorPolicy = jRequire.SkipAfterBeforeAllErrorPolicy( + j$.private.util = jRequire.util(j$); + j$.private.errors = jRequire.errors(); + j$.private.formatErrorMsg = jRequire.formatErrorMsg(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.getClearStack = jRequire.clearStack(j$); + j$.private.Clock = jRequire.Clock(); + 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.JsApiReporter = jRequire.JsApiReporter(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( j$ ); - j$.CompleteOnFirstErrorSkipPolicy = jRequire.CompleteOnFirstErrorSkipPolicy( + j$.private.CompleteOnFirstErrorSkipPolicy = jRequire.CompleteOnFirstErrorSkipPolicy( j$ ); - j$.reporterEvents = jRequire.reporterEvents(j$); - j$.ReportDispatcher = jRequire.ReportDispatcher(j$); + j$.private.reporterEvents = jRequire.reporterEvents(j$); + j$.private.ReportDispatcher = jRequire.ReportDispatcher(j$); j$.ParallelReportDispatcher = jRequire.ParallelReportDispatcher(j$); - j$.CurrentRunableTracker = jRequire.CurrentRunableTracker(); - j$.RunableResources = jRequire.RunableResources(j$); - j$.Runner = jRequire.Runner(j$); - j$.Spec = jRequire.Spec(j$); - j$.Spy = jRequire.Spy(j$); - j$.SpyFactory = jRequire.SpyFactory(j$); - j$.SpyRegistry = jRequire.SpyRegistry(j$); - j$.SpyStrategy = jRequire.SpyStrategy(j$); - j$.StringMatching = jRequire.StringMatching(j$); - j$.StringContaining = jRequire.StringContaining(j$); - j$.UserContext = jRequire.UserContext(j$); - j$.Suite = jRequire.Suite(j$); - j$.SuiteBuilder = jRequire.SuiteBuilder(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$); j$.Timer = jRequire.Timer(); - j$.TreeProcessor = jRequire.TreeProcessor(j$); - j$.TreeRunner = jRequire.TreeRunner(j$); + j$.private.TreeProcessor = jRequire.TreeProcessor(j$); + j$.private.TreeRunner = jRequire.TreeRunner(j$); j$.version = jRequire.version(); - j$.Order = jRequire.Order(); - j$.DiffBuilder = jRequire.DiffBuilder(j$); - j$.NullDiffBuilder = jRequire.NullDiffBuilder(j$); - j$.ObjectPath = jRequire.ObjectPath(j$); - j$.MismatchTree = jRequire.MismatchTree(j$); + 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$); - // zone.js tries to monkey patch GlobalErrors in a way that is either a - // no-op or causes Jasmine to crash, depending on whether it's done before - // or after env creation. Prevent that. - const GlobalErrors = jRequire.GlobalErrors(j$); - Object.defineProperty(j$, 'GlobalErrors', { - enumerable: true, - configurable: false, - get() { - return GlobalErrors; - }, - set() {} - }); - - j$.Truthy = jRequire.Truthy(j$); - j$.Falsy = jRequire.Falsy(j$); - j$.Empty = jRequire.Empty(j$); - j$.NotEmpty = jRequire.NotEmpty(j$); - j$.Is = jRequire.Is(j$); - - j$.matchers = jRequire.requireMatchers(jRequire, j$); - j$.asyncMatchers = jRequire.requireAsyncMatchers(jRequire, j$); + j$.private.matchers = jRequire.requireMatchers(jRequire, j$); + j$.private.asyncMatchers = jRequire.requireAsyncMatchers(jRequire, j$); return j$; }; @@ -240,7 +227,10 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) { return DEFAULT_TIMEOUT_INTERVAL; }, set: function(newValue) { - j$.util.validateTimeout(newValue, 'jasmine.DEFAULT_TIMEOUT_INTERVAL'); + j$.private.util.validateTimeout( + newValue, + 'jasmine.DEFAULT_TIMEOUT_INTERVAL' + ); DEFAULT_TIMEOUT_INTERVAL = newValue; } }); @@ -258,58 +248,61 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) { * @return {Env} */ j$.getEnv = function(options) { - const env = (j$.currentEnv_ = j$.currentEnv_ || new j$.Env(options)); + const env = (j$.private.currentEnv_ = + j$.private.currentEnv_ || new j$.private.Env(options)); //jasmine. singletons in here (setTimeout blah blah). return env; }; - j$.isArray_ = function(value) { - return j$.isA_('Array', value); + j$.private.isArray = function(value) { + return j$.private.isA('Array', value); }; - j$.isObject_ = function(value) { - return value !== undefined && value !== null && j$.isA_('Object', value); - }; - - j$.isString_ = function(value) { - return j$.isA_('String', value); - }; - - j$.isNumber_ = function(value) { - return j$.isA_('Number', value); - }; - - j$.isFunction_ = function(value) { - return j$.isA_('Function', value); - }; - - j$.isAsyncFunction_ = function(value) { - return j$.isA_('AsyncFunction', value); - }; - - j$.isGeneratorFunction_ = function(value) { - return j$.isA_('GeneratorFunction', value); - }; - - j$.isTypedArray_ = function(value) { + j$.private.isObject = function(value) { return ( - j$.isA_('Float32Array', value) || - j$.isA_('Float64Array', value) || - j$.isA_('Int16Array', value) || - j$.isA_('Int32Array', value) || - j$.isA_('Int8Array', value) || - j$.isA_('Uint16Array', value) || - j$.isA_('Uint32Array', value) || - j$.isA_('Uint8Array', value) || - j$.isA_('Uint8ClampedArray', value) + value !== undefined && value !== null && j$.private.isA('Object', value) ); }; - j$.isA_ = function(typeName, value) { - return j$.getType_(value) === '[object ' + typeName + ']'; + j$.private.isString = function(value) { + return j$.private.isA('String', value); }; - j$.isError_ = function(value) { + j$.private.isNumber = function(value) { + return j$.private.isA('Number', value); + }; + + j$.private.isFunction = function(value) { + return j$.private.isA('Function', value); + }; + + j$.private.isAsyncFunction = function(value) { + return j$.private.isA('AsyncFunction', value); + }; + + j$.private.isGeneratorFunction = function(value) { + return j$.private.isA('GeneratorFunction', value); + }; + + j$.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) + ); + }; + + j$.private.isA = function(typeName, value) { + return j$.private.getType(value) === '[object ' + typeName + ']'; + }; + + j$.private.isError = function(value) { if (!value) { return false; } @@ -321,15 +314,15 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) { return typeof value.stack === 'string' && typeof value.message === 'string'; }; - j$.isAsymmetricEqualityTester_ = function(obj) { - return obj ? j$.isA_('Function', obj.asymmetricMatch) : false; + j$.private.isAsymmetricEqualityTester = function(obj) { + return obj ? j$.private.isA('Function', obj.asymmetricMatch) : false; }; - j$.getType_ = function(value) { + j$.private.getType = function(value) { return Object.prototype.toString.apply(value); }; - j$.isDomNode = function(obj) { + j$.private.isDomNode = function(obj) { // Node is a function, because constructors return typeof jasmineGlobal.Node !== 'undefined' ? obj instanceof jasmineGlobal.Node @@ -340,7 +333,7 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) { // return obj.nodeType > 0; }; - j$.isMap = function(obj) { + j$.private.isMap = function(obj) { return ( obj !== null && typeof obj !== 'undefined' && @@ -348,7 +341,7 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) { ); }; - j$.isSet = function(obj) { + j$.private.isSet = function(obj) { return ( obj !== null && typeof obj !== 'undefined' && @@ -356,7 +349,7 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) { ); }; - j$.isWeakMap = function(obj) { + j$.private.isWeakMap = function(obj) { return ( obj !== null && typeof obj !== 'undefined' && @@ -364,7 +357,7 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) { ); }; - j$.isURL = function(obj) { + j$.private.isURL = function(obj) { return ( obj !== null && typeof obj !== 'undefined' && @@ -372,11 +365,11 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) { ); }; - j$.isIterable_ = function(value) { + j$.private.isIterable = function(value) { return value && !!value[Symbol.iterator]; }; - j$.isDataView = function(obj) { + j$.private.isDataView = function(obj) { return ( obj !== null && typeof obj !== 'undefined' && @@ -384,15 +377,15 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) { ); }; - j$.isPromise = function(obj) { + j$.private.isPromise = function(obj) { return !!obj && obj.constructor === jasmineGlobal.Promise; }; - j$.isPromiseLike = function(obj) { - return !!obj && j$.isFunction_(obj.then); + j$.private.isPromiseLike = function(obj) { + return !!obj && j$.private.isFunction(obj.then); }; - j$.fnNameFor = function(func) { + j$.private.fnNameFor = function(func) { if (func.name) { return func.name; } @@ -404,7 +397,7 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) { return matches ? matches[1] : ''; }; - j$.isPending_ = function(promise) { + j$.private.isPending = function(promise) { const sentinel = {}; return Promise.race([promise, Promise.resolve(sentinel)]).then( function(result) { @@ -426,7 +419,7 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) { * @param {Constructor} clazz - The constructor to check against. */ j$.any = function(clazz) { - return new j$.Any(clazz); + return new j$.private.Any(clazz); }; /** @@ -438,7 +431,7 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) { * @function */ j$.anything = function() { - return new j$.Anything(); + return new j$.private.Anything(); }; /** @@ -450,7 +443,7 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) { * @function */ j$.truthy = function() { - return new j$.Truthy(); + return new j$.private.Truthy(); }; /** @@ -463,7 +456,7 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) { * @function */ j$.falsy = function() { - return new j$.Falsy(); + return new j$.private.Falsy(); }; /** @@ -475,7 +468,7 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) { * @function */ j$.empty = function() { - return new j$.Empty(); + return new j$.private.Empty(); }; /** @@ -487,7 +480,7 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) { * @param {Object} sample - The value to compare the actual to. */ j$.is = function(sample) { - return new j$.Is(sample); + return new j$.private.Is(sample); }; /** @@ -499,7 +492,7 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) { * @function */ j$.notEmpty = function() { - return new j$.NotEmpty(); + return new j$.private.NotEmpty(); }; /** @@ -512,7 +505,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$.ObjectContaining(sample); + return new j$.private.ObjectContaining(sample); }; /** @@ -525,7 +518,7 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) { * @param {RegExp|String} expected */ j$.stringMatching = function(expected) { - return new j$.StringMatching(expected); + return new j$.private.StringMatching(expected); }; /** @@ -538,7 +531,7 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) { * @param {String} expected */ j$.stringContaining = function(expected) { - return new j$.StringContaining(expected); + return new j$.private.StringContaining(expected); }; /** @@ -551,7 +544,7 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) { * @param {Array} sample */ j$.arrayContaining = function(sample) { - return new j$.ArrayContaining(sample); + return new j$.private.ArrayContaining(sample); }; /** @@ -565,7 +558,7 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) { * @param {Array} sample */ j$.arrayWithExactContents = function(sample) { - return new j$.ArrayWithExactContents(sample); + return new j$.private.ArrayWithExactContents(sample); }; /** @@ -579,7 +572,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$.MapContaining(sample); + return new j$.private.MapContaining(sample); }; /** @@ -593,7 +586,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$.SetContaining(sample); + return new j$.private.SetContaining(sample); }; /** @@ -609,8 +602,8 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) { return false; } return ( - putativeSpy.and instanceof j$.SpyStrategy && - putativeSpy.calls instanceof j$.CallTracker + putativeSpy.and instanceof j$.private.SpyStrategy && + putativeSpy.calls instanceof j$.private.CallTracker ); }; @@ -715,7 +708,7 @@ getJasmineRequireObj().util = function(j$) { } else if (str === '[object Date]') { return new Date(arg.valueOf()); } else { - return j$.util.clone(arg); + return j$.private.util.clone(arg); } }); }; @@ -737,7 +730,7 @@ getJasmineRequireObj().util = function(j$) { }; function callerFile() { - const trace = new j$.StackTrace(new Error()); + const trace = new j$.private.StackTrace(new Error()); return trace.frames[1].file; } @@ -824,7 +817,7 @@ getJasmineRequireObj().Spec = function(j$) { } addExpectationResult(passed, data, isError) { - const expectationResult = j$.buildExpectationResult(data); + const expectationResult = j$.private.buildExpectationResult(data); if (passed) { this.result.passedExpectations.push(expectationResult); @@ -841,7 +834,7 @@ getJasmineRequireObj().Spec = function(j$) { } if (this.#throwOnExpectationFailure && !isError) { - throw new j$.errors.ExpectationFailed(); + throw new j$.private.errors.ExpectationFailed(); } } } @@ -855,8 +848,8 @@ 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. - j$.util.assertStructuredCloneable(key, 'Key'); - j$.util.assertStructuredCloneable(value, 'Value'); + j$.private.util.assertStructuredCloneable(key, 'Key'); + j$.private.util.assertStructuredCloneable(value, 'Value'); this.result.properties = this.result.properties || {}; this.result.properties[key] = value; } @@ -975,7 +968,7 @@ getJasmineRequireObj().Spec = function(j$) { return; } - if (e instanceof j$.errors.ExpectationFailed) { + if (e instanceof j$.private.errors.ExpectationFailed) { return; } @@ -1045,7 +1038,7 @@ getJasmineRequireObj().Spec = function(j$) { deprecation = { message: deprecation }; } this.result.deprecationWarnings.push( - j$.buildExpectationResult(deprecation) + j$.private.buildExpectationResult(deprecation) ); } @@ -1199,18 +1192,18 @@ getJasmineRequireObj().Env = function(j$) { envOptions = envOptions || {}; const self = this; - const GlobalErrors = envOptions.GlobalErrors || j$.GlobalErrors; + const GlobalErrors = envOptions.GlobalErrors || j$.private.GlobalErrors; const global = envOptions.global || j$.getGlobal(); const realSetTimeout = global.setTimeout; const realClearTimeout = global.clearTimeout; - const clearStack = j$.getClearStack(global); - this.clock = new j$.Clock( + const clearStack = j$.private.getClearStack(global); + this.clock = new j$.private.Clock( global, function() { - return new j$.DelayedFunctionScheduler(); + return new j$.private.DelayedFunctionScheduler(); }, - new j$.MockDate(global) + new j$.private.MockDate(global) ); const globalErrors = new GlobalErrors( @@ -1238,7 +1231,7 @@ getJasmineRequireObj().Env = function(j$) { }; })(); - const runableResources = new j$.RunableResources({ + const runableResources = new j$.private.RunableResources({ getCurrentRunableId: function() { const r = runner.currentRunable(); return r ? r.id : null; @@ -1251,7 +1244,7 @@ getJasmineRequireObj().Env = function(j$) { let runner; let parallelLoadingState = null; // 'specs', 'helpers', or null for non-parallel - const config = new j$.Configuration(); + const config = new j$.private.Configuration(); if (!envOptions.suppressLoadErrors) { installGlobalErrors(); @@ -1320,11 +1313,11 @@ getJasmineRequireObj().Env = function(j$) { runableResources.customObjectFormatters().push(formatter); }; - j$.Expectation.addCoreMatchers(j$.matchers); - j$.Expectation.addAsyncCoreMatchers(j$.asyncMatchers); + j$.private.Expectation.addCoreMatchers(j$.private.matchers); + j$.private.Expectation.addAsyncCoreMatchers(j$.private.asyncMatchers); const expectationFactory = function(actual, spec) { - return j$.Expectation.factory({ + return j$.private.Expectation.factory({ matchersUtil: runableResources.makeMatchersUtil(), customMatchers: runableResources.customMatchers(), actual: actual, @@ -1357,7 +1350,7 @@ getJasmineRequireObj().Env = function(j$) { }; const throwUnlessFactory = function(actual, spec) { - return j$.Expectation.factory({ + return j$.private.Expectation.factory({ matchersUtil: runableResources.makeMatchersUtil(), customMatchers: runableResources.customMatchers(), actual: actual, @@ -1366,7 +1359,7 @@ getJasmineRequireObj().Env = function(j$) { }; const throwUnlessAsyncFactory = function(actual, spec) { - return j$.Expectation.asyncFactory({ + return j$.private.Expectation.asyncFactory({ matchersUtil: runableResources.makeMatchersUtil(), customAsyncMatchers: runableResources.customAsyncMatchers(), actual: actual, @@ -1381,7 +1374,7 @@ getJasmineRequireObj().Env = function(j$) { error.matcherName !== undefined && error.passed !== undefined; const result = isExpectationResult ? error - : j$.buildExpectationResult({ + : j$.private.buildExpectationResult({ error, passed: false, matcherName: '', @@ -1442,7 +1435,7 @@ getJasmineRequireObj().Env = function(j$) { } const asyncExpectationFactory = function(actual, spec, runableType) { - return j$.Expectation.asyncFactory({ + return j$.private.Expectation.asyncFactory({ matchersUtil: runableResources.makeMatchersUtil(), customAsyncMatchers: runableResources.customAsyncMatchers(), actual: actual, @@ -1498,10 +1491,10 @@ getJasmineRequireObj().Env = function(j$) { (runner.currentRunable() || topSuite).handleException(e); }; - new j$.QueueRunner(options).execute(); + new j$.private.QueueRunner(options).execute(); } - const suiteBuilder = new j$.SuiteBuilder({ + const suiteBuilder = new j$.private.SuiteBuilder({ env: this, expectationFactory, asyncExpectationFactory, @@ -1509,7 +1502,7 @@ getJasmineRequireObj().Env = function(j$) { runQueue }); topSuite = suiteBuilder.topSuite; - const deprecator = new j$.Deprecator(topSuite); + const deprecator = new j$.private.Deprecator(topSuite); /** * Provides the root suite, through which all suites and specs can be @@ -1529,23 +1522,23 @@ getJasmineRequireObj().Env = function(j$) { * @interface Reporter * @see custom_reporter */ - reportDispatcher = new j$.ReportDispatcher( - j$.reporterEvents, + reportDispatcher = new j$.private.ReportDispatcher( + j$.private.reporterEvents, function(options) { - options.SkipPolicy = j$.NeverSkipPolicy; + options.SkipPolicy = j$.private.NeverSkipPolicy; return runQueue(options); }, recordLateError ); - runner = new j$.Runner({ + runner = new j$.private.Runner({ topSuite, totalSpecsDefined: () => suiteBuilder.totalSpecsDefined, focusedRunables: () => suiteBuilder.focusedRunables, runableResources, reportDispatcher, runQueue, - TreeProcessor: j$.TreeProcessor, + TreeProcessor: j$.private.TreeProcessor, globalErrors, getConfig: () => config }); @@ -1711,7 +1704,7 @@ getJasmineRequireObj().Env = function(j$) { try { const maybePromise = fn(spy); - if (!j$.isPromiseLike(maybePromise)) { + if (!j$.private.isPromiseLike(maybePromise)) { throw new Error( 'The callback to spyOnGlobalErrorsAsync must be an async or promise-returning function' ); @@ -1946,7 +1939,7 @@ getJasmineRequireObj().Env = function(j$) { }; this.pending = function(message) { - let fullMessage = j$.Spec.pendingSpecExceptionMessage; + let fullMessage = j$.private.Spec.pendingSpecExceptionMessage; if (message) { fullMessage += message; } @@ -1965,7 +1958,7 @@ getJasmineRequireObj().Env = function(j$) { message += ': '; if (error.message) { message += error.message; - } else if (j$.isString_(error)) { + } else if (j$.private.isString(error)) { message += error; } else { // pretty print all kind of objects. This includes arrays. @@ -1994,7 +1987,7 @@ getJasmineRequireObj().Env = function(j$) { } function callerCallerFilename() { - const frames = new j$.StackTrace(new Error()).frames; + const frames = new j$.private.StackTrace(new Error()).frames; // frames[3] should always exist except in Jasmine's own tests, which bypass // the global it/describe layer, but don't crash if it doesn't. return frames[3] && frames[3].file; @@ -2173,7 +2166,7 @@ getJasmineRequireObj().Any = function(j$) { }; Any.prototype.jasmineToString = function() { - return ''; + return ''; }; return Any; @@ -2199,10 +2192,10 @@ getJasmineRequireObj().ArrayContaining = function(j$) { } ArrayContaining.prototype.asymmetricMatch = function(other, matchersUtil) { - if (!j$.isArray_(this.sample)) { + if (!j$.private.isArray(this.sample)) { throw new Error( 'You must provide an array to arrayContaining, not ' + - j$.basicPrettyPrinter_(this.sample) + + j$.private.basicPrettyPrinter(this.sample) + '.' ); } @@ -2210,7 +2203,7 @@ getJasmineRequireObj().ArrayContaining = function(j$) { // If the actual parameter is not an array, we can fail immediately, since it couldn't // possibly be an "array containing" anything. However, we also want an empty sample // array to match anything, so we need to double-check we aren't in that case - if (!j$.isArray_(other) && this.sample.length > 0) { + if (!j$.private.isArray(other) && this.sample.length > 0) { return false; } @@ -2239,10 +2232,10 @@ getJasmineRequireObj().ArrayWithExactContents = function(j$) { other, matchersUtil ) { - if (!j$.isArray_(this.sample)) { + if (!j$.private.isArray(this.sample)) { throw new Error( 'You must provide an array to arrayWithExactContents, not ' + - j$.basicPrettyPrinter_(this.sample) + + j$.private.basicPrettyPrinter(this.sample) + '.' ); } @@ -2271,15 +2264,19 @@ getJasmineRequireObj().Empty = function(j$) { function Empty() {} Empty.prototype.asymmetricMatch = function(other) { - if (j$.isString_(other) || j$.isArray_(other) || j$.isTypedArray_(other)) { + if ( + j$.private.isString(other) || + j$.private.isArray(other) || + j$.private.isTypedArray(other) + ) { return other.length === 0; } - if (j$.isMap(other) || j$.isSet(other)) { + if (j$.private.isMap(other) || j$.private.isSet(other)) { return other.size === 0; } - if (j$.isObject_(other)) { + if (j$.private.isObject(other)) { return Object.keys(other).length === 0; } return false; @@ -2326,10 +2323,10 @@ getJasmineRequireObj().Is = function(j$) { getJasmineRequireObj().MapContaining = function(j$) { function MapContaining(sample) { - if (!j$.isMap(sample)) { + if (!j$.private.isMap(sample)) { throw new Error( 'You must provide a map to `mapContaining`, not ' + - j$.basicPrettyPrinter_(sample) + j$.private.basicPrettyPrinter(sample) ); } @@ -2337,7 +2334,7 @@ getJasmineRequireObj().MapContaining = function(j$) { } MapContaining.prototype.asymmetricMatch = function(other, matchersUtil) { - if (!j$.isMap(other)) { + if (!j$.private.isMap(other)) { return false; } @@ -2374,15 +2371,19 @@ getJasmineRequireObj().NotEmpty = function(j$) { function NotEmpty() {} NotEmpty.prototype.asymmetricMatch = function(other) { - if (j$.isString_(other) || j$.isArray_(other) || j$.isTypedArray_(other)) { + if ( + j$.private.isString(other) || + j$.private.isArray(other) || + j$.private.isTypedArray(other) + ) { return other.length !== 0; } - if (j$.isMap(other) || j$.isSet(other)) { + if (j$.private.isMap(other) || j$.private.isSet(other)) { return other.size !== 0; } - if (j$.isObject_(other)) { + if (j$.private.isObject(other)) { return Object.keys(other).length !== 0; } @@ -2438,7 +2439,7 @@ getJasmineRequireObj().ObjectContaining = function(j$) { }; ObjectContaining.prototype.valuesForDiff_ = function(other, pp) { - if (!j$.isObject_(other)) { + if (!j$.private.isObject(other)) { return { self: this.jasmineToString(pp), other: other @@ -2467,10 +2468,10 @@ getJasmineRequireObj().ObjectContaining = function(j$) { getJasmineRequireObj().SetContaining = function(j$) { function SetContaining(sample) { - if (!j$.isSet(sample)) { + if (!j$.private.isSet(sample)) { throw new Error( 'You must provide a set to `setContaining`, not ' + - j$.basicPrettyPrinter_(sample) + j$.private.basicPrettyPrinter(sample) ); } @@ -2478,7 +2479,7 @@ getJasmineRequireObj().SetContaining = function(j$) { } SetContaining.prototype.asymmetricMatch = function(other, matchersUtil) { - if (!j$.isSet(other)) { + if (!j$.private.isSet(other)) { return false; } @@ -2511,7 +2512,7 @@ getJasmineRequireObj().SetContaining = function(j$) { getJasmineRequireObj().StringContaining = function(j$) { function StringContaining(expected) { - if (!j$.isString_(expected)) { + if (!j$.private.isString(expected)) { throw new Error('Expected is not a String'); } @@ -2519,7 +2520,7 @@ getJasmineRequireObj().StringContaining = function(j$) { } StringContaining.prototype.asymmetricMatch = function(other) { - if (!j$.isString_(other)) { + if (!j$.private.isString(other)) { // Arrays, etc. don't match no matter what their indexOf returns. return false; } @@ -2536,7 +2537,7 @@ getJasmineRequireObj().StringContaining = function(j$) { getJasmineRequireObj().StringMatching = function(j$) { function StringMatching(expected) { - if (!j$.isString_(expected) && !j$.isA_('RegExp', expected)) { + if (!j$.private.isString(expected) && !j$.private.isA('RegExp', expected)) { throw new Error('Expected is not a String or a RegExp'); } @@ -2571,7 +2572,7 @@ getJasmineRequireObj().Truthy = function(j$) { //TODO: expectation result may make more sense as a presentation of an expectation. getJasmineRequireObj().buildExpectationResult = function(j$) { function buildExpectationResult(options) { - const exceptionFormatter = new j$.ExceptionFormatter(); + const exceptionFormatter = new j$.private.ExceptionFormatter(); /** * Describes the result of evaluating an expectation @@ -2594,7 +2595,7 @@ getJasmineRequireObj().buildExpectationResult = function(j$) { }; if (!result.passed) { - if (options.error && !j$.isString_(options.error)) { + if (options.error && !j$.private.isString(options.error)) { if ('code' in options.error) { result.code = options.error.code; } @@ -2768,7 +2769,9 @@ 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$.util.cloneArgs) { + this.saveArgumentsByValue = function( + argsCloner = j$.private.util.cloneArgs + ) { opts.cloneArgs = true; opts.argsCloner = argsCloner; }; @@ -3759,7 +3762,7 @@ getJasmineRequireObj().Deprecator = function(j$) { ) { options = options || {}; - if (!this.verbose_ && !j$.isError_(deprecation)) { + if (!this.verbose_ && !j$.private.isError(deprecation)) { if (this.toSuppress_.indexOf(deprecation) !== -1) { return; } @@ -3771,7 +3774,7 @@ getJasmineRequireObj().Deprecator = function(j$) { }; Deprecator.prototype.log_ = function(runnable, deprecation, options) { - if (j$.isError_(deprecation)) { + if (j$.private.isError(deprecation)) { // eslint-disable-next-line no-console console.error(deprecation); return; @@ -3800,7 +3803,7 @@ getJasmineRequireObj().Deprecator = function(j$) { }; Deprecator.prototype.stackTrace_ = function() { - const formatter = new j$.ExceptionFormatter(); + const formatter = new j$.private.ExceptionFormatter(); return formatter.stack(new Error()).replace(/^Error\n/m, ''); }; @@ -3809,7 +3812,7 @@ getJasmineRequireObj().Deprecator = function(j$) { runnable = this.topSuite_; } - if (j$.isError_(deprecation)) { + if (j$.private.isError(deprecation)) { runnable.addDeprecationWarning(deprecation); return; } @@ -3854,7 +3857,7 @@ getJasmineRequireObj().ExceptionFormatter = function(j$) { function ExceptionFormatter(options) { const jasmineFile = - (options && options.jasmineFile) || j$.util.jasmineFile(); + (options && options.jasmineFile) || j$.private.util.jasmineFile(); this.message = function(error) { let message = ''; @@ -3898,7 +3901,7 @@ getJasmineRequireObj().ExceptionFormatter = function(j$) { lines.pop(); } - const stackTrace = new j$.StackTrace(error); + const stackTrace = new j$.private.StackTrace(error); lines = lines.concat(filterJasmine(stackTrace)); if (messageHandling === 'require') { @@ -3951,7 +3954,9 @@ getJasmineRequireObj().ExceptionFormatter = function(j$) { } if (!empty) { - return 'error properties: ' + j$.basicPrettyPrinter_(result) + '\n'; + return ( + 'error properties: ' + j$.private.basicPrettyPrinter(result) + '\n' + ); } return ''; @@ -3967,7 +3972,7 @@ getJasmineRequireObj().Expectation = function(j$) { * @namespace matchers */ function Expectation(options) { - this.expector = new j$.Expector(options); + this.expector = new j$.private.Expector(options); const customMatchers = options.customMatchers || {}; for (const matcherName in customMatchers) { @@ -4043,7 +4048,7 @@ getJasmineRequireObj().Expectation = function(j$) { * @namespace async-matchers */ function AsyncExpectation(options) { - this.expector = new j$.Expector(options); + this.expector = new j$.private.Expector(options); const customAsyncMatchers = options.customAsyncMatchers || {}; for (const matcherName in customAsyncMatchers) { @@ -4136,7 +4141,7 @@ getJasmineRequireObj().Expectation = function(j$) { function negatedFailureMessage(result, matcherName, args, matchersUtil) { if (result.message) { - if (j$.isFunction_(result.message)) { + if (j$.private.isFunction(result.message)) { return result.message(); } else { return result.message; @@ -4181,7 +4186,7 @@ getJasmineRequireObj().Expectation = function(j$) { return function(actual) { const matcherArgs = arguments; - return j$.isPending_(actual).then(function(isPending) { + return j$.private.isPending(actual).then(function(isPending) { if (isPending) { return { pass: false, @@ -4286,7 +4291,7 @@ getJasmineRequireObj().Expector = function(j$) { }; this.actual = options.actual; this.addExpectationResult = options.addExpectationResult || function() {}; - this.filters = new j$.ExpectationFilterChain(); + this.filters = new j$.private.ExpectationFilterChain(); } Expector.prototype.instantiateMatcher = function( @@ -4320,7 +4325,7 @@ getJasmineRequireObj().Expector = function(j$) { this.matchersUtil, args ); - } else if (j$.isFunction_(result.message)) { + } else if (j$.private.isFunction(result.message)) { return result.message(); } else { return result.message; @@ -4409,7 +4414,7 @@ getJasmineRequireObj().GlobalErrors = function(j$) { if ( global.process && global.process.listeners && - j$.isFunction_(global.process.on) + j$.private.isFunction(global.process.on) ) { this.#adapter = new NodeAdapter(global, dispatch); } else { @@ -4558,7 +4563,7 @@ getJasmineRequireObj().GlobalErrors = function(j$) { const jasmineMessage = 'Unhandled promise rejection: ' + event.reason; let reason; - if (j$.isError_(event.reason)) { + if (j$.private.isError(event.reason)) { reason = event.reason; reason.jasmineMessage = jasmineMessage; } else { @@ -4637,7 +4642,7 @@ getJasmineRequireObj().GlobalErrors = function(j$) { jasmineMessagePrefix = 'Uncaught exception'; } - if (j$.isError_(error)) { + if (j$.private.isError(error)) { error.jasmineMessage = jasmineMessagePrefix + ': ' + error; return error; } else { @@ -4690,7 +4695,7 @@ getJasmineRequireObj().toBePending = function(j$) { return function toBePending() { return { compare: function(actual) { - if (!j$.isPromiseLike(actual)) { + if (!j$.private.isPromiseLike(actual)) { throw new Error( `Expected toBePending to be called on a promise but was on a ${typeof actual}.` ); @@ -4724,7 +4729,7 @@ getJasmineRequireObj().toBeRejected = function(j$) { return function toBeRejected() { return { compare: function(actual) { - if (!j$.isPromiseLike(actual)) { + if (!j$.private.isPromiseLike(actual)) { throw new Error( `Expected toBeRejected to be called on a promise but was on a ${typeof actual}.` ); @@ -4758,7 +4763,7 @@ getJasmineRequireObj().toBeRejectedWith = function(j$) { return function toBeRejectedWith(matchersUtil) { return { compare: function(actualPromise, expectedValue) { - if (!j$.isPromiseLike(actualPromise)) { + if (!j$.private.isPromiseLike(actualPromise)) { throw new Error( `Expected toBeRejectedWith to be called on a promise but was on a ${typeof actualPromise}.` ); @@ -4822,7 +4827,7 @@ getJasmineRequireObj().toBeRejectedWithError = function(j$) { return function toBeRejectedWithError(matchersUtil) { return { compare: function(actualPromise, arg1, arg2) { - if (!j$.isPromiseLike(actualPromise)) { + if (!j$.private.isPromiseLike(actualPromise)) { throw new Error( `Expected toBeRejectedWithError to be called on a promise but was on a ${typeof actualPromise}.` ); @@ -4846,14 +4851,14 @@ getJasmineRequireObj().toBeRejectedWithError = function(j$) { }; function matchError(actual, expected, matchersUtil) { - if (!j$.isError_(actual)) { + if (!j$.private.isError(actual)) { return fail(expected, 'rejected with ' + matchersUtil.pp(actual)); } if (!(actual instanceof expected.error)) { return fail( expected, - 'rejected with type ' + j$.fnNameFor(actual.constructor) + 'rejected with type ' + j$.private.fnNameFor(actual.constructor) ); } @@ -4913,7 +4918,7 @@ getJasmineRequireObj().toBeRejectedWithError = function(j$) { error: error, message: message, printValue: - j$.fnNameFor(error) + + j$.private.fnNameFor(error) + (typeof message === 'undefined' ? '' : ': ' + matchersUtil.pp(message)) }; } @@ -4921,7 +4926,7 @@ getJasmineRequireObj().toBeRejectedWithError = function(j$) { function isErrorConstructor(value) { return ( typeof value === 'function' && - (value === Error || j$.isError_(value.prototype)) + (value === Error || j$.private.isError(value.prototype)) ); } }; @@ -4941,7 +4946,7 @@ getJasmineRequireObj().toBeResolved = function(j$) { return function toBeResolved(matchersUtil) { return { compare: function(actual) { - if (!j$.isPromiseLike(actual)) { + if (!j$.private.isPromiseLike(actual)) { throw new Error( `Expected toBeResolved to be called on a promise but was on a ${typeof actual}.` ); @@ -4983,7 +4988,7 @@ getJasmineRequireObj().toBeResolvedTo = function(j$) { return function toBeResolvedTo(matchersUtil) { return { compare: function(actualPromise, expectedValue) { - if (!j$.isPromiseLike(actualPromise)) { + if (!j$.private.isPromiseLike(actualPromise)) { throw new Error( `Expected toBeResolvedTo to be called on a promise but was on a ${typeof actualPromise}.` ); @@ -5036,9 +5041,9 @@ getJasmineRequireObj().DiffBuilder = function(j$) { class DiffBuilder { constructor(config) { this.prettyPrinter_ = - (config || {}).prettyPrinter || j$.makePrettyPrinter(); - this.mismatches_ = new j$.MismatchTree(); - this.path_ = new j$.ObjectPath(); + (config || {}).prettyPrinter || j$.private.makePrettyPrinter(); + this.mismatches_ = new j$.private.MismatchTree(); + this.path_ = new j$.private.ObjectPath(); this.actualRoot_ = undefined; this.expectedRoot_ = undefined; } @@ -5099,8 +5104,8 @@ getJasmineRequireObj().DiffBuilder = function(j$) { const handleAsymmetricExpected = () => { if ( - j$.isAsymmetricEqualityTester_(expected) && - j$.isFunction_(expected.valuesForDiff_) + j$.private.isAsymmetricEqualityTester(expected) && + j$.private.isFunction(expected.valuesForDiff_) ) { const asymmetricResult = expected.valuesForDiff_( actual, @@ -5184,7 +5189,7 @@ getJasmineRequireObj().MatchersUtil = function(j$) { return false; } - if (j$.isSet(haystack)) { + if (j$.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. @@ -5193,7 +5198,7 @@ getJasmineRequireObj().MatchersUtil = function(j$) { } } - if (j$.isIterable_(haystack) && !j$.isString_(haystack)) { + if (j$.private.isIterable(haystack) && !j$.private.isString(haystack)) { // Arrays, Sets, etc. for (const candidate of haystack) { if (this.equals(candidate, needle)) { @@ -5209,7 +5214,7 @@ getJasmineRequireObj().MatchersUtil = function(j$) { return haystack.indexOf(needle) >= 0; } - if (j$.isNumber_(haystack.length)) { + if (j$.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)) { @@ -5256,7 +5261,7 @@ getJasmineRequireObj().MatchersUtil = function(j$) { bStack, diffBuilder ) { - if (j$.isFunction_(b.valuesForDiff_)) { + if (j$.private.isFunction(b.valuesForDiff_)) { const values = b.valuesForDiff_(a, this.pp); this.eq_(values.other, values.self, aStack, bStack, diffBuilder); } else { @@ -5271,8 +5276,8 @@ getJasmineRequireObj().MatchersUtil = function(j$) { bStack, diffBuilder ) { - const asymmetricA = j$.isAsymmetricEqualityTester_(a); - const asymmetricB = j$.isAsymmetricEqualityTester_(b); + const asymmetricA = j$.private.isAsymmetricEqualityTester(a); + const asymmetricB = j$.private.isAsymmetricEqualityTester(b); if (asymmetricA === asymmetricB) { return undefined; @@ -5307,7 +5312,7 @@ getJasmineRequireObj().MatchersUtil = function(j$) { * @returns {boolean} True if the values are equal */ MatchersUtil.prototype.equals = function(a, b, diffBuilder) { - diffBuilder = diffBuilder || j$.NullDiffBuilder(); + diffBuilder = diffBuilder || j$.private.NullDiffBuilder(); diffBuilder.setRoots(a, b); return this.eq_(a, b, [], [], diffBuilder); @@ -5422,8 +5427,8 @@ getJasmineRequireObj().MatchersUtil = function(j$) { return false; } - const aIsDomNode = j$.isDomNode(a); - const bIsDomNode = j$.isDomNode(b); + const aIsDomNode = j$.private.isDomNode(a); + const bIsDomNode = j$.private.isDomNode(b); if (aIsDomNode && bIsDomNode) { // At first try to use DOM3 method isEqualNode result = a.isEqualNode(b); @@ -5437,8 +5442,8 @@ getJasmineRequireObj().MatchersUtil = function(j$) { return false; } - const aIsPromise = j$.isPromise(a); - const bIsPromise = j$.isPromise(b); + const aIsPromise = j$.private.isPromise(a); + const bIsPromise = j$.private.isPromise(b); if (aIsPromise && bIsPromise) { return a === b; } @@ -5492,7 +5497,7 @@ getJasmineRequireObj().MatchersUtil = function(j$) { if (!result) { return false; } - } else if (j$.isMap(a) && j$.isMap(b)) { + } else if (j$.private.isMap(a) && j$.private.isMap(b)) { if (a.size != b.size) { diffBuilder.recordMismatch(); return false; @@ -5525,9 +5530,15 @@ 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$.isAsymmetricEqualityTester_(mapKey) || - (j$.isAsymmetricEqualityTester_(cmpKey) && - this.eq_(mapKey, cmpKey, aStack, bStack, j$.NullDiffBuilder())) + j$.private.isAsymmetricEqualityTester(mapKey) || + (j$.private.isAsymmetricEqualityTester(cmpKey) && + this.eq_( + mapKey, + cmpKey, + aStack, + bStack, + j$.private.NullDiffBuilder() + )) ) { mapValueB = b.get(cmpKey); } else { @@ -5538,7 +5549,7 @@ getJasmineRequireObj().MatchersUtil = function(j$) { mapValueB, aStack, bStack, - j$.NullDiffBuilder() + j$.private.NullDiffBuilder() ); } } @@ -5547,7 +5558,7 @@ getJasmineRequireObj().MatchersUtil = function(j$) { diffBuilder.recordMismatch(); return false; } - } else if (j$.isSet(a) && j$.isSet(b)) { + } else if (j$.private.isSet(a) && j$.private.isSet(b)) { if (a.size != b.size) { diffBuilder.recordMismatch(); return false; @@ -5583,7 +5594,7 @@ getJasmineRequireObj().MatchersUtil = function(j$) { otherValue, baseStack, otherStack, - j$.NullDiffBuilder() + j$.private.NullDiffBuilder() ); if (!found && prevStackSize !== baseStack.length) { baseStack.splice(prevStackSize); @@ -5598,7 +5609,7 @@ getJasmineRequireObj().MatchersUtil = function(j$) { diffBuilder.recordMismatch(); return false; } - } else if (j$.isURL(a) && j$.isURL(b)) { + } else if (j$.private.isURL(a) && j$.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(); @@ -5636,7 +5647,7 @@ getJasmineRequireObj().MatchersUtil = function(j$) { for (const key of aKeys) { // Deep compare each member - if (!j$.util.has(b, key)) { + if (!j$.private.util.has(b, key)) { diffBuilder.recordMismatch( objectKeysAreDifferentFormatter.bind(null, this.pp) ); @@ -5666,7 +5677,7 @@ getJasmineRequireObj().MatchersUtil = function(j$) { const allKeys = (function(o) { const keys = []; for (const key in o) { - if (j$.util.has(o, key)) { + if (j$.private.util.has(o, key)) { keys.push(key); } } @@ -5707,7 +5718,7 @@ getJasmineRequireObj().MatchersUtil = function(j$) { // and not in objB. function extraKeysAndValues(objA, objB) { return MatchersUtil.keys(objA) - .filter(key => !j$.util.has(objB, key)) + .filter(key => !j$.private.util.has(objB, key)) .map(key => [key, objA[key]]); } @@ -5746,7 +5757,7 @@ getJasmineRequireObj().MatchersUtil = function(j$) { 'Expected ' + path + ' to be a kind of ' + - j$.fnNameFor(expected.constructor) + + j$.private.fnNameFor(expected.constructor) + ', but was ' + pp(actual) + '.' @@ -5835,7 +5846,7 @@ getJasmineRequireObj().MismatchTree = function(j$) { */ class MismatchTree { constructor(path) { - this.path = path || new j$.ObjectPath([]); + this.path = path || new j$.private.ObjectPath([]); this.formatter = undefined; this.children = []; this.isMismatch = false; @@ -6182,7 +6193,7 @@ getJasmineRequireObj().toBeGreaterThanOrEqual = function() { }; getJasmineRequireObj().toBeInstanceOf = function(j$) { - const usageError = j$.formatErrorMsg( + const usageError = j$.private.formatErrorMsg( '', 'expect(value).toBeInstanceOf()' ); @@ -6203,16 +6214,16 @@ getJasmineRequireObj().toBeInstanceOf = function(j$) { compare: function(actual, expected) { const actualType = actual && actual.constructor - ? j$.fnNameFor(actual.constructor) + ? j$.private.fnNameFor(actual.constructor) : matchersUtil.pp(actual); const expectedType = expected - ? j$.fnNameFor(expected) + ? j$.private.fnNameFor(expected) : matchersUtil.pp(expected); let expectedMatcher; let pass; try { - expectedMatcher = new j$.Any(expected); + expectedMatcher = new j$.private.Any(expected); pass = expectedMatcher.asymmetricMatch(actual); // eslint-disable-next-line no-unused-vars } catch (error) { @@ -6539,7 +6550,9 @@ getJasmineRequireObj().toEqual = function(j$) { const result = { pass: false }, - diffBuilder = new j$.DiffBuilder({ prettyPrinter: matchersUtil.pp }); + diffBuilder = new j$.private.DiffBuilder({ + prettyPrinter: matchersUtil.pp + }); result.pass = matchersUtil.equals(actual, expected, diffBuilder); @@ -6555,7 +6568,7 @@ getJasmineRequireObj().toEqual = function(j$) { }; getJasmineRequireObj().toHaveBeenCalled = function(j$) { - const getErrorMsg = j$.formatErrorMsg( + const getErrorMsg = j$.private.formatErrorMsg( '', 'expect().toHaveBeenCalled()' ); @@ -6605,7 +6618,7 @@ getJasmineRequireObj().toHaveBeenCalled = function(j$) { }; getJasmineRequireObj().toHaveBeenCalledBefore = function(j$) { - const getErrorMsg = j$.formatErrorMsg( + const getErrorMsg = j$.private.formatErrorMsg( '', 'expect().toHaveBeenCalledBefore()' ); @@ -6701,7 +6714,7 @@ getJasmineRequireObj().toHaveBeenCalledBefore = function(j$) { }; getJasmineRequireObj().toHaveBeenCalledOnceWith = function(j$) { - const getErrorMsg = j$.formatErrorMsg( + const getErrorMsg = j$.private.formatErrorMsg( '', 'expect().toHaveBeenCalledOnceWith(...arguments)' ); @@ -6764,7 +6777,7 @@ getJasmineRequireObj().toHaveBeenCalledOnceWith = function(j$) { function getDiffs() { return actual.calls.allArgs().map(function(argsForCall, callIx) { - const diffBuilder = new j$.DiffBuilder(); + const diffBuilder = new j$.private.DiffBuilder(); matchersUtil.equals(argsForCall, expectedArgs, diffBuilder); return diffBuilder.getMessage(); }); @@ -6810,7 +6823,7 @@ getJasmineRequireObj().toHaveBeenCalledOnceWith = function(j$) { }; getJasmineRequireObj().toHaveBeenCalledTimes = function(j$) { - const getErrorMsg = j$.formatErrorMsg( + const getErrorMsg = j$.private.formatErrorMsg( '', 'expect().toHaveBeenCalledTimes()' ); @@ -6838,7 +6851,7 @@ getJasmineRequireObj().toHaveBeenCalledTimes = function(j$) { const args = Array.prototype.slice.call(arguments, 0), result = { pass: false }; - if (!j$.isNumber_(expected)) { + if (!j$.private.isNumber(expected)) { throw new Error( getErrorMsg( 'The expected times failed is a required argument and must be a number.' @@ -6886,7 +6899,7 @@ getJasmineRequireObj().toHaveBeenCalledTimes = function(j$) { }; getJasmineRequireObj().toHaveBeenCalledWith = function(j$) { - const getErrorMsg = j$.formatErrorMsg( + const getErrorMsg = j$.private.formatErrorMsg( '', 'expect().toHaveBeenCalledWith(...arguments)' ); @@ -6958,7 +6971,7 @@ getJasmineRequireObj().toHaveBeenCalledWith = function(j$) { const diffs = actual.calls .allArgs() .map(function(argsForCall, callIx) { - const diffBuilder = new j$.DiffBuilder(); + const diffBuilder = new j$.private.DiffBuilder(); matchersUtil.equals(argsForCall, expectedArgs, diffBuilder); return ( 'Call ' + @@ -7020,7 +7033,9 @@ getJasmineRequireObj().toHaveClass = function(j$) { function isElement(maybeEl) { return ( - maybeEl && maybeEl.classList && j$.isFunction_(maybeEl.classList.contains) + maybeEl && + maybeEl.classList && + j$.private.isFunction(maybeEl.classList.contains) ); } @@ -7055,7 +7070,9 @@ getJasmineRequireObj().toHaveClasses = function(j$) { function isElement(maybeEl) { return ( - maybeEl && maybeEl.classList && j$.isFunction_(maybeEl.classList.contains) + maybeEl && + maybeEl.classList && + j$.private.isFunction(maybeEl.classList.contains) ); } @@ -7063,7 +7080,7 @@ getJasmineRequireObj().toHaveClasses = function(j$) { }; getJasmineRequireObj().toHaveNoOtherSpyInteractions = function(j$) { - const getErrorMsg = j$.formatErrorMsg( + const getErrorMsg = j$.private.formatErrorMsg( '', 'expect().toHaveNoOtherSpyInteractions()' ); @@ -7081,7 +7098,7 @@ getJasmineRequireObj().toHaveNoOtherSpyInteractions = function(j$) { compare: function(actual) { const result = {}; - if (!j$.isObject_(actual)) { + if (!j$.private.isObject(actual)) { throw new Error( getErrorMsg('Expected an object, but got ' + typeof actual + '.') ); @@ -7167,15 +7184,15 @@ getJasmineRequireObj().toHaveSize = function(j$) { }; if ( - j$.isA_('WeakSet', actual) || - j$.isWeakMap(actual) || - j$.isDataView(actual) + j$.private.isA('WeakSet', actual) || + j$.private.isWeakMap(actual) || + j$.private.isDataView(actual) ) { throw new Error('Cannot get size of ' + actual + '.'); } let actualSize; - if (j$.isSet(actual) || j$.isMap(actual)) { + if (j$.private.isSet(actual) || j$.private.isMap(actual)) { actualSize = actual.size; } else if (isLength(actual.length)) { actualSize = actual.length; @@ -7218,7 +7235,7 @@ getJasmineRequireObj().toHaveSize = function(j$) { }; getJasmineRequireObj().toHaveSpyInteractions = function(j$) { - const getErrorMsg = j$.formatErrorMsg( + const getErrorMsg = j$.private.formatErrorMsg( '', 'expect().toHaveSpyInteractions()' ); @@ -7237,7 +7254,7 @@ getJasmineRequireObj().toHaveSpyInteractions = function(j$) { compare: function(actual) { const result = {}; - if (!j$.isObject_(actual)) { + if (!j$.private.isObject(actual)) { throw new Error( getErrorMsg('Expected a spy object, but got ' + typeof actual + '.') ); @@ -7297,7 +7314,7 @@ getJasmineRequireObj().toHaveSpyInteractions = function(j$) { }; getJasmineRequireObj().toMatch = function(j$) { - const getErrorMsg = j$.formatErrorMsg( + const getErrorMsg = j$.private.formatErrorMsg( '', 'expect().toMatch( || )' ); @@ -7315,7 +7332,10 @@ getJasmineRequireObj().toMatch = function(j$) { function toMatch() { return { compare: function(actual, expected) { - if (!j$.isString_(expected) && !j$.isA_('RegExp', expected)) { + if ( + !j$.private.isString(expected) && + !j$.private.isA('RegExp', expected) + ) { throw new Error(getErrorMsg('Expected is not a String or a RegExp')); } @@ -7332,7 +7352,7 @@ getJasmineRequireObj().toMatch = function(j$) { }; getJasmineRequireObj().toThrow = function(j$) { - const getErrorMsg = j$.formatErrorMsg( + const getErrorMsg = j$.private.formatErrorMsg( '', 'expect(function() {}).toThrow()' ); @@ -7413,7 +7433,7 @@ getJasmineRequireObj().toThrow = function(j$) { }; getJasmineRequireObj().toThrowError = function(j$) { - const getErrorMsg = j$.formatErrorMsg( + const getErrorMsg = j$.private.formatErrorMsg( '', 'expect(function() {}).toThrowError(, )' ); @@ -7450,7 +7470,7 @@ getJasmineRequireObj().toThrowError = function(j$) { thrown = e; } - if (!j$.isError_(thrown)) { + if (!j$.private.isError(thrown)) { return fail(function() { return ( 'Expected function to throw an Error, but it threw ' + @@ -7493,7 +7513,7 @@ getJasmineRequireObj().toThrowError = function(j$) { match: function(error) { return pass( 'Expected function not to throw an Error, but it threw ' + - j$.fnNameFor(error) + + j$.private.fnNameFor(error) + '.' ); } @@ -7522,12 +7542,12 @@ getJasmineRequireObj().toThrowError = function(j$) { } const errorTypeDescription = errorType - ? j$.fnNameFor(errorType) + ? j$.private.fnNameFor(errorType) : 'an exception'; function thrownDescription(thrown) { const thrownName = errorType - ? j$.fnNameFor(thrown.constructor) + ? j$.private.fnNameFor(thrown.constructor) : 'an exception'; let thrownMessage = ''; @@ -7593,7 +7613,7 @@ getJasmineRequireObj().toThrowError = function(j$) { const Surrogate = function() {}; Surrogate.prototype = type.prototype; - return j$.isError_(new Surrogate()); + return j$.private.isError(new Surrogate()); } } @@ -7615,7 +7635,7 @@ getJasmineRequireObj().toThrowError = function(j$) { }; getJasmineRequireObj().toThrowMatching = function(j$) { - const usageError = j$.formatErrorMsg( + const usageError = j$.private.formatErrorMsg( '', 'expect(function() {}).toThrowMatching()' ); @@ -7669,7 +7689,7 @@ getJasmineRequireObj().toThrowMatching = function(j$) { function thrownDescription(thrown) { if (thrown && thrown.constructor) { return ( - j$.fnNameFor(thrown.constructor) + + j$.private.fnNameFor(thrown.constructor) + ' with message ' + matchersUtil.pp(thrown.message) ); @@ -7834,11 +7854,12 @@ 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$.ReportDispatcher; - const QueueRunner = deps.QueueRunner || j$.QueueRunner; - const globalErrors = deps.globalErrors || new j$.GlobalErrors(); + const ReportDispatcher = + deps.ReportDispatcher || j$.private.ReportDispatcher; + const QueueRunner = deps.QueueRunner || j$.private.QueueRunner; + const globalErrors = deps.globalErrors || new j$.private.GlobalErrors(); const dispatcher = new ReportDispatcher( - j$.reporterEvents, + j$.private.reporterEvents, function(queueRunnerOptions) { queueRunnerOptions = { ...queueRunnerOptions, @@ -7902,7 +7923,7 @@ getJasmineRequireObj().ParallelReportDispatcher = function(j$) { } }; - for (const eventName of j$.reporterEvents) { + for (const eventName of j$.private.reporterEvents) { self[eventName] = dispatcher[eventName].bind(dispatcher); } @@ -7940,7 +7961,7 @@ getJasmineRequireObj().makePrettyPrinter = function(j$) { this.emitScalar(''); } else if (value.jasmineToString) { this.emitScalar(value.jasmineToString(this.pp_)); - } else if (j$.isString_(value)) { + } else if (j$.private.isString(value)) { this.emitString(value); } else if (j$.isSpy(value)) { this.emitScalar('spy on ' + value.and.identity); @@ -7954,7 +7975,7 @@ getJasmineRequireObj().makePrettyPrinter = function(j$) { } else { this.emitScalar('Function'); } - } else if (j$.isDomNode(value)) { + } else if (j$.private.isDomNode(value)) { if (value.tagName) { this.emitDomElement(value); } else { @@ -7962,16 +7983,16 @@ getJasmineRequireObj().makePrettyPrinter = function(j$) { } } else if (value instanceof Date) { this.emitScalar('Date(' + value + ')'); - } else if (j$.isSet(value)) { + } else if (j$.private.isSet(value)) { this.emitSet(value); - } else if (j$.isMap(value)) { + } else if (j$.private.isMap(value)) { this.emitMap(value); - } else if (j$.isTypedArray_(value)) { + } else if (j$.private.isTypedArray(value)) { this.emitTypedArray(value); } else if ( value.toString && typeof value === 'object' && - !j$.isArray_(value) && + !j$.private.isArray(value) && hasCustomToString(value) ) { try { @@ -7983,12 +8004,15 @@ getJasmineRequireObj().makePrettyPrinter = function(j$) { } else if (this.seen.includes(value)) { this.emitScalar( '' ); - } else if (j$.isArray_(value) || j$.isA_('Object', value)) { + } else if ( + j$.private.isArray(value) || + j$.private.isA('Object', value) + ) { this.seen.push(value); - if (j$.isArray_(value)) { + if (j$.private.isArray(value)) { this.emitArray(value); } else { this.emitObject(value); @@ -8011,7 +8035,10 @@ getJasmineRequireObj().makePrettyPrinter = function(j$) { } iterateObject(obj, fn) { - const objKeys = j$.MatchersUtil.keys(obj, j$.isArray_(obj)); + const objKeys = j$.private.MatchersUtil.keys( + obj, + j$.private.isArray(obj) + ); const length = Math.min(objKeys.length, j$.MAX_PRETTY_PRINT_ARRAY_LENGTH); for (let i = 0; i < length; i++) { @@ -8120,7 +8147,7 @@ getJasmineRequireObj().makePrettyPrinter = function(j$) { const ctor = obj.constructor; const constructorName = typeof ctor === 'function' && obj instanceof ctor - ? j$.fnNameFor(obj.constructor) + ? j$.private.fnNameFor(obj.constructor) : 'null'; this.append(constructorName); @@ -8150,7 +8177,7 @@ getJasmineRequireObj().makePrettyPrinter = function(j$) { } emitTypedArray(arr) { - const constructorName = j$.fnNameFor(arr.constructor); + const constructorName = j$.private.fnNameFor(arr.constructor); const limitedArray = Array.prototype.slice.call( arr, 0, @@ -8219,7 +8246,7 @@ getJasmineRequireObj().makePrettyPrinter = function(j$) { // iframe, web worker) try { return ( - j$.isFunction_(value.toString) && + j$.private.isFunction(value.toString) && value.toString !== Object.prototype.toString && value.toString() !== Object.prototype.toString.call(value) ); @@ -8283,7 +8310,7 @@ getJasmineRequireObj().QueueRunner = function(j$) { function StopExecutionError() {} StopExecutionError.prototype = new Error(); - j$.StopExecutionError = StopExecutionError; + j$.private.StopExecutionError = StopExecutionError; function once(fn, onTwice) { let called = false; @@ -8336,7 +8363,7 @@ getJasmineRequireObj().QueueRunner = function(j$) { }; this.onException = attrs.onException || emptyFn; this.onMultipleDone = attrs.onMultipleDone || fallbackOnMultipleDone; - this.userContext = attrs.userContext || new j$.UserContext(); + this.userContext = attrs.userContext || new j$.private.UserContext(); this.timeout = attrs.timeout || { setTimeout: setTimeout, clearTimeout: clearTimeout @@ -8347,7 +8374,7 @@ getJasmineRequireObj().QueueRunner = function(j$) { popListener: emptyFn }; - const SkipPolicy = attrs.SkipPolicy || j$.NeverSkipPolicy; + const SkipPolicy = attrs.SkipPolicy || j$.private.NeverSkipPolicy; this.skipPolicy_ = new SkipPolicy(this.queueableFns); this.errored_ = false; @@ -8470,7 +8497,7 @@ getJasmineRequireObj().QueueRunner = function(j$) { if (queueableFn.fn.length === 0) { maybeThenable = queueableFn.fn.call(this.userContext); - if (maybeThenable && j$.isFunction_(maybeThenable.then)) { + if (maybeThenable && j$.private.isFunction(maybeThenable.then)) { maybeThenable.then( wrapInPromiseResolutionHandler(next), onPromiseRejection @@ -8540,11 +8567,11 @@ getJasmineRequireObj().QueueRunner = function(j$) { }; QueueRunner.prototype.diagnoseConflictingAsync_ = function(fn, retval) { - if (retval && j$.isFunction_(retval.then)) { + if (retval && j$.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$.isAsyncFunction_(fn)) { + if (j$.private.isAsyncFunction(fn)) { this.onException( new Error( 'An asynchronous before/it/after ' + @@ -8568,7 +8595,7 @@ getJasmineRequireObj().QueueRunner = function(j$) { function wrapInPromiseResolutionHandler(fn) { return function(maybeArg) { - if (j$.isError_(maybeArg)) { + if (j$.private.isError(maybeArg)) { fn(maybeArg); } else { fn(); @@ -8673,7 +8700,7 @@ getJasmineRequireObj().ReportDispatcher = function(j$) { return ReportDispatcher; }; -getJasmineRequireObj().reporterEvents = function() { +getJasmineRequireObj().reporterEvents = function(j$) { /** * Used to tell Jasmine what optional or uncommonly implemented features * the reporter supports. If not specified, the defaults described in @@ -9124,7 +9151,7 @@ getJasmineRequireObj().interface = function(jasmine, env) { return env.spyOnAllFunctions(obj, includeNonEnumerable); }, - jsApiReporter: new jasmine.JsApiReporter({ + jsApiReporter: new jasmine.private.JsApiReporter({ timer: new jasmine.Timer() }), @@ -9300,7 +9327,7 @@ getJasmineRequireObj().RunableResources = function(j$) { this.getCurrentRunableId_ = options.getCurrentRunableId; this.globalErrors_ = options.globalErrors; - this.spyFactory = new j$.SpyFactory( + this.spyFactory = new j$.private.SpyFactory( () => { if (this.getCurrentRunableId_()) { return this.customSpyStrategies(); @@ -9312,7 +9339,7 @@ getJasmineRequireObj().RunableResources = function(j$) { () => this.makeMatchersUtil() ); - this.spyRegistry = new j$.SpyRegistry({ + this.spyRegistry = new j$.private.SpyRegistry({ currentSpies: () => this.spies(), createSpy: (name, originalFn) => this.spyFactory.createSpy(name, originalFn) @@ -9343,7 +9370,7 @@ getJasmineRequireObj().RunableResources = function(j$) { ]; for (const k of toClone) { - newRes[k] = j$.util.clone(parentRes[k]); + newRes[k] = j$.private.util.clone(parentRes[k]); } } } @@ -9421,17 +9448,19 @@ getJasmineRequireObj().RunableResources = function(j$) { } makePrettyPrinter() { - return j$.makePrettyPrinter(this.customObjectFormatters()); + return j$.private.makePrettyPrinter(this.customObjectFormatters()); } makeMatchersUtil() { if (this.getCurrentRunableId_()) { - return new j$.MatchersUtil({ + return new j$.private.MatchersUtil({ customTesters: this.customEqualityTesters(), pp: this.makePrettyPrinter() }); } else { - return new j$.MatchersUtil({ pp: j$.basicPrettyPrinter_ }); + return new j$.private.MatchersUtil({ + pp: j$.private.basicPrettyPrinter + }); } } @@ -9475,7 +9504,7 @@ getJasmineRequireObj().Runner = function(j$) { this.#reportDispatcher = options.reportDispatcher; this.#getConfig = options.getConfig; this.#executedBefore = false; - this.#currentRunableTracker = new j$.CurrentRunableTracker(); + this.#currentRunableTracker = new j$.private.CurrentRunableTracker(); } currentSpec() { @@ -9515,9 +9544,9 @@ getJasmineRequireObj().Runner = function(j$) { } } - const order = new j$.Order({ + const order = new j$.private.Order({ random: config.random, - seed: j$.isNumber_(config.seed) ? config.seed + '' : config.seed + seed: j$.private.isNumber(config.seed) ? config.seed + '' : config.seed }); const treeProcessor = new this.#TreeProcessor({ @@ -9559,7 +9588,7 @@ getJasmineRequireObj().Runner = function(j$) { }); this.#currentRunableTracker.pushSuite(this.#topSuite); - const treeRunner = new j$.TreeRunner({ + const treeRunner = new j$.private.TreeRunner({ executionTree: this.#executionTree, globalErrors: this.#globalErrors, runableResources: this.#runableResources, @@ -9729,7 +9758,7 @@ getJasmineRequireObj().Spy = function(j$) { }, matchersUtil ), - callTracker = new j$.CallTracker(); + callTracker = new j$.private.CallTracker(); function makeFunc(length, fn) { switch (length) { @@ -9821,9 +9850,9 @@ getJasmineRequireObj().Spy = function(j$) { } function SpyStrategyDispatcher(strategyArgs, matchersUtil) { - const baseStrategy = new j$.SpyStrategy(strategyArgs); + const baseStrategy = new j$.private.SpyStrategy(strategyArgs); const argsStrategies = new StrategyDict(function() { - return new j$.SpyStrategy(strategyArgs); + return new j$.private.SpyStrategy(strategyArgs); }, matchersUtil); this.and = baseStrategy; @@ -9895,12 +9924,12 @@ getJasmineRequireObj().SpyFactory = function(j$) { getMatchersUtil ) { this.createSpy = function(name, originalFn) { - if (j$.isFunction_(name) && originalFn === undefined) { + if (j$.private.isFunction(name) && originalFn === undefined) { originalFn = name; name = originalFn.name; } - return j$.Spy(name, getMatchersUtil(), { + return j$.private.Spy(name, getMatchersUtil(), { originalFn, customStrategies: getCustomStrategies(), defaultStrategyFn: getDefaultStrategyFn() @@ -9909,7 +9938,7 @@ getJasmineRequireObj().SpyFactory = function(j$) { this.createSpyObj = function(baseName, methodNames, propertyNames) { const baseNameIsCollection = - j$.isObject_(baseName) || j$.isArray_(baseName); + j$.private.isObject(baseName) || j$.private.isArray(baseName); if (baseNameIsCollection) { propertyNames = methodNames; @@ -9955,11 +9984,11 @@ getJasmineRequireObj().SpyFactory = function(j$) { function normalizeKeyValues(object) { const result = []; - if (j$.isArray_(object)) { + if (j$.private.isArray(object)) { for (let i = 0; i < object.length; i++) { result.push([object[i]]); } - } else if (j$.isObject_(object)) { + } else if (j$.private.isObject(object)) { for (const key in object) { if (object.hasOwnProperty(key)) { result.push([key, object[key]]); @@ -9973,11 +10002,11 @@ getJasmineRequireObj().SpyFactory = function(j$) { }; getJasmineRequireObj().SpyRegistry = function(j$) { - const spyOnMsg = j$.formatErrorMsg( + const spyOnMsg = j$.private.formatErrorMsg( '', 'spyOn(, )' ); - const spyOnPropertyMsg = j$.formatErrorMsg( + const spyOnPropertyMsg = j$.private.formatErrorMsg( '', 'spyOnProperty(, , [accessType])' ); @@ -10017,7 +10046,10 @@ getJasmineRequireObj().SpyRegistry = function(j$) { // Spying on mock clock timing fns would prevent the real ones from being // restored. - if (obj[methodName] && obj[methodName][j$.Clock.IsMockClockTimingFn]) { + if ( + obj[methodName] && + obj[methodName][j$.private.Clock.IsMockClockTimingFn] + ) { throw new Error("Mock clock timing functions can't be spied on"); } @@ -10068,7 +10100,7 @@ getJasmineRequireObj().SpyRegistry = function(j$) { // localStorage in Firefox and later Safari versions, have no-op setters. if (obj[methodName] !== spiedMethod) { throw new Error( - j$.formatErrorMsg('')( + j$.private.formatErrorMsg('')( `Can't spy on ${methodName} because assigning to it had no effect` ) ); @@ -10096,7 +10128,10 @@ getJasmineRequireObj().SpyRegistry = function(j$) { throw new Error(getErrorMsg('No property name supplied')); } - const descriptor = j$.util.getPropertyDescriptor(obj, propertyName); + const descriptor = j$.private.util.getPropertyDescriptor( + obj, + propertyName + ); if (!descriptor) { throw new Error(getErrorMsg(propertyName + ' property does not exist')); @@ -10131,7 +10166,7 @@ getJasmineRequireObj().SpyRegistry = function(j$) { } } - const originalDescriptor = j$.util.clone(descriptor); + const originalDescriptor = j$.private.util.clone(descriptor); const spy = createSpy(propertyName, descriptor[accessType]); let restoreStrategy; @@ -10268,7 +10303,7 @@ getJasmineRequireObj().SpyStrategy = function(j$) { const cs = options.customStrategies || {}; for (const k in cs) { - if (j$.util.has(cs, k) && !this[k]) { + if (j$.private.util.has(cs, k) && !this[k]) { this[k] = createCustomPlan(cs[k]); } } @@ -10306,7 +10341,7 @@ getJasmineRequireObj().SpyStrategy = function(j$) { return function() { const plan = factory.apply(null, arguments); - if (!j$.isFunction_(plan)) { + if (!j$.private.isFunction(plan)) { throw new Error('Spy strategy must return a function'); } @@ -10378,7 +10413,9 @@ getJasmineRequireObj().SpyStrategy = function(j$) { * @param {Error|Object|String} something Thing to throw */ SpyStrategy.prototype.throwError = function(something) { - const error = j$.isString_(something) ? new Error(something) : something; + const error = j$.private.isString(something) + ? new Error(something) + : something; this.plan = function() { throw error; }; @@ -10395,9 +10432,9 @@ getJasmineRequireObj().SpyStrategy = function(j$) { SpyStrategy.prototype.callFake = function(fn) { if ( !( - j$.isFunction_(fn) || - j$.isAsyncFunction_(fn) || - j$.isGeneratorFunction_(fn) + j$.private.isFunction(fn) || + j$.private.isAsyncFunction(fn) || + j$.private.isGeneratorFunction(fn) ) ) { throw new Error( @@ -10594,8 +10631,8 @@ 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. - j$.util.assertStructuredCloneable(key, 'Key'); - j$.util.assertStructuredCloneable(value, 'Value'); + j$.private.util.assertStructuredCloneable(key, 'Key'); + j$.private.util.assertStructuredCloneable(value, 'Value'); this.result.properties = this.result.properties || {}; this.result.properties[key] = value; } @@ -10730,18 +10767,18 @@ getJasmineRequireObj().Suite = function(j$) { if (!this.sharedContext) { this.sharedContext = this.parentSuite ? this.parentSuite.clonedSharedUserContext() - : new j$.UserContext(); + : new j$.private.UserContext(); } return this.sharedContext; } clonedSharedUserContext() { - return j$.UserContext.fromExisting(this.sharedUserContext()); + return j$.private.UserContext.fromExisting(this.sharedUserContext()); } handleException() { - if (arguments[0] instanceof j$.errors.ExpectationFailed) { + if (arguments[0] instanceof j$.private.errors.ExpectationFailed) { return; } @@ -10750,7 +10787,7 @@ getJasmineRequireObj().Suite = function(j$) { passed: false, error: arguments[0] }; - const failedExpectation = j$.buildExpectationResult(data); + const failedExpectation = j$.private.buildExpectationResult(data); if (!this.parentSuite) { failedExpectation.globalErrorType = 'afterAll'; @@ -10792,7 +10829,7 @@ getJasmineRequireObj().Suite = function(j$) { return; } - const expectationResult = j$.buildExpectationResult(data); + const expectationResult = j$.private.buildExpectationResult(data); if (this.reportedDone) { this.onLateError(expectationResult); @@ -10806,7 +10843,7 @@ getJasmineRequireObj().Suite = function(j$) { } if (this.#throwOnExpectationFailure) { - throw new j$.errors.ExpectationFailed(); + throw new j$.private.errors.ExpectationFailed(); } } @@ -10815,7 +10852,7 @@ getJasmineRequireObj().Suite = function(j$) { deprecation = { message: deprecation }; } this.result.deprecationWarnings.push( - j$.buildExpectationResult(deprecation) + j$.private.buildExpectationResult(deprecation) ); } @@ -11000,7 +11037,7 @@ getJasmineRequireObj().SuiteBuilder = function(j$) { ensureIsFunctionOrAsync(fn, 'fit'); if (timeout) { - j$.util.validateTimeout(timeout); + j$.private.util.validateTimeout(timeout); } const spec = this.specFactory_(description, fn, timeout, filename); this.currentDeclarationSuite_.addChild(spec); @@ -11013,7 +11050,7 @@ getJasmineRequireObj().SuiteBuilder = function(j$) { ensureIsFunctionOrAsync(beforeEachFunction, 'beforeEach'); if (timeout) { - j$.util.validateTimeout(timeout); + j$.private.util.validateTimeout(timeout); } this.currentDeclarationSuite_.beforeEach({ @@ -11026,7 +11063,7 @@ getJasmineRequireObj().SuiteBuilder = function(j$) { ensureIsFunctionOrAsync(beforeAllFunction, 'beforeAll'); if (timeout) { - j$.util.validateTimeout(timeout); + j$.private.util.validateTimeout(timeout); } this.currentDeclarationSuite_.beforeAll({ @@ -11039,7 +11076,7 @@ getJasmineRequireObj().SuiteBuilder = function(j$) { ensureIsFunctionOrAsync(afterEachFunction, 'afterEach'); if (timeout) { - j$.util.validateTimeout(timeout); + j$.private.util.validateTimeout(timeout); } afterEachFunction.isCleanup = true; @@ -11053,7 +11090,7 @@ getJasmineRequireObj().SuiteBuilder = function(j$) { ensureIsFunctionOrAsync(afterAllFunction, 'afterAll'); if (timeout) { - j$.util.validateTimeout(timeout); + j$.private.util.validateTimeout(timeout); } this.currentDeclarationSuite_.afterAll({ @@ -11064,7 +11101,7 @@ getJasmineRequireObj().SuiteBuilder = function(j$) { it_(description, fn, timeout, filename) { if (timeout) { - j$.util.validateTimeout(timeout); + j$.private.util.validateTimeout(timeout); } this.checkDuplicate_(description, 'spec'); @@ -11103,7 +11140,7 @@ getJasmineRequireObj().SuiteBuilder = function(j$) { const parentSuite = this.currentDeclarationSuite_; const reportedParentSuiteId = parentSuite === this.topSuite ? null : parentSuite.id; - return new j$.Suite({ + return new j$.private.Suite({ id: 'suite' + this.nextSuiteId_++, description, filename, @@ -11145,7 +11182,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$.Spec({ + const spec = new j$.private.Spec({ id: 'spec' + this.nextSpecId_++, filename, parentSuiteId, @@ -11208,17 +11245,21 @@ getJasmineRequireObj().SuiteBuilder = function(j$) { } function ensureIsFunction(fn, caller) { - if (!j$.isFunction_(fn)) { + if (!j$.private.isFunction(fn)) { throw new Error( - caller + ' expects a function argument; received ' + j$.getType_(fn) + caller + + ' expects a function argument; received ' + + j$.private.getType(fn) ); } } function ensureIsFunctionOrAsync(fn, caller) { - if (!j$.isFunction_(fn) && !j$.isAsyncFunction_(fn)) { + if (!j$.private.isFunction(fn) && !j$.private.isAsyncFunction(fn)) { throw new Error( - caller + ' expects a function argument; received ' + j$.getType_(fn) + caller + + ' expects a function argument; received ' + + j$.private.getType(fn) ); } } @@ -11587,14 +11628,14 @@ getJasmineRequireObj().TreeRunner = function(j$) { }, onComplete: () => { if (spec.result.status === 'failed') { - specOverallDone(new j$.StopExecutionError('spec failed')); + specOverallDone(new j$.private.StopExecutionError('spec failed')); } else { specOverallDone(); } }, userContext: spec.userContext(), runnableName: spec.getFullName.bind(spec), - SkipPolicy: j$.CompleteOnFirstErrorSkipPolicy + SkipPolicy: j$.private.CompleteOnFirstErrorSkipPolicy }); } @@ -11769,7 +11810,7 @@ getJasmineRequireObj().TreeRunner = function(j$) { async #reportChildrenOfBeforeAllFailure(suite) { for (const child of suite.children) { - if (child instanceof j$.Suite) { + if (child instanceof j$.private.Suite) { await this.#reportDispatcher.suiteStarted(child.result); await this.#reportChildrenOfBeforeAllFailure(child); @@ -11801,9 +11842,9 @@ getJasmineRequireObj().TreeRunner = function(j$) { #suiteSkipPolicy() { if (this.#getConfig().stopOnSpecFailure) { - return j$.CompleteOnFirstErrorSkipPolicy; + return j$.private.CompleteOnFirstErrorSkipPolicy; } else { - return j$.SkipAfterBeforeAllErrorPolicy; + return j$.private.SkipAfterBeforeAllErrorPolicy; } } } diff --git a/release_notes/3.9.0.md b/release_notes/3.9.0.md index ca12f32b..79ec1111 100644 --- a/release_notes/3.9.0.md +++ b/release_notes/3.9.0.md @@ -2,7 +2,7 @@ ## New features and bug fixes -* Fixed Trusted Types error in `j$.isError_` in Chromium-based browsers +* Fixed Trusted Types error in `j$.private.isError` in Chromium-based browsers * Merges [#1921](https://github.com/jasmine/jasmine/pull/1921) from @bjarkler * Fixes [#1910](https://github.com/jasmine/jasmine/issues/1910) * Fixes [#1653](https://github.com/jasmine/jasmine/issues/1653) diff --git a/spec/core/AsyncExpectationSpec.js b/spec/core/AsyncExpectationSpec.js index dc687f53..e7653b4e 100644 --- a/spec/core/AsyncExpectationSpec.js +++ b/spec/core/AsyncExpectationSpec.js @@ -1,7 +1,7 @@ describe('AsyncExpectation', function() { beforeEach(function() { - jasmineUnderTest.Expectation.addAsyncCoreMatchers( - jasmineUnderTest.asyncMatchers + privateUnderTest.Expectation.addAsyncCoreMatchers( + privateUnderTest.asyncMatchers ); }); @@ -9,9 +9,9 @@ describe('AsyncExpectation', function() { it('converts a pass to a fail', function() { const addExpectationResult = jasmine.createSpy('addExpectationResult'), actual = Promise.resolve(), - pp = jasmineUnderTest.makePrettyPrinter(), - expectation = jasmineUnderTest.Expectation.asyncFactory({ - matchersUtil: new jasmineUnderTest.MatchersUtil({ pp: pp }), + pp = privateUnderTest.makePrettyPrinter(), + expectation = privateUnderTest.Expectation.asyncFactory({ + matchersUtil: new privateUnderTest.MatchersUtil({ pp: pp }), actual: actual, addExpectationResult: addExpectationResult }); @@ -30,8 +30,8 @@ describe('AsyncExpectation', function() { it('converts a fail to a pass', function() { const addExpectationResult = jasmine.createSpy('addExpectationResult'), actual = Promise.reject(new Error('nope')), - expectation = jasmineUnderTest.Expectation.asyncFactory({ - matchersUtil: new jasmineUnderTest.MatchersUtil({ + expectation = privateUnderTest.Expectation.asyncFactory({ + matchersUtil: new privateUnderTest.MatchersUtil({ pp: function() {} }), actual: actual, @@ -55,7 +55,7 @@ describe('AsyncExpectation', function() { const addExpectationResult = jasmine.createSpy('addExpectationResult'), actual = dummyPromise(), - expectation = jasmineUnderTest.Expectation.asyncFactory({ + expectation = privateUnderTest.Expectation.asyncFactory({ actual: actual, addExpectationResult: addExpectationResult }); @@ -80,7 +80,7 @@ describe('AsyncExpectation', function() { } }, addExpectationResult = jasmine.createSpy('addExpectationResult'), - expectation = jasmineUnderTest.Expectation.asyncFactory({ + expectation = privateUnderTest.Expectation.asyncFactory({ actual: Promise.reject('rejected'), addExpectationResult: addExpectationResult, matchersUtil: matchersUtil @@ -105,10 +105,10 @@ describe('AsyncExpectation', function() { buildFailureMessage: function() { return 'failure message'; }, - pp: jasmineUnderTest.makePrettyPrinter() + pp: privateUnderTest.makePrettyPrinter() }, addExpectationResult = jasmine.createSpy('addExpectationResult'), - expectation = jasmineUnderTest.Expectation.asyncFactory({ + expectation = privateUnderTest.Expectation.asyncFactory({ actual: Promise.reject('b'), addExpectationResult: addExpectationResult, matchersUtil: matchersUtil @@ -140,7 +140,7 @@ describe('AsyncExpectation', function() { }; const addExpectationResult = jasmine.createSpy('addExpectationResult'); const actual = Promise.reject(new Error('nope')); - const expectation = jasmineUnderTest.Expectation.asyncFactory({ + const expectation = privateUnderTest.Expectation.asyncFactory({ actual: actual, addExpectationResult: addExpectationResult, matchersUtil: matchersUtil @@ -161,11 +161,11 @@ describe('AsyncExpectation', function() { it('works with #not', function() { const addExpectationResult = jasmine.createSpy('addExpectationResult'), actual = Promise.resolve(), - pp = jasmineUnderTest.makePrettyPrinter(), - expectation = jasmineUnderTest.Expectation.asyncFactory({ + pp = privateUnderTest.makePrettyPrinter(), + expectation = privateUnderTest.Expectation.asyncFactory({ actual: actual, addExpectationResult: addExpectationResult, - matchersUtil: new jasmineUnderTest.MatchersUtil({ pp: pp }) + matchersUtil: new privateUnderTest.MatchersUtil({ pp: pp }) }); return expectation @@ -185,11 +185,11 @@ describe('AsyncExpectation', function() { it('works with #not and a custom message', function() { const addExpectationResult = jasmine.createSpy('addExpectationResult'), actual = Promise.resolve('a'), - expectation = jasmineUnderTest.Expectation.asyncFactory({ + expectation = privateUnderTest.Expectation.asyncFactory({ actual: actual, addExpectationResult: addExpectationResult, - matchersUtil: new jasmineUnderTest.MatchersUtil({ - pp: jasmineUnderTest.makePrettyPrinter() + matchersUtil: new privateUnderTest.MatchersUtil({ + pp: privateUnderTest.makePrettyPrinter() }) }); @@ -214,7 +214,7 @@ describe('AsyncExpectation', function() { toFoo: function() {}, toBar: function() {} }, - expectation = jasmineUnderTest.Expectation.asyncFactory({ + expectation = privateUnderTest.Expectation.asyncFactory({ customAsyncMatchers: asyncMatchers }); @@ -236,7 +236,7 @@ describe('AsyncExpectation', function() { buildFailureMessage: jasmine.createSpy('buildFailureMessage') }, addExpectationResult = jasmine.createSpy('addExpectationResult'), - expectation = jasmineUnderTest.Expectation.asyncFactory({ + expectation = privateUnderTest.Expectation.asyncFactory({ matchersUtil: matchersUtil, customAsyncMatchers: matchers, actual: 'an actual', @@ -263,7 +263,7 @@ describe('AsyncExpectation', function() { buildFailureMessage: jasmine.createSpy('buildFailureMessage') }, addExpectationResult = jasmine.createSpy('addExpectationResult'), - expectation = jasmineUnderTest.Expectation.asyncFactory({ + expectation = privateUnderTest.Expectation.asyncFactory({ matchersUtil: matchersUtil, customAsyncMatchers: matchers, actual: 'an actual', @@ -290,7 +290,7 @@ describe('AsyncExpectation', function() { }; const addExpectationResult = jasmine.createSpy('addExpectationResult'); - const expectation = jasmineUnderTest.Expectation.asyncFactory({ + const expectation = privateUnderTest.Expectation.asyncFactory({ customAsyncMatchers: matchers, matchersUtil: matchersUtil, actual: 'an actual', @@ -325,7 +325,7 @@ describe('AsyncExpectation', function() { }; const addExpectationResult = jasmine.createSpy('addExpectationResult'); - const expectation = jasmineUnderTest.Expectation.asyncFactory({ + const expectation = privateUnderTest.Expectation.asyncFactory({ customAsyncMatchers: matchers, matchersUtil: matchersUtil, actual: 'an actual', @@ -358,7 +358,7 @@ describe('AsyncExpectation', function() { }; const addExpectationResult = jasmine.createSpy('addExpectationResult'); - const expectation = jasmineUnderTest.Expectation.asyncFactory({ + const expectation = privateUnderTest.Expectation.asyncFactory({ actual: 'an actual', customAsyncMatchers: matchers, addExpectationResult: addExpectationResult @@ -392,7 +392,7 @@ describe('AsyncExpectation', function() { }; const addExpectationResult = jasmine.createSpy('addExpectationResult'); - const expectation = jasmineUnderTest.Expectation.asyncFactory({ + const expectation = privateUnderTest.Expectation.asyncFactory({ customAsyncMatchers: matchers, actual: 'an actual', addExpectationResult: addExpectationResult @@ -421,7 +421,7 @@ describe('AsyncExpectation', function() { }; const addExpectationResult = jasmine.createSpy('addExpectationResult'); - const expectation = jasmineUnderTest.Expectation.asyncFactory({ + const expectation = privateUnderTest.Expectation.asyncFactory({ customAsyncMatchers: matchers, actual: 'an actual', addExpectationResult: addExpectationResult @@ -455,7 +455,7 @@ describe('AsyncExpectation', function() { }; const addExpectationResult = jasmine.createSpy('addExpectationResult'); - const expectation = jasmineUnderTest.Expectation.asyncFactory({ + const expectation = privateUnderTest.Expectation.asyncFactory({ customAsyncMatchers: matchers, actual: 'an actual', matchersUtil: matchersUtil, @@ -488,7 +488,7 @@ describe('AsyncExpectation', function() { }; const addExpectationResult = jasmine.createSpy('addExpectationResult'); - const expectation = jasmineUnderTest.Expectation.asyncFactory({ + const expectation = privateUnderTest.Expectation.asyncFactory({ customAsyncMatchers: matchers, actual: 'an actual', addExpectationResult: addExpectationResult @@ -520,7 +520,7 @@ describe('AsyncExpectation', function() { }; const addExpectationResult = jasmine.createSpy('addExpectationResult'); - const expectation = jasmineUnderTest.Expectation.asyncFactory({ + const expectation = privateUnderTest.Expectation.asyncFactory({ customAsyncMatchers: matchers, actual: 'an actual', addExpectationResult: addExpectationResult @@ -555,7 +555,7 @@ describe('AsyncExpectation', function() { }; const addExpectationResult = jasmine.createSpy('addExpectationResult'); - const expectation = jasmineUnderTest.Expectation.asyncFactory({ + const expectation = privateUnderTest.Expectation.asyncFactory({ customAsyncMatchers: matchers, actual: 'an actual', addExpectationResult: addExpectationResult @@ -589,7 +589,7 @@ describe('AsyncExpectation', function() { }; const addExpectationResult = jasmine.createSpy('addExpectationResult'); - const expectation = jasmineUnderTest.Expectation.asyncFactory({ + const expectation = privateUnderTest.Expectation.asyncFactory({ actual: 'an actual', customAsyncMatchers: matchers, addExpectationResult: addExpectationResult @@ -621,7 +621,7 @@ describe('AsyncExpectation', function() { }; const addExpectationResult = jasmine.createSpy('addExpectationResult'); - const expectation = jasmineUnderTest.Expectation.asyncFactory({ + const expectation = privateUnderTest.Expectation.asyncFactory({ actual: 'an actual', customAsyncMatchers: matchers, addExpectationResult: addExpectationResult @@ -655,7 +655,7 @@ describe('AsyncExpectation', function() { }; const addExpectationResult = jasmine.createSpy('addExpectationResult'); - let expectation = jasmineUnderTest.Expectation.asyncFactory({ + let expectation = privateUnderTest.Expectation.asyncFactory({ actual: 'an actual', customAsyncMatchers: matchers, addExpectationResult: addExpectationResult diff --git a/spec/core/CallTrackerSpec.js b/spec/core/CallTrackerSpec.js index 55541b72..07d6d83d 100644 --- a/spec/core/CallTrackerSpec.js +++ b/spec/core/CallTrackerSpec.js @@ -1,6 +1,6 @@ describe('CallTracker', function() { it('tracks that it was called when executed', function() { - const callTracker = new jasmineUnderTest.CallTracker(); + const callTracker = new privateUnderTest.CallTracker(); expect(callTracker.any()).toBe(false); @@ -10,7 +10,7 @@ describe('CallTracker', function() { }); it('tracks that number of times that it is executed', function() { - const callTracker = new jasmineUnderTest.CallTracker(); + const callTracker = new privateUnderTest.CallTracker(); expect(callTracker.count()).toEqual(0); @@ -20,7 +20,7 @@ describe('CallTracker', function() { }); it('tracks the params from each execution', function() { - const callTracker = new jasmineUnderTest.CallTracker(); + const callTracker = new privateUnderTest.CallTracker(); callTracker.track({ object: void 0, args: [] }); callTracker.track({ object: {}, args: [0, 'foo'] }); @@ -31,7 +31,7 @@ describe('CallTracker', function() { }); it("tracks the 'this' object from each execution", function() { - const callTracker = new jasmineUnderTest.CallTracker(); + const callTracker = new privateUnderTest.CallTracker(); const this0 = {}, this1 = {}; @@ -45,13 +45,13 @@ describe('CallTracker', function() { }); it('returns any empty array when there was no call', function() { - const callTracker = new jasmineUnderTest.CallTracker(); + const callTracker = new privateUnderTest.CallTracker(); expect(callTracker.argsFor(0)).toEqual([]); }); it('allows access for the arguments for all calls', function() { - const callTracker = new jasmineUnderTest.CallTracker(); + const callTracker = new privateUnderTest.CallTracker(); callTracker.track({ object: {}, args: [] }); callTracker.track({ object: {}, args: [0, 'foo'] }); @@ -60,7 +60,7 @@ describe('CallTracker', function() { }); it('tracks the context and arguments for each call', function() { - const callTracker = new jasmineUnderTest.CallTracker(); + const callTracker = new privateUnderTest.CallTracker(); callTracker.track({ object: {}, args: [] }); callTracker.track({ object: {}, args: [0, 'foo'] }); @@ -71,7 +71,7 @@ describe('CallTracker', function() { }); it('simplifies access to the arguments for the last (most recent) call', function() { - const callTracker = new jasmineUnderTest.CallTracker(); + const callTracker = new privateUnderTest.CallTracker(); callTracker.track(); callTracker.track({ object: {}, args: [0, 'foo'] }); @@ -83,13 +83,13 @@ describe('CallTracker', function() { }); it("returns a useful falsy value when there isn't a last (most recent) call", function() { - const callTracker = new jasmineUnderTest.CallTracker(); + const callTracker = new privateUnderTest.CallTracker(); expect(callTracker.mostRecent()).toBeFalsy(); }); it('simplifies access to the arguments for the first (oldest) call', function() { - const callTracker = new jasmineUnderTest.CallTracker(); + const callTracker = new privateUnderTest.CallTracker(); callTracker.track({ object: {}, args: [0, 'foo'] }); @@ -97,13 +97,13 @@ describe('CallTracker', function() { }); it("returns a useful falsy value when there isn't a first (oldest) call", function() { - const callTracker = new jasmineUnderTest.CallTracker(); + const callTracker = new privateUnderTest.CallTracker(); expect(callTracker.first()).toBeFalsy(); }); it('allows the tracking to be reset', function() { - const callTracker = new jasmineUnderTest.CallTracker(); + const callTracker = new privateUnderTest.CallTracker(); callTracker.track(); callTracker.track({ object: {}, args: [0, 'foo'] }); @@ -117,7 +117,7 @@ describe('CallTracker', function() { }); it('allows object arguments to be shallow cloned', function() { - const callTracker = new jasmineUnderTest.CallTracker(); + const callTracker = new privateUnderTest.CallTracker(); callTracker.saveArgumentsByValue(); const objectArg = { foo: 'bar' }, @@ -135,7 +135,7 @@ describe('CallTracker', function() { }); it('allows object arguments to be deep cloned', function() { - const callTracker = new jasmineUnderTest.CallTracker(); + const callTracker = new privateUnderTest.CallTracker(); callTracker.saveArgumentsByValue(args => JSON.parse(JSON.stringify(args))); const objectArg = { foo: { bar: { baz: ['qux'] } } }, @@ -158,7 +158,7 @@ describe('CallTracker', function() { }); it('can take any function to transform arguments when saving by value', function() { - const callTracker = new jasmineUnderTest.CallTracker(); + const callTracker = new privateUnderTest.CallTracker(); callTracker.saveArgumentsByValue(JSON.stringify); const objectArg = { foo: { bar: { baz: ['qux'] } } }, @@ -171,7 +171,7 @@ describe('CallTracker', function() { }); it('saves primitive arguments by value', function() { - const callTracker = new jasmineUnderTest.CallTracker(), + const callTracker = new privateUnderTest.CallTracker(), args = [undefined, null, false, '', /\s/, 0, 1.2, NaN]; callTracker.saveArgumentsByValue(); diff --git a/spec/core/ClearStackSpec.js b/spec/core/ClearStackSpec.js index 1fa06c73..8b2aff34 100644 --- a/spec/core/ClearStackSpec.js +++ b/spec/core/ClearStackSpec.js @@ -1,6 +1,6 @@ describe('ClearStack', function() { it('works in an integrationy way', function(done) { - const clearStack = jasmineUnderTest.getClearStack( + const clearStack = privateUnderTest.getClearStack( jasmineUnderTest.getGlobal() ); @@ -36,7 +36,7 @@ describe('ClearStack', function() { queueMicrotask }; - const clearStack = jasmineUnderTest.getClearStack(global); + const clearStack = privateUnderTest.getClearStack(global); for (let i = 0; i < 9; i++) { clearStack(function() {}); @@ -104,7 +104,7 @@ describe('ClearStack', function() { ...makeGlobal(), MessageChannel: fakeMessageChannel }; - const clearStack = jasmineUnderTest.getClearStack(global); + const clearStack = privateUnderTest.getClearStack(global); let called = false; clearStack(function() { @@ -125,7 +125,7 @@ describe('ClearStack', function() { return fakeChannel; } }; - const clearStack = jasmineUnderTest.getClearStack(global); + const clearStack = privateUnderTest.getClearStack(global); for (let i = 0; i < 9; i++) { clearStack(function() {}); @@ -150,7 +150,7 @@ describe('ClearStack', function() { setTimeout, MessageChannel: fakeMessageChannel }; - const clearStack = jasmineUnderTest.getClearStack(global); + const clearStack = privateUnderTest.getClearStack(global); const fn = jasmine.createSpy('second clearStack function'); clearStack(function() { @@ -170,7 +170,7 @@ describe('ClearStack', function() { fn(); } }; - const clearStack = jasmineUnderTest.getClearStack(global); + const clearStack = privateUnderTest.getClearStack(global); let called = false; clearStack(function() { @@ -188,7 +188,7 @@ describe('ClearStack', function() { queueMicrotask, setTimeout }; - const clearStack = jasmineUnderTest.getClearStack(global); + const clearStack = privateUnderTest.getClearStack(global); for (let i = 0; i < 9; i++) { clearStack(function() {}); @@ -215,7 +215,7 @@ describe('ClearStack', function() { fn(); } }; - const clearStack = jasmineUnderTest.getClearStack(global); + const clearStack = privateUnderTest.getClearStack(global); let called = false; clearStack(function() { @@ -233,7 +233,7 @@ describe('ClearStack', function() { queueMicrotask, setTimeout }; - const clearStack = jasmineUnderTest.getClearStack(global); + const clearStack = privateUnderTest.getClearStack(global); clearStack(function() {}); clearStack(function() {}); diff --git a/spec/core/ClockSpec.js b/spec/core/ClockSpec.js index 2fb48d65..a4d92f85 100644 --- a/spec/core/ClockSpec.js +++ b/spec/core/ClockSpec.js @@ -17,7 +17,7 @@ describe('Clock', function() { tick: function() {}, uninstall: function() {} }, - clock = new jasmineUnderTest.Clock( + clock = new privateUnderTest.Clock( fakeGlobal, function() { return delayedFunctionScheduler; @@ -51,7 +51,7 @@ describe('Clock', function() { tick: function() {}, uninstall: function() {} }, - clock = new jasmineUnderTest.Clock( + clock = new privateUnderTest.Clock( fakeGlobal, function() { return delayedFunctionScheduler; @@ -88,7 +88,7 @@ describe('Clock', function() { tick: function() {}, uninstall: function() {} }, - clock = new jasmineUnderTest.Clock( + clock = new privateUnderTest.Clock( fakeGlobal, function() { return delayedFunctionScheduler; @@ -122,7 +122,7 @@ describe('Clock', function() { tick: function() {}, uninstall: function() {} }, - clock = new jasmineUnderTest.Clock( + clock = new privateUnderTest.Clock( fakeGlobal, function() { return delayedFunctionScheduler; @@ -154,7 +154,7 @@ describe('Clock', function() { 'delayedFunctionSchedulerFactory' ), mockDate = {}, - clock = new jasmineUnderTest.Clock( + clock = new privateUnderTest.Clock( fakeGlobal, delayedFunctionSchedulerFactory, mockDate @@ -178,7 +178,7 @@ describe('Clock', function() { 'delayedFunctionSchedulerFactory' ), mockDate = {}, - clock = new jasmineUnderTest.Clock( + clock = new privateUnderTest.Clock( fakeGlobal, delayedFunctionSchedulerFactory, mockDate @@ -202,7 +202,7 @@ describe('Clock', function() { 'delayedFunctionSchedulerFactory' ), mockDate = {}, - clock = new jasmineUnderTest.Clock( + clock = new privateUnderTest.Clock( fakeGlobal, delayedFunctionSchedulerFactory, mockDate @@ -226,7 +226,7 @@ describe('Clock', function() { 'delayedFunctionSchedulerFactory' ), mockDate = {}, - clock = new jasmineUnderTest.Clock( + clock = new privateUnderTest.Clock( fakeGlobal, delayedFunctionSchedulerFactory, mockDate @@ -263,7 +263,7 @@ describe('Clock', function() { tick: function() {}, uninstall: function() {} }, - clock = new jasmineUnderTest.Clock( + clock = new privateUnderTest.Clock( fakeGlobal, function() { return delayedFunctionScheduler; @@ -306,7 +306,7 @@ describe('Clock', function() { tick: function() {}, uninstall: function() {} }, - clock = new jasmineUnderTest.Clock( + clock = new privateUnderTest.Clock( fakeGlobal, function() { return delayedFunctionScheduler; @@ -366,7 +366,7 @@ describe('Clock', function() { tick: function() {}, uninstall: function() {} }, - clock = new jasmineUnderTest.Clock( + clock = new privateUnderTest.Clock( fakeGlobal, function() { return delayedFunctionScheduler; @@ -420,7 +420,7 @@ describe('Clock', function() { tick: function() {}, uninstall: function() {} }; - const clock = new jasmineUnderTest.Clock( + const clock = new privateUnderTest.Clock( fakeGlobal, function() { return delayedFunctionScheduler; @@ -430,16 +430,16 @@ describe('Clock', function() { clock.install(); expect( - fakeGlobal.setTimeout[jasmineUnderTest.Clock.IsMockClockTimingFn] + fakeGlobal.setTimeout[privateUnderTest.Clock.IsMockClockTimingFn] ).toEqual(true); expect( - fakeGlobal.clearTimeout[jasmineUnderTest.Clock.IsMockClockTimingFn] + fakeGlobal.clearTimeout[privateUnderTest.Clock.IsMockClockTimingFn] ).toEqual(true); expect( - fakeGlobal.setInterval[jasmineUnderTest.Clock.IsMockClockTimingFn] + fakeGlobal.setInterval[privateUnderTest.Clock.IsMockClockTimingFn] ).toEqual(true); expect( - fakeGlobal.clearInterval[jasmineUnderTest.Clock.IsMockClockTimingFn] + fakeGlobal.clearInterval[privateUnderTest.Clock.IsMockClockTimingFn] ).toEqual(true); }); @@ -455,7 +455,7 @@ describe('Clock', function() { tick: function() {}, uninstall: function() {} }, - clock = new jasmineUnderTest.Clock( + clock = new privateUnderTest.Clock( fakeGlobal, function() { return delayedFunctionScheduler; @@ -500,7 +500,7 @@ describe('Clock', function() { tick: function() {}, uninstall: function() {} }, - clock = new jasmineUnderTest.Clock( + clock = new privateUnderTest.Clock( fakeGlobal, function() { return delayedFunctionScheduler; @@ -532,7 +532,7 @@ describe('Clock', function() { tick: function() {}, uninstall: function() {} }, - clock = new jasmineUnderTest.Clock( + clock = new privateUnderTest.Clock( fakeGlobal, function() { return delayedFunctionScheduler; @@ -562,7 +562,7 @@ describe('Clock', function() { tick: function() {}, uninstall: function() {} }, - clock = new jasmineUnderTest.Clock( + clock = new privateUnderTest.Clock( fakeGlobal, function() { return delayedFunctionScheduler; @@ -608,7 +608,7 @@ describe('Clock', function() { tick: function() {}, uninstall: function() {} }, - clock = new jasmineUnderTest.Clock( + clock = new privateUnderTest.Clock( fakeGlobal, function() { return delayedFunctionScheduler; @@ -640,7 +640,7 @@ describe('Clock', function() { tick: function() {}, uninstall: function() {} }, - clock = new jasmineUnderTest.Clock( + clock = new privateUnderTest.Clock( fakeGlobal, function() { return delayedFunctionScheduler; @@ -659,7 +659,7 @@ describe('Clock', function() { }); it('gives you a friendly reminder if the Clock is not installed and you tick', function() { - const clock = new jasmineUnderTest.Clock( + const clock = new privateUnderTest.Clock( {}, jasmine.createSpyObj('delayedFunctionScheduler', ['tick']) ); @@ -675,13 +675,13 @@ describe('Clock (acceptance)', function() { delayedFn2 = jasmine.createSpy('delayedFn2'), delayedFn3 = jasmine.createSpy('delayedFn3'), recurring1 = jasmine.createSpy('recurring1'), - delayedFunctionScheduler = new jasmineUnderTest.DelayedFunctionScheduler(), + delayedFunctionScheduler = new privateUnderTest.DelayedFunctionScheduler(), mockDate = { install: function() {}, tick: function() {}, uninstall: function() {} }, - clock = new jasmineUnderTest.Clock( + clock = new privateUnderTest.Clock( { setTimeout: setTimeout }, function() { return delayedFunctionScheduler; @@ -736,7 +736,7 @@ describe('Clock (acceptance)', function() { let clock; beforeEach(() => { - delayedFunctionScheduler = new jasmineUnderTest.DelayedFunctionScheduler(); + delayedFunctionScheduler = new privateUnderTest.DelayedFunctionScheduler(); mockDate = { install: function() {}, tick: function() {}, @@ -747,7 +747,7 @@ describe('Clock (acceptance)', function() { typeof window !== 'undefined' ? setTimeout.bind(window) : setTimeout; // passing a fake global allows us to preserve the real timing functions for use in tests const _global = { setTimeout: _setTimeout, setInterval: setInterval }; - clock = new jasmineUnderTest.Clock( + clock = new privateUnderTest.Clock( _global, function() { return delayedFunctionScheduler; @@ -885,13 +885,13 @@ describe('Clock (acceptance)', function() { it('can clear a previously set timeout', function() { const clearedFn = jasmine.createSpy('clearedFn'), - delayedFunctionScheduler = new jasmineUnderTest.DelayedFunctionScheduler(), + delayedFunctionScheduler = new privateUnderTest.DelayedFunctionScheduler(), mockDate = { install: function() {}, tick: function() {}, uninstall: function() {} }, - clock = new jasmineUnderTest.Clock( + clock = new privateUnderTest.Clock( { setTimeout: function() {} }, function() { return delayedFunctionScheduler; @@ -912,13 +912,13 @@ describe('Clock (acceptance)', function() { it("can clear a previously set interval using that interval's handler", function() { const spy = jasmine.createSpy('spy'), - delayedFunctionScheduler = new jasmineUnderTest.DelayedFunctionScheduler(), + delayedFunctionScheduler = new privateUnderTest.DelayedFunctionScheduler(), mockDate = { install: function() {}, tick: function() {}, uninstall: function() {} }, - clock = new jasmineUnderTest.Clock( + clock = new privateUnderTest.Clock( { setInterval: function() {} }, function() { return delayedFunctionScheduler; @@ -939,13 +939,13 @@ describe('Clock (acceptance)', function() { it('correctly schedules functions after the Clock has advanced', function() { const delayedFn1 = jasmine.createSpy('delayedFn1'), - delayedFunctionScheduler = new jasmineUnderTest.DelayedFunctionScheduler(), + delayedFunctionScheduler = new privateUnderTest.DelayedFunctionScheduler(), mockDate = { install: function() {}, tick: function() {}, uninstall: function() {} }, - clock = new jasmineUnderTest.Clock( + clock = new privateUnderTest.Clock( { setTimeout: function() {} }, function() { return delayedFunctionScheduler; @@ -966,13 +966,13 @@ describe('Clock (acceptance)', function() { it('correctly schedules functions while the Clock is advancing', function() { const delayedFn1 = jasmine.createSpy('delayedFn1'), delayedFn2 = jasmine.createSpy('delayedFn2'), - delayedFunctionScheduler = new jasmineUnderTest.DelayedFunctionScheduler(), + delayedFunctionScheduler = new privateUnderTest.DelayedFunctionScheduler(), mockDate = { install: function() {}, tick: function() {}, uninstall: function() {} }, - clock = new jasmineUnderTest.Clock( + clock = new privateUnderTest.Clock( { setTimeout: function() {} }, function() { return delayedFunctionScheduler; @@ -997,13 +997,13 @@ describe('Clock (acceptance)', function() { it('correctly calls functions scheduled while the Clock is advancing', function() { const delayedFn1 = jasmine.createSpy('delayedFn1'), delayedFn2 = jasmine.createSpy('delayedFn2'), - delayedFunctionScheduler = new jasmineUnderTest.DelayedFunctionScheduler(), + delayedFunctionScheduler = new privateUnderTest.DelayedFunctionScheduler(), mockDate = { install: function() {}, tick: function() {}, uninstall: function() {} }, - clock = new jasmineUnderTest.Clock( + clock = new privateUnderTest.Clock( { setTimeout: function() {} }, function() { return delayedFunctionScheduler; @@ -1025,13 +1025,13 @@ describe('Clock (acceptance)', function() { it('correctly schedules functions scheduled while the Clock is advancing but after the Clock is uninstalled', function() { const delayedFn1 = jasmine.createSpy('delayedFn1'), delayedFn2 = jasmine.createSpy('delayedFn2'), - delayedFunctionScheduler = new jasmineUnderTest.DelayedFunctionScheduler(), + delayedFunctionScheduler = new privateUnderTest.DelayedFunctionScheduler(), mockDate = { install: function() {}, tick: function() {}, uninstall: function() {} }, - clock = new jasmineUnderTest.Clock( + clock = new privateUnderTest.Clock( { setTimeout: function() {} }, function() { return delayedFunctionScheduler; @@ -1057,10 +1057,10 @@ describe('Clock (acceptance)', function() { }); it('does not mock the Date object by default', function() { - const delayedFunctionScheduler = new jasmineUnderTest.DelayedFunctionScheduler(), + const delayedFunctionScheduler = new privateUnderTest.DelayedFunctionScheduler(), global = { Date: Date }, - mockDate = new jasmineUnderTest.MockDate(global), - clock = new jasmineUnderTest.Clock( + mockDate = new privateUnderTest.MockDate(global), + clock = new privateUnderTest.Clock( { setTimeout: setTimeout }, function() { return delayedFunctionScheduler; @@ -1080,10 +1080,10 @@ describe('Clock (acceptance)', function() { }); it('mocks the Date object and sets it to current time', function() { - const delayedFunctionScheduler = new jasmineUnderTest.DelayedFunctionScheduler(), + const delayedFunctionScheduler = new privateUnderTest.DelayedFunctionScheduler(), global = { Date: Date }, - mockDate = new jasmineUnderTest.MockDate(global), - clock = new jasmineUnderTest.Clock( + mockDate = new privateUnderTest.MockDate(global), + clock = new privateUnderTest.Clock( { setTimeout: setTimeout }, function() { return delayedFunctionScheduler; @@ -1110,10 +1110,10 @@ describe('Clock (acceptance)', function() { }); it('mocks the Date object and sets it to a given time', function() { - const delayedFunctionScheduler = new jasmineUnderTest.DelayedFunctionScheduler(), + const delayedFunctionScheduler = new privateUnderTest.DelayedFunctionScheduler(), global = { Date: Date }, - mockDate = new jasmineUnderTest.MockDate(global), - clock = new jasmineUnderTest.Clock( + mockDate = new privateUnderTest.MockDate(global), + clock = new privateUnderTest.Clock( { setTimeout: setTimeout }, function() { return delayedFunctionScheduler; @@ -1143,10 +1143,10 @@ describe('Clock (acceptance)', function() { }); it('throws mockDate is called with a non-Date', function() { - const delayedFunctionScheduler = new jasmineUnderTest.DelayedFunctionScheduler(), + const delayedFunctionScheduler = new privateUnderTest.DelayedFunctionScheduler(), global = { Date: Date }, - mockDate = new jasmineUnderTest.MockDate(global), - clock = new jasmineUnderTest.Clock( + mockDate = new privateUnderTest.MockDate(global), + clock = new privateUnderTest.Clock( { setTimeout: setTimeout }, function() { return delayedFunctionScheduler; @@ -1161,10 +1161,10 @@ describe('Clock (acceptance)', function() { }); it('mocks the Date object and updates the date per delayed function', function() { - const delayedFunctionScheduler = new jasmineUnderTest.DelayedFunctionScheduler(), + const delayedFunctionScheduler = new privateUnderTest.DelayedFunctionScheduler(), global = { Date: Date }, - mockDate = new jasmineUnderTest.MockDate(global), - clock = new jasmineUnderTest.Clock( + mockDate = new privateUnderTest.MockDate(global), + clock = new privateUnderTest.Clock( { setTimeout: setTimeout }, function() { return delayedFunctionScheduler; @@ -1200,10 +1200,10 @@ describe('Clock (acceptance)', function() { }); it('correctly clears a scheduled timeout while the Clock is advancing', function() { - const delayedFunctionScheduler = new jasmineUnderTest.DelayedFunctionScheduler(), + const delayedFunctionScheduler = new privateUnderTest.DelayedFunctionScheduler(), global = { Date: Date, setTimeout: undefined }, - mockDate = new jasmineUnderTest.MockDate(global), - clock = new jasmineUnderTest.Clock( + mockDate = new privateUnderTest.MockDate(global), + clock = new privateUnderTest.Clock( global, function() { return delayedFunctionScheduler; @@ -1225,10 +1225,10 @@ describe('Clock (acceptance)', function() { }); it('correctly clears a scheduled interval while the Clock is advancing', function() { - const delayedFunctionScheduler = new jasmineUnderTest.DelayedFunctionScheduler(), + const delayedFunctionScheduler = new privateUnderTest.DelayedFunctionScheduler(), global = { Date: Date, setTimeout: undefined }, - mockDate = new jasmineUnderTest.MockDate(global), - clock = new jasmineUnderTest.Clock( + mockDate = new privateUnderTest.MockDate(global), + clock = new privateUnderTest.Clock( global, function() { return delayedFunctionScheduler; diff --git a/spec/core/CompleteOnFirstErrorSkipPolicySpec.js b/spec/core/CompleteOnFirstErrorSkipPolicySpec.js index babe4605..3d499581 100644 --- a/spec/core/CompleteOnFirstErrorSkipPolicySpec.js +++ b/spec/core/CompleteOnFirstErrorSkipPolicySpec.js @@ -2,7 +2,7 @@ describe('CompleteOnFirstErrorSkipPolicy', function() { describe('#skipTo', function() { describe('Before anything has errored', function() { it('returns the next index', function() { - const policy = new jasmineUnderTest.CompleteOnFirstErrorSkipPolicy( + const policy = new privateUnderTest.CompleteOnFirstErrorSkipPolicy( arrayOfArbitraryFns(4), 4 ); @@ -15,7 +15,7 @@ describe('CompleteOnFirstErrorSkipPolicy', function() { const fns = arrayOfArbitraryFns(4); fns[2].type = arbitraryCleanupType(); fns[3].type = arbitraryCleanupType(); - const policy = new jasmineUnderTest.CompleteOnFirstErrorSkipPolicy(fns); + const policy = new privateUnderTest.CompleteOnFirstErrorSkipPolicy(fns); policy.fnErrored(0); expect(policy.skipTo(0)).toEqual(2); @@ -27,7 +27,7 @@ describe('CompleteOnFirstErrorSkipPolicy', function() { it(`does not skip ${type} fns`, function() { const fns = arrayOfArbitraryFns(2); fns[1].type = type; - const policy = new jasmineUnderTest.CompleteOnFirstErrorSkipPolicy( + const policy = new privateUnderTest.CompleteOnFirstErrorSkipPolicy( fns ); @@ -58,7 +58,7 @@ describe('CompleteOnFirstErrorSkipPolicy', function() { type: arbitraryCleanupType() } ]; - const policy = new jasmineUnderTest.CompleteOnFirstErrorSkipPolicy( + const policy = new privateUnderTest.CompleteOnFirstErrorSkipPolicy( fns ); @@ -90,7 +90,7 @@ describe('CompleteOnFirstErrorSkipPolicy', function() { type: arbitraryCleanupType() } ]; - const policy = new jasmineUnderTest.CompleteOnFirstErrorSkipPolicy( + const policy = new privateUnderTest.CompleteOnFirstErrorSkipPolicy( fns ); @@ -107,7 +107,7 @@ describe('CompleteOnFirstErrorSkipPolicy', function() { type: arbitraryCleanupType() } ]; - const policy = new jasmineUnderTest.CompleteOnFirstErrorSkipPolicy(fns); + const policy = new privateUnderTest.CompleteOnFirstErrorSkipPolicy(fns); policy.fnErrored(0); expect(policy.skipTo(0)).toEqual(1); diff --git a/spec/core/ConfigurationSpec.js b/spec/core/ConfigurationSpec.js index b90ec59c..aec33af2 100644 --- a/spec/core/ConfigurationSpec.js +++ b/spec/core/ConfigurationSpec.js @@ -15,7 +15,7 @@ describe('Configuration', function() { Object.freeze(allKeys); it('provides defaults', function() { - const subject = new jasmineUnderTest.Configuration(); + const subject = new privateUnderTest.Configuration(); expect(subject.random).toEqual(true); expect(subject.seed).toBeNull(); expect(subject.stopOnSpecFailure).toEqual(false); @@ -32,7 +32,7 @@ describe('Configuration', function() { describe('copy()', function() { it('returns a copy of the configuration as a plain old JS object', function() { - const subject = new jasmineUnderTest.Configuration(); + const subject = new privateUnderTest.Configuration(); const copy = subject.copy(); @@ -47,7 +47,7 @@ describe('Configuration', function() { describe('update()', function() { it('does not update properties that are absent from the parameter', function() { - const subject = new jasmineUnderTest.Configuration(); + const subject = new privateUnderTest.Configuration(); const originalValues = subject.copy(); subject.update({}); @@ -56,7 +56,7 @@ describe('Configuration', function() { function booleanPropertyBehavior(key) { it('does not update the property if the specified value is undefined', function() { - const subject = new jasmineUnderTest.Configuration(); + const subject = new privateUnderTest.Configuration(); const orig = subject[key]; subject.update({ [key]: undefined }); @@ -65,7 +65,7 @@ describe('Configuration', function() { }); it('updates the property if the specified value is not undefined', function() { - const subject = new jasmineUnderTest.Configuration(); + const subject = new privateUnderTest.Configuration(); const orig = subject[key]; subject.update({ [key]: !orig }); @@ -83,7 +83,7 @@ describe('Configuration', function() { } it('sets specFilter when truthy', function() { - const subject = new jasmineUnderTest.Configuration(); + const subject = new privateUnderTest.Configuration(); const orig = subject.specFilter; subject.update({ specFilter: undefined }); @@ -98,7 +98,7 @@ describe('Configuration', function() { }); it('sets seed when not undefined', function() { - const subject = new jasmineUnderTest.Configuration(); + const subject = new privateUnderTest.Configuration(); subject.update({ seed: undefined }); expect(subject.seed).toBeNull(); diff --git a/spec/core/DelayedFunctionSchedulerSpec.js b/spec/core/DelayedFunctionSchedulerSpec.js index 20674c3d..6a2f775e 100644 --- a/spec/core/DelayedFunctionSchedulerSpec.js +++ b/spec/core/DelayedFunctionSchedulerSpec.js @@ -2,7 +2,7 @@ describe('DelayedFunctionScheduler', function() { 'use strict'; it('schedules a function for later execution', function() { - const scheduler = new jasmineUnderTest.DelayedFunctionScheduler(), + const scheduler = new privateUnderTest.DelayedFunctionScheduler(), fn = jasmine.createSpy('fn'); scheduler.scheduleFunction(fn, 0); @@ -15,7 +15,7 @@ describe('DelayedFunctionScheduler', function() { }); it('throws if a string is passed', function() { - const scheduler = new jasmineUnderTest.DelayedFunctionScheduler(); + const scheduler = new privateUnderTest.DelayedFunctionScheduler(); expect(function() { scheduler.scheduleFunction('horrible = true;', 0); @@ -25,7 +25,7 @@ describe('DelayedFunctionScheduler', function() { }); it('#tick defaults to 0', function() { - const scheduler = new jasmineUnderTest.DelayedFunctionScheduler(), + const scheduler = new privateUnderTest.DelayedFunctionScheduler(), fn = jasmine.createSpy('fn'); scheduler.scheduleFunction(fn, 0); @@ -38,7 +38,7 @@ describe('DelayedFunctionScheduler', function() { }); it('defaults delay to 0', function() { - const scheduler = new jasmineUnderTest.DelayedFunctionScheduler(), + const scheduler = new privateUnderTest.DelayedFunctionScheduler(), fn = jasmine.createSpy('fn'); scheduler.scheduleFunction(fn); @@ -51,7 +51,7 @@ describe('DelayedFunctionScheduler', function() { }); it('optionally passes params to scheduled functions', function() { - const scheduler = new jasmineUnderTest.DelayedFunctionScheduler(), + const scheduler = new privateUnderTest.DelayedFunctionScheduler(), fn = jasmine.createSpy('fn'); scheduler.scheduleFunction(fn, 0, ['foo', 'bar']); @@ -64,7 +64,7 @@ describe('DelayedFunctionScheduler', function() { }); it('scheduled fns can optionally reoccur', function() { - const scheduler = new jasmineUnderTest.DelayedFunctionScheduler(), + const scheduler = new privateUnderTest.DelayedFunctionScheduler(), fn = jasmine.createSpy('fn'); scheduler.scheduleFunction(fn, 20, [], true); @@ -85,7 +85,7 @@ describe('DelayedFunctionScheduler', function() { }); it('increments scheduled fns ids unless one is passed', function() { - const scheduler = new jasmineUnderTest.DelayedFunctionScheduler(); + const scheduler = new privateUnderTest.DelayedFunctionScheduler(); const initial = scheduler.scheduleFunction(function() {}, 0); expect(scheduler.scheduleFunction(function() {}, 0)).toBe(initial + 1); @@ -97,7 +97,7 @@ describe('DelayedFunctionScheduler', function() { }); it('#removeFunctionWithId removes a previously scheduled function with a given id', function() { - const scheduler = new jasmineUnderTest.DelayedFunctionScheduler(), + const scheduler = new privateUnderTest.DelayedFunctionScheduler(), fn = jasmine.createSpy('fn'), timeoutKey = scheduler.scheduleFunction(fn, 0); @@ -111,7 +111,7 @@ describe('DelayedFunctionScheduler', function() { }); it('executes recurring functions interleaved with regular functions in the correct order', function() { - const scheduler = new jasmineUnderTest.DelayedFunctionScheduler(); + const scheduler = new privateUnderTest.DelayedFunctionScheduler(); const fn = jasmine.createSpy('fn'); let recurringCallCount = 0; const recurring = jasmine.createSpy('recurring').and.callFake(function() { @@ -132,7 +132,7 @@ describe('DelayedFunctionScheduler', function() { }); it('schedules a function for later execution during a tick', function() { - const scheduler = new jasmineUnderTest.DelayedFunctionScheduler(), + const scheduler = new privateUnderTest.DelayedFunctionScheduler(), fn = jasmine.createSpy('fn'), fnDelay = 10; @@ -148,7 +148,7 @@ describe('DelayedFunctionScheduler', function() { }); it('#removeFunctionWithId removes a previously scheduled function with a given id during a tick', function() { - const scheduler = new jasmineUnderTest.DelayedFunctionScheduler(), + const scheduler = new privateUnderTest.DelayedFunctionScheduler(), fn = jasmine.createSpy('fn'), fnDelay = 10; let timeoutKey; @@ -166,7 +166,7 @@ describe('DelayedFunctionScheduler', function() { }); it('executes recurring functions interleaved with regular functions and functions scheduled during a tick in the correct order', function() { - const scheduler = new jasmineUnderTest.DelayedFunctionScheduler(); + const scheduler = new privateUnderTest.DelayedFunctionScheduler(); const fn = jasmine.createSpy('fn'); let recurringCallCount = 0; const recurring = jasmine.createSpy('recurring').and.callFake(function() { @@ -199,7 +199,7 @@ describe('DelayedFunctionScheduler', function() { }); it('executes recurring functions after rescheduling them', function() { - const scheduler = new jasmineUnderTest.DelayedFunctionScheduler(), + const scheduler = new privateUnderTest.DelayedFunctionScheduler(), recurring = function() { expect(scheduler.scheduleFunction).toHaveBeenCalled(); }; @@ -212,7 +212,7 @@ describe('DelayedFunctionScheduler', function() { }); it('removes functions during a tick that runs the function', function() { - const scheduler = new jasmineUnderTest.DelayedFunctionScheduler(), + const scheduler = new privateUnderTest.DelayedFunctionScheduler(), spy = jasmine.createSpy('fn'), spyAndRemove = jasmine.createSpy('fn'), fnDelay = 10; @@ -233,7 +233,7 @@ describe('DelayedFunctionScheduler', function() { }); it('removes functions during the first tick that runs the function', function() { - const scheduler = new jasmineUnderTest.DelayedFunctionScheduler(), + const scheduler = new privateUnderTest.DelayedFunctionScheduler(), fn = jasmine.createSpy('fn'), fnDelay = 10; let timeoutKey; @@ -252,7 +252,7 @@ describe('DelayedFunctionScheduler', function() { }); it("does not remove a function that hasn't been added yet", function() { - const scheduler = new jasmineUnderTest.DelayedFunctionScheduler(), + const scheduler = new privateUnderTest.DelayedFunctionScheduler(), fn = jasmine.createSpy('fn'), fnDelay = 10; @@ -267,7 +267,7 @@ describe('DelayedFunctionScheduler', function() { }); it('runs the next scheduled funtion', function() { - const scheduler = new jasmineUnderTest.DelayedFunctionScheduler(); + const scheduler = new privateUnderTest.DelayedFunctionScheduler(); const fn = jasmine.createSpy('fn'); const tickSpy = jasmine.createSpy('tick'); @@ -282,7 +282,7 @@ describe('DelayedFunctionScheduler', function() { }); it('runs the only a single scheduled funtion in a time slot', function() { - const scheduler = new jasmineUnderTest.DelayedFunctionScheduler(); + const scheduler = new privateUnderTest.DelayedFunctionScheduler(); const fn1 = jasmine.createSpy('fn'); const fn2 = jasmine.createSpy('fn2'); const tickSpy = jasmine.createSpy('tick'); @@ -303,7 +303,7 @@ describe('DelayedFunctionScheduler', function() { }); it('updates the mockDate per scheduled time', function() { - const scheduler = new jasmineUnderTest.DelayedFunctionScheduler(), + const scheduler = new privateUnderTest.DelayedFunctionScheduler(), tickDate = jasmine.createSpy('tickDate'); scheduler.scheduleFunction(function() {}); @@ -325,7 +325,7 @@ describe('DelayedFunctionScheduler', function() { } const nativeTimeoutId = setTimeout(function() {}, 100); - const scheduler = new jasmineUnderTest.DelayedFunctionScheduler(); + const scheduler = new privateUnderTest.DelayedFunctionScheduler(); const fn = jasmine.createSpy('fn'); for (let i = 0; i < nativeTimeoutId; i++) { diff --git a/spec/core/DeprecatorSpec.js b/spec/core/DeprecatorSpec.js index c2a126bf..5f6e6ff4 100644 --- a/spec/core/DeprecatorSpec.js +++ b/spec/core/DeprecatorSpec.js @@ -7,7 +7,7 @@ describe('Deprecator', function() { it('logs the mesage without context when the runnable is the top suite', function() { const runnable = { addDeprecationWarning: function() {} }; - const deprecator = new jasmineUnderTest.Deprecator(runnable); + const deprecator = new privateUnderTest.Deprecator(runnable); deprecator.verboseDeprecations(true); deprecator.addDeprecationWarning(runnable, 'the message', { @@ -25,7 +25,7 @@ describe('Deprecator', function() { }, children: [] }; - const deprecator = new jasmineUnderTest.Deprecator({}); + const deprecator = new privateUnderTest.Deprecator({}); deprecator.verboseDeprecations(true); deprecator.addDeprecationWarning(runnable, 'the message', { @@ -44,7 +44,7 @@ describe('Deprecator', function() { return 'the spec'; } }; - const deprecator = new jasmineUnderTest.Deprecator({}); + const deprecator = new privateUnderTest.Deprecator({}); deprecator.verboseDeprecations(true); deprecator.addDeprecationWarning(runnable, 'the message', { @@ -61,7 +61,7 @@ describe('Deprecator', function() { 'addDeprecationWarning', 'getFullName' ]); - const deprecator = new jasmineUnderTest.Deprecator(topSuite); + const deprecator = new privateUnderTest.Deprecator(topSuite); const runnable = jasmine.createSpyObj('spec', [ 'addDeprecationWarning', 'getFullName' @@ -105,7 +105,7 @@ describe('Deprecator', function() { }); it('emits the deprecation only once when verboseDeprecations is not set', function() { - const deprecator = new jasmineUnderTest.Deprecator({}); + const deprecator = new privateUnderTest.Deprecator({}); const runnable1 = jasmine.createSpyObj('runnable1', [ 'addDeprecationWarning', 'getFullName' @@ -124,7 +124,7 @@ describe('Deprecator', function() { }); it('emits the deprecation only once when verboseDeprecations is false', function() { - const deprecator = new jasmineUnderTest.Deprecator({}); + const deprecator = new privateUnderTest.Deprecator({}); const runnable1 = jasmine.createSpyObj('runnable1', [ 'addDeprecationWarning', 'getFullName' @@ -144,7 +144,7 @@ describe('Deprecator', function() { }); it('emits the deprecation for each call when verboseDeprecations is true', function() { - const deprecator = new jasmineUnderTest.Deprecator({}); + const deprecator = new privateUnderTest.Deprecator({}); const runnable1 = jasmine.createSpyObj('runnable1', [ 'addDeprecationWarning', 'getFullName' @@ -164,7 +164,7 @@ describe('Deprecator', function() { }); it('includes a note about verboseDeprecations', function() { - const deprecator = new jasmineUnderTest.Deprecator({}); + const deprecator = new privateUnderTest.Deprecator({}); const runnable = jasmine.createSpyObj('runnable', [ 'addDeprecationWarning', 'getFullName' @@ -183,7 +183,7 @@ describe('Deprecator', function() { }); it('omits the note about verboseDeprecations when verboseDeprecations is true', function() { - const deprecator = new jasmineUnderTest.Deprecator({}); + const deprecator = new privateUnderTest.Deprecator({}); const runnable = jasmine.createSpyObj('runnable', [ 'addDeprecationWarning', 'getFullName' @@ -207,7 +207,7 @@ describe('Deprecator', function() { // to report their own deprecations through Jasmine. See // . it('passes the error through unchanged', function() { - const deprecator = new jasmineUnderTest.Deprecator({}); + const deprecator = new privateUnderTest.Deprecator({}); const runnable = jasmine.createSpyObj('runnable', [ 'addDeprecationWarning', 'getFullName' @@ -238,7 +238,7 @@ describe('Deprecator', function() { }); it('reports the deprecation every time, regardless of config.verboseDeprecations', function() { - const deprecator = new jasmineUnderTest.Deprecator({}); + const deprecator = new privateUnderTest.Deprecator({}); const runnable = jasmine.createSpyObj('runnable', [ 'addDeprecationWarning', 'getFullName' @@ -259,7 +259,7 @@ describe('Deprecator', function() { }); it('omits the note about verboseDeprecations', function() { - const deprecator = new jasmineUnderTest.Deprecator({}); + const deprecator = new privateUnderTest.Deprecator({}); const runnable = jasmine.createSpyObj('runnable', [ 'addDeprecationWarning', 'getFullName' @@ -293,7 +293,7 @@ describe('Deprecator', function() { } function testStackTrace(options) { - const deprecator = new jasmineUnderTest.Deprecator({}); + const deprecator = new privateUnderTest.Deprecator({}); const runnable = jasmine.createSpyObj('runnable', [ 'addDeprecationWarning', 'getFullName' @@ -311,7 +311,7 @@ describe('Deprecator', function() { } function testNoStackTrace(options) { - const deprecator = new jasmineUnderTest.Deprecator({}); + const deprecator = new privateUnderTest.Deprecator({}); const runnable = jasmine.createSpyObj('runnable', [ 'addDeprecationWarning', 'getFullName' diff --git a/spec/core/EnvSpec.js b/spec/core/EnvSpec.js index 353ab285..faffc2d7 100644 --- a/spec/core/EnvSpec.js +++ b/spec/core/EnvSpec.js @@ -2,7 +2,7 @@ describe('Env', function() { let env; beforeEach(function() { - env = new jasmineUnderTest.Env(); + env = new privateUnderTest.Env(); }); afterEach(function() { @@ -13,14 +13,14 @@ describe('Env', function() { it('throws the Pending Spec exception', function() { expect(function() { env.pending(); - }).toThrow(jasmineUnderTest.Spec.pendingSpecExceptionMessage); + }).toThrow(privateUnderTest.Spec.pendingSpecExceptionMessage); }); it('throws the Pending Spec exception with a custom message', function() { expect(function() { env.pending('custom message'); }).toThrow( - jasmineUnderTest.Spec.pendingSpecExceptionMessage + 'custom message' + privateUnderTest.Spec.pendingSpecExceptionMessage + 'custom message' ); }); }); @@ -38,24 +38,24 @@ describe('Env', function() { }); const suite = env.topSuite(); - expect(suite).not.toBeInstanceOf(jasmineUnderTest.Suite); + expect(suite).not.toBeInstanceOf(privateUnderTest.Suite); expect(suite.description).toEqual('Jasmine__TopLevel__Suite'); expect(suite.getFullName()).toEqual(''); expect(suite.children.length).toEqual(2); - expect(suite.children[0]).not.toBeInstanceOf(jasmineUnderTest.Spec); + expect(suite.children[0]).not.toBeInstanceOf(privateUnderTest.Spec); expect(suite.children[0].description).toEqual('a top level spec'); expect(suite.children[0].getFullName()).toEqual('a top level spec'); expect(suite.children[0].children).toBeFalsy(); - expect(suite.children[1]).not.toBeInstanceOf(jasmineUnderTest.Suite); + expect(suite.children[1]).not.toBeInstanceOf(privateUnderTest.Suite); expect(suite.children[1].description).toEqual('a suite'); expect(suite.children[1].getFullName()).toEqual('a suite'); expect(suite.children[1].parentSuite).toBe(suite); expect(suite.children[1].children.length).toEqual(2); expect(suite.children[1].children[0]).not.toBeInstanceOf( - jasmineUnderTest.Spec + privateUnderTest.Spec ); expect(suite.children[1].children[0].description).toEqual('a spec'); expect(suite.children[1].children[0].getFullName()).toEqual( @@ -102,9 +102,9 @@ describe('Env', function() { it('can configure specs to throw errors on expectation failures', function() { env.configure({ stopSpecOnExpectationFailure: true }); - spyOn(jasmineUnderTest, 'Spec').and.callThrough(); + spyOn(privateUnderTest, 'Spec').and.callThrough(); env.it('foo', function() {}); - expect(jasmineUnderTest.Spec).toHaveBeenCalledWith( + expect(privateUnderTest.Spec).toHaveBeenCalledWith( jasmine.objectContaining({ throwOnExpectationFailure: true }) @@ -114,9 +114,9 @@ describe('Env', function() { it('can configure suites to throw errors on expectation failures', function() { env.configure({ stopSpecOnExpectationFailure: true }); - spyOn(jasmineUnderTest, 'Suite'); + spyOn(privateUnderTest, 'Suite'); env.describe('foo', function() {}); - expect(jasmineUnderTest.Suite).toHaveBeenCalledWith( + expect(privateUnderTest.Suite).toHaveBeenCalledWith( jasmine.objectContaining({ throwOnExpectationFailure: true }) @@ -150,9 +150,9 @@ describe('Env', function() { }); it('defaults to multiple failures for specs', function() { - spyOn(jasmineUnderTest, 'Spec').and.callThrough(); + spyOn(privateUnderTest, 'Spec').and.callThrough(); env.it('bar', function() {}); - expect(jasmineUnderTest.Spec).toHaveBeenCalledWith( + expect(privateUnderTest.Spec).toHaveBeenCalledWith( jasmine.objectContaining({ throwOnExpectationFailure: false }) @@ -160,9 +160,9 @@ describe('Env', function() { }); it('defaults to multiple failures for suites', function() { - spyOn(jasmineUnderTest, 'Suite'); + spyOn(privateUnderTest, 'Suite'); env.describe('foo', function() {}); - expect(jasmineUnderTest.Suite).toHaveBeenCalledWith( + expect(privateUnderTest.Suite).toHaveBeenCalledWith( jasmine.objectContaining({ throwOnExpectationFailure: false }) @@ -337,7 +337,7 @@ describe('Env', function() { it('calls spec.exclude with "Temporarily disabled with xit"', function() { const excludeSpy = jasmine.createSpy(); - spyOn(jasmineUnderTest.SuiteBuilder.prototype, 'it_').and.returnValue({ + spyOn(privateUnderTest.SuiteBuilder.prototype, 'it_').and.returnValue({ exclude: excludeSpy }); env.xit('foo', function() {}); @@ -346,9 +346,9 @@ describe('Env', function() { it('calls spec.pend with "Temporarily disabled with xit"', function() { const pendSpy = jasmine.createSpy(); - const realExclude = jasmineUnderTest.Spec.prototype.exclude; + const realExclude = privateUnderTest.Spec.prototype.exclude; - spyOn(jasmineUnderTest.SuiteBuilder.prototype, 'it_').and.returnValue({ + spyOn(privateUnderTest.SuiteBuilder.prototype, 'it_').and.returnValue({ exclude: realExclude, pend: pendSpy }); @@ -626,7 +626,7 @@ describe('Env', function() { 'removeOverrideListener' ]); env.cleanup_(); - env = new jasmineUnderTest.Env({ + env = new privateUnderTest.Env({ GlobalErrors: function() { return globalErrors; } @@ -645,7 +645,7 @@ describe('Env', function() { 'removeOverrideListener' ]); env.cleanup_(); - env = new jasmineUnderTest.Env({ + env = new privateUnderTest.Env({ suppressLoadErrors: true, GlobalErrors: function() { return globalErrors; @@ -661,12 +661,12 @@ describe('Env', function() { function customEqualityTester() {} function customObjectFormatter() {} function prettyPrinter() {} - const RealSpec = jasmineUnderTest.Spec; + const RealSpec = privateUnderTest.Spec; let specInstance; let expectationFactory; - spyOn(jasmineUnderTest, 'MatchersUtil'); - spyOn(jasmineUnderTest, 'makePrettyPrinter').and.returnValue(prettyPrinter); - spyOn(jasmineUnderTest, 'Spec').and.callFake(function(options) { + spyOn(privateUnderTest, 'MatchersUtil'); + spyOn(privateUnderTest, 'makePrettyPrinter').and.returnValue(prettyPrinter); + spyOn(privateUnderTest, 'Spec').and.callFake(function(options) { expectationFactory = options.expectationFactory; specInstance = new RealSpec(options); return specInstance; @@ -679,10 +679,10 @@ describe('Env', function() { }); await env.execute(); - expect(jasmineUnderTest.makePrettyPrinter).toHaveBeenCalledWith([ + expect(privateUnderTest.makePrettyPrinter).toHaveBeenCalledWith([ customObjectFormatter ]); - expect(jasmineUnderTest.MatchersUtil).toHaveBeenCalledWith({ + expect(privateUnderTest.MatchersUtil).toHaveBeenCalledWith({ customTesters: [customEqualityTester], pp: prettyPrinter }); @@ -692,12 +692,12 @@ describe('Env', function() { function customEqualityTester() {} function customObjectFormatter() {} function prettyPrinter() {} - const RealSpec = jasmineUnderTest.Spec; + const RealSpec = privateUnderTest.Spec; let specInstance; let asyncExpectationFactory; - spyOn(jasmineUnderTest, 'MatchersUtil'); - spyOn(jasmineUnderTest, 'makePrettyPrinter').and.returnValue(prettyPrinter); - spyOn(jasmineUnderTest, 'Spec').and.callFake(function(options) { + spyOn(privateUnderTest, 'MatchersUtil'); + spyOn(privateUnderTest, 'makePrettyPrinter').and.returnValue(prettyPrinter); + spyOn(privateUnderTest, 'Spec').and.callFake(function(options) { asyncExpectationFactory = options.asyncExpectationFactory; specInstance = new RealSpec(options); return specInstance; @@ -711,10 +711,10 @@ describe('Env', function() { await env.execute(); - expect(jasmineUnderTest.makePrettyPrinter).toHaveBeenCalledWith([ + expect(privateUnderTest.makePrettyPrinter).toHaveBeenCalledWith([ customObjectFormatter ]); - expect(jasmineUnderTest.MatchersUtil).toHaveBeenCalledWith({ + expect(privateUnderTest.MatchersUtil).toHaveBeenCalledWith({ customTesters: [customEqualityTester], pp: prettyPrinter }); @@ -729,7 +729,7 @@ describe('Env', function() { env.it('has a spec'); }); - expect(suiteThis).not.toBeInstanceOf(jasmineUnderTest.Suite); + expect(suiteThis).not.toBeInstanceOf(privateUnderTest.Suite); }); describe('#execute', function() { @@ -738,7 +738,7 @@ describe('Env', function() { }); it('should reset the topSuite when run twice', function() { - spyOn(jasmineUnderTest.Suite.prototype, 'reset'); + spyOn(privateUnderTest.Suite.prototype, 'reset'); return env .execute() // 1 .then(function() { @@ -746,9 +746,9 @@ describe('Env', function() { }) .then(function() { expect( - jasmineUnderTest.Suite.prototype.reset + privateUnderTest.Suite.prototype.reset ).toHaveBeenCalledOnceWith(); - const id = jasmineUnderTest.Suite.prototype.reset.calls.thisFor(0).id; + const id = privateUnderTest.Suite.prototype.reset.calls.thisFor(0).id; expect(id).toBeTruthy(); expect(id).toEqual(env.topSuite().id); }); @@ -757,9 +757,9 @@ describe('Env', function() { it('should not reset the topSuite if parallelReset was called since the last run', async function() { await env.execute(); env.parallelReset(); - spyOn(jasmineUnderTest.Suite.prototype, 'reset'); + spyOn(privateUnderTest.Suite.prototype, 'reset'); await env.execute(); - expect(jasmineUnderTest.Suite.prototype.reset).not.toHaveBeenCalled(); + expect(privateUnderTest.Suite.prototype.reset).not.toHaveBeenCalled(); }); describe('In parallel mode', function() { diff --git a/spec/core/ExceptionFormatterSpec.js b/spec/core/ExceptionFormatterSpec.js index c720da1d..47217fd6 100644 --- a/spec/core/ExceptionFormatterSpec.js +++ b/spec/core/ExceptionFormatterSpec.js @@ -7,7 +7,7 @@ describe('ExceptionFormatter', function() { message: 'you got your foo in my bar', name: 'A Classic Mistake' }, - exceptionFormatter = new jasmineUnderTest.ExceptionFormatter(), + exceptionFormatter = new privateUnderTest.ExceptionFormatter(), message = exceptionFormatter.message(sampleFirefoxException); expect(message).toEqual( @@ -22,7 +22,7 @@ describe('ExceptionFormatter', function() { message: 'you got your foo in my bar', name: 'A Classic Mistake' }, - exceptionFormatter = new jasmineUnderTest.ExceptionFormatter(), + exceptionFormatter = new privateUnderTest.ExceptionFormatter(), message = exceptionFormatter.message(sampleWebkitException); expect(message).toEqual( @@ -35,7 +35,7 @@ describe('ExceptionFormatter', function() { message: 'you got your foo in my bar', name: 'A Classic Mistake' }, - exceptionFormatter = new jasmineUnderTest.ExceptionFormatter(), + exceptionFormatter = new privateUnderTest.ExceptionFormatter(), message = exceptionFormatter.message(sampleV8); expect(message).toEqual('A Classic Mistake: you got your foo in my bar'); @@ -44,7 +44,7 @@ describe('ExceptionFormatter', function() { it('formats unnamed exceptions with message', function() { const unnamedError = { message: 'This is an unnamed error message.' }; - const exceptionFormatter = new jasmineUnderTest.ExceptionFormatter(), + const exceptionFormatter = new privateUnderTest.ExceptionFormatter(), message = exceptionFormatter.message(unnamedError); expect(message).toEqual('This is an unnamed error message.'); @@ -57,7 +57,7 @@ describe('ExceptionFormatter', function() { }; const emptyError = new EmptyError(); - const exceptionFormatter = new jasmineUnderTest.ExceptionFormatter(), + const exceptionFormatter = new privateUnderTest.ExceptionFormatter(), message = exceptionFormatter.message(emptyError); expect(message).toEqual('[EmptyError] thrown'); @@ -65,7 +65,7 @@ describe('ExceptionFormatter', function() { it("formats thrown exceptions that aren't errors", function() { const thrown = 'crazy error', - exceptionFormatter = new jasmineUnderTest.ExceptionFormatter(), + exceptionFormatter = new privateUnderTest.ExceptionFormatter(), message = exceptionFormatter.message(thrown); expect(message).toEqual('crazy error thrown'); @@ -76,7 +76,7 @@ describe('ExceptionFormatter', function() { it('formats stack traces', function() { const error = new Error('an error'); - expect(new jasmineUnderTest.ExceptionFormatter().stack(error)).toMatch( + expect(new privateUnderTest.ExceptionFormatter().stack(error)).toMatch( /ExceptionFormatterSpec\.js.*\d+/ ); }); @@ -96,7 +96,7 @@ describe('ExceptionFormatter', function() { ' at fn3 (C:\\__jasmine__\\lib\\jasmine-core\\jasmine.js:7575:25)\n' + ' at fn4 (node:internal/timers:462:21)\n' }; - const subject = new jasmineUnderTest.ExceptionFormatter({ + const subject = new privateUnderTest.ExceptionFormatter({ jasmineFile: 'C:\\__jasmine__\\lib\\jasmine-core\\jasmine.js' }); const result = subject.stack(error); @@ -122,7 +122,7 @@ describe('ExceptionFormatter', function() { ' at fn3 (http://localhost:8888/__jasmine__/jasmine.js:4320:20)\n' + ' at fn4 (http://localhost:8888/__spec__/core/UtilSpec.js:110:19)\n' }; - const subject = new jasmineUnderTest.ExceptionFormatter({ + const subject = new privateUnderTest.ExceptionFormatter({ jasmineFile: 'http://localhost:8888/__jasmine__/jasmine.js' }); const result = subject.stack(error); @@ -142,7 +142,7 @@ describe('ExceptionFormatter', function() { 'fn2@http://localhost:8888/__jasmine__/jasmine.js:4320:27\n' + 'http://localhost:8888/__spec__/core/UtilSpec.js:115:28' }; - const subject = new jasmineUnderTest.ExceptionFormatter({ + const subject = new privateUnderTest.ExceptionFormatter({ jasmineFile: 'http://localhost:8888/__jasmine__/jasmine.js' }); const result = subject.stack(error); @@ -161,7 +161,7 @@ describe('ExceptionFormatter', function() { 'setTimeout handler*fn2@http://localhost:8888/__jasmine__/jasmine.js:4320:27\n' + 'http://localhost:8888/__spec__/core/UtilSpec.js:115:28' }; - const subject = new jasmineUnderTest.ExceptionFormatter({ + const subject = new privateUnderTest.ExceptionFormatter({ jasmineFile: 'http://localhost:8888/__jasmine__/jasmine.js' }); const result = subject.stack(error); @@ -174,8 +174,8 @@ describe('ExceptionFormatter', function() { it('filters Jasmine stack frames in this environment', function() { const error = new Error('an error'); - const subject = new jasmineUnderTest.ExceptionFormatter({ - jasmineFile: jasmine.util.jasmineFile() + const subject = new privateUnderTest.ExceptionFormatter({ + jasmineFile: jasmine.private.util.jasmineFile() }); const result = subject.stack(error); jasmine.debugLog('Original stack trace: ' + error.stack); @@ -202,8 +202,8 @@ describe('ExceptionFormatter', function() { if (error.stack.indexOf(msg) === -1) { pending("Stack traces don't have messages in this environment"); } - const subject = new jasmineUnderTest.ExceptionFormatter({ - jasmineFile: jasmine.util.jasmineFile() + const subject = new privateUnderTest.ExceptionFormatter({ + jasmineFile: jasmine.private.util.jasmineFile() }); const result = subject.stack(error); const lines = result.split('\n'); @@ -215,14 +215,14 @@ describe('ExceptionFormatter', function() { }); it('returns null if no Error provided', function() { - expect(new jasmineUnderTest.ExceptionFormatter().stack()).toBeNull(); + expect(new privateUnderTest.ExceptionFormatter().stack()).toBeNull(); }); it("includes the error's own properties in stack", function() { const error = new Error('an error'); error.someProperty = 'hello there'; - const result = new jasmineUnderTest.ExceptionFormatter().stack(error); + const result = new privateUnderTest.ExceptionFormatter().stack(error); expect(result).toMatch(/error properties:.*someProperty.*hello there/); }); @@ -236,7 +236,7 @@ describe('ExceptionFormatter', function() { CustomError.prototype.anInheritedProp = 'something'; const error = new CustomError('nope'); - const result = new jasmineUnderTest.ExceptionFormatter().stack(error); + const result = new privateUnderTest.ExceptionFormatter().stack(error); expect(result).not.toContain('anInheritedProp'); }); @@ -251,7 +251,7 @@ describe('ExceptionFormatter', function() { ' at fn3 (http://localhost:8888/__jasmine__/jasmine.js:4320:20)\n' + ' at fn4 (http://localhost:8888/__spec__/core/UtilSpec.js:110:19)\n' }; - const subject = new jasmineUnderTest.ExceptionFormatter({ + const subject = new privateUnderTest.ExceptionFormatter({ jasmineFile: 'http://localhost:8888/__jasmine__/jasmine.js' }); const result = subject.stack(error, { omitMessage: true }); @@ -270,7 +270,7 @@ describe('ExceptionFormatter', function() { 'fn2@http://localhost:8888/__jasmine__/jasmine.js:4320:27\n' + 'http://localhost:8888/__spec__/core/UtilSpec.js:115:28' }; - const subject = new jasmineUnderTest.ExceptionFormatter({ + const subject = new privateUnderTest.ExceptionFormatter({ jasmineFile: 'http://localhost:8888/__jasmine__/jasmine.js' }); const result = subject.stack(error, { omitMessage: true }); @@ -283,8 +283,8 @@ 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 jasmineUnderTest.ExceptionFormatter({ - jasmineFile: jasmine.util.jasmineFile() + const subject = new privateUnderTest.ExceptionFormatter({ + jasmineFile: jasmine.private.util.jasmineFile() }); const result = subject.stack(error, { omitMessage: true }); expect(result).not.toContain('an error'); @@ -293,7 +293,7 @@ describe('ExceptionFormatter', function() { describe('when the error has a cause property', function() { it('recursively includes the cause in the stack trace in this environment', function() { - const subject = new jasmineUnderTest.ExceptionFormatter(); + const subject = new privateUnderTest.ExceptionFormatter(); const rootCause = new Error('root cause'); const proximateCause = new Error('proximate cause', { cause: rootCause @@ -327,7 +327,7 @@ describe('ExceptionFormatter', function() { }); it('does not throw if cause is a non Error', function() { - const formatter = new jasmineUnderTest.ExceptionFormatter(); + const formatter = new privateUnderTest.ExceptionFormatter(); expect(function() { formatter.stack( diff --git a/spec/core/ExceptionsSpec.js b/spec/core/ExceptionsSpec.js index c357290c..108a1253 100644 --- a/spec/core/ExceptionsSpec.js +++ b/spec/core/ExceptionsSpec.js @@ -2,7 +2,7 @@ describe('Exceptions:', function() { let env; beforeEach(function() { - env = new jasmineUnderTest.Env(); + env = new privateUnderTest.Env(); }); afterEach(function() { diff --git a/spec/core/ExpectationFilterChainSpec.js b/spec/core/ExpectationFilterChainSpec.js index aab7171d..f0acbb5d 100644 --- a/spec/core/ExpectationFilterChainSpec.js +++ b/spec/core/ExpectationFilterChainSpec.js @@ -3,7 +3,7 @@ describe('ExpectationFilterChain', function() { it('returns a new filter chain with the added filter', function() { const first = jasmine.createSpy('first'), second = jasmine.createSpy('second'), - orig = new jasmineUnderTest.ExpectationFilterChain({ + orig = new privateUnderTest.ExpectationFilterChain({ modifyFailureMessage: first }), added = orig.addFilter({ selectComparisonFunc: second }); @@ -15,7 +15,7 @@ describe('ExpectationFilterChain', function() { }); it('does not modify the original filter chain', function() { - const orig = new jasmineUnderTest.ExpectationFilterChain({}), + const orig = new privateUnderTest.ExpectationFilterChain({}), f = jasmine.createSpy('f'); orig.addFilter({ selectComparisonFunc: f }); @@ -28,7 +28,7 @@ describe('ExpectationFilterChain', function() { describe('#selectComparisonFunc', function() { describe('When no filters have #selectComparisonFunc', function() { it('returns undefined', function() { - const chain = new jasmineUnderTest.ExpectationFilterChain(); + const chain = new privateUnderTest.ExpectationFilterChain(); chain.addFilter({}); expect(chain.selectComparisonFunc()).toBeUndefined(); }); @@ -38,7 +38,7 @@ describe('ExpectationFilterChain', function() { it('calls the first filter that has #selectComparisonFunc', function() { const first = jasmine.createSpy('first').and.returnValue('first'), second = jasmine.createSpy('second').and.returnValue('second'), - chain = new jasmineUnderTest.ExpectationFilterChain() + chain = new privateUnderTest.ExpectationFilterChain() .addFilter({ selectComparisonFunc: first }) .addFilter({ selectComparisonFunc: second }), matcher = {}, @@ -54,7 +54,7 @@ describe('ExpectationFilterChain', function() { describe('#buildFailureMessage', function() { describe('When no filters have #buildFailureMessage', function() { it('returns undefined', function() { - const chain = new jasmineUnderTest.ExpectationFilterChain(); + const chain = new privateUnderTest.ExpectationFilterChain(); chain.addFilter({}); expect(chain.buildFailureMessage()).toBeUndefined(); }); @@ -64,7 +64,7 @@ describe('ExpectationFilterChain', function() { it('calls the first filter that has #buildFailureMessage', function() { const first = jasmine.createSpy('first').and.returnValue('first'), second = jasmine.createSpy('second').and.returnValue('second'), - chain = new jasmineUnderTest.ExpectationFilterChain() + chain = new privateUnderTest.ExpectationFilterChain() .addFilter({ buildFailureMessage: first }) .addFilter({ buildFailureMessage: second }), matcherResult = { pass: false }, @@ -94,7 +94,7 @@ describe('ExpectationFilterChain', function() { describe('#modifyFailureMessage', function() { describe('When no filters have #modifyFailureMessage', function() { it('returns the original message', function() { - const chain = new jasmineUnderTest.ExpectationFilterChain(); + const chain = new privateUnderTest.ExpectationFilterChain(); chain.addFilter({}); expect(chain.modifyFailureMessage('msg')).toEqual('msg'); }); @@ -104,7 +104,7 @@ describe('ExpectationFilterChain', function() { it('calls the first filter that has #modifyFailureMessage', function() { const first = jasmine.createSpy('first').and.returnValue('first'), second = jasmine.createSpy('second').and.returnValue('second'), - chain = new jasmineUnderTest.ExpectationFilterChain() + chain = new privateUnderTest.ExpectationFilterChain() .addFilter({ modifyFailureMessage: first }) .addFilter({ modifyFailureMessage: second }), result = chain.modifyFailureMessage('original'); diff --git a/spec/core/ExpectationSpec.js b/spec/core/ExpectationSpec.js index 06964b40..0e1f110f 100644 --- a/spec/core/ExpectationSpec.js +++ b/spec/core/ExpectationSpec.js @@ -4,7 +4,7 @@ describe('Expectation', function() { toFoo: function() {}, toBar: function() {} }, - expectation = jasmineUnderTest.Expectation.factory({ + expectation = privateUnderTest.Expectation.factory({ customMatchers: matchers }); @@ -17,9 +17,9 @@ describe('Expectation', function() { toQuux: function() {} }; - jasmineUnderTest.Expectation.addCoreMatchers(coreMatchers); + privateUnderTest.Expectation.addCoreMatchers(coreMatchers); - const expectation = jasmineUnderTest.Expectation.factory({}); + const expectation = privateUnderTest.Expectation.factory({}); expect(expectation.toQuux).toBeDefined(); }); @@ -39,7 +39,7 @@ describe('Expectation', function() { }, addExpectationResult = jasmine.createSpy('addExpectationResult'); - const expectation = jasmineUnderTest.Expectation.factory({ + const expectation = privateUnderTest.Expectation.factory({ matchersUtil: matchersUtil, customMatchers: matchers, actual: 'an actual', @@ -67,7 +67,7 @@ describe('Expectation', function() { }, addExpectationResult = jasmine.createSpy('addExpectationResult'); - const expectation = jasmineUnderTest.Expectation.factory({ + const expectation = privateUnderTest.Expectation.factory({ matchersUtil: matchersUtil, customMatchers: matchers, actual: 'an actual', @@ -94,7 +94,7 @@ describe('Expectation', function() { }, addExpectationResult = jasmine.createSpy('addExpectationResult'); - const expectation = jasmineUnderTest.Expectation.factory({ + const expectation = privateUnderTest.Expectation.factory({ customMatchers: matchers, matchersUtil: matchersUtil, actual: 'an actual', @@ -129,7 +129,7 @@ describe('Expectation', function() { }, addExpectationResult = jasmine.createSpy('addExpectationResult'); - const expectation = jasmineUnderTest.Expectation.factory({ + const expectation = privateUnderTest.Expectation.factory({ customMatchers: matchers, matchersUtil: matchersUtil, actual: 'an actual', @@ -162,7 +162,7 @@ describe('Expectation', function() { }, addExpectationResult = jasmine.createSpy('addExpectationResult'); - const expectation = jasmineUnderTest.Expectation.factory({ + const expectation = privateUnderTest.Expectation.factory({ actual: 'an actual', customMatchers: matchers, addExpectationResult: addExpectationResult @@ -196,7 +196,7 @@ describe('Expectation', function() { }, addExpectationResult = jasmine.createSpy('addExpectationResult'); - const expectation = jasmineUnderTest.Expectation.factory({ + const expectation = privateUnderTest.Expectation.factory({ customMatchers: matchers, actual: 'an actual', addExpectationResult: addExpectationResult @@ -225,7 +225,7 @@ describe('Expectation', function() { }, addExpectationResult = jasmine.createSpy('addExpectationResult'); - const expectation = jasmineUnderTest.Expectation.factory({ + const expectation = privateUnderTest.Expectation.factory({ customMatchers: matchers, actual: 'an actual', addExpectationResult: addExpectationResult @@ -259,7 +259,7 @@ describe('Expectation', function() { }, addExpectationResult = jasmine.createSpy('addExpectationResult'); - const expectation = jasmineUnderTest.Expectation.factory({ + const expectation = privateUnderTest.Expectation.factory({ customMatchers: matchers, actual: 'an actual', matchersUtil: matchersUtil, @@ -292,7 +292,7 @@ describe('Expectation', function() { }, addExpectationResult = jasmine.createSpy('addExpectationResult'); - const expectation = jasmineUnderTest.Expectation.factory({ + const expectation = privateUnderTest.Expectation.factory({ customMatchers: matchers, actual: 'an actual', addExpectationResult: addExpectationResult @@ -324,7 +324,7 @@ describe('Expectation', function() { }, addExpectationResult = jasmine.createSpy('addExpectationResult'); - const expectation = jasmineUnderTest.Expectation.factory({ + const expectation = privateUnderTest.Expectation.factory({ customMatchers: matchers, actual: 'an actual', addExpectationResult: addExpectationResult @@ -359,7 +359,7 @@ describe('Expectation', function() { }, addExpectationResult = jasmine.createSpy('addExpectationResult'); - const expectation = jasmineUnderTest.Expectation.factory({ + const expectation = privateUnderTest.Expectation.factory({ customMatchers: matchers, actual: 'an actual', addExpectationResult: addExpectationResult @@ -393,7 +393,7 @@ describe('Expectation', function() { }, addExpectationResult = jasmine.createSpy('addExpectationResult'); - const expectation = jasmineUnderTest.Expectation.factory({ + const expectation = privateUnderTest.Expectation.factory({ actual: 'an actual', customMatchers: matchers, addExpectationResult: addExpectationResult @@ -427,7 +427,7 @@ describe('Expectation', function() { }, addExpectationResult = jasmine.createSpy('addExpectationResult'); - const expectation = jasmineUnderTest.Expectation.factory({ + const expectation = privateUnderTest.Expectation.factory({ actual: 'an actual', customMatchers: matchers, addExpectationResult: addExpectationResult @@ -463,7 +463,7 @@ describe('Expectation', function() { }, addExpectationResult = jasmine.createSpy('addExpectationResult'); - const expectation = jasmineUnderTest.Expectation.factory({ + const expectation = privateUnderTest.Expectation.factory({ actual: 'an actual', customMatchers: matchers, addExpectationResult: addExpectationResult @@ -497,7 +497,7 @@ describe('Expectation', function() { } }, addExpectationResult = jasmine.createSpy('addExpectationResult'), - expectation = jasmineUnderTest.Expectation.factory({ + expectation = privateUnderTest.Expectation.factory({ customMatchers: matchers, matchersUtil: matchersUtil, actual: 'an actual', @@ -525,7 +525,7 @@ describe('Expectation', function() { } }, addExpectationResult = jasmine.createSpy('addExpectationResult'), - expectation = jasmineUnderTest.Expectation.factory({ + expectation = privateUnderTest.Expectation.factory({ customMatchers: matchers, actual: 'an actual', addExpectationResult: addExpectationResult @@ -552,7 +552,7 @@ describe('Expectation', function() { } }, addExpectationResult = jasmine.createSpy('addExpectationResult'), - expectation = jasmineUnderTest.Expectation.factory({ + expectation = privateUnderTest.Expectation.factory({ customMatchers: matchers, actual: 'an actual', addExpectationResult: addExpectationResult @@ -582,7 +582,7 @@ describe('Expectation', function() { } }, addExpectationResult = jasmine.createSpy('addExpectationResult'), - expectation = jasmineUnderTest.Expectation.factory({ + expectation = privateUnderTest.Expectation.factory({ customMatchers: matchers, actual: 'an actual', addExpectationResult: addExpectationResult @@ -609,10 +609,10 @@ describe('Expectation', function() { } }, addExpectationResult = jasmine.createSpy('addExpectationResult'), - pp = jasmineUnderTest.makePrettyPrinter(), - expectation = jasmineUnderTest.Expectation.factory({ + pp = privateUnderTest.makePrettyPrinter(), + expectation = privateUnderTest.Expectation.factory({ customMatchers: matchers, - matchersUtil: new jasmineUnderTest.MatchersUtil({ pp: pp }), + matchersUtil: new privateUnderTest.MatchersUtil({ pp: pp }), actual: 'an actual', addExpectationResult: addExpectationResult }); @@ -645,7 +645,7 @@ describe('Expectation', function() { } }, addExpectationResult = jasmine.createSpy('addExpectationResult'), - expectation = jasmineUnderTest.Expectation.factory({ + expectation = privateUnderTest.Expectation.factory({ actual: 'an actual', customMatchers: matchers, addExpectationResult: addExpectationResult diff --git a/spec/core/GlobalErrorsSpec.js b/spec/core/GlobalErrorsSpec.js index 959bb340..d53695ad 100644 --- a/spec/core/GlobalErrorsSpec.js +++ b/spec/core/GlobalErrorsSpec.js @@ -2,7 +2,7 @@ describe('GlobalErrors', function() { it('calls the added handler on error', function() { const globals = browserGlobals(); const handler = jasmine.createSpy('errorHandler'); - const errors = new jasmineUnderTest.GlobalErrors( + const errors = new privateUnderTest.GlobalErrors( globals.global, () => ({}) ); @@ -22,7 +22,7 @@ describe('GlobalErrors', function() { it('is not affected by overriding global.onerror', function() { const globals = browserGlobals(); const handler = jasmine.createSpy('errorHandler'); - const errors = new jasmineUnderTest.GlobalErrors( + const errors = new privateUnderTest.GlobalErrors( globals.global, () => ({}) ); @@ -45,7 +45,7 @@ describe('GlobalErrors', function() { const globals = browserGlobals(); const handler1 = jasmine.createSpy('errorHandler1'); const handler2 = jasmine.createSpy('errorHandler2'); - const errors = new jasmineUnderTest.GlobalErrors( + const errors = new privateUnderTest.GlobalErrors( globals.global, () => ({}) ); @@ -68,7 +68,7 @@ describe('GlobalErrors', function() { const globals = browserGlobals(); const handler1 = jasmine.createSpy('errorHandler1'); const handler2 = jasmine.createSpy('errorHandler2'); - const errors = new jasmineUnderTest.GlobalErrors( + const errors = new privateUnderTest.GlobalErrors( globals.global, () => ({}) ); @@ -90,7 +90,7 @@ describe('GlobalErrors', function() { }); it('throws when no listener is passed to #popListener', function() { - const errors = new jasmineUnderTest.GlobalErrors({}); + const errors = new privateUnderTest.GlobalErrors({}); expect(function() { errors.popListener(); }).toThrowError('popListener expects a listener'); @@ -98,7 +98,7 @@ describe('GlobalErrors', function() { it('uninstalls itself', function() { const globals = browserGlobals(); - const errors = new jasmineUnderTest.GlobalErrors( + const errors = new privateUnderTest.GlobalErrors( globals.global, () => ({}) ); @@ -113,7 +113,7 @@ describe('GlobalErrors', function() { it('rethrows the original error when there is no handler', function() { const globals = browserGlobals(); - const errors = new jasmineUnderTest.GlobalErrors( + const errors = new privateUnderTest.GlobalErrors( globals.global, () => ({}) ); @@ -132,7 +132,7 @@ describe('GlobalErrors', function() { it('reports uncaught exceptions in node.js', function() { const globals = nodeGlobals(); - const errors = new jasmineUnderTest.GlobalErrors( + const errors = new privateUnderTest.GlobalErrors( globals.global, () => ({}) ); @@ -165,7 +165,7 @@ describe('GlobalErrors', function() { describe('Reporting unhandled promise rejections in node.js', function() { it('reports rejections with `Error` reasons', function() { const globals = nodeGlobals(); - const errors = new jasmineUnderTest.GlobalErrors( + const errors = new privateUnderTest.GlobalErrors( globals.global, () => ({}) ); @@ -197,7 +197,7 @@ describe('GlobalErrors', function() { it('reports rejections with non-`Error` reasons', function() { const globals = nodeGlobals(); - const errors = new jasmineUnderTest.GlobalErrors( + const errors = new privateUnderTest.GlobalErrors( globals.global, () => ({}) ); @@ -220,7 +220,7 @@ describe('GlobalErrors', function() { it('reports rejections with no reason provided', function() { const globals = nodeGlobals(); - const errors = new jasmineUnderTest.GlobalErrors( + const errors = new privateUnderTest.GlobalErrors( globals.global, () => ({}) ); @@ -246,7 +246,7 @@ describe('GlobalErrors', function() { beforeEach(function() { globals = nodeGlobals(); - errors = new jasmineUnderTest.GlobalErrors(globals.global, () => ({ + errors = new privateUnderTest.GlobalErrors(globals.global, () => ({ detectLateRejectionHandling: true })); }); @@ -379,7 +379,7 @@ describe('GlobalErrors', function() { describe('Reporting unhandled promise rejections in the browser', function() { it('subscribes and unsubscribes from the unhandledrejection event', function() { const globals = browserGlobals(); - const errors = new jasmineUnderTest.GlobalErrors( + const errors = new privateUnderTest.GlobalErrors( globals.global, () => ({}) ); @@ -396,7 +396,7 @@ describe('GlobalErrors', function() { it('reports rejections whose reason is a string', function() { const globals = browserGlobals(); const handler = jasmine.createSpy('errorHandler'); - const errors = new jasmineUnderTest.GlobalErrors( + const errors = new privateUnderTest.GlobalErrors( globals.global, () => ({}) ); @@ -416,7 +416,7 @@ describe('GlobalErrors', function() { it('reports rejections whose reason is an Error', function() { const globals = browserGlobals(); const handler = jasmine.createSpy('errorHandler'); - const errors = new jasmineUnderTest.GlobalErrors( + const errors = new privateUnderTest.GlobalErrors( globals.global, () => ({}) ); @@ -443,7 +443,7 @@ describe('GlobalErrors', function() { beforeEach(function() { globals = browserGlobals(); - errors = new jasmineUnderTest.GlobalErrors(globals.global, () => ({ + errors = new privateUnderTest.GlobalErrors(globals.global, () => ({ detectLateRejectionHandling: true })); }); @@ -556,7 +556,7 @@ describe('GlobalErrors', function() { describe('Reporting uncaught exceptions in node.js', function() { it('prepends a descriptive message when the error is not an `Error`', function() { const globals = nodeGlobals(); - const errors = new jasmineUnderTest.GlobalErrors( + const errors = new privateUnderTest.GlobalErrors( globals.global, () => ({}) ); @@ -575,7 +575,7 @@ describe('GlobalErrors', function() { it('substitutes a descriptive message when the error is falsy', function() { const globals = nodeGlobals(); - const errors = new jasmineUnderTest.GlobalErrors( + const errors = new privateUnderTest.GlobalErrors( globals.global, () => ({}) ); @@ -599,7 +599,7 @@ describe('GlobalErrors', function() { const handler0 = jasmine.createSpy('handler0'); const handler1 = jasmine.createSpy('handler1'); const overrideHandler = jasmine.createSpy('overrideHandler'); - const errors = new jasmineUnderTest.GlobalErrors( + const errors = new privateUnderTest.GlobalErrors( globals.global, () => ({}) ); @@ -627,7 +627,7 @@ describe('GlobalErrors', function() { const handler0 = jasmine.createSpy('handler0'); const handler1 = jasmine.createSpy('handler1'); const overrideHandler = jasmine.createSpy('overrideHandler'); - const errors = new jasmineUnderTest.GlobalErrors( + const errors = new privateUnderTest.GlobalErrors( globals.global, () => ({}) ); @@ -655,7 +655,7 @@ describe('GlobalErrors', function() { const globals = browserGlobals(); const handler = jasmine.createSpy('handler'); const overrideHandler = jasmine.createSpy('overrideHandler'); - const errors = new jasmineUnderTest.GlobalErrors( + const errors = new privateUnderTest.GlobalErrors( globals.global, () => ({}) ); @@ -683,7 +683,7 @@ describe('GlobalErrors', function() { const handler0 = jasmine.createSpy('handler0'); const handler1 = jasmine.createSpy('handler1'); const overrideHandler = jasmine.createSpy('overrideHandler'); - const errors = new jasmineUnderTest.GlobalErrors( + const errors = new privateUnderTest.GlobalErrors( globals.global, () => ({}) ); @@ -701,7 +701,7 @@ describe('GlobalErrors', function() { }); it('throws if there is already an override handler', function() { - const errors = new jasmineUnderTest.GlobalErrors(browserGlobals().global); + const errors = new privateUnderTest.GlobalErrors(browserGlobals().global); errors.setOverrideListener(() => {}, () => {}); expect(function() { @@ -713,7 +713,7 @@ describe('GlobalErrors', function() { describe('#removeOverrideListener', function() { it("calls the handler's onRemove callback", function() { const onRemove = jasmine.createSpy('onRemove'); - const errors = new jasmineUnderTest.GlobalErrors(browserGlobals().global); + const errors = new privateUnderTest.GlobalErrors(browserGlobals().global); errors.setOverrideListener(() => {}, onRemove); errors.removeOverrideListener(); @@ -722,7 +722,7 @@ describe('GlobalErrors', function() { }); it('does not throw if there is no handler', function() { - const errors = new jasmineUnderTest.GlobalErrors(browserGlobals().global); + const errors = new privateUnderTest.GlobalErrors(browserGlobals().global); expect(() => errors.removeOverrideListener()).not.toThrow(); }); diff --git a/spec/core/JsApiReporterSpec.js b/spec/core/JsApiReporterSpec.js index 28f9e3b8..d2af65ce 100644 --- a/spec/core/JsApiReporterSpec.js +++ b/spec/core/JsApiReporterSpec.js @@ -1,6 +1,6 @@ describe('JsApiReporter', function() { it('knows when a full environment is started', function() { - const reporter = new jasmineUnderTest.JsApiReporter({}); + const reporter = new privateUnderTest.JsApiReporter({}); expect(reporter.started).toBe(false); expect(reporter.finished).toBe(false); @@ -12,7 +12,7 @@ describe('JsApiReporter', function() { }); it('knows when a full environment is done', function() { - const reporter = new jasmineUnderTest.JsApiReporter({}); + const reporter = new privateUnderTest.JsApiReporter({}); expect(reporter.started).toBe(false); expect(reporter.finished).toBe(false); @@ -24,13 +24,13 @@ describe('JsApiReporter', function() { }); it("defaults to 'loaded' status", function() { - const reporter = new jasmineUnderTest.JsApiReporter({}); + const reporter = new privateUnderTest.JsApiReporter({}); expect(reporter.status()).toEqual('loaded'); }); it("reports 'started' when Jasmine has started", function() { - const reporter = new jasmineUnderTest.JsApiReporter({}); + const reporter = new privateUnderTest.JsApiReporter({}); reporter.jasmineStarted(); @@ -38,7 +38,7 @@ describe('JsApiReporter', function() { }); it("reports 'done' when Jasmine is done", function() { - const reporter = new jasmineUnderTest.JsApiReporter({}); + const reporter = new privateUnderTest.JsApiReporter({}); reporter.jasmineDone({}); @@ -46,7 +46,7 @@ describe('JsApiReporter', function() { }); it('tracks a suite', function() { - const reporter = new jasmineUnderTest.JsApiReporter({}); + const reporter = new privateUnderTest.JsApiReporter({}); reporter.suiteStarted({ id: 123, @@ -71,7 +71,7 @@ describe('JsApiReporter', function() { describe('#specResults', function() { let reporter, specResult1, specResult2; beforeEach(function() { - reporter = new jasmineUnderTest.JsApiReporter({}); + reporter = new privateUnderTest.JsApiReporter({}); specResult1 = { id: 1, description: 'A spec' @@ -101,7 +101,7 @@ describe('JsApiReporter', function() { describe('#suiteResults', function() { let reporter, suiteStarted1, suiteResult1, suiteResult2; beforeEach(function() { - reporter = new jasmineUnderTest.JsApiReporter({}); + reporter = new privateUnderTest.JsApiReporter({}); suiteStarted1 = { id: 1 }; @@ -138,7 +138,7 @@ describe('JsApiReporter', function() { describe('#executionTime', function() { it('should start the timer when jasmine starts', function() { const timerSpy = jasmine.createSpyObj('timer', ['start', 'elapsed']), - reporter = new jasmineUnderTest.JsApiReporter({ + reporter = new privateUnderTest.JsApiReporter({ timer: timerSpy }); @@ -148,7 +148,7 @@ describe('JsApiReporter', function() { it('should return the time it took the specs to run, in ms', function() { const timerSpy = jasmine.createSpyObj('timer', ['start', 'elapsed']), - reporter = new jasmineUnderTest.JsApiReporter({ + reporter = new privateUnderTest.JsApiReporter({ timer: timerSpy }); @@ -160,7 +160,7 @@ describe('JsApiReporter', function() { describe("when the specs haven't finished being run", function() { it('should return undefined', function() { const timerSpy = jasmine.createSpyObj('timer', ['start', 'elapsed']), - reporter = new jasmineUnderTest.JsApiReporter({ + reporter = new privateUnderTest.JsApiReporter({ timer: timerSpy }); @@ -171,7 +171,7 @@ describe('JsApiReporter', function() { describe('#runDetails', function() { it('should have details about the run', function() { - const reporter = new jasmineUnderTest.JsApiReporter({}); + const reporter = new privateUnderTest.JsApiReporter({}); reporter.jasmineDone({ some: { run: 'details' } }); expect(reporter.runDetails).toEqual({ some: { run: 'details' } }); }); diff --git a/spec/core/MockDateSpec.js b/spec/core/MockDateSpec.js index b4ce40dd..e394ac8e 100644 --- a/spec/core/MockDateSpec.js +++ b/spec/core/MockDateSpec.js @@ -1,7 +1,7 @@ describe('FakeDate', function() { it('does not fail if no global date is found', function() { const fakeGlobal = {}, - mockDate = new jasmineUnderTest.MockDate(fakeGlobal); + mockDate = new privateUnderTest.MockDate(fakeGlobal); expect(function() { mockDate.install(); @@ -19,7 +19,7 @@ describe('FakeDate', function() { }; }), fakeGlobal = { Date: globalDate }, - mockDate = new jasmineUnderTest.MockDate(fakeGlobal); + mockDate = new privateUnderTest.MockDate(fakeGlobal); expect(fakeGlobal.Date).toEqual(globalDate); mockDate.install(); @@ -36,7 +36,7 @@ describe('FakeDate', function() { }; }), fakeGlobal = { Date: globalDate }, - mockDate = new jasmineUnderTest.MockDate(fakeGlobal); + mockDate = new privateUnderTest.MockDate(fakeGlobal); mockDate.install(); mockDate.uninstall(); @@ -55,7 +55,7 @@ describe('FakeDate', function() { }; }), fakeGlobal = { Date: globalDate }, - mockDate = new jasmineUnderTest.MockDate(fakeGlobal); + mockDate = new privateUnderTest.MockDate(fakeGlobal); mockDate.install(); @@ -66,7 +66,7 @@ describe('FakeDate', function() { it('can accept a date as time base when installing', function() { const fakeGlobal = { Date: Date }, - mockDate = new jasmineUnderTest.MockDate(fakeGlobal), + mockDate = new privateUnderTest.MockDate(fakeGlobal), baseDate = new Date(); spyOn(baseDate, 'getTime').and.returnValue(123); @@ -77,7 +77,7 @@ describe('FakeDate', function() { it('makes real dates', function() { const fakeGlobal = { Date: Date }, - mockDate = new jasmineUnderTest.MockDate(fakeGlobal); + mockDate = new privateUnderTest.MockDate(fakeGlobal); mockDate.install(); expect(new fakeGlobal.Date()).toEqual(jasmine.any(Date)); @@ -97,7 +97,7 @@ describe('FakeDate', function() { fakeGlobal = { Date: globalDate }; globalDate.now = function() {}; - const mockDate = new jasmineUnderTest.MockDate(fakeGlobal); + const mockDate = new privateUnderTest.MockDate(fakeGlobal); mockDate.install(); @@ -117,7 +117,7 @@ describe('FakeDate', function() { fakeGlobal = { Date: globalDate }; globalDate.now = function() {}; - const mockDate = new jasmineUnderTest.MockDate(fakeGlobal); + const mockDate = new privateUnderTest.MockDate(fakeGlobal); mockDate.install(); @@ -143,7 +143,7 @@ describe('FakeDate', function() { fakeGlobal = { Date: globalDate }; globalDate.now = function() {}; - const mockDate = new jasmineUnderTest.MockDate(fakeGlobal); + const mockDate = new privateUnderTest.MockDate(fakeGlobal); mockDate.install(); @@ -156,7 +156,7 @@ describe('FakeDate', function() { it('allows creation of a Date in a different time than the mocked time', function() { const fakeGlobal = { Date: Date }, - mockDate = new jasmineUnderTest.MockDate(fakeGlobal); + mockDate = new privateUnderTest.MockDate(fakeGlobal); mockDate.install(); @@ -168,7 +168,7 @@ describe('FakeDate', function() { it("allows creation of a Date that isn't fully specified", function() { const fakeGlobal = { Date: Date }, - mockDate = new jasmineUnderTest.MockDate(fakeGlobal); + mockDate = new privateUnderTest.MockDate(fakeGlobal); mockDate.install(); @@ -178,7 +178,7 @@ describe('FakeDate', function() { it('allows creation of a Date with millis', function() { const fakeGlobal = { Date: Date }, - mockDate = new jasmineUnderTest.MockDate(fakeGlobal), + mockDate = new privateUnderTest.MockDate(fakeGlobal), now = new Date(2014, 3, 15).getTime(); mockDate.install(); @@ -189,7 +189,7 @@ describe('FakeDate', function() { it('copies all Date properties to the mocked date', function() { const fakeGlobal = { Date: Date }, - mockDate = new jasmineUnderTest.MockDate(fakeGlobal); + mockDate = new privateUnderTest.MockDate(fakeGlobal); mockDate.install(); diff --git a/spec/core/PrettyPrintSpec.js b/spec/core/PrettyPrintSpec.js index 88194b56..f737cb30 100644 --- a/spec/core/PrettyPrintSpec.js +++ b/spec/core/PrettyPrintSpec.js @@ -1,12 +1,12 @@ describe('PrettyPrinter', function() { it('should wrap strings in single quotes', function() { - const pp = jasmineUnderTest.makePrettyPrinter(); + const pp = privateUnderTest.makePrettyPrinter(); expect(pp('some string')).toEqual("'some string'"); expect(pp("som' string")).toEqual("'som' string'"); }); it('stringifies empty string primitives and objects recognizably', function() { - const pp = jasmineUnderTest.makePrettyPrinter(); + const pp = privateUnderTest.makePrettyPrinter(); expect(pp(new String(''))).toEqual(pp('')); expect(pp(new String(''))).toEqual("''"); expect(pp([new String('')])).toEqual(pp([''])); @@ -14,7 +14,7 @@ describe('PrettyPrinter', function() { }); it('should stringify primitives properly', function() { - const pp = jasmineUnderTest.makePrettyPrinter(); + const pp = privateUnderTest.makePrettyPrinter(); expect(pp(true)).toEqual('true'); expect(pp(false)).toEqual('false'); expect(pp(null)).toEqual('null'); @@ -29,7 +29,7 @@ describe('PrettyPrinter', function() { const set = new Set(); set.add(1); set.add(2); - const pp = jasmineUnderTest.makePrettyPrinter(); + const pp = privateUnderTest.makePrettyPrinter(); expect(pp(set)).toEqual('Set( 1, 2 )'); }); @@ -42,7 +42,7 @@ describe('PrettyPrinter', function() { set.add('a'); set.add('b'); set.add('c'); - const pp = jasmineUnderTest.makePrettyPrinter(); + const pp = privateUnderTest.makePrettyPrinter(); expect(pp(set)).toEqual("Set( 'a', 'b', ... )"); } finally { jasmineUnderTest.MAX_PRETTY_PRINT_ARRAY_LENGTH = originalMaxSize; @@ -54,7 +54,7 @@ describe('PrettyPrinter', function() { it('should stringify maps properly', function() { const map = new Map(); map.set(1, 2); - const pp = jasmineUnderTest.makePrettyPrinter(); + const pp = privateUnderTest.makePrettyPrinter(); expect(pp(map)).toEqual('Map( [ 1, 2 ] )'); }); @@ -67,7 +67,7 @@ describe('PrettyPrinter', function() { map.set('a', 1); map.set('b', 2); map.set('c', 3); - const pp = jasmineUnderTest.makePrettyPrinter(); + const pp = privateUnderTest.makePrettyPrinter(); expect(pp(map)).toEqual("Map( [ 'a', 1 ], [ 'b', 2 ], ... )"); } finally { jasmineUnderTest.MAX_PRETTY_PRINT_ARRAY_LENGTH = originalMaxSize; @@ -77,7 +77,7 @@ describe('PrettyPrinter', function() { describe('stringify arrays', function() { it('should stringify arrays properly', function() { - const pp = jasmineUnderTest.makePrettyPrinter(); + const pp = privateUnderTest.makePrettyPrinter(); expect(pp([1, 2])).toEqual('[ 1, 2 ]'); expect(pp([1, 'foo', {}, jasmine.undefined, null])).toEqual( "[ 1, 'foo', Object({ }), undefined, null ]" @@ -85,14 +85,14 @@ describe('PrettyPrinter', function() { }); it('includes symbols', function() { - const pp = jasmineUnderTest.makePrettyPrinter(); + const pp = privateUnderTest.makePrettyPrinter(); expect(pp([1, Symbol('foo'), 2])).toEqual('[ 1, Symbol(foo), 2 ]'); }); it('should truncate arrays that are longer than jasmineUnderTest.MAX_PRETTY_PRINT_ARRAY_LENGTH', function() { const originalMaxLength = jasmineUnderTest.MAX_PRETTY_PRINT_ARRAY_LENGTH; const array = [1, 2, 3]; - const pp = jasmineUnderTest.makePrettyPrinter(); + const pp = privateUnderTest.makePrettyPrinter(); try { jasmineUnderTest.MAX_PRETTY_PRINT_ARRAY_LENGTH = 2; @@ -103,7 +103,7 @@ describe('PrettyPrinter', function() { }); it('should stringify arrays with properties properly', function() { - const pp = jasmineUnderTest.makePrettyPrinter(); + const pp = privateUnderTest.makePrettyPrinter(); const arr = [1, 2]; arr.foo = 'bar'; arr.baz = {}; @@ -111,7 +111,7 @@ describe('PrettyPrinter', function() { }); it('should stringify empty arrays with properties properly', function() { - const pp = jasmineUnderTest.makePrettyPrinter(); + const pp = privateUnderTest.makePrettyPrinter(); const empty = []; empty.foo = 'bar'; empty.baz = {}; @@ -119,7 +119,7 @@ describe('PrettyPrinter', function() { }); it('should stringify long arrays with properties properly', function() { - const pp = jasmineUnderTest.makePrettyPrinter(); + const pp = privateUnderTest.makePrettyPrinter(); const originalMaxLength = jasmineUnderTest.MAX_PRETTY_PRINT_ARRAY_LENGTH; const long = [1, 2, 3]; long.foo = 'bar'; @@ -136,7 +136,7 @@ describe('PrettyPrinter', function() { }); it('should indicate circular array references', function() { - const pp = jasmineUnderTest.makePrettyPrinter(); + const pp = privateUnderTest.makePrettyPrinter(); const array1 = [1, 2]; const array2 = [array1]; array1.push(array2); @@ -144,14 +144,14 @@ describe('PrettyPrinter', function() { }); it('should not indicate circular references incorrectly', function() { - const pp = jasmineUnderTest.makePrettyPrinter(); + const pp = privateUnderTest.makePrettyPrinter(); const array = [[1]]; expect(pp(array)).toEqual('[ [ 1 ] ]'); }); }); it('should stringify objects properly', function() { - const pp = jasmineUnderTest.makePrettyPrinter(); + const pp = privateUnderTest.makePrettyPrinter(); expect(pp({ foo: 'bar' })).toEqual("Object({ foo: 'bar' })"); expect( pp({ @@ -169,14 +169,14 @@ describe('PrettyPrinter', function() { }); it('includes symbol keys in objects', function() { - const pp = jasmineUnderTest.makePrettyPrinter(); + const pp = privateUnderTest.makePrettyPrinter(); const obj = {}; obj[Symbol('foo')] = 'bar'; expect(pp(obj)).toEqual("Object({ Symbol(foo): 'bar' })"); }); it('stringifies string and symbol keys differently', function() { - const pp = jasmineUnderTest.makePrettyPrinter(); + const pp = privateUnderTest.makePrettyPrinter(); const symObj = {}; const strObj = {}; const k = 'foo'; @@ -188,12 +188,12 @@ describe('PrettyPrinter', function() { }); it('should stringify objects that almost look like DOM nodes', function() { - const pp = jasmineUnderTest.makePrettyPrinter(); + const pp = privateUnderTest.makePrettyPrinter(); expect(pp({ nodeType: 1 })).toEqual('Object({ nodeType: 1 })'); }); it('should truncate objects with too many keys', function() { - const pp = jasmineUnderTest.makePrettyPrinter(); + const pp = privateUnderTest.makePrettyPrinter(); const originalMaxLength = jasmineUnderTest.MAX_PRETTY_PRINT_ARRAY_LENGTH; const long = { a: 1, b: 2, c: 3 }; @@ -217,7 +217,7 @@ describe('PrettyPrinter', function() { } it('should truncate outputs that are too long', function() { - const pp = jasmineUnderTest.makePrettyPrinter(); + const pp = privateUnderTest.makePrettyPrinter(); const big = [{ a: 1, b: 'a long string' }, {}]; withMaxChars(34, function() { @@ -246,7 +246,7 @@ describe('PrettyPrinter', function() { .createSpy('d jasmineToString') .and.returnValue('') }, - pp = jasmineUnderTest.makePrettyPrinter(); + pp = privateUnderTest.makePrettyPrinter(); withMaxChars(30, function() { pp([{ a: a, b: b, c: c }, d]); @@ -256,13 +256,13 @@ describe('PrettyPrinter', function() { }); it("should print 'null' as the constructor of an object with its own constructor property", function() { - const pp = jasmineUnderTest.makePrettyPrinter(); + const pp = privateUnderTest.makePrettyPrinter(); expect(pp({ constructor: function() {} })).toContain('null({'); expect(pp({ constructor: 'foo' })).toContain('null({'); }); it('should not include inherited properties when stringifying an object', function() { - const pp = jasmineUnderTest.makePrettyPrinter(); + const pp = privateUnderTest.makePrettyPrinter(); const SomeClass = function SomeClass() {}; SomeClass.prototype.foo = 'inherited foo'; const instance = new SomeClass(); @@ -271,7 +271,7 @@ describe('PrettyPrinter', function() { }); it('should not recurse objects and arrays more deeply than jasmineUnderTest.MAX_PRETTY_PRINT_DEPTH', function() { - const pp = jasmineUnderTest.makePrettyPrinter(); + const pp = privateUnderTest.makePrettyPrinter(); const originalMaxDepth = jasmineUnderTest.MAX_PRETTY_PRINT_DEPTH; const nestedObject = { level1: { level2: { level3: { level4: 'leaf' } } } }; const nestedArray = [1, [2, [3, [4, 'leaf']]]]; @@ -300,7 +300,7 @@ describe('PrettyPrinter', function() { }); it('should stringify immutable circular objects', function() { - const pp = jasmineUnderTest.makePrettyPrinter(); + const pp = privateUnderTest.makePrettyPrinter(); let frozenObject = { foo: { bar: 'baz' } }; frozenObject.circular = frozenObject; frozenObject = Object.freeze(frozenObject); @@ -310,12 +310,12 @@ describe('PrettyPrinter', function() { }); it('should stringify RegExp objects properly', function() { - const pp = jasmineUnderTest.makePrettyPrinter(); + const pp = privateUnderTest.makePrettyPrinter(); expect(pp(/x|y|z/)).toEqual('/x|y|z/'); }); it('should indicate circular object references', function() { - const pp = jasmineUnderTest.makePrettyPrinter(); + const pp = privateUnderTest.makePrettyPrinter(); const sampleValue = { foo: 'hello' }; sampleValue.nested = sampleValue; expect(pp(sampleValue)).toEqual( @@ -324,7 +324,7 @@ describe('PrettyPrinter', function() { }); it('should use the return value of getters', function() { - const pp = jasmineUnderTest.makePrettyPrinter(); + const pp = privateUnderTest.makePrettyPrinter(); const sampleValue = { id: 1, get calculatedValue() { @@ -337,19 +337,19 @@ describe('PrettyPrinter', function() { }); it('should not do HTML escaping of strings', function() { - const pp = jasmineUnderTest.makePrettyPrinter(); + const pp = privateUnderTest.makePrettyPrinter(); expect(pp('some html string &', false)).toEqual( "'some html string &'" ); }); it('should abbreviate the global (usually window) object', function() { - const pp = jasmineUnderTest.makePrettyPrinter(); + const pp = privateUnderTest.makePrettyPrinter(); expect(pp(jasmine.getGlobal())).toEqual(''); }); it('should stringify Date objects properly', function() { - const pp = jasmineUnderTest.makePrettyPrinter(); + const pp = privateUnderTest.makePrettyPrinter(); const now = new Date(); expect(pp(now)).toEqual('Date(' + now.toString() + ')'); }); @@ -358,8 +358,8 @@ describe('PrettyPrinter', function() { let env, pp; beforeEach(function() { - env = new jasmineUnderTest.Env(); - pp = jasmineUnderTest.makePrettyPrinter(); + env = new privateUnderTest.Env(); + pp = privateUnderTest.makePrettyPrinter(); }); afterEach(function() { @@ -371,12 +371,12 @@ describe('PrettyPrinter', function() { someFunction: function() {} }; - const spyRegistry = new jasmineUnderTest.SpyRegistry({ + const spyRegistry = new privateUnderTest.SpyRegistry({ currentSpies: function() { return []; }, createSpy: function(name, originalFn) { - return jasmineUnderTest.Spy(name, originalFn); + return privateUnderTest.Spy(name, originalFn); } }); @@ -390,15 +390,15 @@ describe('PrettyPrinter', function() { const TestObject = { someFunction: function() {} }, - env = new jasmineUnderTest.Env(), - pp = jasmineUnderTest.makePrettyPrinter(); + env = new privateUnderTest.Env(), + pp = privateUnderTest.makePrettyPrinter(); - const spyRegistry = new jasmineUnderTest.SpyRegistry({ + const spyRegistry = new privateUnderTest.SpyRegistry({ currentSpies: function() { return []; }, createSpy: function(name, originalFn) { - return jasmineUnderTest.Spy(name, originalFn); + return privateUnderTest.Spy(name, originalFn); } }); @@ -410,7 +410,7 @@ describe('PrettyPrinter', function() { }); it('should stringify objects that implement jasmineToString', function() { - const pp = jasmineUnderTest.makePrettyPrinter(); + const pp = privateUnderTest.makePrettyPrinter(); const obj = { jasmineToString: function() { return 'strung'; @@ -421,7 +421,7 @@ describe('PrettyPrinter', function() { }); it('should pass itself to jasmineToString', function() { - const pp = jasmineUnderTest.makePrettyPrinter([]); + const pp = privateUnderTest.makePrettyPrinter([]); const obj = { jasmineToString: jasmine.createSpy('jasmineToString').and.returnValue('') }; @@ -431,7 +431,7 @@ describe('PrettyPrinter', function() { }); it('should stringify objects that implement custom toString', function() { - const pp = jasmineUnderTest.makePrettyPrinter(); + const pp = privateUnderTest.makePrettyPrinter(); const obj = { toString: function() { return 'my toString'; @@ -455,7 +455,7 @@ describe('PrettyPrinter', function() { }); it("should stringify objects have have a toString that isn't a function", function() { - const pp = jasmineUnderTest.makePrettyPrinter(); + const pp = privateUnderTest.makePrettyPrinter(); const obj = { toString: 'foo' }; @@ -464,7 +464,7 @@ describe('PrettyPrinter', function() { }); it('should stringify objects from anonymous constructors with custom toString', function() { - const pp = jasmineUnderTest.makePrettyPrinter(); + const pp = privateUnderTest.makePrettyPrinter(); const MyAnonymousConstructor = (function() { return function() {}; })(); @@ -478,18 +478,18 @@ describe('PrettyPrinter', function() { }); it('stringifies functions with names', function() { - const pp = jasmineUnderTest.makePrettyPrinter(); + const pp = privateUnderTest.makePrettyPrinter(); expect(pp(foo)).toEqual("Function 'foo'"); function foo() {} }); it('stringifies functions without names', function() { - const pp = jasmineUnderTest.makePrettyPrinter(); + const pp = privateUnderTest.makePrettyPrinter(); expect(pp(function() {})).toEqual('Function'); }); it('should handle objects with null prototype', function() { - const pp = jasmineUnderTest.makePrettyPrinter(); + const pp = privateUnderTest.makePrettyPrinter(); const obj = Object.create(null); obj.foo = 'bar'; @@ -497,7 +497,7 @@ describe('PrettyPrinter', function() { }); it('should gracefully handle objects with invalid toString implementations', function() { - const pp = jasmineUnderTest.makePrettyPrinter(); + const pp = privateUnderTest.makePrettyPrinter(); const obj = { foo: { toString: function() { @@ -545,7 +545,7 @@ describe('PrettyPrinter', function() { return '3rd: ' + obj.foo; } ], - pp = jasmineUnderTest.makePrettyPrinter(customObjectFormatters), + pp = privateUnderTest.makePrettyPrinter(customObjectFormatters), obj = { foo: 'bar' }; expect(pp(obj)).toEqual('2nd: bar'); @@ -557,7 +557,7 @@ describe('PrettyPrinter', function() { return undefined; } ], - pp = jasmineUnderTest.makePrettyPrinter(customObjectFormatters), + pp = privateUnderTest.makePrettyPrinter(customObjectFormatters), obj = { foo: 'bar' }; expect(pp(obj)).toEqual("Object({ foo: 'bar' })"); @@ -577,7 +577,7 @@ describe('PrettyPrinter', function() { return '3rd: ' + obj.foo; } ], - pp = jasmineUnderTest.makePrettyPrinter(customObjectFormatters), + pp = privateUnderTest.makePrettyPrinter(customObjectFormatters), obj = { foo: 'bar' }; expect(pp.customFormat_(obj)).toEqual('2nd: bar'); @@ -589,7 +589,7 @@ describe('PrettyPrinter', function() { return undefined; } ], - pp = jasmineUnderTest.makePrettyPrinter(customObjectFormatters), + pp = privateUnderTest.makePrettyPrinter(customObjectFormatters), obj = { foo: 'bar' }; expect(pp.customFormat_(obj)).toBeUndefined(); diff --git a/spec/core/QueueRunnerSpec.js b/spec/core/QueueRunnerSpec.js index 8eac83cd..9d5a3673 100644 --- a/spec/core/QueueRunnerSpec.js +++ b/spec/core/QueueRunnerSpec.js @@ -1,7 +1,7 @@ describe('QueueRunner', function() { it('validates that queueableFns are truthy', function() { expect(function() { - new jasmineUnderTest.QueueRunner({ + new privateUnderTest.QueueRunner({ queueableFns: [undefined] }); }).toThrowError('Received a falsy queueableFn'); @@ -9,7 +9,7 @@ describe('QueueRunner', function() { it('validates that queueableFns have fn properties', function() { expect(function() { - new jasmineUnderTest.QueueRunner({ + new privateUnderTest.QueueRunner({ queueableFns: [{ fn: undefined }] }); }).toThrowError('Received a queueableFn with no fn'); @@ -19,7 +19,7 @@ describe('QueueRunner', function() { const calls = [], queueableFn1 = { fn: jasmine.createSpy('fn1') }, queueableFn2 = { fn: jasmine.createSpy('fn2') }, - queueRunner = new jasmineUnderTest.QueueRunner({ + queueRunner = new privateUnderTest.QueueRunner({ queueableFns: [queueableFn1, queueableFn2] }); queueableFn1.fn.and.callFake(function() { @@ -44,14 +44,14 @@ describe('QueueRunner', function() { done(); } }, - queueRunner = new jasmineUnderTest.QueueRunner({ + queueRunner = new privateUnderTest.QueueRunner({ queueableFns: [queueableFn1, queueableFn2, queueableFn3] }); queueRunner.execute(); const context = queueableFn1.fn.calls.first().object; - expect(context).toEqual(new jasmineUnderTest.UserContext()); + expect(context).toEqual(new privateUnderTest.UserContext()); expect(queueableFn2.fn.calls.first().object).toBe(context); expect(asyncContext).toBe(context); }); @@ -91,7 +91,7 @@ describe('QueueRunner', function() { setTimeout(done, 100); } }, - queueRunner = new jasmineUnderTest.QueueRunner({ + queueRunner = new privateUnderTest.QueueRunner({ queueableFns: [queueableFn1, queueableFn2, queueableFn3], onComplete: onComplete }); @@ -129,7 +129,7 @@ describe('QueueRunner', function() { }, queueableFn2 = { fn: jasmine.createSpy('fn2') }, failFn = jasmine.createSpy('fail'), - queueRunner = new jasmineUnderTest.QueueRunner({ + queueRunner = new privateUnderTest.QueueRunner({ queueableFns: [queueableFn1, queueableFn2], fail: failFn }); @@ -157,7 +157,7 @@ describe('QueueRunner', function() { }, queueableFn2 = { fn: jasmine.createSpy('fn2') }, failFn = jasmine.createSpy('fail'), - queueRunner = new jasmineUnderTest.QueueRunner({ + queueRunner = new privateUnderTest.QueueRunner({ queueableFns: [queueableFn1, queueableFn2], fail: failFn }); @@ -189,7 +189,7 @@ describe('QueueRunner', function() { }, queueableFn2 = { fn: jasmine.createSpy('fn2') }, failFn = jasmine.createSpy('fail'), - queueRunner = new jasmineUnderTest.QueueRunner({ + queueRunner = new privateUnderTest.QueueRunner({ queueableFns: [queueableFn1, queueableFn2], fail: failFn, onComplete: function() { @@ -211,7 +211,7 @@ describe('QueueRunner', function() { } }, failFn = jasmine.createSpy('fail'), - queueRunner = new jasmineUnderTest.QueueRunner({ + queueRunner = new privateUnderTest.QueueRunner({ queueableFns: [queueableFn1], fail: failFn, onComplete: function() { @@ -227,7 +227,7 @@ describe('QueueRunner', function() { }); it('does not cause an explicit fail if execution is being stopped', function() { - const err = new jasmineUnderTest.StopExecutionError('foo'), + const err = new privateUnderTest.StopExecutionError('foo'), queueableFn1 = { fn: function(done) { setTimeout(function() { @@ -237,7 +237,7 @@ describe('QueueRunner', function() { }, queueableFn2 = { fn: jasmine.createSpy('fn2') }, failFn = jasmine.createSpy('fail'), - queueRunner = new jasmineUnderTest.QueueRunner({ + queueRunner = new privateUnderTest.QueueRunner({ queueableFns: [queueableFn1, queueableFn2], fail: failFn }); @@ -259,7 +259,7 @@ describe('QueueRunner', function() { queueableFn = { fn: jasmine.createSpy('fn'), type: 'queueable' }, onComplete = jasmine.createSpy('onComplete'), onException = jasmine.createSpy('onException'), - queueRunner = new jasmineUnderTest.QueueRunner({ + queueRunner = new privateUnderTest.QueueRunner({ queueableFns: [beforeFn, queueableFn], onComplete: onComplete, onException: onException @@ -287,7 +287,7 @@ describe('QueueRunner', function() { }; const onComplete = jasmine.createSpy('onComplete'); const onMultipleDone = jasmine.createSpy('onMultipleDone'); - const queueRunner = new jasmineUnderTest.QueueRunner({ + const queueRunner = new privateUnderTest.QueueRunner({ queueableFns: [queueableFn], onComplete: onComplete, onMultipleDone: onMultipleDone @@ -306,7 +306,7 @@ describe('QueueRunner', function() { queueableFn = { fn: jasmine.createSpy('fn') }, onComplete = jasmine.createSpy('onComplete'), onException = jasmine.createSpy('onException'), - queueRunner = new jasmineUnderTest.QueueRunner({ + queueRunner = new privateUnderTest.QueueRunner({ queueableFns: [beforeFn, queueableFn], onComplete: onComplete, onException: onException @@ -330,7 +330,7 @@ describe('QueueRunner', function() { }, onComplete = jasmine.createSpy('onComplete'), onException = jasmine.createSpy('onException'), - queueRunner = new jasmineUnderTest.QueueRunner({ + queueRunner = new privateUnderTest.QueueRunner({ queueableFns: [queueableFn], onComplete: onComplete, onException: onException @@ -353,7 +353,7 @@ describe('QueueRunner', function() { }, onComplete = jasmine.createSpy('onComplete'), onException = jasmine.createSpy('onException'), - queueRunner = new jasmineUnderTest.QueueRunner({ + queueRunner = new privateUnderTest.QueueRunner({ queueableFns: [queueableFn], onComplete: onComplete, onException: onException @@ -377,7 +377,7 @@ describe('QueueRunner', function() { }, nextQueueableFn = { fn: jasmine.createSpy('nextFn') }, onMultipleDone = jasmine.createSpy('onMultipleDone'), - queueRunner = new jasmineUnderTest.QueueRunner({ + queueRunner = new privateUnderTest.QueueRunner({ queueableFns: [queueableFn, nextQueueableFn], onMultipleDone: onMultipleDone }); @@ -396,7 +396,7 @@ describe('QueueRunner', function() { } }, nextQueueableFn = { fn: jasmine.createSpy('nextFn') }, - queueRunner = new jasmineUnderTest.QueueRunner({ + queueRunner = new privateUnderTest.QueueRunner({ queueableFns: [queueableFn, nextQueueableFn] }); queueRunner.execute(); @@ -412,7 +412,7 @@ describe('QueueRunner', function() { doneReturn = done(); } }; - const queueRunner = new jasmineUnderTest.QueueRunner({ + const queueRunner = new privateUnderTest.QueueRunner({ queueableFns: [queueableFn] }); @@ -433,7 +433,7 @@ describe('QueueRunner', function() { pushListener: jasmine.createSpy('pushListener'), popListener: jasmine.createSpy('popListener') }, - queueRunner = new jasmineUnderTest.QueueRunner({ + queueRunner = new privateUnderTest.QueueRunner({ queueableFns: [queueableFn, nextQueueableFn], onException: onException, globalErrors: globalErrors @@ -485,7 +485,7 @@ describe('QueueRunner', function() { pushListener: jasmine.createSpy('pushListener'), popListener: jasmine.createSpy('popListener') }; - const queueRunner = new jasmineUnderTest.QueueRunner({ + const queueRunner = new privateUnderTest.QueueRunner({ queueableFns: [queueableFn], onException: onException, globalErrors: globalErrors @@ -513,7 +513,7 @@ describe('QueueRunner', function() { }, clearStack = jasmine.createSpy('clearStack'), onException = jasmine.createSpy('onException'), - queueRunner = new jasmineUnderTest.QueueRunner({ + queueRunner = new privateUnderTest.QueueRunner({ queueableFns: [queueableFn], globalErrors: globalErrors, clearStack: clearStack, @@ -547,7 +547,7 @@ describe('QueueRunner', function() { }; const clearStack = jasmine.createSpy('clearStack'); const onException = jasmine.createSpy('onException'); - const queueRunner = new jasmineUnderTest.QueueRunner({ + const queueRunner = new privateUnderTest.QueueRunner({ queueableFns: [queueableFn], globalErrors: globalErrors, clearStack: clearStack, @@ -603,7 +603,7 @@ describe('QueueRunner', function() { return p2; } }, - queueRunner = new jasmineUnderTest.QueueRunner({ + queueRunner = new privateUnderTest.QueueRunner({ queueableFns: [queueableFn1, queueableFn2], onComplete: onComplete }); @@ -634,7 +634,7 @@ describe('QueueRunner', function() { }, queueableFn2 = { fn: jasmine.createSpy('fn2') }, onExceptionCallback = jasmine.createSpy('on exception callback'), - queueRunner = new jasmineUnderTest.QueueRunner({ + queueRunner = new privateUnderTest.QueueRunner({ queueableFns: [queueableFn1, queueableFn2], onException: onExceptionCallback }); @@ -657,7 +657,7 @@ describe('QueueRunner', function() { } }, onException = jasmine.createSpy('onException'), - queueRunner = new jasmineUnderTest.QueueRunner({ + queueRunner = new privateUnderTest.QueueRunner({ queueableFns: [queueableFn], onException: onException }); @@ -678,7 +678,7 @@ describe('QueueRunner', function() { it('issues a more specific error if the function is `async`', function() { async function fn(done) {} const onException = jasmine.createSpy('onException'), - queueRunner = new jasmineUnderTest.QueueRunner({ + queueRunner = new privateUnderTest.QueueRunner({ queueableFns: [{ fn: fn }], onException: onException }); @@ -699,7 +699,7 @@ describe('QueueRunner', function() { it('passes final errors to exception handlers', function() { const error = new Error('fake error'), onExceptionCallback = jasmine.createSpy('on exception callback'), - queueRunner = new jasmineUnderTest.QueueRunner({ + queueRunner = new privateUnderTest.QueueRunner({ onException: onExceptionCallback }); @@ -717,7 +717,7 @@ describe('QueueRunner', function() { } }, onExceptionCallback = jasmine.createSpy('on exception callback'), - queueRunner = new jasmineUnderTest.QueueRunner({ + queueRunner = new privateUnderTest.QueueRunner({ queueableFns: [queueableFn], onException: onExceptionCallback }); @@ -734,7 +734,7 @@ describe('QueueRunner', function() { } }, nextQueueableFn = { fn: jasmine.createSpy('nextFunction') }, - queueRunner = new jasmineUnderTest.QueueRunner({ + queueRunner = new privateUnderTest.QueueRunner({ queueableFns: [queueableFn, nextQueueableFn] }); @@ -747,7 +747,7 @@ describe('QueueRunner', function() { const SkipPolicy = jasmine.createSpy('SkipPolicy ctor'); const queueableFns = [{ fn: () => {} }, { fn: () => {} }]; - new jasmineUnderTest.QueueRunner({ + new privateUnderTest.QueueRunner({ queueableFns, SkipPolicy }); @@ -769,7 +769,7 @@ describe('QueueRunner', function() { skipPolicy.skipTo.and.callFake(function(lastRanIx) { return lastRanIx === 0 ? 2 : lastRanIx + 1; }); - const queueRunner = new jasmineUnderTest.QueueRunner({ + const queueRunner = new privateUnderTest.QueueRunner({ queueableFns, SkipPolicy: function() { return skipPolicy; @@ -790,7 +790,7 @@ describe('QueueRunner', function() { it('throws if the skip policy returns the current fn', function() { const skipPolicy = { skipTo: i => i }; const queueableFns = [{ fn: () => {} }]; - const queueRunner = new jasmineUnderTest.QueueRunner({ + const queueRunner = new privateUnderTest.QueueRunner({ queueableFns, SkipPolicy: function() { return skipPolicy; @@ -816,17 +816,17 @@ describe('QueueRunner', function() { type: 'specCleanup' }, onComplete = jasmine.createSpy('onComplete'), - queueRunner = new jasmineUnderTest.QueueRunner({ + queueRunner = new privateUnderTest.QueueRunner({ queueableFns: [queueableFn, nextQueueableFn, cleanupFn], onComplete: onComplete, - SkipPolicy: jasmineUnderTest.CompleteOnFirstErrorSkipPolicy + SkipPolicy: privateUnderTest.CompleteOnFirstErrorSkipPolicy }); queueRunner.execute(); expect(nextQueueableFn.fn).not.toHaveBeenCalled(); expect(cleanupFn.fn).toHaveBeenCalled(); expect(onComplete).toHaveBeenCalledWith( - jasmine.any(jasmineUnderTest.StopExecutionError) + jasmine.any(privateUnderTest.StopExecutionError) ); }); @@ -842,9 +842,9 @@ describe('QueueRunner', function() { fn: jasmine.createSpy('cleanupFn2'), type: 'afterEach' }, - queueRunner = new jasmineUnderTest.QueueRunner({ + queueRunner = new privateUnderTest.QueueRunner({ queueableFns: [queueableFn, cleanupFn1, cleanupFn2], - SkipPolicy: jasmineUnderTest.CompleteOnFirstErrorSkipPolicy + SkipPolicy: privateUnderTest.CompleteOnFirstErrorSkipPolicy }); queueRunner.execute(); @@ -873,7 +873,7 @@ describe('QueueRunner', function() { fn: jasmine.createSpy('cleanup'), type: 'specCleanup' }; - const queueRunner = new jasmineUnderTest.QueueRunner({ + const queueRunner = new privateUnderTest.QueueRunner({ globalErrors: { pushListener: function(f) { errorListeners.push(f); @@ -883,7 +883,7 @@ describe('QueueRunner', function() { } }, queueableFns: [queueableFn, nextQueueableFn, cleanupFn], - SkipPolicy: jasmineUnderTest.CompleteOnFirstErrorSkipPolicy + SkipPolicy: privateUnderTest.CompleteOnFirstErrorSkipPolicy }); queueRunner.execute(); @@ -902,9 +902,9 @@ describe('QueueRunner', function() { }, nextQueueableFn = { fn: jasmine.createSpy('nextFunction') }, cleanupFn = { fn: jasmine.createSpy('cleanup'), type: 'specCleanup' }, - queueRunner = new jasmineUnderTest.QueueRunner({ + queueRunner = new privateUnderTest.QueueRunner({ queueableFns: [queueableFn, nextQueueableFn, cleanupFn], - SkipPolicy: jasmineUnderTest.CompleteOnFirstErrorSkipPolicy + SkipPolicy: privateUnderTest.CompleteOnFirstErrorSkipPolicy }); queueRunner.execute(); @@ -924,9 +924,9 @@ describe('QueueRunner', function() { fn: jasmine.createSpy('cleanup'), type: 'specCleanup' }, - queueRunner = new jasmineUnderTest.QueueRunner({ + queueRunner = new privateUnderTest.QueueRunner({ queueableFns: [queueableFn, nextQueueableFn, cleanupFn], - SkipPolicy: jasmineUnderTest.CompleteOnFirstErrorSkipPolicy + SkipPolicy: privateUnderTest.CompleteOnFirstErrorSkipPolicy }); queueRunner.execute(); @@ -940,7 +940,7 @@ describe('QueueRunner', function() { it('calls a provided complete callback when done', function() { const queueableFn = { fn: jasmine.createSpy('fn') }, completeCallback = jasmine.createSpy('completeCallback'), - queueRunner = new jasmineUnderTest.QueueRunner({ + queueRunner = new privateUnderTest.QueueRunner({ queueableFns: [queueableFn], onComplete: completeCallback }); @@ -968,7 +968,7 @@ describe('QueueRunner', function() { afterFn = { fn: jasmine.createSpy('afterFn') }, completeCallback = jasmine.createSpy('completeCallback'), clearStack = jasmine.createSpy('clearStack'), - queueRunner = new jasmineUnderTest.QueueRunner({ + queueRunner = new privateUnderTest.QueueRunner({ queueableFns: [asyncFn, afterFn], clearStack: clearStack, onComplete: completeCallback @@ -992,7 +992,7 @@ describe('QueueRunner', function() { const fn = jasmine.createSpy('fn1'); this.fn = fn; - this.queueRunner = new jasmineUnderTest.QueueRunner({ + this.queueRunner = new privateUnderTest.QueueRunner({ queueableFns: [{ fn: fn }] }); }); @@ -1005,7 +1005,7 @@ describe('QueueRunner', function() { this.queueRunner.execute(); - expect(context.constructor).toBe(jasmineUnderTest.UserContext); + expect(context.constructor).toBe(privateUnderTest.UserContext); }); }); @@ -1015,8 +1015,8 @@ describe('QueueRunner', function() { let context; this.fn = fn; - this.context = context = new jasmineUnderTest.UserContext(); - this.queueRunner = new jasmineUnderTest.QueueRunner({ + this.context = context = new privateUnderTest.UserContext(); + this.queueRunner = new privateUnderTest.QueueRunner({ queueableFns: [{ fn: fn }], userContext: context }); diff --git a/spec/core/ReportDispatcherSpec.js b/spec/core/ReportDispatcherSpec.js index c1234e65..260aa28b 100644 --- a/spec/core/ReportDispatcherSpec.js +++ b/spec/core/ReportDispatcherSpec.js @@ -1,6 +1,6 @@ describe('ReportDispatcher', function() { it('builds an interface of requested methods', function() { - const dispatcher = new jasmineUnderTest.ReportDispatcher([ + const dispatcher = new privateUnderTest.ReportDispatcher([ 'foo', 'bar', 'baz' @@ -13,7 +13,7 @@ describe('ReportDispatcher', function() { it('dispatches requested methods to added reporters', function() { const runQueue = jasmine.createSpy('runQueue'), - dispatcher = new jasmineUnderTest.ReportDispatcher( + dispatcher = new privateUnderTest.ReportDispatcher( ['foo', 'bar'], runQueue ), @@ -68,7 +68,7 @@ describe('ReportDispatcher', function() { it('passes each reporter a separate deep copy of the event', function() { const runQueue = jasmine.createSpy('runQueue'); - const dispatcher = new jasmineUnderTest.ReportDispatcher( + const dispatcher = new privateUnderTest.ReportDispatcher( ['foo', 'bar'], runQueue ); @@ -101,7 +101,7 @@ describe('ReportDispatcher', function() { it("does not dispatch to a reporter if the reporter doesn't accept the method", function() { const runQueue = jasmine.createSpy('runQueue'), - dispatcher = new jasmineUnderTest.ReportDispatcher(['foo'], runQueue), + dispatcher = new privateUnderTest.ReportDispatcher(['foo'], runQueue), reporter = jasmine.createSpyObj('reporter', ['baz']); dispatcher.addReporter(reporter); @@ -116,7 +116,7 @@ describe('ReportDispatcher', function() { it("allows providing a fallback reporter in case there's no other reporter", function() { const runQueue = jasmine.createSpy('runQueue'), - dispatcher = new jasmineUnderTest.ReportDispatcher( + dispatcher = new privateUnderTest.ReportDispatcher( ['foo', 'bar'], runQueue ), @@ -139,7 +139,7 @@ describe('ReportDispatcher', function() { it('does not call fallback reporting methods when another reporter is provided', function() { const runQueue = jasmine.createSpy('runQueue'), - dispatcher = new jasmineUnderTest.ReportDispatcher( + dispatcher = new privateUnderTest.ReportDispatcher( ['foo', 'bar'], runQueue ), @@ -165,7 +165,7 @@ describe('ReportDispatcher', function() { it('allows registered reporters to be cleared', function() { const runQueue = jasmine.createSpy('runQueue'), - dispatcher = new jasmineUnderTest.ReportDispatcher( + dispatcher = new privateUnderTest.ReportDispatcher( ['foo', 'bar'], runQueue ), diff --git a/spec/core/RunableResourcesSpec.js b/spec/core/RunableResourcesSpec.js index a337c291..20283de4 100644 --- a/spec/core/RunableResourcesSpec.js +++ b/spec/core/RunableResourcesSpec.js @@ -38,7 +38,7 @@ describe('RunableResources', function() { describe('#addCustomMatchers', function() { it("adds all properties to the current runable's matchers", function() { const currentRunableId = 1; - const runableResources = new jasmineUnderTest.RunableResources({ + const runableResources = new privateUnderTest.RunableResources({ globalErrors: stubGlobalErrors(), getCurrentRunableId: () => currentRunableId }); @@ -70,7 +70,7 @@ describe('RunableResources', function() { describe('#addCustomAsyncMatchers', function() { it("adds all properties to the current runable's matchers", function() { const currentRunableId = 1; - const runableResources = new jasmineUnderTest.RunableResources({ + const runableResources = new privateUnderTest.RunableResources({ globalErrors: stubGlobalErrors(), getCurrentRunableId: () => currentRunableId }); @@ -95,7 +95,7 @@ describe('RunableResources', function() { describe('#defaultSpyStrategy', function() { it('returns undefined for a newly initialized resource', function() { let currentRunableId = 1; - const runableResources = new jasmineUnderTest.RunableResources({ + const runableResources = new privateUnderTest.RunableResources({ globalErrors: stubGlobalErrors(), getCurrentRunableId: () => currentRunableId }); @@ -106,7 +106,7 @@ describe('RunableResources', function() { it('returns the value previously set by #setDefaultSpyStrategy', function() { let currentRunableId = 1; - const runableResources = new jasmineUnderTest.RunableResources({ + const runableResources = new privateUnderTest.RunableResources({ globalErrors: stubGlobalErrors(), getCurrentRunableId: () => currentRunableId }); @@ -119,7 +119,7 @@ describe('RunableResources', function() { it('is per-runable', function() { let currentRunableId = 1; - const runableResources = new jasmineUnderTest.RunableResources({ + const runableResources = new privateUnderTest.RunableResources({ globalErrors: stubGlobalErrors(), getCurrentRunableId: () => currentRunableId }); @@ -132,7 +132,7 @@ describe('RunableResources', function() { }); it('does not require a current runable', function() { - const runableResources = new jasmineUnderTest.RunableResources({ + const runableResources = new privateUnderTest.RunableResources({ globalErrors: stubGlobalErrors(), getCurrentRunableId: () => null }); @@ -141,7 +141,7 @@ describe('RunableResources', function() { it("inherits the parent runable's value", function() { let currentRunableId = 1; - const runableResources = new jasmineUnderTest.RunableResources({ + const runableResources = new privateUnderTest.RunableResources({ globalErrors: stubGlobalErrors(), getCurrentRunableId: () => currentRunableId }); @@ -157,7 +157,7 @@ describe('RunableResources', function() { describe('#setDefaultSpyStrategy', function() { it('throws a user-facing error when there is no current runable', function() { - const runableResources = new jasmineUnderTest.RunableResources({ + const runableResources = new privateUnderTest.RunableResources({ globalErrors: stubGlobalErrors(), getCurrentRunableId: () => null }); @@ -171,21 +171,21 @@ describe('RunableResources', function() { describe('#makePrettyPrinter', function() { it('returns a pretty printer configured with the current customObjectFormatters', function() { - const runableResources = new jasmineUnderTest.RunableResources({ + const runableResources = new privateUnderTest.RunableResources({ globalErrors: stubGlobalErrors(), getCurrentRunableId: () => 1 }); runableResources.initForRunable(1); function cof() {} runableResources.customObjectFormatters().push(cof); - spyOn(jasmineUnderTest, 'makePrettyPrinter').and.callThrough(); + spyOn(privateUnderTest, 'makePrettyPrinter').and.callThrough(); const pp = runableResources.makePrettyPrinter(); - expect(jasmineUnderTest.makePrettyPrinter).toHaveBeenCalledOnceWith([ + expect(privateUnderTest.makePrettyPrinter).toHaveBeenCalledOnceWith([ cof ]); expect(pp).toBe( - jasmineUnderTest.makePrettyPrinter.calls.first().returnValue + privateUnderTest.makePrettyPrinter.calls.first().returnValue ); }); }); @@ -193,7 +193,7 @@ describe('RunableResources', function() { describe('#makeMatchersUtil', function() { describe('When there is a current runable', function() { it('returns a MatchersUtil configured with the current resources', function() { - const runableResources = new jasmineUnderTest.RunableResources({ + const runableResources = new privateUnderTest.RunableResources({ globalErrors: stubGlobalErrors(), getCurrentRunableId: () => 1 }); @@ -204,26 +204,26 @@ describe('RunableResources', function() { runableResources.customEqualityTesters().push(ceq); const expectedPP = {}; const expectedMatchersUtil = {}; - spyOn(jasmineUnderTest, 'makePrettyPrinter').and.returnValue( + spyOn(privateUnderTest, 'makePrettyPrinter').and.returnValue( expectedPP ); - spyOn(jasmineUnderTest, 'MatchersUtil').and.returnValue( + spyOn(privateUnderTest, 'MatchersUtil').and.returnValue( expectedMatchersUtil ); const matchersUtil = runableResources.makeMatchersUtil(); expect(matchersUtil).toBe(expectedMatchersUtil); - expect(jasmineUnderTest.makePrettyPrinter).toHaveBeenCalledOnceWith([ + expect(privateUnderTest.makePrettyPrinter).toHaveBeenCalledOnceWith([ cof ]); // We need === equality on the pp passed to MatchersUtil - expect(jasmineUnderTest.MatchersUtil).toHaveBeenCalledOnceWith( + expect(privateUnderTest.MatchersUtil).toHaveBeenCalledOnceWith( jasmine.objectContaining({ customTesters: [ceq] }) ); - expect(jasmineUnderTest.MatchersUtil.calls.argsFor(0)[0].pp).toBe( + expect(privateUnderTest.MatchersUtil.calls.argsFor(0)[0].pp).toBe( expectedPP ); }); @@ -231,12 +231,12 @@ describe('RunableResources', function() { describe('When there is no current runable', function() { it('returns a MatchersUtil configured with defaults', function() { - const runableResources = new jasmineUnderTest.RunableResources({ + const runableResources = new privateUnderTest.RunableResources({ globalErrors: stubGlobalErrors(), getCurrentRunableId: () => null }); const expectedMatchersUtil = {}; - spyOn(jasmineUnderTest, 'MatchersUtil').and.returnValue( + spyOn(privateUnderTest, 'MatchersUtil').and.returnValue( expectedMatchersUtil ); @@ -244,12 +244,12 @@ describe('RunableResources', function() { expect(matchersUtil).toBe(expectedMatchersUtil); // We need === equality on the pp passed to MatchersUtil - expect(jasmineUnderTest.MatchersUtil).toHaveBeenCalledTimes(1); - expect(jasmineUnderTest.MatchersUtil.calls.argsFor(0)[0].pp).toBe( - jasmineUnderTest.basicPrettyPrinter_ + expect(privateUnderTest.MatchersUtil).toHaveBeenCalledTimes(1); + expect(privateUnderTest.MatchersUtil.calls.argsFor(0)[0].pp).toBe( + privateUnderTest.basicPrettyPrinter ); expect( - jasmineUnderTest.MatchersUtil.calls.argsFor(0)[0].customTesters + privateUnderTest.MatchersUtil.calls.argsFor(0)[0].customTesters ).toBeUndefined(); }); }); @@ -258,11 +258,11 @@ describe('RunableResources', function() { describe('.spyFactory', function() { describe('When there is no current runable', function() { it('is configured with default strategies and matchersUtil', function() { - const runableResources = new jasmineUnderTest.RunableResources({ + const runableResources = new privateUnderTest.RunableResources({ globalErrors: stubGlobalErrors(), getCurrentRunableId: () => null }); - spyOn(jasmineUnderTest, 'Spy'); + spyOn(privateUnderTest, 'Spy'); const matchersUtil = {}; spyOn(runableResources, 'makeMatchersUtil').and.returnValue( matchersUtil @@ -270,7 +270,7 @@ describe('RunableResources', function() { runableResources.spyFactory.createSpy('foo'); - expect(jasmineUnderTest.Spy).toHaveBeenCalledWith( + expect(privateUnderTest.Spy).toHaveBeenCalledWith( 'foo', is(matchersUtil), jasmine.objectContaining({ @@ -283,7 +283,7 @@ describe('RunableResources', function() { describe('When there is a current runable', function() { it("is configured with the current runable's strategies and matchersUtil", function() { - const runableResources = new jasmineUnderTest.RunableResources({ + const runableResources = new privateUnderTest.RunableResources({ globalErrors: stubGlobalErrors(), getCurrentRunableId: () => 1 }); @@ -292,7 +292,7 @@ describe('RunableResources', function() { function defaultStrategy() {} runableResources.customSpyStrategies().foo = customStrategy; runableResources.setDefaultSpyStrategy(defaultStrategy); - spyOn(jasmineUnderTest, 'Spy'); + spyOn(privateUnderTest, 'Spy'); const matchersUtil = {}; spyOn(runableResources, 'makeMatchersUtil').and.returnValue( matchersUtil @@ -300,7 +300,7 @@ describe('RunableResources', function() { runableResources.spyFactory.createSpy('foo'); - expect(jasmineUnderTest.Spy).toHaveBeenCalledWith( + expect(privateUnderTest.Spy).toHaveBeenCalledWith( 'foo', is(matchersUtil), jasmine.objectContaining({ @@ -325,7 +325,7 @@ describe('RunableResources', function() { describe('.spyRegistry', function() { it("writes to the current runable's spies", function() { - const runableResources = new jasmineUnderTest.RunableResources({ + const runableResources = new privateUnderTest.RunableResources({ globalErrors: stubGlobalErrors(), getCurrentRunableId: () => 1 }); @@ -348,7 +348,7 @@ describe('RunableResources', function() { describe('#clearForRunable', function() { it('removes resources for the specified runable', function() { - const runableResources = new jasmineUnderTest.RunableResources({ + const runableResources = new privateUnderTest.RunableResources({ globalErrors: stubGlobalErrors(), getCurrentRunableId: () => 1 }); @@ -363,7 +363,7 @@ describe('RunableResources', function() { }); it('clears spies', function() { - const runableResources = new jasmineUnderTest.RunableResources({ + const runableResources = new privateUnderTest.RunableResources({ globalErrors: stubGlobalErrors(), getCurrentRunableId: () => 1 }); @@ -381,7 +381,7 @@ describe('RunableResources', function() { const globalErrors = jasmine.createSpyObj('globalErrors', [ 'removeOverrideListener' ]); - const runableResources = new jasmineUnderTest.RunableResources({ + const runableResources = new privateUnderTest.RunableResources({ getCurrentRunableId: () => 1, globalErrors }); @@ -392,7 +392,7 @@ describe('RunableResources', function() { }); it('does not remove resources for other runables', function() { - const runableResources = new jasmineUnderTest.RunableResources({ + const runableResources = new privateUnderTest.RunableResources({ globalErrors: stubGlobalErrors(), getCurrentRunableId: () => 1 }); @@ -411,7 +411,7 @@ describe('RunableResources', function() { ) { it('is initially empty', function() { const currentRunableId = 1; - const runableResources = new jasmineUnderTest.RunableResources({ + const runableResources = new privateUnderTest.RunableResources({ globalErrors: stubGlobalErrors(), getCurrentRunableId: () => currentRunableId }); @@ -422,7 +422,7 @@ describe('RunableResources', function() { it('is mutable', function() { const currentRunableId = 1; - const runableResources = new jasmineUnderTest.RunableResources({ + const runableResources = new privateUnderTest.RunableResources({ globalErrors: stubGlobalErrors(), getCurrentRunableId: () => currentRunableId }); @@ -434,7 +434,7 @@ describe('RunableResources', function() { it('is per-runable', function() { let currentRunableId = 1; - const runableResources = new jasmineUnderTest.RunableResources({ + const runableResources = new privateUnderTest.RunableResources({ globalErrors: stubGlobalErrors(), getCurrentRunableId: () => currentRunableId }); @@ -446,7 +446,7 @@ describe('RunableResources', function() { }); it('throws a user-facing error when there is no current runable', function() { - const runableResources = new jasmineUnderTest.RunableResources({ + const runableResources = new privateUnderTest.RunableResources({ globalErrors: stubGlobalErrors(), getCurrentRunableId: () => null }); @@ -458,7 +458,7 @@ describe('RunableResources', function() { if (inherits) { it('inherits from the parent runable', function() { let currentRunableId = 1; - const runableResources = new jasmineUnderTest.RunableResources({ + const runableResources = new privateUnderTest.RunableResources({ globalErrors: stubGlobalErrors(), getCurrentRunableId: () => currentRunableId }); @@ -480,7 +480,7 @@ describe('RunableResources', function() { function behavesLikeAPerRunableMutableObject(methodName, errorMsg) { it('is initially empty', function() { const currentRunableId = 1; - const runableResources = new jasmineUnderTest.RunableResources({ + const runableResources = new privateUnderTest.RunableResources({ globalErrors: stubGlobalErrors(), getCurrentRunableId: () => currentRunableId }); @@ -491,7 +491,7 @@ describe('RunableResources', function() { it('is mutable', function() { const currentRunableId = 1; - const runableResources = new jasmineUnderTest.RunableResources({ + const runableResources = new privateUnderTest.RunableResources({ globalErrors: stubGlobalErrors(), getCurrentRunableId: () => currentRunableId }); @@ -503,7 +503,7 @@ describe('RunableResources', function() { it('is per-runable', function() { let currentRunableId = 1; - const runableResources = new jasmineUnderTest.RunableResources({ + const runableResources = new privateUnderTest.RunableResources({ globalErrors: stubGlobalErrors(), getCurrentRunableId: () => currentRunableId }); @@ -515,7 +515,7 @@ describe('RunableResources', function() { }); it('throws a user-facing error when there is no current runable', function() { - const runableResources = new jasmineUnderTest.RunableResources({ + const runableResources = new privateUnderTest.RunableResources({ globalErrors: stubGlobalErrors(), getCurrentRunableId: () => null }); @@ -526,7 +526,7 @@ describe('RunableResources', function() { it('inherits from the parent runable', function() { let currentRunableId = 1; - const runableResources = new jasmineUnderTest.RunableResources({ + const runableResources = new privateUnderTest.RunableResources({ globalErrors: stubGlobalErrors(), getCurrentRunableId: () => currentRunableId }); diff --git a/spec/core/RunnerSpec.js b/spec/core/RunnerSpec.js index 57547975..b4170886 100644 --- a/spec/core/RunnerSpec.js +++ b/spec/core/RunnerSpec.js @@ -15,10 +15,10 @@ describe('Runner', function() { globalErrors = 'the global errors instance'; reportDispatcher = jasmine.createSpyObj( 'reportDispatcher', - jasmineUnderTest.reporterEvents + privateUnderTest.reporterEvents ); - for (const k of jasmineUnderTest.reporterEvents) { + for (const k of privateUnderTest.reporterEvents) { reportDispatcher[k].and.returnValue(Promise.resolve()); } @@ -26,7 +26,7 @@ describe('Runner', function() { failSpecWithNoExpectations = false; detectLateRejectionHandling = false; - spyOn(jasmineUnderTest.TreeRunner.prototype, '_executeSpec'); + spyOn(privateUnderTest.TreeRunner.prototype, '_executeSpec'); }); function StubSuite(attrs) { @@ -72,7 +72,7 @@ describe('Runner', function() { }), focusedRunables: () => [], totalSpecsDefined: () => 1, - TreeProcessor: jasmineUnderTest.TreeProcessor, + TreeProcessor: privateUnderTest.TreeProcessor, runableResources: { initForRunable: () => {}, clearForRunable: () => {} @@ -81,7 +81,7 @@ describe('Runner', function() { globalErrors, runQueue }; - return new jasmineUnderTest.Runner({ + return new privateUnderTest.Runner({ ...defaultOptions, topSuite }); @@ -90,7 +90,7 @@ describe('Runner', function() { function arrayNotContaining(item) { return { asymmetricMatch(other, matchersUtil) { - if (!jasmine.isArray_(other)) { + if (!jasmine.private.isArray(other)) { return false; } @@ -105,9 +105,9 @@ describe('Runner', function() { }; } - // Precondition: jasmineUnderTest.TreeRunner.prototype._executeSpec is a spy + // Precondition: privateUnderTest.TreeRunner.prototype._executeSpec is a spy function verifyAndFinishSpec(spec, queueableFn, shouldBeExcluded) { - const ex = jasmineUnderTest.TreeRunner.prototype._executeSpec; + const ex = privateUnderTest.TreeRunner.prototype._executeSpec; ex.withArgs(spec, 'onComplete').and.callThrough(); queueableFn.fn('onComplete'); @@ -116,7 +116,7 @@ describe('Runner', function() { expect(runQueue).toHaveBeenCalledWith( jasmine.objectContaining({ isLeaf: true, - SkipPolicy: jasmineUnderTest.CompleteOnFirstErrorSkipPolicy, + SkipPolicy: privateUnderTest.CompleteOnFirstErrorSkipPolicy, queueableFns: shouldBeExcluded ? arrayNotContaining(spec.queueableFn) : jasmine.arrayContaining([spec.queueableFn]) @@ -142,7 +142,7 @@ describe('Runner', function() { userContext: { root: 'context' }, queueableFns: [{ fn: jasmine.any(Function) }], onMultipleDone: null, - SkipPolicy: jasmineUnderTest.SkipAfterBeforeAllErrorPolicy + SkipPolicy: privateUnderTest.SkipAfterBeforeAllErrorPolicy }); const runQueueArgs = runQueue.calls.mostRecent().args[0]; @@ -169,7 +169,7 @@ describe('Runner', function() { userContext: { for: 'topSuite' }, queueableFns: [{ fn: jasmine.any(Function) }], onMultipleDone: null, - SkipPolicy: jasmineUnderTest.SkipAfterBeforeAllErrorPolicy + SkipPolicy: privateUnderTest.SkipAfterBeforeAllErrorPolicy }); const runQueueArgs = runQueue.calls.mostRecent().args[0]; @@ -182,7 +182,7 @@ describe('Runner', function() { userContext: { for: 'suite' }, onException: jasmine.any(Function), onMultipleDone: null, - SkipPolicy: jasmineUnderTest.SkipAfterBeforeAllErrorPolicy + SkipPolicy: privateUnderTest.SkipAfterBeforeAllErrorPolicy }); runQueue.calls.mostRecent().args[0].queueableFns[0].fn('foo'); @@ -266,7 +266,7 @@ describe('Runner', function() { queueableFns[1].fn('foo'); expect( - jasmineUnderTest.TreeRunner.prototype._executeSpec + privateUnderTest.TreeRunner.prototype._executeSpec ).toHaveBeenCalledWith(spec, 'foo'); await expectAsync(promise).toBePending(); @@ -362,16 +362,16 @@ describe('Runner', function() { queueableFns[0].fn('done'); expect( - jasmineUnderTest.TreeRunner.prototype._executeSpec + privateUnderTest.TreeRunner.prototype._executeSpec ).not.toHaveBeenCalledWith(specs[0], jasmine.anything()); expect( - jasmineUnderTest.TreeRunner.prototype._executeSpec + privateUnderTest.TreeRunner.prototype._executeSpec ).toHaveBeenCalledWith(specs[1], 'done'); queueableFns[1].fn('done'); expect( - jasmineUnderTest.TreeRunner.prototype._executeSpec + privateUnderTest.TreeRunner.prototype._executeSpec ).toHaveBeenCalledWith(specs[0], 'done'); await expectAsync(promise).toBePending(); @@ -390,16 +390,16 @@ describe('Runner', function() { queueableFns[0].fn('done'); expect( - jasmineUnderTest.TreeRunner.prototype._executeSpec + privateUnderTest.TreeRunner.prototype._executeSpec ).not.toHaveBeenCalledWith(nonSpecified, jasmine.anything()); expect( - jasmineUnderTest.TreeRunner.prototype._executeSpec + privateUnderTest.TreeRunner.prototype._executeSpec ).toHaveBeenCalledWith(specified, 'done'); queueableFns[1].fn('done'); expect( - jasmineUnderTest.TreeRunner.prototype._executeSpec + privateUnderTest.TreeRunner.prototype._executeSpec ).toHaveBeenCalledWith(nonSpecified, 'done'); await expectAsync(promise).toBePending(); @@ -424,12 +424,12 @@ describe('Runner', function() { const nodeQueueableFns = runQueue.calls.mostRecent().args[0].queueableFns; nodeQueueableFns[1].fn('done'); expect( - jasmineUnderTest.TreeRunner.prototype._executeSpec + privateUnderTest.TreeRunner.prototype._executeSpec ).toHaveBeenCalledWith(nonSpecifiedSpec, 'done'); queueableFns[1].fn('done'); expect( - jasmineUnderTest.TreeRunner.prototype._executeSpec + privateUnderTest.TreeRunner.prototype._executeSpec ).toHaveBeenCalledWith(specifiedSpec, 'done'); await expectAsync(promise).toBePending(); @@ -451,7 +451,7 @@ describe('Runner', function() { queueableFns[0].fn('done'); expect( - jasmineUnderTest.TreeRunner.prototype._executeSpec + privateUnderTest.TreeRunner.prototype._executeSpec ).toHaveBeenCalledWith(spec1, 'done'); queueableFns[1].fn(); @@ -459,12 +459,12 @@ describe('Runner', function() { expect(childFns.length).toBe(3); childFns[1].fn('done'); expect( - jasmineUnderTest.TreeRunner.prototype._executeSpec + privateUnderTest.TreeRunner.prototype._executeSpec ).toHaveBeenCalledWith(spec2, 'done'); childFns[2].fn('done'); expect( - jasmineUnderTest.TreeRunner.prototype._executeSpec + privateUnderTest.TreeRunner.prototype._executeSpec ).toHaveBeenCalledWith(spec3, 'done'); await expectAsync(promise).toBePending(); @@ -496,12 +496,12 @@ describe('Runner', function() { expect(runQueue.calls.mostRecent().args[0].queueableFns.length).toBe(2); runQueue.calls.mostRecent().args[0].queueableFns[1].fn('done'); expect( - jasmineUnderTest.TreeRunner.prototype._executeSpec + privateUnderTest.TreeRunner.prototype._executeSpec ).toHaveBeenCalledWith(spec1, 'done'); queueableFns[1].fn('done'); expect( - jasmineUnderTest.TreeRunner.prototype._executeSpec + privateUnderTest.TreeRunner.prototype._executeSpec ).toHaveBeenCalledWith(spec4, 'done'); queueableFns[2].fn(); @@ -509,12 +509,12 @@ describe('Runner', function() { expect(runQueue.calls.mostRecent().args[0].queueableFns.length).toBe(2); runQueue.calls.mostRecent().args[0].queueableFns[1].fn('done'); expect( - jasmineUnderTest.TreeRunner.prototype._executeSpec + privateUnderTest.TreeRunner.prototype._executeSpec ).toHaveBeenCalledWith(spec2, 'done'); queueableFns[3].fn('done'); expect( - jasmineUnderTest.TreeRunner.prototype._executeSpec + privateUnderTest.TreeRunner.prototype._executeSpec ).toHaveBeenCalledWith(spec5, 'done'); queueableFns[4].fn(); @@ -522,7 +522,7 @@ describe('Runner', function() { expect(runQueue.calls.mostRecent().args[0].queueableFns.length).toBe(2); runQueue.calls.mostRecent().args[0].queueableFns[1].fn('done'); expect( - jasmineUnderTest.TreeRunner.prototype._executeSpec + privateUnderTest.TreeRunner.prototype._executeSpec ).toHaveBeenCalledWith(spec3, 'done'); await expectAsync(promise).toBePending(); @@ -561,12 +561,12 @@ describe('Runner', function() { runQueue.calls.mostRecent().args[0].queueableFns[1].fn('done'); expect( - jasmineUnderTest.TreeRunner.prototype._executeSpec + privateUnderTest.TreeRunner.prototype._executeSpec ).toHaveBeenCalledWith(spec1, 'done'); queueableFns[1].fn('done'); expect( - jasmineUnderTest.TreeRunner.prototype._executeSpec + privateUnderTest.TreeRunner.prototype._executeSpec ).toHaveBeenCalledWith(spec4, 'done'); queueableFns[2].fn(); @@ -578,12 +578,12 @@ describe('Runner', function() { runQueue.calls.mostRecent().args[0].queueableFns[1].fn('done'); expect( - jasmineUnderTest.TreeRunner.prototype._executeSpec + privateUnderTest.TreeRunner.prototype._executeSpec ).toHaveBeenCalledWith(spec2, 'done'); queueableFns[3].fn('done'); expect( - jasmineUnderTest.TreeRunner.prototype._executeSpec + privateUnderTest.TreeRunner.prototype._executeSpec ).toHaveBeenCalledWith(spec5, 'done'); queueableFns[4].fn(); @@ -595,7 +595,7 @@ describe('Runner', function() { runQueue.calls.mostRecent().args[0].queueableFns[1].fn('done'); expect( - jasmineUnderTest.TreeRunner.prototype._executeSpec + privateUnderTest.TreeRunner.prototype._executeSpec ).toHaveBeenCalledWith(spec3, 'done'); await expectAsync(promise).toBePending(); @@ -620,7 +620,7 @@ describe('Runner', function() { for (let i = 0; i < 11; i++) { queueableFns[i].fn('done'); expect( - jasmineUnderTest.TreeRunner.prototype._executeSpec + privateUnderTest.TreeRunner.prototype._executeSpec ).toHaveBeenCalledWith(specs[i], 'done'); } diff --git a/spec/core/SkipAfterBeforeAllErrorPolicySpec.js b/spec/core/SkipAfterBeforeAllErrorPolicySpec.js index 455f4381..c4b8f37f 100644 --- a/spec/core/SkipAfterBeforeAllErrorPolicySpec.js +++ b/spec/core/SkipAfterBeforeAllErrorPolicySpec.js @@ -2,7 +2,7 @@ describe('SkipAfterBeforeAllErrorPolicy', function() { describe('#skipTo', function() { describe('When nothing has errored', function() { it('does not skip anything', function() { - const policy = new jasmineUnderTest.SkipAfterBeforeAllErrorPolicy( + const policy = new privateUnderTest.SkipAfterBeforeAllErrorPolicy( arrayOfArbitraryFns(4) ); @@ -15,7 +15,7 @@ describe('SkipAfterBeforeAllErrorPolicy', function() { describe('When anything but a beforeAll has errored', function() { it('does not skip anything', function() { - const policy = new jasmineUnderTest.SkipAfterBeforeAllErrorPolicy( + const policy = new privateUnderTest.SkipAfterBeforeAllErrorPolicy( arrayOfArbitraryFns(4) ); @@ -40,7 +40,7 @@ describe('SkipAfterBeforeAllErrorPolicy', function() { { type: 'afterAll', fn: () => {} }, { type: 'afterAll', fn: () => {} } ]; - const policy = new jasmineUnderTest.SkipAfterBeforeAllErrorPolicy(fns); + const policy = new privateUnderTest.SkipAfterBeforeAllErrorPolicy(fns); policy.fnErrored(0); expect(policy.skipTo(0)).toEqual(3); @@ -54,7 +54,7 @@ describe('SkipAfterBeforeAllErrorPolicy', function() { it("sets the suite's hadBeforeAllFailure property to true", function() { const suite = {}; const fns = [{ type: 'beforeAll', fn: () => {}, suite }]; - const policy = new jasmineUnderTest.SkipAfterBeforeAllErrorPolicy(fns); + const policy = new privateUnderTest.SkipAfterBeforeAllErrorPolicy(fns); policy.fnErrored(0); @@ -65,7 +65,7 @@ describe('SkipAfterBeforeAllErrorPolicy', function() { describe('When the fn is not a beforeAll', function() { it('does not try to access the suite, which is probably not there', function() { const fns = [{ fn: () => {} /* no suite */ }]; - const policy = new jasmineUnderTest.SkipAfterBeforeAllErrorPolicy(fns); + const policy = new privateUnderTest.SkipAfterBeforeAllErrorPolicy(fns); expect(() => policy.fnErrored(0)).not.toThrow(); }); diff --git a/spec/core/SpecSpec.js b/spec/core/SpecSpec.js index 18769efa..13bcddf7 100644 --- a/spec/core/SpecSpec.js +++ b/spec/core/SpecSpec.js @@ -1,24 +1,24 @@ describe('Spec', function() { it('#isPendingSpecException returns true for a pending spec exception', function() { - const e = new Error(jasmineUnderTest.Spec.pendingSpecExceptionMessage); + const e = new Error(privateUnderTest.Spec.pendingSpecExceptionMessage); - expect(jasmineUnderTest.Spec.isPendingSpecException(e)).toBe(true); + expect(privateUnderTest.Spec.isPendingSpecException(e)).toBe(true); }); it('#isPendingSpecException returns true for a pending spec exception (even when FF bug is present)', function() { const fakeError = { toString: function() { - return 'Error: ' + jasmineUnderTest.Spec.pendingSpecExceptionMessage; + return 'Error: ' + privateUnderTest.Spec.pendingSpecExceptionMessage; } }; - expect(jasmineUnderTest.Spec.isPendingSpecException(fakeError)).toBe(true); + expect(privateUnderTest.Spec.isPendingSpecException(fakeError)).toBe(true); }); it('#isPendingSpecException returns true for a pending spec exception with a custom message', function() { expect( - jasmineUnderTest.Spec.isPendingSpecException( - jasmineUnderTest.Spec.pendingSpecExceptionMessage + 'foo' + privateUnderTest.Spec.isPendingSpecException( + privateUnderTest.Spec.pendingSpecExceptionMessage + 'foo' ) ).toBe(true); }); @@ -26,16 +26,16 @@ describe('Spec', function() { it('#isPendingSpecException returns false for not a pending spec exception', function() { const e = new Error('foo'); - expect(jasmineUnderTest.Spec.isPendingSpecException(e)).toBe(false); + expect(privateUnderTest.Spec.isPendingSpecException(e)).toBe(false); }); it("#isPendingSpecException returns false for thrown values that don't have toString", function() { - expect(jasmineUnderTest.Spec.isPendingSpecException(void 0)).toBe(false); + expect(privateUnderTest.Spec.isPendingSpecException(void 0)).toBe(false); }); describe('#executionFinished', function() { it('removes the fn if autoCleanClosures is true', function() { - const spec = new jasmineUnderTest.Spec({ + const spec = new privateUnderTest.Spec({ queueableFn: { fn: () => {} }, autoCleanClosures: true }); @@ -45,7 +45,7 @@ describe('Spec', function() { }); it('removes the fn after execution if autoCleanClosures is undefined', function() { - const spec = new jasmineUnderTest.Spec({ + const spec = new privateUnderTest.Spec({ queueableFn: { fn: () => {} }, autoCleanClosures: undefined }); @@ -56,7 +56,7 @@ describe('Spec', function() { it('does not remove the fn after execution if autoCleanClosures is false', function() { function originalFn() {} - const spec = new jasmineUnderTest.Spec({ + const spec = new privateUnderTest.Spec({ queueableFn: { fn: originalFn }, autoCleanClosures: false }); @@ -68,7 +68,7 @@ describe('Spec', function() { describe('#getSpecProperty', function() { it('get the property value', function() { - const spec = new jasmineUnderTest.Spec({ + const spec = new privateUnderTest.Spec({ queueableFn: { fn: () => {} } }); @@ -79,7 +79,7 @@ describe('Spec', function() { describe('#setSpecProperty', function() { it('adds the property to the result', function() { - const spec = new jasmineUnderTest.Spec({ + const spec = new privateUnderTest.Spec({ queueableFn: { fn: () => {} } }); @@ -89,7 +89,7 @@ describe('Spec', function() { }); it('replace the property result when it was previously set', function() { - const spec = new jasmineUnderTest.Spec({ + const spec = new privateUnderTest.Spec({ queueableFn: { fn: () => {} } }); @@ -104,7 +104,7 @@ describe('Spec', function() { }); it('throws if the key is not structured-cloneable', function() { - const spec = new jasmineUnderTest.Spec({ + const spec = new privateUnderTest.Spec({ queueableFn: { fn: () => {} } }); @@ -114,7 +114,7 @@ describe('Spec', function() { }); it('throws if the value is not structured-cloneable', function() { - const spec = new jasmineUnderTest.Spec({ + const spec = new privateUnderTest.Spec({ queueableFn: { fn: () => {} } }); @@ -126,14 +126,14 @@ describe('Spec', function() { describe('status', function() { it('is "passed" by default', function() { - const spec = new jasmineUnderTest.Spec({ + const spec = new privateUnderTest.Spec({ queueableFn: { fn: () => {} } }); expect(spec.getResult().status).toBe('passed'); }); it('is "passed" if all expectations passed', function() { - const spec = new jasmineUnderTest.Spec({ + const spec = new privateUnderTest.Spec({ queueableFn: { fn: () => {} } }); @@ -143,7 +143,7 @@ describe('Spec', function() { }); it('is "failed" if any expectation failed', function() { - const spec = new jasmineUnderTest.Spec({ + const spec = new privateUnderTest.Spec({ queueableFn: { fn: () => {} } }); @@ -156,7 +156,7 @@ describe('Spec', function() { it('is "pending" if created without a function body', function() { const startCallback = jasmine.createSpy('startCallback'), resultCallback = jasmine.createSpy('resultCallback'), - spec = new jasmineUnderTest.Spec({ + spec = new privateUnderTest.Spec({ onStart: startCallback, queueableFn: { fn: null }, resultCallback: resultCallback @@ -168,7 +168,7 @@ describe('Spec', function() { describe('#addExpectationResult', function() { it('keeps track of passed and failed expectations', function() { - const spec = new jasmineUnderTest.Spec({ + const spec = new privateUnderTest.Spec({ queueableFn: { fn: () => {} } }); @@ -185,7 +185,7 @@ describe('Spec', function() { describe("when 'throwOnExpectationFailure' is set", function() { it('throws an ExpectationFailed error', function() { - const spec = new jasmineUnderTest.Spec({ + const spec = new privateUnderTest.Spec({ queueableFn: { fn: () => {} }, throwOnExpectationFailure: true }); @@ -193,7 +193,7 @@ describe('Spec', function() { spec.addExpectationResult(true, { message: 'passed' }); expect(function() { spec.addExpectationResult(false, { message: 'failed' }); - }).toThrowError(jasmineUnderTest.errors.ExpectationFailed); + }).toThrowError(jasmineUnderTest.private.errors.ExpectationFailed); expect(spec.result.failedExpectations).toEqual([ jasmine.objectContaining({ message: 'failed' }) @@ -203,7 +203,7 @@ describe('Spec', function() { describe("when 'throwOnExpectationFailure' is not set", function() { it('does not throw', function() { - const spec = new jasmineUnderTest.Spec({ + const spec = new privateUnderTest.Spec({ queueableFn: { fn: () => {} } }); @@ -218,7 +218,7 @@ describe('Spec', function() { it('forwards late expectation failures to onLateError', function() { const onLateError = jasmine.createSpy('onLateError'); - const spec = new jasmineUnderTest.Spec({ + const spec = new privateUnderTest.Spec({ onLateError, queueableFn: { fn: function() {} } }); @@ -243,7 +243,7 @@ describe('Spec', function() { it('does not forward non-late expectation failures to onLateError', function() { const onLateError = jasmine.createSpy('onLateError'); - const spec = new jasmineUnderTest.Spec({ + const spec = new privateUnderTest.Spec({ onLateError, queueableFn: { fn: function() {} } }); @@ -262,7 +262,7 @@ describe('Spec', function() { it('forwards late handleException calls to onLateError', function() { const onLateError = jasmine.createSpy('onLateError'); - const spec = new jasmineUnderTest.Spec({ + const spec = new privateUnderTest.Spec({ onLateError, queueableFn: { fn: function() {} } }); @@ -280,7 +280,7 @@ describe('Spec', function() { it('does not forward non-late handleException calls to onLateError', function() { const onLateError = jasmine.createSpy('onLateError'); - const spec = new jasmineUnderTest.Spec({ + const spec = new privateUnderTest.Spec({ onLateError, queueableFn: { fn: function() {} } }); @@ -293,7 +293,7 @@ describe('Spec', function() { }); it('clears the reportedDone flag when reset', function() { - const spec = new jasmineUnderTest.Spec({ + const spec = new privateUnderTest.Spec({ queueableFn: { fn: function() {} } }); spec.reportedDone = true; @@ -305,7 +305,7 @@ describe('Spec', function() { it('does not throw an ExpectationFailed error when handling an error', function() { const resultCallback = jasmine.createSpy('resultCallback'), - spec = new jasmineUnderTest.Spec({ + spec = new privateUnderTest.Spec({ queueableFn: { fn: function() {} }, resultCallback: resultCallback, throwOnExpectationFailure: true @@ -319,7 +319,7 @@ describe('Spec', function() { .createSpy('getPath') .and.returnValue(['expected', 'val']); - const spec = new jasmineUnderTest.Spec({ + const spec = new privateUnderTest.Spec({ getPath, queueableFn: { fn: null } }); @@ -333,7 +333,7 @@ describe('Spec', function() { .createSpy('getPath') .and.returnValue(['expected val']); - const spec = new jasmineUnderTest.Spec({ + const spec = new privateUnderTest.Spec({ getPath, queueableFn: { fn: null } }); @@ -346,7 +346,7 @@ describe('Spec', function() { describe('#handleException', function() { it('records a failure', function() { - const spec = new jasmineUnderTest.Spec({ + const spec = new privateUnderTest.Spec({ queueableFn: {} }); @@ -364,11 +364,13 @@ describe('Spec', function() { }); it('does not record an additional failure when the error is ExpectationFailed', function() { - const spec = new jasmineUnderTest.Spec({ + const spec = new privateUnderTest.Spec({ queueableFn: {} }); - spec.handleException(new jasmineUnderTest.errors.ExpectationFailed()); + spec.handleException( + new jasmineUnderTest.private.errors.ExpectationFailed() + ); expect(spec.result.failedExpectations).toEqual([]); }); @@ -377,7 +379,7 @@ describe('Spec', function() { describe('#debugLog', function() { it('adds the messages to the result', function() { const timer = jasmine.createSpyObj('timer', ['start', 'elapsed']); - const spec = new jasmineUnderTest.Spec({ + const spec = new privateUnderTest.Spec({ queueableFn: { fn: () => {} }, timer: timer }); @@ -400,7 +402,7 @@ describe('Spec', function() { describe('When the spec passes', function() { it('removes the logs from the result', function() { - const spec = new jasmineUnderTest.Spec({ + const spec = new privateUnderTest.Spec({ queueableFn: { fn: () => {} } }); @@ -414,7 +416,7 @@ describe('Spec', function() { describe('When the spec fails', function() { it('includes the messages in the result', function() { const timer = jasmine.createSpyObj('timer', ['start', 'elapsed']); - const spec = new jasmineUnderTest.Spec({ + const spec = new privateUnderTest.Spec({ queueableFn: { fn: () => {} }, timer: timer }); @@ -435,7 +437,7 @@ describe('Spec', function() { describe('#startedEvent', function() { it('includes only properties that are known before execution', function() { - const spec = new jasmineUnderTest.Spec({ + const spec = new privateUnderTest.Spec({ id: 'spec1', parentSuiteId: 'suite1', description: 'a spec', @@ -464,7 +466,7 @@ describe('Spec', function() { return 123; } }; - const spec = new jasmineUnderTest.Spec({ + const spec = new privateUnderTest.Spec({ id: 'spec1', parentSuiteId: 'suite1', description: 'a spec', @@ -514,7 +516,7 @@ describe('Spec', function() { return 123; } }; - const spec = new jasmineUnderTest.Spec({ + const spec = new privateUnderTest.Spec({ id: 'spec1', parentSuiteId: 'suite1', description: 'a spec', @@ -571,7 +573,7 @@ describe('Spec', function() { }); it("reports a status of 'pending' for a declaratively pended spec", function() { - const spec = new jasmineUnderTest.Spec({ + const spec = new privateUnderTest.Spec({ queueableFn: {} }); @@ -583,7 +585,7 @@ describe('Spec', function() { }); it("reports a status of 'pending' for a spec pended by #pend", function() { - const spec = new jasmineUnderTest.Spec({ + const spec = new privateUnderTest.Spec({ queueableFn: { fn: () => {} } }); @@ -596,7 +598,7 @@ describe('Spec', function() { }); it("reports a status of 'excluded' for an excluded spec", function() { - const spec = new jasmineUnderTest.Spec({ + const spec = new privateUnderTest.Spec({ queueableFn: { fn: () => {} } }); @@ -607,7 +609,7 @@ describe('Spec', function() { describe('When failSpecWithNoExpectations is true', function() { it("reports a status of 'failed' for a spec with no expectations", function() { - const spec = new jasmineUnderTest.Spec({ + const spec = new privateUnderTest.Spec({ queueableFn: { fn: () => {} } }); @@ -618,7 +620,7 @@ describe('Spec', function() { }); it('includes deprecation warnings', function() { - const spec = new jasmineUnderTest.Spec({ + const spec = new privateUnderTest.Spec({ queueableFn: { fn: () => {} } }); @@ -643,7 +645,7 @@ describe('Spec', function() { return 123; } }; - const spec = new jasmineUnderTest.Spec({ + const spec = new privateUnderTest.Spec({ timer, queueableFn: { fn: () => {} } }); @@ -659,7 +661,7 @@ describe('Spec', function() { }); it('includes spec properties', function() { - const spec = new jasmineUnderTest.Spec({ + const spec = new privateUnderTest.Spec({ queueableFn: { fn: () => {} } }); diff --git a/spec/core/SpyRegistrySpec.js b/spec/core/SpyRegistrySpec.js index 74ba4a2d..1d5f772b 100644 --- a/spec/core/SpyRegistrySpec.js +++ b/spec/core/SpyRegistrySpec.js @@ -1,11 +1,11 @@ describe('SpyRegistry', function() { function createSpy(name, originalFn) { - return jasmineUnderTest.Spy(name, originalFn); + return privateUnderTest.Spy(name, originalFn); } describe('#spyOn', function() { it('checks for the existence of the object', function() { - const spyRegistry = new jasmineUnderTest.SpyRegistry({ + const spyRegistry = new privateUnderTest.SpyRegistry({ createSpy: createSpy }); expect(function() { @@ -14,7 +14,7 @@ describe('SpyRegistry', function() { }); it('checks that a method name was passed', function() { - const spyRegistry = new jasmineUnderTest.SpyRegistry(), + const spyRegistry = new privateUnderTest.SpyRegistry(), target = {}; expect(function() { @@ -23,14 +23,14 @@ describe('SpyRegistry', function() { }); it('checks that the object is not `null`', function() { - const spyRegistry = new jasmineUnderTest.SpyRegistry(); + const spyRegistry = new privateUnderTest.SpyRegistry(); expect(function() { spyRegistry.spyOn(null, 'pants'); }).toThrowError(/could not find an object/); }); it('checks that the method name is not `null`', function() { - const spyRegistry = new jasmineUnderTest.SpyRegistry(), + const spyRegistry = new privateUnderTest.SpyRegistry(), target = {}; expect(function() { @@ -39,7 +39,7 @@ describe('SpyRegistry', function() { }); it('checks for the existence of the method', function() { - const spyRegistry = new jasmineUnderTest.SpyRegistry(), + const spyRegistry = new privateUnderTest.SpyRegistry(), target = {}; expect(function() { @@ -49,7 +49,7 @@ describe('SpyRegistry', function() { it('checks if it has already been spied upon', function() { const spies = [], - spyRegistry = new jasmineUnderTest.SpyRegistry({ + spyRegistry = new privateUnderTest.SpyRegistry({ currentSpies: function() { return spies; }, @@ -78,7 +78,7 @@ describe('SpyRegistry', function() { }); const spies = [], - spyRegistry = new jasmineUnderTest.SpyRegistry({ + spyRegistry = new privateUnderTest.SpyRegistry({ currentSpies: function() { return spies; } @@ -108,7 +108,7 @@ describe('SpyRegistry', function() { set() {} }); - const spyRegistry = new jasmineUnderTest.SpyRegistry({ + const spyRegistry = new privateUnderTest.SpyRegistry({ createSpy: createSpy }); expect(function() { @@ -120,7 +120,7 @@ describe('SpyRegistry', function() { it('overrides the method on the object and returns the spy', function() { let originalFunctionWasCalled = false; - const spyRegistry = new jasmineUnderTest.SpyRegistry({ + const spyRegistry = new privateUnderTest.SpyRegistry({ createSpy: createSpy }); const target = { @@ -137,11 +137,11 @@ describe('SpyRegistry', function() { }); it('throws if the method is a mock clock method', function() { - const spyRegistry = new jasmineUnderTest.SpyRegistry({ + const spyRegistry = new privateUnderTest.SpyRegistry({ createSpy: createSpy }); const target = { spiedFunc: function() {} }; - target.spiedFunc[jasmineUnderTest.Clock.IsMockClockTimingFn] = true; + target.spiedFunc[privateUnderTest.Clock.IsMockClockTimingFn] = true; expect(function() { spyRegistry.spyOn(target, 'spiedFunc'); @@ -151,14 +151,14 @@ describe('SpyRegistry', function() { describe('#spyOnProperty', function() { it('checks for the existence of the object', function() { - const spyRegistry = new jasmineUnderTest.SpyRegistry(); + const spyRegistry = new privateUnderTest.SpyRegistry(); expect(function() { spyRegistry.spyOnProperty(void 0, 'pants'); }).toThrowError(/could not find an object/); }); it('checks that a property name was passed', function() { - const spyRegistry = new jasmineUnderTest.SpyRegistry(), + const spyRegistry = new privateUnderTest.SpyRegistry(), target = {}; expect(function() { @@ -167,7 +167,7 @@ describe('SpyRegistry', function() { }); it('checks for the existence of the method', function() { - const spyRegistry = new jasmineUnderTest.SpyRegistry(), + const spyRegistry = new privateUnderTest.SpyRegistry(), target = {}; expect(function() { @@ -176,7 +176,7 @@ describe('SpyRegistry', function() { }); it('checks for the existence of access type', function() { - const spyRegistry = new jasmineUnderTest.SpyRegistry(), + const spyRegistry = new privateUnderTest.SpyRegistry(), target = {}; Object.defineProperty(target, 'pants', { @@ -203,7 +203,7 @@ describe('SpyRegistry', function() { configurable: true }); - const spyRegistry = new jasmineUnderTest.SpyRegistry(); + const spyRegistry = new privateUnderTest.SpyRegistry(); expect(function() { spyRegistry.spyOnProperty(target, 'myProp'); @@ -215,7 +215,7 @@ describe('SpyRegistry', function() { }); it('overrides the property getter on the object and returns the spy', function() { - const spyRegistry = new jasmineUnderTest.SpyRegistry({ + const spyRegistry = new privateUnderTest.SpyRegistry({ createSpy: createSpy }), target = {}, @@ -239,7 +239,7 @@ describe('SpyRegistry', function() { }); it('overrides the property setter on the object and returns the spy', function() { - const spyRegistry = new jasmineUnderTest.SpyRegistry({ + const spyRegistry = new privateUnderTest.SpyRegistry({ createSpy: createSpy }), target = {}, @@ -263,7 +263,7 @@ describe('SpyRegistry', function() { describe('when the property is already spied upon', function() { it('throws an error if respy is not allowed', function() { - const spyRegistry = new jasmineUnderTest.SpyRegistry({ + const spyRegistry = new privateUnderTest.SpyRegistry({ createSpy: createSpy }), target = {}; @@ -283,7 +283,7 @@ describe('SpyRegistry', function() { }); it('returns the original spy if respy is allowed', function() { - const spyRegistry = new jasmineUnderTest.SpyRegistry({ + const spyRegistry = new privateUnderTest.SpyRegistry({ createSpy: createSpy }), target = {}; @@ -308,14 +308,14 @@ describe('SpyRegistry', function() { describe('#spyOnAllFunctions', function() { it('checks for the existence of the object', function() { - const spyRegistry = new jasmineUnderTest.SpyRegistry(); + const spyRegistry = new privateUnderTest.SpyRegistry(); expect(function() { spyRegistry.spyOnAllFunctions(void 0); }).toThrowError(/spyOnAllFunctions could not find an object to spy upon/); }); it('overrides all writable and configurable functions of the object and its parents', function() { - const spyRegistry = new jasmineUnderTest.SpyRegistry({ + const spyRegistry = new privateUnderTest.SpyRegistry({ createSpy: function() { return 'I am a spy'; } @@ -405,7 +405,7 @@ describe('SpyRegistry', function() { }); it('overrides prototype methods on the object', function() { - const spyRegistry = new jasmineUnderTest.SpyRegistry({ + const spyRegistry = new privateUnderTest.SpyRegistry({ createSpy: function() { return 'I am a spy'; } @@ -428,7 +428,7 @@ describe('SpyRegistry', function() { }); it('does not override non-enumerable properties (like Object.prototype methods)', function() { - const spyRegistry = new jasmineUnderTest.SpyRegistry({ + const spyRegistry = new privateUnderTest.SpyRegistry({ createSpy: function() { return 'I am a spy'; } @@ -445,7 +445,7 @@ describe('SpyRegistry', function() { }); describe('when includeNonEnumerable is true', function() { it('does not override Object.prototype methods', function() { - const spyRegistry = new jasmineUnderTest.SpyRegistry({ + const spyRegistry = new privateUnderTest.SpyRegistry({ createSpy: function() { return 'I am a spy'; } @@ -462,7 +462,7 @@ describe('SpyRegistry', function() { }); it('overrides non-enumerable properties', function() { - const spyRegistry = new jasmineUnderTest.SpyRegistry({ + const spyRegistry = new privateUnderTest.SpyRegistry({ createSpy: function() { return 'I am a spy'; } @@ -485,7 +485,7 @@ describe('SpyRegistry', function() { }); it('should not spy on non-enumerable functions named constructor', function() { - const spyRegistry = new jasmineUnderTest.SpyRegistry({ + const spyRegistry = new privateUnderTest.SpyRegistry({ createSpy: function() { return 'I am a spy'; } @@ -506,7 +506,7 @@ describe('SpyRegistry', function() { }); it('should spy on enumerable functions named constructor', function() { - const spyRegistry = new jasmineUnderTest.SpyRegistry({ + const spyRegistry = new privateUnderTest.SpyRegistry({ createSpy: function() { return 'I am a spy'; } @@ -521,7 +521,7 @@ describe('SpyRegistry', function() { }); it('should not throw an exception if we try and access strict mode restricted properties', function() { - const spyRegistry = new jasmineUnderTest.SpyRegistry({ + const spyRegistry = new privateUnderTest.SpyRegistry({ createSpy: function() { return 'I am a spy'; } @@ -535,7 +535,7 @@ describe('SpyRegistry', function() { }); it('should not spy on properties which are more permissable further up the prototype chain', function() { - const spyRegistry = new jasmineUnderTest.SpyRegistry({ + const spyRegistry = new privateUnderTest.SpyRegistry({ createSpy: function() { return 'I am a spy'; } @@ -565,7 +565,7 @@ describe('SpyRegistry', function() { describe('#clearSpies', function() { it('restores the original functions on the spied-upon objects', function() { const spies = [], - spyRegistry = new jasmineUnderTest.SpyRegistry({ + spyRegistry = new privateUnderTest.SpyRegistry({ currentSpies: function() { return spies; }, @@ -582,7 +582,7 @@ describe('SpyRegistry', function() { it('restores the original functions, even when that spy has been replace and re-spied upon', function() { const spies = [], - spyRegistry = new jasmineUnderTest.SpyRegistry({ + spyRegistry = new privateUnderTest.SpyRegistry({ currentSpies: function() { return spies; }, @@ -606,7 +606,7 @@ describe('SpyRegistry', function() { it("does not add a property that the spied-upon object didn't originally have", function() { const spies = [], - spyRegistry = new jasmineUnderTest.SpyRegistry({ + spyRegistry = new privateUnderTest.SpyRegistry({ currentSpies: function() { return spies; }, @@ -628,7 +628,7 @@ describe('SpyRegistry', function() { it("restores the original function when it's inherited and cannot be deleted", function() { const spies = [], - spyRegistry = new jasmineUnderTest.SpyRegistry({ + spyRegistry = new privateUnderTest.SpyRegistry({ currentSpies: function() { return spies; }, @@ -657,7 +657,7 @@ describe('SpyRegistry', function() { const spies = [], global = new FakeWindow(), - spyRegistry = new jasmineUnderTest.SpyRegistry({ + spyRegistry = new privateUnderTest.SpyRegistry({ currentSpies: function() { return spies; }, @@ -675,7 +675,7 @@ describe('SpyRegistry', function() { describe('spying on properties', function() { it('restores the original properties on the spied-upon objects', function() { const spies = [], - spyRegistry = new jasmineUnderTest.SpyRegistry({ + spyRegistry = new privateUnderTest.SpyRegistry({ currentSpies: function() { return spies; }, @@ -699,7 +699,7 @@ describe('SpyRegistry', function() { it("does not add a property that the spied-upon object didn't originally have", function() { const spies = [], - spyRegistry = new jasmineUnderTest.SpyRegistry({ + spyRegistry = new privateUnderTest.SpyRegistry({ currentSpies: function() { return spies; }, diff --git a/spec/core/SpySpec.js b/spec/core/SpySpec.js index d880d290..0280a658 100644 --- a/spec/core/SpySpec.js +++ b/spec/core/SpySpec.js @@ -2,7 +2,7 @@ describe('Spies', function() { let env; beforeEach(function() { - env = new jasmineUnderTest.Env(); + env = new privateUnderTest.Env(); }); afterEach(function() { @@ -50,8 +50,8 @@ describe('Spies', function() { TestClass.prototype.someFunction ); - expect(spy.and).toEqual(jasmine.any(jasmineUnderTest.SpyStrategy)); - expect(spy.calls).toEqual(jasmine.any(jasmineUnderTest.CallTracker)); + expect(spy.and).toEqual(jasmine.any(privateUnderTest.SpyStrategy)); + expect(spy.calls).toEqual(jasmine.any(privateUnderTest.CallTracker)); }); it('tracks the argument of calls', function() { @@ -241,7 +241,7 @@ describe('Spies', function() { }); it('uses the provided matchersUtil selecting a strategy', function() { - const matchersUtil = new jasmineUnderTest.MatchersUtil({ + const matchersUtil = new privateUnderTest.MatchersUtil({ customTesters: [ function(a, b) { if ((a === 'bar' && b === 'baz') || (a === 'baz' && b === 'bar')) { @@ -250,7 +250,7 @@ describe('Spies', function() { } ] }); - const spy = new jasmineUnderTest.Spy('aSpy', matchersUtil); + const spy = new privateUnderTest.Spy('aSpy', matchersUtil); spy.and.returnValue('default strategy return value'); spy.withArgs('bar').and.returnValue('custom strategy return value'); expect(spy('foo')).toEqual('default strategy return value'); diff --git a/spec/core/SpyStrategySpec.js b/spec/core/SpyStrategySpec.js index a6492018..57c35e9d 100644 --- a/spec/core/SpyStrategySpec.js +++ b/spec/core/SpyStrategySpec.js @@ -1,19 +1,19 @@ describe('SpyStrategy', function() { it('defaults its name to unknown', function() { - const spyStrategy = new jasmineUnderTest.SpyStrategy(); + const spyStrategy = new privateUnderTest.SpyStrategy(); expect(spyStrategy.identity).toEqual('unknown'); }); it('takes a name', function() { - const spyStrategy = new jasmineUnderTest.SpyStrategy({ name: 'foo' }); + const spyStrategy = new privateUnderTest.SpyStrategy({ name: 'foo' }); expect(spyStrategy.identity).toEqual('foo'); }); it('stubs an original function, if provided', function() { const originalFn = jasmine.createSpy('original'), - spyStrategy = new jasmineUnderTest.SpyStrategy({ fn: originalFn }); + spyStrategy = new privateUnderTest.SpyStrategy({ fn: originalFn }); spyStrategy.exec(); @@ -22,7 +22,7 @@ describe('SpyStrategy', function() { it("allows an original function to be called, passed through the params and returns it's value", function() { const originalFn = jasmine.createSpy('original').and.returnValue(42), - spyStrategy = new jasmineUnderTest.SpyStrategy({ fn: originalFn }); + spyStrategy = new privateUnderTest.SpyStrategy({ fn: originalFn }); spyStrategy.callThrough(); const returnValue = spyStrategy.exec(null, ['foo']); @@ -34,7 +34,7 @@ describe('SpyStrategy', function() { it('can return a specified value when executed', function() { const originalFn = jasmine.createSpy('original'), - spyStrategy = new jasmineUnderTest.SpyStrategy({ fn: originalFn }); + spyStrategy = new privateUnderTest.SpyStrategy({ fn: originalFn }); spyStrategy.returnValue(17); const returnValue = spyStrategy.exec(); @@ -45,7 +45,7 @@ describe('SpyStrategy', function() { it('can return specified values in order specified when executed', function() { const originalFn = jasmine.createSpy('original'), - spyStrategy = new jasmineUnderTest.SpyStrategy({ fn: originalFn }); + spyStrategy = new privateUnderTest.SpyStrategy({ fn: originalFn }); spyStrategy.returnValues('value1', 'value2', 'value3'); @@ -58,7 +58,7 @@ describe('SpyStrategy', function() { it('allows an exception to be thrown when executed', function() { const originalFn = jasmine.createSpy('original'), - spyStrategy = new jasmineUnderTest.SpyStrategy({ fn: originalFn }); + spyStrategy = new privateUnderTest.SpyStrategy({ fn: originalFn }); spyStrategy.throwError(new TypeError('bar')); @@ -70,7 +70,7 @@ describe('SpyStrategy', function() { it('allows a string to be thrown, wrapping it into an exception when executed', function() { const originalFn = jasmine.createSpy('original'), - spyStrategy = new jasmineUnderTest.SpyStrategy({ fn: originalFn }); + spyStrategy = new privateUnderTest.SpyStrategy({ fn: originalFn }); spyStrategy.throwError('bar'); @@ -82,7 +82,7 @@ describe('SpyStrategy', function() { it('allows a non-Error to be thrown when executed', function() { const originalFn = jasmine.createSpy('original'), - spyStrategy = new jasmineUnderTest.SpyStrategy({ fn: originalFn }); + spyStrategy = new privateUnderTest.SpyStrategy({ fn: originalFn }); spyStrategy.throwError({ code: 'ESRCH' }); @@ -95,7 +95,7 @@ describe('SpyStrategy', function() { it('allows a fake function to be called instead', function() { const originalFn = jasmine.createSpy('original'), fakeFn = jasmine.createSpy('fake').and.returnValue(67), - spyStrategy = new jasmineUnderTest.SpyStrategy({ fn: originalFn }); + spyStrategy = new privateUnderTest.SpyStrategy({ fn: originalFn }); spyStrategy.callFake(fakeFn); const returnValue = spyStrategy.exec(); @@ -109,7 +109,7 @@ describe('SpyStrategy', function() { fakeFn = jasmine.createSpy('fake').and.callFake(async () => { return 67; }), - spyStrategy = new jasmineUnderTest.SpyStrategy({ fn: originalFn }); + spyStrategy = new privateUnderTest.SpyStrategy({ fn: originalFn }); spyStrategy.callFake(fakeFn); spyStrategy @@ -128,7 +128,7 @@ describe('SpyStrategy', function() { describe('#resolveTo', function() { it('allows a resolved promise to be returned', function(done) { const originalFn = jasmine.createSpy('original'), - spyStrategy = new jasmineUnderTest.SpyStrategy({ + spyStrategy = new privateUnderTest.SpyStrategy({ fn: originalFn }); @@ -144,7 +144,7 @@ describe('SpyStrategy', function() { it('allows an empty resolved promise to be returned', function(done) { const originalFn = jasmine.createSpy('original'), - spyStrategy = new jasmineUnderTest.SpyStrategy({ + spyStrategy = new privateUnderTest.SpyStrategy({ fn: originalFn }); @@ -162,7 +162,7 @@ describe('SpyStrategy', function() { describe('#rejectWith', function() { it('allows a rejected promise to be returned', function(done) { const originalFn = jasmine.createSpy('original'), - spyStrategy = new jasmineUnderTest.SpyStrategy({ + spyStrategy = new privateUnderTest.SpyStrategy({ fn: originalFn }); @@ -179,7 +179,7 @@ describe('SpyStrategy', function() { it('allows an empty rejected promise to be returned', function(done) { const originalFn = jasmine.createSpy('original'), - spyStrategy = new jasmineUnderTest.SpyStrategy({ + spyStrategy = new privateUnderTest.SpyStrategy({ fn: originalFn }); @@ -196,7 +196,7 @@ describe('SpyStrategy', function() { it('allows a non-Error to be rejected', function(done) { const originalFn = jasmine.createSpy('original'), - spyStrategy = new jasmineUnderTest.SpyStrategy({ + spyStrategy = new privateUnderTest.SpyStrategy({ fn: originalFn }); @@ -220,7 +220,7 @@ describe('SpyStrategy', function() { .createSpy('custom strategy') .and.returnValue(plan), originalFn = jasmine.createSpy('original'), - spyStrategy = new jasmineUnderTest.SpyStrategy({ + spyStrategy = new privateUnderTest.SpyStrategy({ fn: originalFn, customStrategies: { doSomething: customStrategy @@ -237,7 +237,7 @@ describe('SpyStrategy', function() { it("throws an error if a custom strategy doesn't return a function", function() { const originalFn = jasmine.createSpy('original'), - spyStrategy = new jasmineUnderTest.SpyStrategy({ + spyStrategy = new privateUnderTest.SpyStrategy({ fn: originalFn, customStrategies: { doSomething: function() { @@ -252,37 +252,32 @@ describe('SpyStrategy', function() { }); it('does not allow custom strategies to overwrite existing methods', function() { - const spyStrategy = new jasmineUnderTest.SpyStrategy({ + const spyStrategy = new privateUnderTest.SpyStrategy({ fn: function() {}, customStrategies: { exec: function() {} } }); - expect(spyStrategy.exec).toBe(jasmineUnderTest.SpyStrategy.prototype.exec); + expect(spyStrategy.exec).toBe(privateUnderTest.SpyStrategy.prototype.exec); }); it('throws an error when a non-function is passed to callFake strategy', function() { const originalFn = jasmine.createSpy('original'), - spyStrategy = new jasmineUnderTest.SpyStrategy({ fn: originalFn }); - - spyOn(jasmineUnderTest, 'isFunction_').and.returnValue(false); - spyOn(jasmineUnderTest, 'isAsyncFunction_').and.returnValue(false); + spyStrategy = new privateUnderTest.SpyStrategy({ fn: originalFn }); expect(function() { - spyStrategy.callFake(function() {}); - }).toThrowError(/^Argument passed to callFake should be a function, got/); - - expect(function() { - spyStrategy.callFake(function() {}); - }).toThrowError(/^Argument passed to callFake should be a function, got/); + spyStrategy.callFake('not a function'); + }).toThrowError( + 'Argument passed to callFake should be a function, got not a function' + ); }); it('allows generator functions to be passed to callFake strategy', function() { const generator = function*() { yield 'ok'; }, - spyStrategy = new jasmineUnderTest.SpyStrategy({ fn: function() {} }); + spyStrategy = new privateUnderTest.SpyStrategy({ fn: function() {} }); spyStrategy.callFake(generator); @@ -292,7 +287,7 @@ describe('SpyStrategy', function() { it('allows a return to plan stubbing after another strategy', function() { const originalFn = jasmine.createSpy('original'), fakeFn = jasmine.createSpy('fake').and.returnValue(67), - spyStrategy = new jasmineUnderTest.SpyStrategy({ fn: originalFn }); + spyStrategy = new privateUnderTest.SpyStrategy({ fn: originalFn }); spyStrategy.callFake(fakeFn); let returnValue = spyStrategy.exec(); @@ -309,7 +304,7 @@ describe('SpyStrategy', function() { it('returns the spy after changing the strategy', function() { const spy = {}, spyFn = jasmine.createSpy('spyFn').and.returnValue(spy), - spyStrategy = new jasmineUnderTest.SpyStrategy({ getSpy: spyFn }); + spyStrategy = new privateUnderTest.SpyStrategy({ getSpy: spyFn }); expect(spyStrategy.callThrough()).toBe(spy); expect(spyStrategy.returnValue()).toBe(spy); diff --git a/spec/core/StackTraceSpec.js b/spec/core/StackTraceSpec.js index 2f94799d..0248b5f3 100644 --- a/spec/core/StackTraceSpec.js +++ b/spec/core/StackTraceSpec.js @@ -8,7 +8,7 @@ describe('StackTrace', function() { ' at QueueRunner.run (http://localhost:8888/__jasmine__/jasmine.js:4320:20)' }; - const result = new jasmineUnderTest.StackTrace(error); + const result = new privateUnderTest.StackTrace(error); expect(result.message).toEqual('Error: nope'); expect(result.style).toEqual('v8'); @@ -39,7 +39,7 @@ describe('StackTrace', function() { ' at QueueRunner.run (http://localhost:8888/__jasmine__/jasmine.js:4320:20)' }; - const result = new jasmineUnderTest.StackTrace(error); + const result = new privateUnderTest.StackTrace(error); expect(result.message).toEqual('Error: line 1\nline 2'); const rawFrames = result.frames.map(function(f) { @@ -60,7 +60,7 @@ describe('StackTrace', function() { ' at QueueRunner.run (http://localhost:8888/__jasmine__/jasmine.js:4320:20)' }; - const result = new jasmineUnderTest.StackTrace(error); + const result = new privateUnderTest.StackTrace(error); expect(result.message).toEqual('Error: line 1\n\nline 2'); const rawFrames = result.frames.map(function(f) { @@ -82,7 +82,7 @@ describe('StackTrace', function() { ' at Immediate. (/somewhere/jasmine/lib/jasmine-core/jasmine.js:4314:12)\n' + ' at runCallback (timers.js:672:20)' }; - const result = new jasmineUnderTest.StackTrace(error); + const result = new privateUnderTest.StackTrace(error); expect(result.message).toEqual('Error'); expect(result.style).toEqual('v8'); @@ -123,7 +123,7 @@ describe('StackTrace', function() { 'http://localhost:8888/__spec__/core/UtilSpec.js:115:28\n' + 'run@http://localhost:8888/__jasmine__/jasmine.js:4320:27' }; - const result = new jasmineUnderTest.StackTrace(error); + const result = new privateUnderTest.StackTrace(error); expect(result.message).toBeFalsy(); expect(result.style).toEqual('webkit'); @@ -150,7 +150,7 @@ describe('StackTrace', function() { '@http://localhost:8888/__spec__/core/FooSpec.js:164:24\n' + 'attempt@http://localhost:8888/__jasmine__/jasmine.js:8074:44\n' }; - const result = new jasmineUnderTest.StackTrace(error); + const result = new privateUnderTest.StackTrace(error); expect(result.message).toBeFalsy(); expect(result.style).toEqual('webkit'); @@ -175,7 +175,7 @@ describe('StackTrace', function() { message: 'nope', stack: 'randomcharsnotincludingwhitespace' }; - const result = new jasmineUnderTest.StackTrace(error); + const result = new privateUnderTest.StackTrace(error); expect(result.style).toBeNull(); expect(result.frames).toEqual([{ raw: error.stack }]); }); @@ -187,7 +187,7 @@ describe('StackTrace', function() { ' at UserContext. (http://localhost:8888/__spec__/core/UtilSpec.js:115:19)\n' }; - const result = new jasmineUnderTest.StackTrace(error); + const result = new privateUnderTest.StackTrace(error); expect(result.frames).toEqual([ { @@ -209,7 +209,7 @@ describe('StackTrace', function() { ' at QueueRunner.run (http://localhost:8888/__jasmine__/jasmine.js:4320:20)' }; - const result = new jasmineUnderTest.StackTrace(error); + const result = new privateUnderTest.StackTrace(error); expect(result.style).toEqual('v8'); expect(result.frames).toEqual([ { @@ -241,7 +241,7 @@ describe('StackTrace', function() { ' at QueueRunner.run (http://localhost:8888/__jasmine__/jasmine.js:4320:20)' }; - const result = new jasmineUnderTest.StackTrace(error); + const result = new privateUnderTest.StackTrace(error); expect(result.message).toEqual('TypeError: nope'); expect(result.frames).toEqual([ @@ -269,7 +269,7 @@ describe('StackTrace', function() { ' at QueueRunner.run (http://localhost:8888/__jasmine__/jasmine.js:4320:20)' }; - const result_no_error = new jasmineUnderTest.StackTrace(no_error); + const result_no_error = new privateUnderTest.StackTrace(no_error); expect(result_no_error.message).not.toEqual(jasmine.anything()); }); diff --git a/spec/core/SuiteBuilderSpec.js b/spec/core/SuiteBuilderSpec.js index 0f03579c..613144ef 100644 --- a/spec/core/SuiteBuilderSpec.js +++ b/spec/core/SuiteBuilderSpec.js @@ -1,12 +1,12 @@ describe('SuiteBuilder', function() { beforeEach(function() { // Rethrow exceptions to ease debugging - spyOn(jasmineUnderTest.Suite.prototype, 'handleException').and.callFake( + spyOn(privateUnderTest.Suite.prototype, 'handleException').and.callFake( function(e) { throw e; } ); - spyOn(jasmineUnderTest.Spec.prototype, 'handleException').and.callFake( + spyOn(privateUnderTest.Spec.prototype, 'handleException').and.callFake( function(e) { throw e; } @@ -15,9 +15,9 @@ describe('SuiteBuilder', function() { it('creates the top suite', function() { const env = { configuration: () => ({}) }; - const suiteBuilder = new jasmineUnderTest.SuiteBuilder({ env }); + const suiteBuilder = new privateUnderTest.SuiteBuilder({ env }); - expect(suiteBuilder.topSuite).toBeInstanceOf(jasmineUnderTest.Suite); + expect(suiteBuilder.topSuite).toBeInstanceOf(privateUnderTest.Suite); expect(suiteBuilder.topSuite.description).toEqual( 'Jasmine__TopLevel__Suite' ); @@ -33,7 +33,7 @@ describe('SuiteBuilder', function() { it('focuses the suite', function() { const env = { configuration: () => ({}) }; - const suiteBuilder = new jasmineUnderTest.SuiteBuilder({ env }); + const suiteBuilder = new privateUnderTest.SuiteBuilder({ env }); const suite = suiteBuilder.fdescribe('a suite', function() { suiteBuilder.it('a spec'); @@ -45,7 +45,7 @@ describe('SuiteBuilder', function() { it('unfocuses any focused ancestor suite', function() { const env = { configuration: () => ({}) }; - const suiteBuilder = new jasmineUnderTest.SuiteBuilder({ env }); + const suiteBuilder = new privateUnderTest.SuiteBuilder({ env }); const grandparent = suiteBuilder.fdescribe('a suite', function() { suiteBuilder.describe('another suite', function() { @@ -64,7 +64,7 @@ describe('SuiteBuilder', function() { it('excludes the suite', function() { const env = { configuration: () => ({}) }; - const suiteBuilder = new jasmineUnderTest.SuiteBuilder({ env }); + const suiteBuilder = new privateUnderTest.SuiteBuilder({ env }); const suite = suiteBuilder.xdescribe('a suite', function() { suiteBuilder.it('a spec'); @@ -75,7 +75,7 @@ describe('SuiteBuilder', function() { it('causes child suites to be marked excluded', function() { const env = { configuration: () => ({}) }; - const suiteBuilder = new jasmineUnderTest.SuiteBuilder({ env }); + const suiteBuilder = new privateUnderTest.SuiteBuilder({ env }); let suite; suiteBuilder.xdescribe('a suite', function() { @@ -103,7 +103,7 @@ describe('SuiteBuilder', function() { function definesSuites(fnName) { it('links suites to their parents and children', function() { const env = { configuration: () => ({}) }; - const suiteBuilder = new jasmineUnderTest.SuiteBuilder({ env }); + const suiteBuilder = new privateUnderTest.SuiteBuilder({ env }); let child; const parent = suiteBuilder[fnName]('parent', function() { @@ -120,7 +120,7 @@ describe('SuiteBuilder', function() { it('gives each suite a unique ID', function() { const env = { configuration: () => ({}) }; - const suiteBuilder = new jasmineUnderTest.SuiteBuilder({ env }); + const suiteBuilder = new privateUnderTest.SuiteBuilder({ env }); let child; const parent = suiteBuilder[fnName]('parent', function() { @@ -142,7 +142,7 @@ describe('SuiteBuilder', function() { function definesSpecs(fnName) { it('adds the spec to its suite', function() { const env = { configuration: () => ({}) }; - const suiteBuilder = new jasmineUnderTest.SuiteBuilder({ env }); + const suiteBuilder = new privateUnderTest.SuiteBuilder({ env }); let spec; const suite = suiteBuilder.describe('a suite', function() { @@ -154,7 +154,7 @@ describe('SuiteBuilder', function() { it('gives each spec a unique ID', function() { const env = { configuration: () => ({}) }; - const suiteBuilder = new jasmineUnderTest.SuiteBuilder({ env }); + const suiteBuilder = new privateUnderTest.SuiteBuilder({ env }); const spec1 = suiteBuilder[fnName]('a spec', function() {}); const spec2 = suiteBuilder[fnName]('another spec', function() {}); @@ -166,7 +166,7 @@ describe('SuiteBuilder', function() { it('gives each spec a full path', function() { const env = { configuration: () => ({}) }; - const suiteBuilder = new jasmineUnderTest.SuiteBuilder({ env }); + const suiteBuilder = new privateUnderTest.SuiteBuilder({ env }); let spec; suiteBuilder.describe('a suite', function() { @@ -199,7 +199,7 @@ describe('SuiteBuilder', function() { }); it('forbids duplicate spec names', function() { - const suiteBuilder = new jasmineUnderTest.SuiteBuilder({ env }); + const suiteBuilder = new privateUnderTest.SuiteBuilder({ env }); expect(function() { suiteBuilder.describe('a suite', function() { @@ -214,7 +214,7 @@ describe('SuiteBuilder', function() { }); it('forbids duplicate spec names in the top suite', function() { - const suiteBuilder = new jasmineUnderTest.SuiteBuilder({ env }); + const suiteBuilder = new privateUnderTest.SuiteBuilder({ env }); expect(function() { suiteBuilder.it('another spec'); @@ -225,7 +225,7 @@ describe('SuiteBuilder', function() { }); it('forbids duplicate suite names', function() { - const suiteBuilder = new jasmineUnderTest.SuiteBuilder({ env }); + const suiteBuilder = new privateUnderTest.SuiteBuilder({ env }); expect(function() { suiteBuilder.describe('a suite', function() { @@ -244,7 +244,7 @@ describe('SuiteBuilder', function() { }); it('forbids duplicate suite names in the top suite', function() { - const suiteBuilder = new jasmineUnderTest.SuiteBuilder({ env }); + const suiteBuilder = new privateUnderTest.SuiteBuilder({ env }); expect(function() { suiteBuilder.describe('a suite', function() { @@ -257,7 +257,7 @@ describe('SuiteBuilder', function() { }); it('allows spec and suite names to be duplicated in different suites', function() { - const suiteBuilder = new jasmineUnderTest.SuiteBuilder({ env }); + const suiteBuilder = new privateUnderTest.SuiteBuilder({ env }); expect(function() { suiteBuilder.describe('suite a', function() { @@ -285,7 +285,7 @@ describe('SuiteBuilder', function() { }); it('allows duplicate spec and suite names', function() { - const suiteBuilder = new jasmineUnderTest.SuiteBuilder({ env }); + const suiteBuilder = new privateUnderTest.SuiteBuilder({ env }); expect(function() { suiteBuilder.describe('dupe suite', function() { @@ -303,10 +303,10 @@ describe('SuiteBuilder', function() { describe('#parallelReset', function() { it('resets the top suite result', function() { - jasmineUnderTest.Suite.prototype.handleException.and.callThrough(); + privateUnderTest.Suite.prototype.handleException.and.callThrough(); const env = { configuration: () => ({}) }; - const suiteBuilder = new jasmineUnderTest.SuiteBuilder({ env }); + const suiteBuilder = new privateUnderTest.SuiteBuilder({ env }); suiteBuilder.topSuite.handleException(new Error('nope')); suiteBuilder.parallelReset(); @@ -326,7 +326,7 @@ describe('SuiteBuilder', function() { it('removes children of the top suite', function() { const env = { configuration: () => ({}) }; - const suiteBuilder = new jasmineUnderTest.SuiteBuilder({ env }); + const suiteBuilder = new privateUnderTest.SuiteBuilder({ env }); suiteBuilder.describe('a suite', function() { suiteBuilder.it('a nested spec'); }); @@ -339,7 +339,7 @@ describe('SuiteBuilder', function() { it('preserves top suite befores and afters', function() { const env = { configuration: () => ({}) }; - const suiteBuilder = new jasmineUnderTest.SuiteBuilder({ env }); + const suiteBuilder = new privateUnderTest.SuiteBuilder({ env }); function beforeAll() {} function beforeEach() {} @@ -369,7 +369,7 @@ describe('SuiteBuilder', function() { it('resets totalSpecsDefined', function() { const env = { configuration: () => ({}) }; - const suiteBuilder = new jasmineUnderTest.SuiteBuilder({ env }); + const suiteBuilder = new privateUnderTest.SuiteBuilder({ env }); suiteBuilder.it('a spec'); suiteBuilder.parallelReset(); @@ -379,7 +379,7 @@ describe('SuiteBuilder', function() { it('resets focusedRunables', function() { const env = { configuration: () => ({}) }; - const suiteBuilder = new jasmineUnderTest.SuiteBuilder({ env }); + const suiteBuilder = new privateUnderTest.SuiteBuilder({ env }); suiteBuilder.fit('a spec', function() {}); suiteBuilder.parallelReset(); diff --git a/spec/core/SuiteSpec.js b/spec/core/SuiteSpec.js index e3961193..4a32fab1 100644 --- a/spec/core/SuiteSpec.js +++ b/spec/core/SuiteSpec.js @@ -2,7 +2,7 @@ describe('Suite', function() { let env; beforeEach(function() { - env = new jasmineUnderTest.Env(); + env = new privateUnderTest.Env(); }); afterEach(function() { @@ -10,7 +10,7 @@ describe('Suite', function() { }); it('keeps its id', function() { - const suite = new jasmineUnderTest.Suite({ + const suite = new privateUnderTest.Suite({ env: env, id: 456, description: 'I am a suite' @@ -20,7 +20,7 @@ describe('Suite', function() { }); it('returns blank full name for top level suite', function() { - const suite = new jasmineUnderTest.Suite({ + const suite = new privateUnderTest.Suite({ env: env, description: 'I am a suite' }); @@ -29,12 +29,12 @@ describe('Suite', function() { }); it('returns its full name when it has parent suites', function() { - const parentSuite = new jasmineUnderTest.Suite({ + const parentSuite = new privateUnderTest.Suite({ env: env, description: 'I am a parent suite', parentSuite: jasmine.createSpy('pretend top level suite') }), - suite = new jasmineUnderTest.Suite({ + suite = new privateUnderTest.Suite({ env: env, description: 'I am a suite', parentSuite: parentSuite @@ -44,7 +44,7 @@ describe('Suite', function() { }); it('adds beforeEach functions in order of needed execution', function() { - const suite = new jasmineUnderTest.Suite({ + const suite = new privateUnderTest.Suite({ env: env, description: 'I am a suite' }), @@ -61,7 +61,7 @@ describe('Suite', function() { }); it('adds beforeAll functions in order of needed execution', function() { - const suite = new jasmineUnderTest.Suite({ + const suite = new privateUnderTest.Suite({ env: env, description: 'I am a suite' }), @@ -78,7 +78,7 @@ describe('Suite', function() { }); it('adds afterEach functions in order of needed execution', function() { - const suite = new jasmineUnderTest.Suite({ + const suite = new privateUnderTest.Suite({ env: env, description: 'I am a suite' }), @@ -95,7 +95,7 @@ describe('Suite', function() { }); it('adds afterAll functions in order of needed execution', function() { - const suite = new jasmineUnderTest.Suite({ + const suite = new privateUnderTest.Suite({ env: env, description: 'I am a suite' }), @@ -112,33 +112,33 @@ describe('Suite', function() { }); it('has a status of failed if any expectations have failed', function() { - const suite = new jasmineUnderTest.Suite({}); + const suite = new privateUnderTest.Suite({}); suite.addExpectationResult(false, {}); expect(suite.getResult().status).toBe('failed'); }); it('retrieves a result with updated status', function() { - const suite = new jasmineUnderTest.Suite({}); + const suite = new privateUnderTest.Suite({}); expect(suite.getResult().status).toBe('passed'); }); it('retrieves a result with pending status', function() { - const suite = new jasmineUnderTest.Suite({}); + const suite = new privateUnderTest.Suite({}); suite.pend(); expect(suite.getResult().status).toBe('pending'); }); it('throws an ExpectationFailed when receiving a failed expectation when throwOnExpectationFailure is set', function() { - const suite = new jasmineUnderTest.Suite({ + const suite = new privateUnderTest.Suite({ throwOnExpectationFailure: true }); expect(function() { suite.addExpectationResult(false, { message: 'failed' }); - }).toThrowError(jasmineUnderTest.errors.ExpectationFailed); + }).toThrowError(jasmineUnderTest.private.errors.ExpectationFailed); expect(suite.getResult().status).toBe('failed'); expect(suite.result.failedExpectations).toEqual([ @@ -147,16 +147,18 @@ describe('Suite', function() { }); it('does not add an additional failure when an expectation fails', function() { - const suite = new jasmineUnderTest.Suite({}); + const suite = new privateUnderTest.Suite({}); - suite.handleException(new jasmineUnderTest.errors.ExpectationFailed()); + suite.handleException( + new jasmineUnderTest.private.errors.ExpectationFailed() + ); expect(suite.getResult().failedExpectations).toEqual([]); }); it('forwards late expectation failures to onLateError', function() { const onLateError = jasmine.createSpy('onLateError'); - const suite = new jasmineUnderTest.Suite({ onLateError }); + const suite = new privateUnderTest.Suite({ onLateError }); const data = { matcherName: '', passed: false, @@ -178,7 +180,7 @@ describe('Suite', function() { it('does not forward non-late expectation failures to onLateError', function() { const onLateError = jasmine.createSpy('onLateError'); - const suite = new jasmineUnderTest.Suite({ + const suite = new privateUnderTest.Suite({ onLateError }); const data = { @@ -197,7 +199,7 @@ describe('Suite', function() { it('forwards late handleException calls to onLateError', function() { const onLateError = jasmine.createSpy('onLateError'); - const suite = new jasmineUnderTest.Suite({ + const suite = new privateUnderTest.Suite({ onLateError }); const error = new Error('oops'); @@ -215,7 +217,7 @@ describe('Suite', function() { it('does not forward non-late handleException calls to onLateError', function() { const onLateError = jasmine.createSpy('onLateError'); - const suite = new jasmineUnderTest.Suite({ + const suite = new privateUnderTest.Suite({ onLateError }); const error = new Error('oops'); @@ -227,7 +229,7 @@ describe('Suite', function() { }); it('clears the reportedDone flag when reset', function() { - const suite = new jasmineUnderTest.Suite({ + const suite = new privateUnderTest.Suite({ queueableFn: { fn: function() {} } }); suite.reportedDone = true; @@ -238,7 +240,7 @@ describe('Suite', function() { }); it('calls timer to compute duration', function() { - const suite = new jasmineUnderTest.Suite({ + const suite = new privateUnderTest.Suite({ env: env, id: 456, description: 'I am a suite', @@ -251,19 +253,19 @@ describe('Suite', function() { describe('#sharedUserContext', function() { beforeEach(function() { - this.suite = new jasmineUnderTest.Suite({}); + this.suite = new privateUnderTest.Suite({}); }); it('returns a UserContext', function() { expect(this.suite.sharedUserContext().constructor).toBe( - jasmineUnderTest.UserContext + privateUnderTest.UserContext ); }); }); describe('attr.autoCleanClosures', function() { function arrangeSuite(attrs) { - const suite = new jasmineUnderTest.Suite(attrs); + const suite = new privateUnderTest.Suite(attrs); suite.beforeAll(function() {}); suite.beforeEach(function() {}); suite.afterEach(function() {}); @@ -301,21 +303,21 @@ describe('Suite', function() { describe('#reset', function() { it('should reset the "pending" status', function() { - const suite = new jasmineUnderTest.Suite({}); + const suite = new privateUnderTest.Suite({}); suite.pend(); suite.reset(); expect(suite.getResult().status).toBe('passed'); }); it('should not reset the "pending" status when the suite was excluded', function() { - const suite = new jasmineUnderTest.Suite({}); + const suite = new privateUnderTest.Suite({}); suite.exclude(); suite.reset(); expect(suite.getResult().status).toBe('pending'); }); it('should also reset the children', function() { - const suite = new jasmineUnderTest.Suite({}); + const suite = new privateUnderTest.Suite({}); const child1 = jasmine.createSpyObj(['reset']); const child2 = jasmine.createSpyObj(['reset']); suite.addChild(child1); @@ -328,7 +330,7 @@ describe('Suite', function() { }); it('should reset the failedExpectations', function() { - const suite = new jasmineUnderTest.Suite({}); + const suite = new privateUnderTest.Suite({}); suite.handleException(new Error()); suite.reset(); @@ -342,7 +344,7 @@ describe('Suite', function() { describe('#onMultipleDone', function() { it('reports a special error when it is the top suite', function() { const onLateError = jasmine.createSpy('onLateError'); - const suite = new jasmineUnderTest.Suite({ + const suite = new privateUnderTest.Suite({ onLateError, parentSuite: null }); @@ -359,7 +361,7 @@ describe('Suite', function() { it('reports an error including the suite name when it is a normal suite', function() { const onLateError = jasmine.createSpy('onLateError'); - const suite = new jasmineUnderTest.Suite({ + const suite = new privateUnderTest.Suite({ onLateError, description: 'the suite', parentSuite: { @@ -381,7 +383,7 @@ describe('Suite', function() { describe('#hasChildWithDescription', function() { it('returns true if there is a child with the given description', function() { - const subject = new jasmineUnderTest.Suite({}); + const subject = new privateUnderTest.Suite({}); const description = 'a spec'; subject.addChild({ description }); @@ -389,15 +391,15 @@ describe('Suite', function() { }); it('returns false if there is no child with the given description', function() { - const subject = new jasmineUnderTest.Suite({}); + const subject = new privateUnderTest.Suite({}); subject.addChild({ description: 'a different spec' }); expect(subject.hasChildWithDescription('a spec')).toBeFalse(); }); it('does not recurse into child suites', function() { - const subject = new jasmineUnderTest.Suite({}); - const childSuite = new jasmineUnderTest.Suite({}); + const subject = new privateUnderTest.Suite({}); + const childSuite = new privateUnderTest.Suite({}); subject.addChild(childSuite); const description = 'a spec'; childSuite.addChild(description); @@ -408,7 +410,7 @@ describe('Suite', function() { describe('#setSuiteProperty', function() { it('throws if the key is not structured-cloneable', function() { - const suite = new jasmineUnderTest.Suite({}); + const suite = new privateUnderTest.Suite({}); expect(function() { suite.setSuiteProperty(new Promise(() => {}), ''); @@ -416,7 +418,7 @@ describe('Suite', function() { }); it('throws if the value is not structured-cloneable', function() { - const suite = new jasmineUnderTest.Suite({}); + const suite = new privateUnderTest.Suite({}); expect(function() { suite.setSuiteProperty('k', new Promise(() => {})); diff --git a/spec/core/TreeProcessorSpec.js b/spec/core/TreeProcessorSpec.js index dc89e515..ceabd5fc 100644 --- a/spec/core/TreeProcessorSpec.js +++ b/spec/core/TreeProcessorSpec.js @@ -28,7 +28,7 @@ describe('TreeProcessor', function() { it('processes a single leaf', function() { const leaf = new Leaf(), - processor = new jasmineUnderTest.TreeProcessor({ + processor = new privateUnderTest.TreeProcessor({ tree: leaf, runnableIds: [leaf.id] }); @@ -40,7 +40,7 @@ describe('TreeProcessor', function() { it('processes a single pending leaf', function() { const leaf = new Leaf({ markedPending: true }), - processor = new jasmineUnderTest.TreeProcessor({ + processor = new privateUnderTest.TreeProcessor({ tree: leaf, runnableIds: [leaf.id] }); @@ -52,7 +52,7 @@ describe('TreeProcessor', function() { it('processes a single non-specified leaf', function() { const leaf = new Leaf(), - processor = new jasmineUnderTest.TreeProcessor({ + processor = new privateUnderTest.TreeProcessor({ tree: leaf, runnableIds: [] }); @@ -64,7 +64,7 @@ describe('TreeProcessor', function() { it('processes a single excluded leaf', function() { const leaf = new Leaf(), - processor = new jasmineUnderTest.TreeProcessor({ + processor = new privateUnderTest.TreeProcessor({ tree: leaf, runnableIds: [leaf.id], excludeNode: function() { @@ -80,7 +80,7 @@ describe('TreeProcessor', function() { it('processes a tree with a single leaf with the root specified', function() { const leaf = new Leaf(), parent = new Node({ children: [leaf] }), - processor = new jasmineUnderTest.TreeProcessor({ + processor = new privateUnderTest.TreeProcessor({ tree: parent, runnableIds: [parent.id] }); @@ -95,7 +95,7 @@ describe('TreeProcessor', function() { it('processes a tree with a single pending leaf, with the root specified', function() { const leaf = new Leaf({ markedPending: true }), parent = new Node({ children: [leaf] }), - processor = new jasmineUnderTest.TreeProcessor({ + processor = new privateUnderTest.TreeProcessor({ tree: parent, runnableIds: [parent.id] }); @@ -111,7 +111,7 @@ describe('TreeProcessor', function() { const specified = new Leaf(); const nonSpecified = new Leaf(); const root = new Node({ children: [nonSpecified, specified] }); - const processor = new jasmineUnderTest.TreeProcessor({ + const processor = new privateUnderTest.TreeProcessor({ tree: root, runnableIds: [specified.id] }); @@ -128,7 +128,7 @@ describe('TreeProcessor', function() { const leaf1 = new Leaf(); const node = new Node({ children: [leaf1] }); const root = new Node({ children: [node] }); - const processor = new jasmineUnderTest.TreeProcessor({ + const processor = new privateUnderTest.TreeProcessor({ tree: root, runnableIds: [] }); @@ -158,7 +158,7 @@ describe('TreeProcessor', function() { children: [childless, pendingNode] }), root = new Node({ children: [parent, parentOfPendings] }), - processor = new jasmineUnderTest.TreeProcessor({ + processor = new privateUnderTest.TreeProcessor({ tree: root, runnableIds: [root.id] }); @@ -203,7 +203,7 @@ describe('TreeProcessor', function() { leaf3 = new Leaf(), reentered = new Node({ noReenter: true, children: [leaf1, leaf2] }), root = new Node({ children: [reentered, leaf3] }), - processor = new jasmineUnderTest.TreeProcessor({ + processor = new privateUnderTest.TreeProcessor({ tree: root, runnableIds: [leaf1.id, leaf3.id, leaf2.id] }); @@ -221,7 +221,7 @@ describe('TreeProcessor', function() { const leaf3 = new Leaf(); const reentered = new Node({ children: [leaf1, leaf2] }); const root = new Node({ children: [reentered, leaf3] }); - const processor = new jasmineUnderTest.TreeProcessor({ + const processor = new privateUnderTest.TreeProcessor({ tree: root, runnableIds: [leaf1.id, leaf3.id, leaf2.id] }); @@ -241,7 +241,7 @@ describe('TreeProcessor', function() { leaf3 = new Leaf(), noReentry = new Node({ noReenter: true }), root = new Node({ children: [noReentry] }), - processor = new jasmineUnderTest.TreeProcessor({ + processor = new privateUnderTest.TreeProcessor({ tree: root, runnableIds: [leaf2.id, leaf1.id, leaf3.id] }); @@ -252,7 +252,7 @@ describe('TreeProcessor', function() { it("does not throw if a node which can't be re-entered is run directly", function() { const noReentry = new Node({ noReenter: true }), root = new Node({ children: [noReentry] }), - processor = new jasmineUnderTest.TreeProcessor({ + processor = new privateUnderTest.TreeProcessor({ tree: root, runnableIds: [root.id] }); @@ -288,7 +288,7 @@ describe('TreeProcessor', function() { ] }); const runQueue = jasmine.createSpy('runQueue'); - const processor = new jasmineUnderTest.TreeProcessor({ + const processor = new privateUnderTest.TreeProcessor({ tree: root, runnableIds: [root.id], runQueue, diff --git a/spec/core/TreeRunnerSpec.js b/spec/core/TreeRunnerSpec.js index ee53c123..634098df 100644 --- a/spec/core/TreeRunnerSpec.js +++ b/spec/core/TreeRunnerSpec.js @@ -2,7 +2,7 @@ describe('TreeRunner', function() { describe('spec execution', function() { it('starts the timer, reports the spec started, and updates run state at the start of the queue', async function() { const timer = jasmine.createSpyObj('timer', ['start']); - const spec = new jasmineUnderTest.Spec({ + const spec = new privateUnderTest.Spec({ id: 'spec1', queueableFn: {}, timer @@ -38,7 +38,7 @@ describe('TreeRunner', function() { it('stops the timer, updates run state, and reports the spec done at the end of the queue', async function() { const timer = jasmine.createSpyObj('timer', ['start', 'elapsed']); - const spec = new jasmineUnderTest.Spec({ + const spec = new privateUnderTest.Spec({ id: 'spec1', queueableFn: {}, timer @@ -82,7 +82,7 @@ describe('TreeRunner', function() { expect(after).not.toHaveBeenCalled(); }) }; - const spec = new jasmineUnderTest.Spec({ + const spec = new privateUnderTest.Spec({ queueableFn: queueableFn, beforeAndAfterFns: function() { return { befores: [before], afters: [after] }; @@ -106,7 +106,7 @@ describe('TreeRunner', function() { spec.pend(); } }; - spec = new jasmineUnderTest.Spec({ queueableFn }); + spec = new privateUnderTest.Spec({ queueableFn }); const { runQueue, suiteRunQueueArgs } = runSingleSpecSuite(spec); suiteRunQueueArgs.queueableFns[0].fn(); @@ -127,7 +127,7 @@ describe('TreeRunner', function() { spec.pend('some reason'); } }; - spec = new jasmineUnderTest.Spec({ queueableFn }); + spec = new privateUnderTest.Spec({ queueableFn }); const { runQueue, suiteRunQueueArgs } = runSingleSpecSuite(spec); suiteRunQueueArgs.queueableFns[0].fn(); @@ -142,7 +142,7 @@ describe('TreeRunner', function() { }); it('passes failSpecWithNoExp to Spec#executionFinished', async function() { - const spec = new jasmineUnderTest.Spec({ + const spec = new privateUnderTest.Spec({ id: 'spec1', queueableFn: {} }); @@ -168,8 +168,8 @@ describe('TreeRunner', function() { describe('Suite execution', function() { it('reports the duration of the suite', async function() { const timer = jasmine.createSpyObj('timer', ['start', 'elapsed']); - const topSuite = new jasmineUnderTest.Suite({ id: 'topSuite' }); - const suite = new jasmineUnderTest.Suite({ + const topSuite = new privateUnderTest.Suite({ id: 'topSuite' }); + const suite = new privateUnderTest.Suite({ id: 'suite1', parentSuite: topSuite, timer @@ -189,13 +189,13 @@ describe('TreeRunner', function() { }; const runQueue = jasmine.createSpy('runQueue'); const reportDispatcher = mockReportDispatcher(); - const subject = new jasmineUnderTest.TreeRunner({ + const subject = new privateUnderTest.TreeRunner({ executionTree, runQueue, globalErrors: mockGlobalErrors(), runableResources: mockRunableResources(), reportDispatcher, - currentRunableTracker: new jasmineUnderTest.CurrentRunableTracker(), + currentRunableTracker: new privateUnderTest.CurrentRunableTracker(), getConfig() { return {}; }, @@ -226,12 +226,12 @@ describe('TreeRunner', function() { }); it('returns false if a suite failed', async function() { - const topSuite = new jasmineUnderTest.Suite({ id: 'topSuite' }); - const failingSuite = new jasmineUnderTest.Suite({ + const topSuite = new privateUnderTest.Suite({ id: 'topSuite' }); + const failingSuite = new privateUnderTest.Suite({ id: 'failingSuite', parentSuite: topSuite }); - const passingSuite = new jasmineUnderTest.Suite({ + const passingSuite = new privateUnderTest.Suite({ id: 'passingSuite', parentSuite: topSuite }); @@ -249,13 +249,13 @@ describe('TreeRunner', function() { }; const runQueue = jasmine.createSpy('runQueue'); const reportDispatcher = mockReportDispatcher(); - const subject = new jasmineUnderTest.TreeRunner({ + const subject = new privateUnderTest.TreeRunner({ executionTree, runQueue, globalErrors: mockGlobalErrors(), runableResources: mockRunableResources(), reportDispatcher, - currentRunableTracker: new jasmineUnderTest.CurrentRunableTracker(), + currentRunableTracker: new privateUnderTest.CurrentRunableTracker(), getConfig() { return {}; }, @@ -290,13 +290,13 @@ describe('TreeRunner', function() { }); it('reports children when there is a beforeAll failure', async function() { - const topSuite = new jasmineUnderTest.Suite({ id: 'topSuite' }); - const suite = new jasmineUnderTest.Suite({ + const topSuite = new privateUnderTest.Suite({ id: 'topSuite' }); + const suite = new privateUnderTest.Suite({ id: 'suite', parentSuite: topSuite }); suite.beforeAll({ fn() {} }); - const spec = new jasmineUnderTest.Spec({ + const spec = new privateUnderTest.Spec({ id: 'spec', parentSuite: suite, queueableFn: { fn() {} } @@ -320,13 +320,13 @@ describe('TreeRunner', function() { const reportChildrenOfBeforeAllFailure = jasmine .createSpy('reportChildrenOfBeforeAllFailure') .and.returnValue(Promise.resolve()); - const subject = new jasmineUnderTest.TreeRunner({ + const subject = new privateUnderTest.TreeRunner({ executionTree, runQueue, globalErrors: mockGlobalErrors(), runableResources: mockRunableResources(), reportDispatcher, - currentRunableTracker: new jasmineUnderTest.CurrentRunableTracker(), + currentRunableTracker: new privateUnderTest.CurrentRunableTracker(), reportChildrenOfBeforeAllFailure, getConfig() { return {}; @@ -356,12 +356,12 @@ describe('TreeRunner', function() { }); it('throws if the wrong suite is completed', async function() { - const topSuite = new jasmineUnderTest.Suite({ id: 'topSuite' }); - const suite = new jasmineUnderTest.Suite({ + const topSuite = new privateUnderTest.Suite({ id: 'topSuite' }); + const suite = new privateUnderTest.Suite({ id: 'suite', parentSuite: topSuite }); - const spec = new jasmineUnderTest.Spec({ + const spec = new privateUnderTest.Spec({ id: 'spec', parentSuite: suite, queueableFn: { fn() {} } @@ -380,13 +380,13 @@ describe('TreeRunner', function() { }; const runQueue = jasmine.createSpy('runQueue'); const reportDispatcher = mockReportDispatcher(); - const subject = new jasmineUnderTest.TreeRunner({ + const subject = new privateUnderTest.TreeRunner({ executionTree, runQueue, globalErrors: mockGlobalErrors(), runableResources: mockRunableResources(), reportDispatcher, - currentRunableTracker: new jasmineUnderTest.CurrentRunableTracker(), + currentRunableTracker: new privateUnderTest.CurrentRunableTracker(), getConfig() { return {}; }, @@ -412,7 +412,7 @@ describe('TreeRunner', function() { }); it('does not remove before and after fns from the top suite', async function() { - const topSuite = new jasmineUnderTest.Suite({ id: 'topSuite' }); + const topSuite = new privateUnderTest.Suite({ id: 'topSuite' }); spyOn(topSuite, 'cleanupBeforeAfter'); const executionTree = { topSuite, @@ -424,13 +424,13 @@ describe('TreeRunner', function() { } }; const runQueue = jasmine.createSpy('runQueue'); - const subject = new jasmineUnderTest.TreeRunner({ + const subject = new privateUnderTest.TreeRunner({ executionTree, runQueue, globalErrors: mockGlobalErrors(), runableResources: mockRunableResources(), reportDispatcher: mockReportDispatcher(), - currentRunableTracker: new jasmineUnderTest.CurrentRunableTracker(), + currentRunableTracker: new privateUnderTest.CurrentRunableTracker(), getConfig() { return {}; } @@ -460,7 +460,7 @@ describe('TreeRunner', function() { expect(after).not.toHaveBeenCalled(); }) }; - const spec = new jasmineUnderTest.Spec({ + const spec = new privateUnderTest.Spec({ queueableFn, beforeAndAfterFns: function() { return { befores: [before], afters: [after] }; @@ -504,13 +504,13 @@ describe('TreeRunner', function() { }); it('works for beforeAll when the detectLateRejectionHandling param is true', async function() { - const topSuite = new jasmineUnderTest.Suite({ id: 'topSuite' }); - const suite = new jasmineUnderTest.Suite({ + const topSuite = new privateUnderTest.Suite({ id: 'topSuite' }); + const suite = new privateUnderTest.Suite({ id: 'suite', parentSuite: topSuite }); suite.beforeAll(function() {}); - const spec = new jasmineUnderTest.Spec({ + const spec = new privateUnderTest.Spec({ queueableFn: { fn() {} }, parentSuite: suite }); @@ -530,14 +530,14 @@ describe('TreeRunner', function() { const reportDispatcher = mockReportDispatcher(); const globalErrors = mockGlobalErrors(); const setTimeout = jasmine.createSpy('setTimeout'); - const subject = new jasmineUnderTest.TreeRunner({ + const subject = new privateUnderTest.TreeRunner({ executionTree, runQueue, globalErrors, runableResources: mockRunableResources(), reportDispatcher, setTimeout, - currentRunableTracker: new jasmineUnderTest.CurrentRunableTracker(), + currentRunableTracker: new privateUnderTest.CurrentRunableTracker(), getConfig() { return { detectLateRejectionHandling: true }; }, @@ -573,13 +573,13 @@ describe('TreeRunner', function() { }); it('works for afterAll when the detectLateRejectionHandling param is true', async function() { - const topSuite = new jasmineUnderTest.Suite({ id: 'topSuite' }); - const suite = new jasmineUnderTest.Suite({ + const topSuite = new privateUnderTest.Suite({ id: 'topSuite' }); + const suite = new privateUnderTest.Suite({ id: 'suite', parentSuite: topSuite }); suite.afterAll(function() {}); - const spec = new jasmineUnderTest.Spec({ + const spec = new privateUnderTest.Spec({ queueableFn: { fn() {} }, parentSuite: suite }); @@ -599,14 +599,14 @@ describe('TreeRunner', function() { const reportDispatcher = mockReportDispatcher(); const globalErrors = mockGlobalErrors(); const setTimeout = jasmine.createSpy('setTimeout'); - const subject = new jasmineUnderTest.TreeRunner({ + const subject = new privateUnderTest.TreeRunner({ executionTree, runQueue, globalErrors, runableResources: mockRunableResources(), reportDispatcher, setTimeout, - currentRunableTracker: new jasmineUnderTest.CurrentRunableTracker(), + currentRunableTracker: new privateUnderTest.CurrentRunableTracker(), getConfig() { return { detectLateRejectionHandling: true }; }, @@ -645,7 +645,7 @@ describe('TreeRunner', function() { function runSingleSpecSuite(spec, optionalConfig) { const topSuiteId = 'suite1'; spec.parentSuiteId = topSuiteId; - const topSuite = new jasmineUnderTest.Suite({ id: topSuiteId }); + const topSuite = new privateUnderTest.Suite({ id: topSuiteId }); topSuite.addChild(spec); const executionTree = { topSuite, @@ -661,8 +661,8 @@ describe('TreeRunner', function() { const runableResources = mockRunableResources(); const globalErrors = mockGlobalErrors(); const setTimeout = jasmine.createSpy('setTimeout'); - const currentRunableTracker = new jasmineUnderTest.CurrentRunableTracker(); - const subject = new jasmineUnderTest.TreeRunner({ + const currentRunableTracker = new privateUnderTest.CurrentRunableTracker(); + const subject = new privateUnderTest.TreeRunner({ executionTree, runQueue, globalErrors, @@ -696,10 +696,10 @@ describe('TreeRunner', function() { function mockReportDispatcher() { const reportDispatcher = jasmine.createSpyObj( 'reportDispatcher', - jasmineUnderTest.reporterEvents + privateUnderTest.reporterEvents ); - for (const k of jasmineUnderTest.reporterEvents) { + for (const k of privateUnderTest.reporterEvents) { reportDispatcher[k].and.returnValue(Promise.resolve()); } diff --git a/spec/core/UserContextSpec.js b/spec/core/UserContextSpec.js index 99caa37c..71836550 100644 --- a/spec/core/UserContextSpec.js +++ b/spec/core/UserContextSpec.js @@ -1,6 +1,6 @@ describe('UserContext', function() { it('Behaves just like an plain object', function() { - const context = new jasmineUnderTest.UserContext(), + const context = new privateUnderTest.UserContext(), properties = []; for (const prop in context) { @@ -15,9 +15,9 @@ describe('UserContext', function() { describe('.fromExisting', function() { describe('when using an already built context as model', function() { beforeEach(function() { - this.context = new jasmineUnderTest.UserContext(); + this.context = new privateUnderTest.UserContext(); this.context.key = 'value'; - this.cloned = jasmineUnderTest.UserContext.fromExisting(this.context); + this.cloned = privateUnderTest.UserContext.fromExisting(this.context); }); it('returns a cloned object', function() { @@ -34,7 +34,7 @@ describe('UserContext', function() { this.context = {}; this.value = 'value'; this.context.key = this.value; - this.cloned = jasmineUnderTest.UserContext.fromExisting(this.context); + this.cloned = privateUnderTest.UserContext.fromExisting(this.context); }); it('returns an object with the same attributes', function() { @@ -46,7 +46,7 @@ describe('UserContext', function() { }); it('returns an UserContext', function() { - expect(this.cloned.constructor).toBe(jasmineUnderTest.UserContext); + expect(this.cloned.constructor).toBe(privateUnderTest.UserContext); }); }); }); diff --git a/spec/core/UtilSpec.js b/spec/core/UtilSpec.js index 5ec6b36b..6a0abc0a 100644 --- a/spec/core/UtilSpec.js +++ b/spec/core/UtilSpec.js @@ -1,33 +1,33 @@ describe('util', function() { - describe('isArray_', function() { + describe('isArray', function() { it('should return true if the argument is an array', function() { - expect(jasmineUnderTest.isArray_([])).toBe(true); - expect(jasmineUnderTest.isArray_(['a'])).toBe(true); + expect(privateUnderTest.isArray([])).toBe(true); + expect(privateUnderTest.isArray(['a'])).toBe(true); }); it('should return false if the argument is not an array', function() { - expect(jasmineUnderTest.isArray_(undefined)).toBe(false); - expect(jasmineUnderTest.isArray_({})).toBe(false); - expect(jasmineUnderTest.isArray_(function() {})).toBe(false); - expect(jasmineUnderTest.isArray_('foo')).toBe(false); - expect(jasmineUnderTest.isArray_(5)).toBe(false); - expect(jasmineUnderTest.isArray_(null)).toBe(false); + expect(privateUnderTest.isArray(undefined)).toBe(false); + expect(privateUnderTest.isArray({})).toBe(false); + expect(privateUnderTest.isArray(function() {})).toBe(false); + expect(privateUnderTest.isArray('foo')).toBe(false); + expect(privateUnderTest.isArray(5)).toBe(false); + expect(privateUnderTest.isArray(null)).toBe(false); }); }); - describe('isObject_', function() { + describe('isObject', function() { it('should return true if the argument is an object', function() { - expect(jasmineUnderTest.isObject_({})).toBe(true); - expect(jasmineUnderTest.isObject_({ an: 'object' })).toBe(true); + expect(privateUnderTest.isObject({})).toBe(true); + expect(privateUnderTest.isObject({ an: 'object' })).toBe(true); }); it('should return false if the argument is not an object', function() { - expect(jasmineUnderTest.isObject_(undefined)).toBe(false); - expect(jasmineUnderTest.isObject_([])).toBe(false); - expect(jasmineUnderTest.isObject_(function() {})).toBe(false); - expect(jasmineUnderTest.isObject_('foo')).toBe(false); - expect(jasmineUnderTest.isObject_(5)).toBe(false); - expect(jasmineUnderTest.isObject_(null)).toBe(false); + expect(privateUnderTest.isObject(undefined)).toBe(false); + expect(privateUnderTest.isObject([])).toBe(false); + expect(privateUnderTest.isObject(function() {})).toBe(false); + expect(privateUnderTest.isObject('foo')).toBe(false); + expect(privateUnderTest.isObject(5)).toBe(false); + expect(privateUnderTest.isObject(null)).toBe(false); }); }); @@ -45,119 +45,121 @@ describe('util', function() { describe('isPromise', function() { it('should return true when passed a native promise', function() { - expect(jasmineUnderTest.isPromise(mockNativePromise)).toBe(true); + expect(privateUnderTest.isPromise(mockNativePromise)).toBe(true); }); it('should return false for promise like objects', function() { - expect(jasmineUnderTest.isPromise(mockPromiseLikeObject)).toBe(false); + expect(privateUnderTest.isPromise(mockPromiseLikeObject)).toBe(false); }); it('should return false for strings', function() { - expect(jasmineUnderTest.isPromise('hello')).toBe(false); + expect(privateUnderTest.isPromise('hello')).toBe(false); }); it('should return false for numbers', function() { - expect(jasmineUnderTest.isPromise(3)).toBe(false); + expect(privateUnderTest.isPromise(3)).toBe(false); }); it('should return false for null', function() { - expect(jasmineUnderTest.isPromise(null)).toBe(false); + expect(privateUnderTest.isPromise(null)).toBe(false); }); it('should return false for undefined', function() { - expect(jasmineUnderTest.isPromise(undefined)).toBe(false); + expect(privateUnderTest.isPromise(undefined)).toBe(false); }); it('should return false for arrays', function() { - expect(jasmineUnderTest.isPromise([])).toBe(false); + expect(privateUnderTest.isPromise([])).toBe(false); }); it('should return false for objects', function() { - expect(jasmineUnderTest.isPromise({})).toBe(false); + expect(privateUnderTest.isPromise({})).toBe(false); }); it('should return false for boolean values', function() { - expect(jasmineUnderTest.isPromise(true)).toBe(false); + expect(privateUnderTest.isPromise(true)).toBe(false); }); }); describe('isPromiseLike', function() { it('should return true when passed a native promise', function() { - expect(jasmineUnderTest.isPromiseLike(mockNativePromise)).toBe(true); + expect(privateUnderTest.isPromiseLike(mockNativePromise)).toBe(true); }); it('should return true for promise like objects', function() { - expect(jasmineUnderTest.isPromiseLike(mockPromiseLikeObject)).toBe( + expect(privateUnderTest.isPromiseLike(mockPromiseLikeObject)).toBe( true ); }); it('should return false if then is not a function', function() { expect( - jasmineUnderTest.isPromiseLike({ then: { its: 'Not a function :O' } }) + privateUnderTest.isPromiseLike({ + then: { its: 'Not a function :O' } + }) ).toBe(false); }); it('should return false for strings', function() { - expect(jasmineUnderTest.isPromiseLike('hello')).toBe(false); + expect(privateUnderTest.isPromiseLike('hello')).toBe(false); }); it('should return false for numbers', function() { - expect(jasmineUnderTest.isPromiseLike(3)).toBe(false); + expect(privateUnderTest.isPromiseLike(3)).toBe(false); }); it('should return false for null', function() { - expect(jasmineUnderTest.isPromiseLike(null)).toBe(false); + expect(privateUnderTest.isPromiseLike(null)).toBe(false); }); it('should return false for undefined', function() { - expect(jasmineUnderTest.isPromiseLike(undefined)).toBe(false); + expect(privateUnderTest.isPromiseLike(undefined)).toBe(false); }); it('should return false for arrays', function() { - expect(jasmineUnderTest.isPromiseLike([])).toBe(false); + expect(privateUnderTest.isPromiseLike([])).toBe(false); }); it('should return false for objects', function() { - expect(jasmineUnderTest.isPromiseLike({})).toBe(false); + expect(privateUnderTest.isPromiseLike({})).toBe(false); }); it('should return false for boolean values', function() { - expect(jasmineUnderTest.isPromiseLike(true)).toBe(false); + expect(privateUnderTest.isPromiseLike(true)).toBe(false); }); }); }); describe('cloneArgs', function() { it('clones primitives as-is', function() { - expect(jasmineUnderTest.util.cloneArgs([true, false])).toEqual([ + expect(privateUnderTest.util.cloneArgs([true, false])).toEqual([ true, false ]); - expect(jasmineUnderTest.util.cloneArgs([0, 1])).toEqual([0, 1]); - expect(jasmineUnderTest.util.cloneArgs(['str'])).toEqual(['str']); + expect(privateUnderTest.util.cloneArgs([0, 1])).toEqual([0, 1]); + expect(privateUnderTest.util.cloneArgs(['str'])).toEqual(['str']); }); it('clones Regexp objects as-is', function() { const regex = /match/; - expect(jasmineUnderTest.util.cloneArgs([regex])).toEqual([regex]); + expect(privateUnderTest.util.cloneArgs([regex])).toEqual([regex]); }); it('clones Date objects as-is', function() { const date = new Date(2022, 1, 1); - expect(jasmineUnderTest.util.cloneArgs([date])).toEqual([date]); + expect(privateUnderTest.util.cloneArgs([date])).toEqual([date]); }); it('clones null and undefined', function() { - expect(jasmineUnderTest.util.cloneArgs([null])).toEqual([null]); - expect(jasmineUnderTest.util.cloneArgs([undefined])).toEqual([undefined]); + expect(privateUnderTest.util.cloneArgs([null])).toEqual([null]); + expect(privateUnderTest.util.cloneArgs([undefined])).toEqual([undefined]); }); }); describe('getPropertyDescriptor', function() { it('get property descriptor from object', function() { const obj = { prop: 1 }, - actual = jasmineUnderTest.util.getPropertyDescriptor(obj, 'prop'), + actual = privateUnderTest.util.getPropertyDescriptor(obj, 'prop'), expected = Object.getOwnPropertyDescriptor(obj, 'prop'); expect(actual).toEqual(expected); @@ -165,7 +167,7 @@ describe('util', function() { it('get property descriptor from object property', function() { const proto = { prop: 1 }, - actual = jasmineUnderTest.util.getPropertyDescriptor(proto, 'prop'), + actual = privateUnderTest.util.getPropertyDescriptor(proto, 'prop'), expected = Object.getOwnPropertyDescriptor(proto, 'prop'); expect(actual).toEqual(expected); @@ -176,8 +178,8 @@ describe('util', function() { it('returns the file containing jasmine.util', function() { // Chrome sometimes reports foo.js as foo.js/, so tolerate // a trailing slash if present. - expect(jasmineUnderTest.util.jasmineFile()).toMatch(/util.js\/?$/); - expect(jasmine.util.jasmineFile()).toMatch(/jasmine.js\/?$/); + expect(privateUnderTest.util.jasmineFile()).toMatch(/util.js\/?$/); + expect(jasmine.private.util.jasmineFile()).toMatch(/jasmine.js\/?$/); }); }); }); diff --git a/spec/core/asymmetric_equality/AnySpec.js b/spec/core/asymmetric_equality/AnySpec.js index e23d93fd..d4382b60 100644 --- a/spec/core/asymmetric_equality/AnySpec.js +++ b/spec/core/asymmetric_equality/AnySpec.js @@ -1,73 +1,73 @@ describe('Any', function() { it('matches a string', function() { - const any = new jasmineUnderTest.Any(String); + const any = new privateUnderTest.Any(String); expect(any.asymmetricMatch('foo')).toBe(true); }); it('matches a number', function() { - const any = new jasmineUnderTest.Any(Number); + const any = new privateUnderTest.Any(Number); expect(any.asymmetricMatch(1)).toBe(true); }); it('matches a function', function() { - const any = new jasmineUnderTest.Any(Function); + const any = new privateUnderTest.Any(Function); expect(any.asymmetricMatch(function() {})).toBe(true); }); it('matches an Object', function() { - const any = new jasmineUnderTest.Any(Object); + const any = new privateUnderTest.Any(Object); expect(any.asymmetricMatch({})).toBe(true); }); it('matches a Boolean', function() { - const any = new jasmineUnderTest.Any(Boolean); + const any = new privateUnderTest.Any(Boolean); expect(any.asymmetricMatch(true)).toBe(true); }); it('matches a Map', function() { - const any = new jasmineUnderTest.Any(Map); + const any = new privateUnderTest.Any(Map); expect(any.asymmetricMatch(new Map())).toBe(true); }); it('matches a Set', function() { - const any = new jasmineUnderTest.Any(Set); + const any = new privateUnderTest.Any(Set); expect(any.asymmetricMatch(new Set())).toBe(true); }); it('matches a TypedArray', function() { - const any = new jasmineUnderTest.Any(Uint32Array); + const any = new privateUnderTest.Any(Uint32Array); expect(any.asymmetricMatch(new Uint32Array([]))).toBe(true); }); it('matches a Symbol', function() { - const any = new jasmineUnderTest.Any(Symbol); + const any = new privateUnderTest.Any(Symbol); expect(any.asymmetricMatch(Symbol())).toBe(true); }); it('matches another constructed object', function() { const Thing = function() {}, - any = new jasmineUnderTest.Any(Thing); + any = new privateUnderTest.Any(Thing); expect(any.asymmetricMatch(new Thing())).toBe(true); }); it('does not treat null as an Object', function() { - const any = new jasmineUnderTest.Any(Object); + const any = new privateUnderTest.Any(Object); expect(any.asymmetricMatch(null)).toBe(false); }); it("jasmineToString's itself", function() { - const any = new jasmineUnderTest.Any(Number); + const any = new privateUnderTest.Any(Number); expect(any.jasmineToString()).toEqual(''); expect(any.jasmineToString()).toEqual(''); @@ -76,7 +76,7 @@ describe('Any', function() { describe('when called without an argument', function() { it('tells the user to pass a constructor or use jasmine.anything()', function() { expect(function() { - new jasmineUnderTest.Any(); + new privateUnderTest.Any(); }).toThrowError(TypeError, /constructor.*anything/); }); }); diff --git a/spec/core/asymmetric_equality/AnythingSpec.js b/spec/core/asymmetric_equality/AnythingSpec.js index a894995a..4cdb1888 100644 --- a/spec/core/asymmetric_equality/AnythingSpec.js +++ b/spec/core/asymmetric_equality/AnythingSpec.js @@ -1,67 +1,67 @@ describe('Anything', function() { it('matches a string', function() { - const anything = new jasmineUnderTest.Anything(); + const anything = new privateUnderTest.Anything(); expect(anything.asymmetricMatch('foo')).toBe(true); }); it('matches a number', function() { - const anything = new jasmineUnderTest.Anything(); + const anything = new privateUnderTest.Anything(); expect(anything.asymmetricMatch(42)).toBe(true); }); it('matches an object', function() { - const anything = new jasmineUnderTest.Anything(); + const anything = new privateUnderTest.Anything(); expect(anything.asymmetricMatch({ foo: 'bar' })).toBe(true); }); it('matches an array', function() { - const anything = new jasmineUnderTest.Anything(); + const anything = new privateUnderTest.Anything(); expect(anything.asymmetricMatch([1, 2, 3])).toBe(true); }); it('matches a Map', function() { - const anything = new jasmineUnderTest.Anything(); + const anything = new privateUnderTest.Anything(); expect(anything.asymmetricMatch(new Map())).toBe(true); }); it('matches a Set', function() { - const anything = new jasmineUnderTest.Anything(); + const anything = new privateUnderTest.Anything(); expect(anything.asymmetricMatch(new Set())).toBe(true); }); it('matches a TypedArray', function() { - const anything = new jasmineUnderTest.Anything(); + const anything = new privateUnderTest.Anything(); expect(anything.asymmetricMatch(new Uint32Array([]))).toBe(true); }); it('matches a Symbol', function() { - const anything = new jasmineUnderTest.Anything(); + const anything = new privateUnderTest.Anything(); expect(anything.asymmetricMatch(Symbol())).toBe(true); }); it("doesn't match undefined", function() { - const anything = new jasmineUnderTest.Anything(); + const anything = new privateUnderTest.Anything(); expect(anything.asymmetricMatch()).toBe(false); expect(anything.asymmetricMatch(undefined)).toBe(false); }); it("doesn't match null", function() { - const anything = new jasmineUnderTest.Anything(); + const anything = new privateUnderTest.Anything(); expect(anything.asymmetricMatch(null)).toBe(false); }); it("jasmineToString's itself", function() { - const anything = new jasmineUnderTest.Anything(); + const anything = new privateUnderTest.Anything(); expect(anything.jasmineToString()).toEqual(''); }); diff --git a/spec/core/asymmetric_equality/ArrayContainingSpec.js b/spec/core/asymmetric_equality/ArrayContainingSpec.js index 96b77143..2c5dccd9 100644 --- a/spec/core/asymmetric_equality/ArrayContainingSpec.js +++ b/spec/core/asymmetric_equality/ArrayContainingSpec.js @@ -1,12 +1,12 @@ describe('ArrayContaining', function() { it('matches any actual to an empty array', function() { - const containing = new jasmineUnderTest.ArrayContaining([]); + const containing = new privateUnderTest.ArrayContaining([]); expect(containing.asymmetricMatch('foo')).toBe(true); }); it('does not work when not passed an array', function() { - const containing = new jasmineUnderTest.ArrayContaining('foo'); + const containing = new privateUnderTest.ArrayContaining('foo'); expect(function() { containing.asymmetricMatch([]); @@ -14,36 +14,36 @@ describe('ArrayContaining', function() { }); it('matches when the item is in the actual', function() { - const containing = new jasmineUnderTest.ArrayContaining(['foo']); - const matchersUtil = new jasmineUnderTest.MatchersUtil(); + const containing = new privateUnderTest.ArrayContaining(['foo']); + const matchersUtil = new privateUnderTest.MatchersUtil(); expect(containing.asymmetricMatch(['foo'], matchersUtil)).toBe(true); }); it('matches when additional items are in the actual', function() { - const containing = new jasmineUnderTest.ArrayContaining(['foo']); - const matchersUtil = new jasmineUnderTest.MatchersUtil(); + const containing = new privateUnderTest.ArrayContaining(['foo']); + const matchersUtil = new privateUnderTest.MatchersUtil(); expect(containing.asymmetricMatch(['foo', 'bar'], matchersUtil)).toBe(true); }); it('does not match when the item is not in the actual', function() { - const containing = new jasmineUnderTest.ArrayContaining(['foo']); - const matchersUtil = new jasmineUnderTest.MatchersUtil(); + const containing = new privateUnderTest.ArrayContaining(['foo']); + const matchersUtil = new privateUnderTest.MatchersUtil(); expect(containing.asymmetricMatch(['bar'], matchersUtil)).toBe(false); }); it('does not match when the actual is not an array', function() { - const containing = new jasmineUnderTest.ArrayContaining(['foo']); - const matchersUtil = new jasmineUnderTest.MatchersUtil(); + const containing = new privateUnderTest.ArrayContaining(['foo']); + const matchersUtil = new privateUnderTest.MatchersUtil(); expect(containing.asymmetricMatch('foo', matchersUtil)).toBe(false); }); it('jasmineToStrings itself', function() { const sample = [], - matcher = new jasmineUnderTest.ArrayContaining(sample), + matcher = new privateUnderTest.ArrayContaining(sample), pp = jasmine.createSpy('pp').and.returnValue('sample'); expect(matcher.jasmineToString(pp)).toEqual( @@ -64,8 +64,8 @@ describe('ArrayContaining', function() { return true; } }; - const containing = new jasmineUnderTest.ArrayContaining(['fooVal']); - const matchersUtil = new jasmineUnderTest.MatchersUtil({ + const containing = new privateUnderTest.ArrayContaining(['fooVal']); + const matchersUtil = new privateUnderTest.MatchersUtil({ customTesters: [tester] }); diff --git a/spec/core/asymmetric_equality/ArrayWithExactContentsSpec.js b/spec/core/asymmetric_equality/ArrayWithExactContentsSpec.js index d2197bbf..644f005d 100644 --- a/spec/core/asymmetric_equality/ArrayWithExactContentsSpec.js +++ b/spec/core/asymmetric_equality/ArrayWithExactContentsSpec.js @@ -1,13 +1,13 @@ describe('ArrayWithExactContents', function() { it('matches an array with the same items in a different order', function() { - const matcher = new jasmineUnderTest.ArrayWithExactContents(['a', 2, /a/]); - const matchersUtil = new jasmineUnderTest.MatchersUtil(); + const matcher = new privateUnderTest.ArrayWithExactContents(['a', 2, /a/]); + const matchersUtil = new privateUnderTest.MatchersUtil(); expect(matcher.asymmetricMatch([2, 'a', /a/], matchersUtil)).toBe(true); }); it('does not work when not passed an array', function() { - const matcher = new jasmineUnderTest.ArrayWithExactContents('foo'); + const matcher = new privateUnderTest.ArrayWithExactContents('foo'); expect(function() { matcher.asymmetricMatch([]); @@ -15,8 +15,8 @@ describe('ArrayWithExactContents', function() { }); it('does not match when an item is missing', function() { - const matcher = new jasmineUnderTest.ArrayWithExactContents(['a', 2, /a/]); - const matchersUtil = new jasmineUnderTest.MatchersUtil(); + const matcher = new privateUnderTest.ArrayWithExactContents(['a', 2, /a/]); + const matchersUtil = new privateUnderTest.MatchersUtil(); expect(matcher.asymmetricMatch(['a', 2], matchersUtil)).toBe(false); expect(matcher.asymmetricMatch(['a', 2, undefined], matchersUtil)).toBe( @@ -25,15 +25,15 @@ describe('ArrayWithExactContents', function() { }); it('does not match when there is an extra item', function() { - const matcher = new jasmineUnderTest.ArrayWithExactContents(['a']); - const matchersUtil = new jasmineUnderTest.MatchersUtil(); + const matcher = new privateUnderTest.ArrayWithExactContents(['a']); + const matchersUtil = new privateUnderTest.MatchersUtil(); expect(matcher.asymmetricMatch(['a', 2], matchersUtil)).toBe(false); }); it('jasmineToStrings itself', function() { const sample = [], - matcher = new jasmineUnderTest.ArrayWithExactContents(sample), + matcher = new privateUnderTest.ArrayWithExactContents(sample), pp = jasmine.createSpy('pp').and.returnValue('sample'); expect(matcher.jasmineToString(pp)).toEqual( @@ -54,8 +54,8 @@ describe('ArrayWithExactContents', function() { return true; } }; - const matcher = new jasmineUnderTest.ArrayWithExactContents(['fooVal']); - const matchersUtil = new jasmineUnderTest.MatchersUtil({ + const matcher = new privateUnderTest.ArrayWithExactContents(['fooVal']); + const matchersUtil = new privateUnderTest.MatchersUtil({ customTesters: [tester] }); diff --git a/spec/core/asymmetric_equality/EmptySpec.js b/spec/core/asymmetric_equality/EmptySpec.js index 25a467c5..910dd768 100644 --- a/spec/core/asymmetric_equality/EmptySpec.js +++ b/spec/core/asymmetric_equality/EmptySpec.js @@ -1,20 +1,20 @@ describe('Empty', function() { it('matches an empty object', function() { - const empty = new jasmineUnderTest.Empty(); + const empty = new privateUnderTest.Empty(); expect(empty.asymmetricMatch({})).toBe(true); expect(empty.asymmetricMatch({ undefined: false })).toBe(false); }); it('matches an empty array', function() { - const empty = new jasmineUnderTest.Empty(); + const empty = new privateUnderTest.Empty(); expect(empty.asymmetricMatch([])).toBe(true); expect(empty.asymmetricMatch([1, 12, 3])).toBe(false); }); it('matches an empty string', function() { - const empty = new jasmineUnderTest.Empty(); + const empty = new privateUnderTest.Empty(); expect(empty.asymmetricMatch('')).toBe(true); expect(empty.asymmetricMatch('')).toBe(true); @@ -22,7 +22,7 @@ describe('Empty', function() { }); it('matches an empty map', function() { - const empty = new jasmineUnderTest.Empty(); + const empty = new privateUnderTest.Empty(); const fullMap = new Map(); fullMap.set('thing', 2); @@ -31,7 +31,7 @@ describe('Empty', function() { }); it('matches an empty set', function() { - const empty = new jasmineUnderTest.Empty(); + const empty = new privateUnderTest.Empty(); const fullSet = new Set(); fullSet.add(3); @@ -40,7 +40,7 @@ describe('Empty', function() { }); it('matches an empty typed array', function() { - const empty = new jasmineUnderTest.Empty(); + const empty = new privateUnderTest.Empty(); expect(empty.asymmetricMatch(new Int16Array())).toBe(true); expect(empty.asymmetricMatch(new Int16Array([1, 2]))).toBe(false); diff --git a/spec/core/asymmetric_equality/FalsySpec.js b/spec/core/asymmetric_equality/FalsySpec.js index 01312d26..9d3e1efe 100644 --- a/spec/core/asymmetric_equality/FalsySpec.js +++ b/spec/core/asymmetric_equality/FalsySpec.js @@ -1,6 +1,6 @@ describe('Falsy', function() { it('is true for an empty string', function() { - const falsy = new jasmineUnderTest.Falsy(); + const falsy = new privateUnderTest.Falsy(); expect(falsy.asymmetricMatch('')).toBe(true); expect(falsy.asymmetricMatch('')).toBe(true); @@ -8,7 +8,7 @@ describe('Falsy', function() { }); it('is false for a number that is 0', function() { - const falsy = new jasmineUnderTest.Falsy(Number); + const falsy = new privateUnderTest.Falsy(Number); expect(falsy.asymmetricMatch(1)).toBe(false); expect(falsy.asymmetricMatch(0)).toBe(true); @@ -17,20 +17,20 @@ describe('Falsy', function() { }); it('is true for a null or undefined', function() { - const falsy = new jasmineUnderTest.Falsy(Function); + const falsy = new privateUnderTest.Falsy(Function); expect(falsy.asymmetricMatch(null)).toBe(true); expect(falsy.asymmetricMatch(undefined)).toBe(true); }); it('is true for NaN', function() { - const falsy = new jasmineUnderTest.Falsy(Object); + const falsy = new privateUnderTest.Falsy(Object); expect(falsy.asymmetricMatch(NaN)).toBe(true); }); it('is true for a false Boolean', function() { - const falsy = new jasmineUnderTest.Falsy(Boolean); + const falsy = new privateUnderTest.Falsy(Boolean); expect(falsy.asymmetricMatch(false)).toBe(true); expect(falsy.asymmetricMatch(true)).toBe(false); diff --git a/spec/core/asymmetric_equality/IsSpec.js b/spec/core/asymmetric_equality/IsSpec.js index c2554aab..e34abc18 100644 --- a/spec/core/asymmetric_equality/IsSpec.js +++ b/spec/core/asymmetric_equality/IsSpec.js @@ -1,28 +1,28 @@ describe('Is', function() { it('passes for primitives that are ===', function() { - const exactly = new jasmineUnderTest.Is(17); + const exactly = new privateUnderTest.Is(17); expect(exactly.asymmetricMatch(17)).toBeTrue(); }); it('fails for primitives that are not ===', function() { - const exactly = new jasmineUnderTest.Is(42); + const exactly = new privateUnderTest.Is(42); expect(exactly.asymmetricMatch('42')).toBeFalse(); }); it('passes for the same object instance', function() { const obj = {}; - const exactly = new jasmineUnderTest.Is(obj); + const exactly = new privateUnderTest.Is(obj); expect(exactly.asymmetricMatch(obj)).toBeTrue(); }); it('fails for different object instances, even if they are deep value equal', function() { - const exactly = new jasmineUnderTest.Is({}); + const exactly = new privateUnderTest.Is({}); expect(exactly.asymmetricMatch({})).toBeFalse(); }); it('describes itself for use in diffs and pretty printing', function() { - const exactly = new jasmineUnderTest.Is({ foo: ['bar'] }); - const pp = jasmineUnderTest.basicPrettyPrinter_; + const exactly = new privateUnderTest.Is({ foo: ['bar'] }); + const pp = privateUnderTest.basicPrettyPrinter; expect(exactly.jasmineToString(pp)).toEqual( "" ); diff --git a/spec/core/asymmetric_equality/MapContainingSpec.js b/spec/core/asymmetric_equality/MapContainingSpec.js index 934084b9..c5cc0581 100644 --- a/spec/core/asymmetric_equality/MapContainingSpec.js +++ b/spec/core/asymmetric_equality/MapContainingSpec.js @@ -1,7 +1,7 @@ describe('MapContaining', function() { it('matches any actual map to an empty map', function() { const actualMap = new Map([['foo', 'bar']]); - const containing = new jasmineUnderTest.MapContaining(new Map()); + const containing = new privateUnderTest.MapContaining(new Map()); expect(containing.asymmetricMatch(actualMap)).toBe(true); }); @@ -17,8 +17,8 @@ describe('MapContaining', function() { [{ foo: 'bar' }, 'baz'], ['foo', [1, 2, 3]] ]); - const containing = new jasmineUnderTest.MapContaining(containingMap); - const matchersUtil = new jasmineUnderTest.MatchersUtil(); + const containing = new privateUnderTest.MapContaining(containingMap); + const matchersUtil = new privateUnderTest.MatchersUtil(); expect(containing.asymmetricMatch(actualMap, matchersUtil)).toBe(true); }); @@ -33,8 +33,8 @@ describe('MapContaining', function() { [{ foo: 'bar' }, 'baz'], ['foo', [1, 2, 3]] ]); - const containing = new jasmineUnderTest.MapContaining(containingMap); - const matchersUtil = new jasmineUnderTest.MatchersUtil(); + const containing = new privateUnderTest.MapContaining(containingMap); + const matchersUtil = new privateUnderTest.MatchersUtil(); expect(containing.asymmetricMatch(actualMap, matchersUtil)).toBe(false); }); @@ -43,8 +43,8 @@ describe('MapContaining', function() { const actualMap = new Map([['foo', [1, 2, 3]], [{ foo: 'bar' }, 'baz']]); const containingMap = new Map([[{ foo: 'bar' }, 'baz'], ['foo', [1, 2]]]); - const containing = new jasmineUnderTest.MapContaining(containingMap); - const matchersUtil = new jasmineUnderTest.MatchersUtil(); + const containing = new privateUnderTest.MapContaining(containingMap); + const matchersUtil = new privateUnderTest.MatchersUtil(); expect(containing.asymmetricMatch(actualMap, matchersUtil)).toBe(false); }); @@ -60,8 +60,8 @@ describe('MapContaining', function() { [jasmineUnderTest.stringMatching(/^foo\d/), 'bar'], ['baz', jasmineUnderTest.arrayContaining([2, 3])] ]); - const containing = new jasmineUnderTest.MapContaining(containingMap); - const matchersUtil = new jasmineUnderTest.MatchersUtil(); + const containing = new privateUnderTest.MapContaining(containingMap); + const matchersUtil = new privateUnderTest.MatchersUtil(); expect(containing.asymmetricMatch(actualMap, matchersUtil)).toBe(true); }); @@ -73,8 +73,8 @@ describe('MapContaining', function() { [jasmineUnderTest.stringMatching(/^foo\d/), 'bar'], ['baz', jasmineUnderTest.arrayContaining([2, 3])] ]); - const containing = new jasmineUnderTest.MapContaining(containingMap); - const matchersUtil = new jasmineUnderTest.MatchersUtil(); + const containing = new privateUnderTest.MapContaining(containingMap); + const matchersUtil = new privateUnderTest.MatchersUtil(); expect(containing.asymmetricMatch(actualMap, matchersUtil)).toBe(false); }); @@ -86,8 +86,8 @@ describe('MapContaining', function() { [jasmineUnderTest.stringMatching(/^foo\d/), 'bar'], ['baz', jasmineUnderTest.arrayContaining([4, 5])] ]); - const containing = new jasmineUnderTest.MapContaining(containingMap); - const matchersUtil = new jasmineUnderTest.MatchersUtil(); + const containing = new privateUnderTest.MapContaining(containingMap); + const matchersUtil = new privateUnderTest.MatchersUtil(); expect(containing.asymmetricMatch(actualMap, matchersUtil)).toBe(false); }); @@ -100,11 +100,11 @@ describe('MapContaining', function() { ]); const containingMap = new Map([ - ['foo', new jasmineUnderTest.MapContaining(new Map([['foo1', 1]]))], - [new jasmineUnderTest.MapContaining(new Map([[2, 'bar2']])), 'bar'] + ['foo', new privateUnderTest.MapContaining(new Map([['foo1', 1]]))], + [new privateUnderTest.MapContaining(new Map([[2, 'bar2']])), 'bar'] ]); - const containing = new jasmineUnderTest.MapContaining(containingMap); - const matchersUtil = new jasmineUnderTest.MatchersUtil(); + const containing = new privateUnderTest.MapContaining(containingMap); + const matchersUtil = new privateUnderTest.MatchersUtil(); expect(containing.asymmetricMatch(actualMap, matchersUtil)).toBe(true); }); @@ -117,10 +117,10 @@ describe('MapContaining', function() { : a === b; } const actualMap = new Map([['foo', -1]]); - const containing = new jasmineUnderTest.MapContaining( + const containing = new privateUnderTest.MapContaining( new Map([['foo', -2]]) ); - const matchersUtil = new jasmineUnderTest.MatchersUtil({ + const matchersUtil = new privateUnderTest.MatchersUtil({ customTesters: [tester] }); @@ -130,13 +130,13 @@ describe('MapContaining', function() { it('does not match when actual is not a map', function() { const containingMap = new Map([['foo', 'bar']]); expect( - new jasmineUnderTest.MapContaining(containingMap).asymmetricMatch('foo') + new privateUnderTest.MapContaining(containingMap).asymmetricMatch('foo') ).toBe(false); expect( - new jasmineUnderTest.MapContaining(containingMap).asymmetricMatch(-1) + new privateUnderTest.MapContaining(containingMap).asymmetricMatch(-1) ).toBe(false); expect( - new jasmineUnderTest.MapContaining(containingMap).asymmetricMatch({ + new privateUnderTest.MapContaining(containingMap).asymmetricMatch({ foo: 'bar' }) ).toBe(false); @@ -144,7 +144,7 @@ describe('MapContaining', function() { it('throws an error when sample is not a map', function() { expect(function() { - new jasmineUnderTest.MapContaining({ foo: 'bar' }).asymmetricMatch( + new privateUnderTest.MapContaining({ foo: 'bar' }).asymmetricMatch( new Map() ); }).toThrowError(/You must provide a map/); @@ -152,7 +152,7 @@ describe('MapContaining', function() { it('defines a `jasmineToString` method', function() { const sample = new Map(), - containing = new jasmineUnderTest.MapContaining(sample), + containing = new privateUnderTest.MapContaining(sample), pp = jasmine.createSpy('pp').and.returnValue('sample'); expect(containing.jasmineToString(pp)).toEqual( diff --git a/spec/core/asymmetric_equality/NotEmptySpec.js b/spec/core/asymmetric_equality/NotEmptySpec.js index 7494135f..527b1f16 100644 --- a/spec/core/asymmetric_equality/NotEmptySpec.js +++ b/spec/core/asymmetric_equality/NotEmptySpec.js @@ -1,20 +1,20 @@ describe('NotEmpty', function() { it('matches a non empty object', function() { - const notEmpty = new jasmineUnderTest.NotEmpty(); + const notEmpty = new privateUnderTest.NotEmpty(); expect(notEmpty.asymmetricMatch({ undefined: false })).toBe(true); expect(notEmpty.asymmetricMatch({})).toBe(false); }); it('matches a non empty array', function() { - const notEmpty = new jasmineUnderTest.NotEmpty(); + const notEmpty = new privateUnderTest.NotEmpty(); expect(notEmpty.asymmetricMatch([1, 12, 3])).toBe(true); expect(notEmpty.asymmetricMatch([])).toBe(false); }); it('matches a non empty string', function() { - const notEmpty = new jasmineUnderTest.NotEmpty(); + const notEmpty = new privateUnderTest.NotEmpty(); expect(notEmpty.asymmetricMatch('12312')).toBe(true); expect(notEmpty.asymmetricMatch('')).toBe(false); @@ -22,7 +22,7 @@ describe('NotEmpty', function() { }); it('matches a non empty map', function() { - const notEmpty = new jasmineUnderTest.NotEmpty(); + const notEmpty = new privateUnderTest.NotEmpty(); const fullMap = new Map(); fullMap.set('one', 1); const emptyMap = new Map(); @@ -32,7 +32,7 @@ describe('NotEmpty', function() { }); it('matches a non empty set', function() { - const notEmpty = new jasmineUnderTest.NotEmpty(); + const notEmpty = new privateUnderTest.NotEmpty(); const filledSet = new Set(); filledSet.add(1); const emptySet = new Set(); @@ -42,7 +42,7 @@ describe('NotEmpty', function() { }); it('matches a non empty typed array', function() { - const notEmpty = new jasmineUnderTest.NotEmpty(); + const notEmpty = new privateUnderTest.NotEmpty(); expect(notEmpty.asymmetricMatch(new Int16Array([1, 2, 3]))).toBe(true); expect(notEmpty.asymmetricMatch(new Int16Array())).toBe(false); diff --git a/spec/core/asymmetric_equality/ObjectContainingSpec.js b/spec/core/asymmetric_equality/ObjectContainingSpec.js index 98bf01b3..70327473 100644 --- a/spec/core/asymmetric_equality/ObjectContainingSpec.js +++ b/spec/core/asymmetric_equality/ObjectContainingSpec.js @@ -1,13 +1,13 @@ describe('ObjectContaining', function() { it('matches any object actual to an empty object', function() { - const containing = new jasmineUnderTest.ObjectContaining({}); - const matchersUtil = new jasmineUnderTest.MatchersUtil(); + const containing = new privateUnderTest.ObjectContaining({}); + const matchersUtil = new privateUnderTest.MatchersUtil(); expect(containing.asymmetricMatch({ foo: 1 }, matchersUtil)).toBe(true); }); it('does not match when the actual is not an object', function() { - const containing = new jasmineUnderTest.ObjectContaining({}); + const containing = new privateUnderTest.ObjectContaining({}); [1, true, undefined, 'a string'].forEach(function(actual) { expect(containing.asymmetricMatch(actual)).toBe(false); @@ -15,7 +15,7 @@ describe('ObjectContaining', function() { }); it('does not match an empty object actual', function() { - const containing = new jasmineUnderTest.ObjectContaining('foo'); + const containing = new privateUnderTest.ObjectContaining('foo'); expect(function() { containing.asymmetricMatch({}); @@ -23,8 +23,8 @@ describe('ObjectContaining', function() { }); it('matches when the key/value pair is present in the actual', function() { - const containing = new jasmineUnderTest.ObjectContaining({ foo: 'fooVal' }); - const matchersUtil = new jasmineUnderTest.MatchersUtil(); + const containing = new privateUnderTest.ObjectContaining({ foo: 'fooVal' }); + const matchersUtil = new privateUnderTest.MatchersUtil(); expect( containing.asymmetricMatch({ foo: 'fooVal', bar: 'barVal' }, matchersUtil) @@ -32,8 +32,8 @@ describe('ObjectContaining', function() { }); it('does not match when the key/value pair is not present in the actual', function() { - const containing = new jasmineUnderTest.ObjectContaining({ foo: 'fooVal' }); - const matchersUtil = new jasmineUnderTest.MatchersUtil(); + const containing = new privateUnderTest.ObjectContaining({ foo: 'fooVal' }); + const matchersUtil = new privateUnderTest.MatchersUtil(); expect( containing.asymmetricMatch( @@ -44,8 +44,8 @@ describe('ObjectContaining', function() { }); it('does not match when the key is present but the value is different in the actual', function() { - const containing = new jasmineUnderTest.ObjectContaining({ foo: 'other' }); - const matchersUtil = new jasmineUnderTest.MatchersUtil(); + const containing = new privateUnderTest.ObjectContaining({ foo: 'other' }); + const matchersUtil = new privateUnderTest.MatchersUtil(); expect( containing.asymmetricMatch({ foo: 'fooVal', bar: 'barVal' }, matchersUtil) @@ -54,7 +54,7 @@ describe('ObjectContaining', function() { it("jasmineToString's itself", function() { const sample = {}, - matcher = new jasmineUnderTest.ObjectContaining(sample), + matcher = new privateUnderTest.ObjectContaining(sample), pp = jasmine.createSpy('pp').and.returnValue('sample'); expect(matcher.jasmineToString(pp)).toEqual( @@ -64,10 +64,10 @@ describe('ObjectContaining', function() { }); it('matches recursively', function() { - const containing = new jasmineUnderTest.ObjectContaining({ - one: new jasmineUnderTest.ObjectContaining({ two: {} }) + const containing = new privateUnderTest.ObjectContaining({ + one: new privateUnderTest.ObjectContaining({ two: {} }) }); - const matchersUtil = new jasmineUnderTest.MatchersUtil(); + const matchersUtil = new privateUnderTest.MatchersUtil(); expect(containing.asymmetricMatch({ one: { two: {} } }, matchersUtil)).toBe( true @@ -75,10 +75,10 @@ describe('ObjectContaining', function() { }); it('matches when key is present with undefined value', function() { - const containing = new jasmineUnderTest.ObjectContaining({ + const containing = new privateUnderTest.ObjectContaining({ one: undefined }); - const matchersUtil = new jasmineUnderTest.MatchersUtil(); + const matchersUtil = new privateUnderTest.MatchersUtil(); expect(containing.asymmetricMatch({ one: undefined }, matchersUtil)).toBe( true @@ -86,17 +86,17 @@ describe('ObjectContaining', function() { }); it('does not match when key with undefined value is not present', function() { - const containing = new jasmineUnderTest.ObjectContaining({ + const containing = new privateUnderTest.ObjectContaining({ one: undefined }); - const matchersUtil = new jasmineUnderTest.MatchersUtil(); + const matchersUtil = new privateUnderTest.MatchersUtil(); expect(containing.asymmetricMatch({}, matchersUtil)).toBe(false); }); it('matches defined properties', function() { - const containing = new jasmineUnderTest.ObjectContaining({ foo: 'fooVal' }); - const matchersUtil = new jasmineUnderTest.MatchersUtil(); + const containing = new privateUnderTest.ObjectContaining({ foo: 'fooVal' }); + const matchersUtil = new privateUnderTest.MatchersUtil(); const definedPropertyObject = {}; Object.defineProperty(definedPropertyObject, 'foo', { @@ -110,8 +110,8 @@ describe('ObjectContaining', function() { }); it('matches prototype properties', function() { - const containing = new jasmineUnderTest.ObjectContaining({ foo: 'fooVal' }); - const matchersUtil = new jasmineUnderTest.MatchersUtil(); + const containing = new privateUnderTest.ObjectContaining({ foo: 'fooVal' }); + const matchersUtil = new privateUnderTest.MatchersUtil(); const prototypeObject = { foo: 'fooVal' }; const obj = Object.create(prototypeObject); @@ -131,8 +131,8 @@ describe('ObjectContaining', function() { return true; } }; - const containing = new jasmineUnderTest.ObjectContaining({ foo: 'fooVal' }); - const matchersUtil = new jasmineUnderTest.MatchersUtil({ + const containing = new privateUnderTest.ObjectContaining({ foo: 'fooVal' }); + const matchersUtil = new privateUnderTest.MatchersUtil({ customTesters: [tester] }); @@ -144,8 +144,8 @@ describe('ObjectContaining', function() { describe('valuesForDiff_', function() { describe('when other is not an object', function() { it('sets self to jasmineToString()', function() { - const containing = new jasmineUnderTest.ObjectContaining({}), - pp = jasmineUnderTest.makePrettyPrinter(), + const containing = new privateUnderTest.ObjectContaining({}), + pp = privateUnderTest.makePrettyPrinter(), result = containing.valuesForDiff_('a', pp); expect(result).toEqual({ @@ -159,11 +159,11 @@ describe('ObjectContaining', function() { it('includes keys that are present in both other and sample', function() { const sample = { a: 1, b: 2 }, other = { a: 3, b: 4 }, - containing = new jasmineUnderTest.ObjectContaining(sample), + containing = new privateUnderTest.ObjectContaining(sample), result = containing.valuesForDiff_(other); expect(result.self).not.toBeInstanceOf( - jasmineUnderTest.ObjectContaining + privateUnderTest.ObjectContaining ); expect(result).toEqual({ self: sample, @@ -174,11 +174,11 @@ describe('ObjectContaining', function() { it('includes keys that are present only in sample', function() { const sample = { a: 1, b: 2 }, other = { a: 3 }, - containing = new jasmineUnderTest.ObjectContaining(sample), + containing = new privateUnderTest.ObjectContaining(sample), result = containing.valuesForDiff_(other); expect(result.self).not.toBeInstanceOf( - jasmineUnderTest.ObjectContaining + privateUnderTest.ObjectContaining ); expect(containing.valuesForDiff_(other)).toEqual({ self: sample, @@ -192,11 +192,11 @@ describe('ObjectContaining', function() { it('omits keys that are present only in other', function() { const sample = { a: 1, b: 2 }, other = { a: 3, b: 4, c: 5 }, - containing = new jasmineUnderTest.ObjectContaining(sample), + containing = new privateUnderTest.ObjectContaining(sample), result = containing.valuesForDiff_(other); expect(result.self).not.toBeInstanceOf( - jasmineUnderTest.ObjectContaining + privateUnderTest.ObjectContaining ); expect(result).toEqual({ self: sample, diff --git a/spec/core/asymmetric_equality/SetContainingSpec.js b/spec/core/asymmetric_equality/SetContainingSpec.js index ab7654b6..6e48acfa 100644 --- a/spec/core/asymmetric_equality/SetContainingSpec.js +++ b/spec/core/asymmetric_equality/SetContainingSpec.js @@ -1,7 +1,7 @@ describe('SetContaining', function() { it('matches any actual set to an empty set', function() { const actualSet = new Set(['foo', 'bar']); - const containing = new jasmineUnderTest.SetContaining(new Set()); + const containing = new privateUnderTest.SetContaining(new Set()); expect(containing.asymmetricMatch(actualSet)).toBe(true); }); @@ -10,8 +10,8 @@ describe('SetContaining', function() { const actualSet = new Set([{ foo: 'bar' }, 'baz', [1, 2, 3]]); const containingSet = new Set([[1, 2, 3], { foo: 'bar' }]); - const containing = new jasmineUnderTest.SetContaining(containingSet); - const matchersUtil = new jasmineUnderTest.MatchersUtil(); + const containing = new privateUnderTest.SetContaining(containingSet); + const matchersUtil = new privateUnderTest.MatchersUtil(); expect(containing.asymmetricMatch(actualSet, matchersUtil)).toBe(true); }); @@ -20,8 +20,8 @@ describe('SetContaining', function() { const actualSet = new Set([{ foo: 'bar' }, 'baz', [1, 2, 3]]); const containingSet = new Set([[1, 2], { foo: 'bar' }]); - const containing = new jasmineUnderTest.SetContaining(containingSet); - const matchersUtil = new jasmineUnderTest.MatchersUtil(); + const containing = new privateUnderTest.SetContaining(containingSet); + const matchersUtil = new privateUnderTest.MatchersUtil(); expect(containing.asymmetricMatch(actualSet, matchersUtil)).toBe(false); }); @@ -33,8 +33,8 @@ describe('SetContaining', function() { jasmineUnderTest.stringMatching(/^foo\d/), jasmineUnderTest.arrayContaining([2, 3]) ]); - const containing = new jasmineUnderTest.SetContaining(containingSet); - const matchersUtil = new jasmineUnderTest.MatchersUtil(); + const containing = new privateUnderTest.SetContaining(containingSet); + const matchersUtil = new privateUnderTest.MatchersUtil(); expect(containing.asymmetricMatch(actualSet, matchersUtil)).toBe(true); }); @@ -46,8 +46,8 @@ describe('SetContaining', function() { jasmine.stringMatching(/^foo\d/), jasmine.arrayContaining([2, 3]) ]); - const containing = new jasmineUnderTest.SetContaining(containingSet); - const matchersUtil = new jasmineUnderTest.MatchersUtil(); + const containing = new privateUnderTest.SetContaining(containingSet); + const matchersUtil = new privateUnderTest.MatchersUtil(); expect(containing.asymmetricMatch(actualSet, matchersUtil)).toBe(false); }); @@ -56,11 +56,11 @@ describe('SetContaining', function() { const actualSet = new Set(['foo', new Set([1, 'bar', 2]), 'other']); const containingSet = new Set([ - new jasmineUnderTest.SetContaining(new Set(['bar'])), + new privateUnderTest.SetContaining(new Set(['bar'])), 'foo' ]); - const containing = new jasmineUnderTest.SetContaining(containingSet); - const matchersUtil = new jasmineUnderTest.MatchersUtil(); + const containing = new privateUnderTest.SetContaining(containingSet); + const matchersUtil = new privateUnderTest.MatchersUtil(); expect(containing.asymmetricMatch(actualSet, matchersUtil)).toBe(true); }); @@ -73,8 +73,8 @@ describe('SetContaining', function() { : a === b; } const actualSet = new Set(['foo', -1]); - const containing = new jasmineUnderTest.SetContaining(new Set([-2, 'foo'])); - const matchersUtil = new jasmineUnderTest.MatchersUtil({ + const containing = new privateUnderTest.SetContaining(new Set([-2, 'foo'])); + const matchersUtil = new privateUnderTest.MatchersUtil({ customTesters: [tester] }); @@ -84,19 +84,19 @@ describe('SetContaining', function() { it('does not match when actual is not a set', function() { const containingSet = new Set(['foo']); expect( - new jasmineUnderTest.SetContaining(containingSet).asymmetricMatch('foo') + new privateUnderTest.SetContaining(containingSet).asymmetricMatch('foo') ).toBe(false); expect( - new jasmineUnderTest.SetContaining(containingSet).asymmetricMatch(1) + new privateUnderTest.SetContaining(containingSet).asymmetricMatch(1) ).toBe(false); expect( - new jasmineUnderTest.SetContaining(containingSet).asymmetricMatch(['foo']) + new privateUnderTest.SetContaining(containingSet).asymmetricMatch(['foo']) ).toBe(false); }); it('throws an error when sample is not a set', function() { expect(function() { - new jasmineUnderTest.SetContaining({ foo: 'bar' }).asymmetricMatch( + new privateUnderTest.SetContaining({ foo: 'bar' }).asymmetricMatch( new Set() ); }).toThrowError(/You must provide a set/); @@ -104,7 +104,7 @@ describe('SetContaining', function() { it('defines a `jasmineToString` method', function() { const sample = new Set(), - containing = new jasmineUnderTest.SetContaining(sample), + containing = new privateUnderTest.SetContaining(sample), pp = jasmine.createSpy('pp').and.returnValue('sample'); expect(containing.jasmineToString(pp)).toEqual( diff --git a/spec/core/asymmetric_equality/StringContainingSpec.js b/spec/core/asymmetric_equality/StringContainingSpec.js index bae3b398..7bd7da54 100644 --- a/spec/core/asymmetric_equality/StringContainingSpec.js +++ b/spec/core/asymmetric_equality/StringContainingSpec.js @@ -1,6 +1,6 @@ describe('StringContaining', function() { it('searches for a provided substring when the expected is a String', function() { - const matcher = new jasmineUnderTest.StringContaining('foo'); + const matcher = new privateUnderTest.StringContaining('foo'); expect(matcher.asymmetricMatch('barfoobaz')).toBe(true); expect(matcher.asymmetricMatch('barbaz')).toBe(false); @@ -8,17 +8,17 @@ describe('StringContaining', function() { it('raises an Error when the expected is not a String', function() { expect(function() { - new jasmineUnderTest.StringContaining(/foo/); + new privateUnderTest.StringContaining(/foo/); }).toThrowError(/not a String/); }); it('fails when the actual is not a String', function() { - const matcher = new jasmineUnderTest.StringContaining('x'); + const matcher = new privateUnderTest.StringContaining('x'); expect(matcher.asymmetricMatch(['x'])).toBe(false); }); it("jasmineToString's itself", function() { - const matching = new jasmineUnderTest.StringContaining('foo'); + const matching = new privateUnderTest.StringContaining('foo'); expect(matching.jasmineToString()).toEqual( '' diff --git a/spec/core/asymmetric_equality/StringMatchingSpec.js b/spec/core/asymmetric_equality/StringMatchingSpec.js index cec1ebe1..dc444b98 100644 --- a/spec/core/asymmetric_equality/StringMatchingSpec.js +++ b/spec/core/asymmetric_equality/StringMatchingSpec.js @@ -1,13 +1,13 @@ describe('StringMatching', function() { it('matches a string against a provided regexp', function() { - const matcher = new jasmineUnderTest.StringMatching(/foo/); + const matcher = new privateUnderTest.StringMatching(/foo/); expect(matcher.asymmetricMatch('barfoobaz')).toBe(true); expect(matcher.asymmetricMatch('barbaz')).toBe(false); }); it('matches a string against provided string', function() { - const matcher = new jasmineUnderTest.StringMatching('foo'); + const matcher = new privateUnderTest.StringMatching('foo'); expect(matcher.asymmetricMatch('barfoobaz')).toBe(true); expect(matcher.asymmetricMatch('barbaz')).toBe(false); @@ -15,12 +15,12 @@ describe('StringMatching', function() { it('raises an Error when the expected is not a String or RegExp', function() { expect(function() { - new jasmineUnderTest.StringMatching({}); + new privateUnderTest.StringMatching({}); }).toThrowError(/not a String or a RegExp/); }); it("jasmineToString's itself", function() { - const matching = new jasmineUnderTest.StringMatching(/^foo/); + const matching = new privateUnderTest.StringMatching(/^foo/); expect(matching.jasmineToString()).toEqual( '' diff --git a/spec/core/asymmetric_equality/TruthySpec.js b/spec/core/asymmetric_equality/TruthySpec.js index 755503f4..266b24d3 100644 --- a/spec/core/asymmetric_equality/TruthySpec.js +++ b/spec/core/asymmetric_equality/TruthySpec.js @@ -1,13 +1,13 @@ describe('Truthy', function() { it('is true for a non empty string', function() { - const truthy = new jasmineUnderTest.Truthy(); + const truthy = new privateUnderTest.Truthy(); expect(truthy.asymmetricMatch('foo')).toBe(true); expect(truthy.asymmetricMatch('')).toBe(false); }); it('is true for a number that is not 0', function() { - const truthy = new jasmineUnderTest.Truthy(); + const truthy = new privateUnderTest.Truthy(); expect(truthy.asymmetricMatch(1)).toBe(true); expect(truthy.asymmetricMatch(0)).toBe(false); @@ -16,44 +16,44 @@ describe('Truthy', function() { }); it('is true for a function', function() { - const truthy = new jasmineUnderTest.Truthy(); + const truthy = new privateUnderTest.Truthy(); expect(truthy.asymmetricMatch(function() {})).toBe(true); }); it('is true for an Object', function() { - const truthy = new jasmineUnderTest.Truthy(); + const truthy = new privateUnderTest.Truthy(); expect(truthy.asymmetricMatch({})).toBe(true); }); it('is true for a truthful Boolean', function() { - const truthy = new jasmineUnderTest.Truthy(); + const truthy = new privateUnderTest.Truthy(); expect(truthy.asymmetricMatch(true)).toBe(true); expect(truthy.asymmetricMatch(false)).toBe(false); }); it('is true for an empty object', function() { - const truthy = new jasmineUnderTest.Truthy(); + const truthy = new privateUnderTest.Truthy(); expect(truthy.asymmetricMatch({})).toBe(true); }); it('is true for an empty array', function() { - const truthy = new jasmineUnderTest.Truthy(); + const truthy = new privateUnderTest.Truthy(); expect(truthy.asymmetricMatch([])).toBe(true); }); it('is true for a date', function() { - const truthy = new jasmineUnderTest.Truthy(); + const truthy = new privateUnderTest.Truthy(); expect(truthy.asymmetricMatch(new Date())).toBe(true); }); it('is true for a infiniti', function() { - const truthy = new jasmineUnderTest.Truthy(); + const truthy = new privateUnderTest.Truthy(); expect(truthy.asymmetricMatch(Infinity)).toBe(true); expect(truthy.asymmetricMatch(-Infinity)).toBe(true); diff --git a/spec/core/baseSpec.js b/spec/core/baseSpec.js index a656d3f4..132dab6e 100644 --- a/spec/core/baseSpec.js +++ b/spec/core/baseSpec.js @@ -1,5 +1,5 @@ describe('base helpers', function() { - describe('isError_', function() { + describe('isError', function() { it('correctly handles WebSocket events', function(done) { if (typeof jasmine.getGlobal().WebSocket === 'undefined') { pending('Environment does not provide WebSocket'); @@ -19,7 +19,7 @@ describe('base helpers', function() { const int = setInterval(function() { if (obj() || left === 0) { - const result = jasmineUnderTest.isError_(obj()); + const result = privateUnderTest.isError(obj()); expect(result).toBe(false); clearInterval(int); done(); @@ -32,11 +32,11 @@ describe('base helpers', function() { it('returns true for an Error subclass', function() { function MyError() {} MyError.prototype = new Error(); - expect(jasmineUnderTest.isError_(new MyError())).toBe(true); + expect(privateUnderTest.isError(new MyError())).toBe(true); }); it('returns true for an un-thrown Error with no message in this environment', function() { - expect(jasmineUnderTest.isError_(new Error())).toBe(true); + expect(privateUnderTest.isError(new Error())).toBe(true); }); it('returns true for an Error that originated from another frame', function() { @@ -50,102 +50,102 @@ describe('base helpers', function() { try { const error = iframe.contentWindow.eval('new Error()'); - expect(jasmineUnderTest.isError_(error)).toBe(true); + expect(privateUnderTest.isError(error)).toBe(true); } finally { document.body.removeChild(iframe); } }); it('returns false for a falsy value', function() { - expect(jasmineUnderTest.isError_(undefined)).toBe(false); + expect(privateUnderTest.isError(undefined)).toBe(false); }); it('returns false for a non-Error object', function() { - expect(jasmineUnderTest.isError_({})).toBe(false); + expect(privateUnderTest.isError({})).toBe(false); }); }); describe('isAsymmetricEqualityTester_', function() { it('returns false when the argument is falsy', function() { - expect(jasmineUnderTest.isAsymmetricEqualityTester_(null)).toBe(false); + expect(privateUnderTest.isAsymmetricEqualityTester(null)).toBe(false); }); it('returns false when the argument does not have a asymmetricMatch property', function() { const obj = {}; - expect(jasmineUnderTest.isAsymmetricEqualityTester_(obj)).toBe(false); + expect(privateUnderTest.isAsymmetricEqualityTester(obj)).toBe(false); }); it("returns false when the argument's asymmetricMatch is not a function", function() { const obj = { asymmetricMatch: 'yes' }; - expect(jasmineUnderTest.isAsymmetricEqualityTester_(obj)).toBe(false); + expect(privateUnderTest.isAsymmetricEqualityTester(obj)).toBe(false); }); it("returns true when the argument's asymmetricMatch is a function", function() { const obj = { asymmetricMatch: function() {} }; - expect(jasmineUnderTest.isAsymmetricEqualityTester_(obj)).toBe(true); + expect(privateUnderTest.isAsymmetricEqualityTester(obj)).toBe(true); }); }); describe('isSet', function() { it('returns true when the object is a Set', function() { - expect(jasmineUnderTest.isSet(new Set())).toBe(true); + expect(privateUnderTest.isSet(new Set())).toBe(true); }); it('returns false when the object is not a Set', function() { - expect(jasmineUnderTest.isSet({})).toBe(false); + expect(privateUnderTest.isSet({})).toBe(false); }); }); describe('isURL', function() { it('returns true when the object is a URL', function() { - expect(jasmineUnderTest.isURL(new URL('http://localhost/'))).toBe(true); + expect(privateUnderTest.isURL(new URL('http://localhost/'))).toBe(true); }); it('returns false when the object is not a URL', function() { - expect(jasmineUnderTest.isURL({})).toBe(false); + expect(privateUnderTest.isURL({})).toBe(false); }); }); - describe('isIterable_', function() { + describe('isIterable', function() { it('returns true when the object is an Array', function() { - expect(jasmineUnderTest.isIterable_([])).toBe(true); + expect(privateUnderTest.isIterable([])).toBe(true); }); it('returns true when the object is a Set', function() { - expect(jasmineUnderTest.isIterable_(new Set())).toBe(true); + expect(privateUnderTest.isIterable(new Set())).toBe(true); }); it('returns true when the object is a Map', function() { - expect(jasmineUnderTest.isIterable_(new Map())).toBe(true); + expect(privateUnderTest.isIterable(new Map())).toBe(true); }); it('returns true when the object implements @@iterator', function() { const myIterable = { [Symbol.iterator]: function() {} }; - expect(jasmineUnderTest.isIterable_(myIterable)).toBe(true); + expect(privateUnderTest.isIterable(myIterable)).toBe(true); }); it('returns false when the object does not implement @@iterator', function() { - expect(jasmineUnderTest.isIterable_({})).toBe(false); + expect(privateUnderTest.isIterable({})).toBe(false); }); }); - describe('isPending_', function() { + describe('isPending', function() { it('returns a promise that resolves to true when the promise is pending', function() { const promise = new Promise(function() {}); - return expectAsync(jasmineUnderTest.isPending_(promise)).toBeResolvedTo( + return expectAsync(privateUnderTest.isPending(promise)).toBeResolvedTo( true ); }); it('returns a promise that resolves to false when the promise is resolved', function() { const promise = Promise.resolve(); - return expectAsync(jasmineUnderTest.isPending_(promise)).toBeResolvedTo( + return expectAsync(privateUnderTest.isPending(promise)).toBeResolvedTo( false ); }); it('returns a promise that resolves to false when the promise is rejected', function() { const promise = Promise.reject(new Error('nope')); - return expectAsync(jasmineUnderTest.isPending_(promise)).toBeResolvedTo( + return expectAsync(privateUnderTest.isPending(promise)).toBeResolvedTo( false ); }); diff --git a/spec/core/buildExpectationResultSpec.js b/spec/core/buildExpectationResultSpec.js index 88b4cc19..9d31afd3 100644 --- a/spec/core/buildExpectationResultSpec.js +++ b/spec/core/buildExpectationResultSpec.js @@ -1,13 +1,13 @@ describe('buildExpectationResult', function() { it('defaults to passed', function() { - const result = jasmineUnderTest.buildExpectationResult({ + const result = privateUnderTest.buildExpectationResult({ passed: 'some-value' }); expect(result.passed).toBe('some-value'); }); it('message defaults to Passed for passing specs', function() { - const result = jasmineUnderTest.buildExpectationResult({ + const result = privateUnderTest.buildExpectationResult({ passed: true, message: 'some-value' }); @@ -15,7 +15,7 @@ describe('buildExpectationResult', function() { }); it('message returns the message for failing expectations', function() { - const result = jasmineUnderTest.buildExpectationResult({ + const result = privateUnderTest.buildExpectationResult({ passed: false, message: 'some-value' }); @@ -24,7 +24,7 @@ describe('buildExpectationResult', function() { describe('When the error property is provided', function() { it('sets the message to the formatted error', function() { - const result = jasmineUnderTest.buildExpectationResult({ + const result = privateUnderTest.buildExpectationResult({ passed: false, error: { message: 'foo', fileName: 'somefile.js' } }); @@ -33,7 +33,7 @@ describe('buildExpectationResult', function() { }); it('delegates stack formatting to the provided formatter', function() { - const result = jasmineUnderTest.buildExpectationResult({ + const result = privateUnderTest.buildExpectationResult({ passed: false, error: { stack: 'foo', extra: 'wombat' } }); @@ -46,7 +46,7 @@ describe('buildExpectationResult', function() { describe('When the errorForStack property is provided', function() { it('builds the stack trace using errorForStack instead of Error', function() { - const result = jasmineUnderTest.buildExpectationResult({ + const result = privateUnderTest.buildExpectationResult({ passed: false, errorForStack: { stack: 'foo' }, error: { stack: 'bar' } @@ -57,7 +57,7 @@ describe('buildExpectationResult', function() { }); it('matcherName returns passed matcherName', function() { - const result = jasmineUnderTest.buildExpectationResult({ + const result = privateUnderTest.buildExpectationResult({ matcherName: 'some-value' }); expect(result.matcherName).toBe('some-value'); @@ -78,7 +78,7 @@ describe('buildExpectationResult', function() { expect(error.code).toEqual('ERR_ASSERTION'); expect(error.operator).toEqual('=='); - const result = jasmineUnderTest.buildExpectationResult({ + const result = privateUnderTest.buildExpectationResult({ passed: false, matcherName: '', error: error diff --git a/spec/core/formatErrorMsgSpec.js b/spec/core/formatErrorMsgSpec.js index aae60be1..4457aef5 100644 --- a/spec/core/formatErrorMsgSpec.js +++ b/spec/core/formatErrorMsgSpec.js @@ -1,12 +1,12 @@ describe('formatErrorMsg', function() { it('should format an error with a domain', function() { - const formator = jasmineUnderTest.formatErrorMsg('api'); + const formator = privateUnderTest.formatErrorMsg('api'); expect(formator('message')).toBe('api : message'); expect(formator('message2')).toBe('api : message2'); }); it('should format an error with a domain and usage', function() { - const formator = jasmineUnderTest.formatErrorMsg('api', 'with a param'); + const formator = privateUnderTest.formatErrorMsg('api', 'with a param'); expect(formator('message')).toBe('api : message\nUsage: with a param'); expect(formator('message2')).toBe('api : message2\nUsage: with a param'); }); diff --git a/spec/core/integration/AsymmetricEqualityTestersSpec.js b/spec/core/integration/AsymmetricEqualityTestersSpec.js index 9fb4d6ca..08910b26 100644 --- a/spec/core/integration/AsymmetricEqualityTestersSpec.js +++ b/spec/core/integration/AsymmetricEqualityTestersSpec.js @@ -1,7 +1,7 @@ describe('Asymmetric equality testers (Integration)', function() { function verifyPasses(expectations) { it('passes', async function() { - const env = new jasmineUnderTest.Env(); + const env = new privateUnderTest.Env(); env.it('a spec', function() { expectations(env); }); @@ -30,7 +30,7 @@ describe('Asymmetric equality testers (Integration)', function() { function verifyFails(expectations) { it('fails', async function() { - const env = new jasmineUnderTest.Env(); + const env = new privateUnderTest.Env(); env.it('a spec', function() { expectations(env); }); diff --git a/spec/core/integration/CustomAsyncMatchersSpec.js b/spec/core/integration/CustomAsyncMatchersSpec.js index 1c167cfb..3b930e41 100644 --- a/spec/core/integration/CustomAsyncMatchersSpec.js +++ b/spec/core/integration/CustomAsyncMatchersSpec.js @@ -2,7 +2,7 @@ describe('Custom Async Matchers (Integration)', function() { let env; beforeEach(function() { - env = new jasmineUnderTest.Env(); + env = new privateUnderTest.Env(); env.configure({ random: false }); }); @@ -107,7 +107,7 @@ describe('Custom Async Matchers (Integration)', function() { const specExpectations = function() { expect(matcherFactorySpy).toHaveBeenCalledWith( - jasmine.any(jasmineUnderTest.MatchersUtil) + jasmine.any(privateUnderTest.MatchersUtil) ); }; diff --git a/spec/core/integration/CustomMatchersSpec.js b/spec/core/integration/CustomMatchersSpec.js index e56f8a04..081b245b 100644 --- a/spec/core/integration/CustomMatchersSpec.js +++ b/spec/core/integration/CustomMatchersSpec.js @@ -2,7 +2,7 @@ describe('Custom Matchers (Integration)', function() { let env; beforeEach(function() { - env = new jasmineUnderTest.Env(); + env = new privateUnderTest.Env(); env.configure({ random: false }); }); @@ -230,7 +230,7 @@ describe('Custom Matchers (Integration)', function() { await env.execute(); expect(matcherFactorySpy).toHaveBeenCalledWith( - jasmine.any(jasmineUnderTest.MatchersUtil) + jasmine.any(privateUnderTest.MatchersUtil) ); }); diff --git a/spec/core/integration/CustomObjectFormatterSpec.js b/spec/core/integration/CustomObjectFormatterSpec.js index 284ad87c..488a8768 100644 --- a/spec/core/integration/CustomObjectFormatterSpec.js +++ b/spec/core/integration/CustomObjectFormatterSpec.js @@ -2,7 +2,7 @@ describe('Custom object formatters', function() { let env; beforeEach(function() { - env = new jasmineUnderTest.Env(); + env = new privateUnderTest.Env(); env.configure({ random: false }); }); diff --git a/spec/core/integration/CustomSpyStrategiesSpec.js b/spec/core/integration/CustomSpyStrategiesSpec.js index 5fdd3e1c..66422116 100644 --- a/spec/core/integration/CustomSpyStrategiesSpec.js +++ b/spec/core/integration/CustomSpyStrategiesSpec.js @@ -2,7 +2,7 @@ describe('Custom Spy Strategies (Integration)', function() { let env; beforeEach(function() { - env = new jasmineUnderTest.Env(); + env = new privateUnderTest.Env(); env.configure({ random: false }); }); diff --git a/spec/core/integration/DefaultSpyStrategySpec.js b/spec/core/integration/DefaultSpyStrategySpec.js index a42dce60..a5fef892 100644 --- a/spec/core/integration/DefaultSpyStrategySpec.js +++ b/spec/core/integration/DefaultSpyStrategySpec.js @@ -2,7 +2,7 @@ describe('Default Spy Strategy (Integration)', function() { let env; beforeEach(function() { - env = new jasmineUnderTest.Env(); + env = new privateUnderTest.Env(); env.configure({ random: false }); }); diff --git a/spec/core/integration/DeprecationSpec.js b/spec/core/integration/DeprecationSpec.js index cbb95b2f..aa8bf710 100644 --- a/spec/core/integration/DeprecationSpec.js +++ b/spec/core/integration/DeprecationSpec.js @@ -3,7 +3,7 @@ describe('Deprecation (integration)', function() { let env; beforeEach(function() { - env = new jasmineUnderTest.Env(); + env = new privateUnderTest.Env(); }); afterEach(function() { diff --git a/spec/core/integration/EnvSpec.js b/spec/core/integration/EnvSpec.js index 688ab1c0..55e8fd67 100644 --- a/spec/core/integration/EnvSpec.js +++ b/spec/core/integration/EnvSpec.js @@ -4,7 +4,7 @@ describe('Env integration', function() { beforeEach(function() { specHelpers.registerIntegrationMatchers(); - env = new jasmineUnderTest.Env(); + env = new privateUnderTest.Env(); }); afterEach(function() { @@ -199,7 +199,7 @@ describe('Env integration', function() { } else { secondSpecContext = this; } - expect(this).toEqual(new jasmineUnderTest.UserContext()); + expect(this).toEqual(new privateUnderTest.UserContext()); }); env.it('sync spec', function() { @@ -229,7 +229,7 @@ describe('Env integration', function() { env.beforeEach(function() { specContext = this; - expect(this).toEqual(new jasmineUnderTest.UserContext()); + expect(this).toEqual(new privateUnderTest.UserContext()); }); env.it('sync spec', function(underTestCallback) { @@ -1110,7 +1110,7 @@ describe('Env integration', function() { ); env.cleanup_(); - env = new jasmineUnderTest.Env({ + env = new privateUnderTest.Env({ global: { setTimeout: globalSetTimeout, clearTimeout: clearTimeout, @@ -1175,7 +1175,7 @@ describe('Env integration', function() { env.cleanup_(); // explicitly pass in timing functions so we can make sure that clear stack always works // no matter how long the suite in the spec is - env = new jasmineUnderTest.Env({ + env = new privateUnderTest.Env({ global: { setTimeout: function(cb, t) { const stack = new Error().stack; @@ -1271,7 +1271,9 @@ 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.basicPrettyPrinter_(event)); + jasmine.debugLog( + 'Spec result: ' + jasmine.private.basicPrettyPrinter(event) + ); expect(event).toEqual(jasmine.objectContaining({ status: 'passed' })); jasmine.clock().tick(1); @@ -2335,7 +2337,7 @@ describe('Env integration', function() { }); it('throws an exception if you try to getSpecProperty outside of a spec', async function() { - const env = new jasmineUnderTest.Env(); + const env = new privateUnderTest.Env(); let exception; env.describe('a suite', function() { @@ -2356,7 +2358,7 @@ describe('Env integration', function() { }); it('reports test properties on specs', async function() { - const env = new jasmineUnderTest.Env(), + const env = new privateUnderTest.Env(), reporter = jasmine.createSpyObj('reporter', ['suiteDone', 'specDone']); reporter.specDone.and.callFake(function(e) { @@ -2389,7 +2391,7 @@ describe('Env integration', function() { }); it('throws an exception if you try to setSpecProperty outside of a spec', async function() { - const env = new jasmineUnderTest.Env(); + const env = new privateUnderTest.Env(); let exception; env.describe('a suite', function() { @@ -2410,7 +2412,7 @@ describe('Env integration', function() { }); it('reports test properties on suites', async function() { - const env = new jasmineUnderTest.Env(), + const env = new privateUnderTest.Env(), reporter = jasmine.createSpyObj('reporter', [ 'jasmineDone', 'suiteDone', @@ -2437,7 +2439,7 @@ describe('Env integration', function() { }); it('throws an exception if you try to setSuiteProperty outside of a suite', function(done) { - const env = new jasmineUnderTest.Env(); + const env = new privateUnderTest.Env(); try { env.setSuiteProperty('a', 'Bee'); @@ -2776,7 +2778,7 @@ describe('Env integration', function() { spyOn(jasmineUnderTest, 'getGlobal').and.returnValue(global); env.cleanup_(); - env = new jasmineUnderTest.Env(); + env = new privateUnderTest.Env(); const reporter = jasmine.createSpyObj('reporter', [ 'jasmineDone', 'suiteDone', @@ -2877,7 +2879,7 @@ describe('Env integration', function() { }); it('should report deprecation stack with an error object', async function() { - const exceptionFormatter = new jasmineUnderTest.ExceptionFormatter(), + const exceptionFormatter = new privateUnderTest.ExceptionFormatter(), reporter = jasmine.createSpyObj('reporter', [ 'jasmineDone', 'suiteDone', @@ -3167,7 +3169,7 @@ describe('Env integration', function() { }); it('supports asymmetric equality testers that take a matchersUtil', async function() { - const env = new jasmineUnderTest.Env(); + const env = new privateUnderTest.Env(); env.it('spec using custom asymmetric equality tester', function() { const customEqualityFn = function(a, b) { @@ -3224,17 +3226,17 @@ describe('Env integration', function() { }); it('is resolved after the stack is cleared', function(done) { - const realClearStack = jasmineUnderTest.getClearStack( + const realClearStack = privateUnderTest.getClearStack( jasmineUnderTest.getGlobal() ), clearStackSpy = jasmine .createSpy('clearStack') .and.callFake(realClearStack); - spyOn(jasmineUnderTest, 'getClearStack').and.returnValue(clearStackSpy); + spyOn(privateUnderTest, 'getClearStack').and.returnValue(clearStackSpy); // Create a new env that has the clearStack defined above env.cleanup_(); - env = new jasmineUnderTest.Env(); + env = new privateUnderTest.Env(); env.describe('suite', function() { env.it('spec', function() {}); @@ -3262,7 +3264,7 @@ describe('Env integration', function() { jasmineUnderTest.DEFAULT_TIMEOUT_INTERVAL = 123456; // a distinctive value - env = new jasmineUnderTest.Env(); + env = new privateUnderTest.Env(); env.describe('suite', function() { env.it('spec', function() {}); @@ -3333,17 +3335,17 @@ describe('Env integration', function() { }); it('is called after the stack is cleared', async function() { - const realClearStack = jasmineUnderTest.getClearStack( + const realClearStack = privateUnderTest.getClearStack( jasmineUnderTest.getGlobal() ), clearStackSpy = jasmine .createSpy('clearStack') .and.callFake(realClearStack); - spyOn(jasmineUnderTest, 'getClearStack').and.returnValue(clearStackSpy); + spyOn(privateUnderTest, 'getClearStack').and.returnValue(clearStackSpy); // Create a new env that has the clearStack defined above env.cleanup_(); - env = new jasmineUnderTest.Env(); + env = new privateUnderTest.Env(); env.describe('suite', function() { env.it('spec', function() {}); @@ -3371,7 +3373,7 @@ describe('Env integration', function() { jasmineUnderTest.DEFAULT_TIMEOUT_INTERVAL = 123456; // a distinctive value - env = new jasmineUnderTest.Env(); + env = new privateUnderTest.Env(); env.describe('suite', function() { env.it('spec', function() {}); diff --git a/spec/core/integration/GlobalErrorHandlingSpec.js b/spec/core/integration/GlobalErrorHandlingSpec.js index 55e5ac47..ef60ea5e 100644 --- a/spec/core/integration/GlobalErrorHandlingSpec.js +++ b/spec/core/integration/GlobalErrorHandlingSpec.js @@ -4,7 +4,7 @@ describe('Global error handling (integration)', function() { beforeEach(function() { specHelpers.registerIntegrationMatchers(); - env = new jasmineUnderTest.Env(); + env = new privateUnderTest.Env(); }); afterEach(function() { @@ -28,7 +28,7 @@ describe('Global error handling (integration)', function() { spyOn(jasmineUnderTest, 'getGlobal').and.returnValue(global); env.cleanup_(); - env = new jasmineUnderTest.Env(); + env = new privateUnderTest.Env(); const reporter = jasmine.createSpyObj('reporter', [ 'jasmineDone', 'suiteDone', @@ -85,12 +85,12 @@ describe('Global error handling (integration)', function() { onerror: originalOnerror }; spyOn(jasmineUnderTest, 'getGlobal').and.returnValue(global); - const globalErrors = new jasmineUnderTest.GlobalErrors(global); + const globalErrors = new privateUnderTest.GlobalErrors(global); const onerror = jasmine.createSpy('onerror'); globalErrors.pushListener(onerror); env.cleanup_(); - env = new jasmineUnderTest.Env({ + env = new privateUnderTest.Env({ suppressLoadErrors: true, GlobalErrors: function() { return globalErrors; @@ -129,7 +129,7 @@ describe('Global error handling (integration)', function() { }; spyOn(jasmineUnderTest, 'getGlobal').and.returnValue(global); env.cleanup_(); - env = new jasmineUnderTest.Env(); + env = new privateUnderTest.Env(); const reporter = jasmine.createSpyObj('fakeReporter', [ 'specDone', 'suiteDone' @@ -170,10 +170,10 @@ describe('Global error handling (integration)', function() { }; spyOn(jasmineUnderTest, 'getGlobal').and.returnValue(global); - const realClearStack = jasmineUnderTest.getClearStack(global); + const realClearStack = privateUnderTest.getClearStack(global); const clearStackCallbacks = {}; let clearStackCallCount = 0; - spyOn(jasmineUnderTest, 'getClearStack').and.returnValue(function(fn) { + spyOn(privateUnderTest, 'getClearStack').and.returnValue(function(fn) { clearStackCallCount++; if (clearStackCallbacks[clearStackCallCount]) { @@ -184,7 +184,7 @@ describe('Global error handling (integration)', function() { }); env.cleanup_(); - env = new jasmineUnderTest.Env(); + env = new privateUnderTest.Env(); let suiteErrors = []; env.addReporter({ @@ -234,7 +234,7 @@ describe('Global error handling (integration)', function() { }; spyOn(jasmineUnderTest, 'getGlobal').and.returnValue(global); env.cleanup_(); - env = new jasmineUnderTest.Env(); + env = new privateUnderTest.Env(); const reporter = jasmine.createSpyObj('fakeReporter', [ 'specDone', 'suiteDone' @@ -287,10 +287,10 @@ describe('Global error handling (integration)', function() { }; spyOn(jasmineUnderTest, 'getGlobal').and.returnValue(global); - const realClearStack = jasmineUnderTest.getClearStack(global); + const realClearStack = privateUnderTest.getClearStack(global); const clearStackCallbacks = {}; let clearStackCallCount = 0; - spyOn(jasmineUnderTest, 'getClearStack').and.returnValue(function(fn) { + spyOn(privateUnderTest, 'getClearStack').and.returnValue(function(fn) { clearStackCallCount++; if (clearStackCallbacks[clearStackCallCount]) { @@ -301,7 +301,7 @@ describe('Global error handling (integration)', function() { }); env.cleanup_(); - env = new jasmineUnderTest.Env(); + env = new privateUnderTest.Env(); let suiteErrors = []; env.addReporter({ @@ -355,7 +355,7 @@ describe('Global error handling (integration)', function() { }; spyOn(jasmineUnderTest, 'getGlobal').and.returnValue(global); env.cleanup_(); - env = new jasmineUnderTest.Env(); + env = new privateUnderTest.Env(); spyOn(console, 'error'); @@ -398,12 +398,12 @@ describe('Global error handling (integration)', function() { }; spyOn(jasmineUnderTest, 'getGlobal').and.returnValue(global); - const realClearStack = jasmineUnderTest.getClearStack(global); + const realClearStack = privateUnderTest.getClearStack(global); let clearStackCallCount = 0; let jasmineDone = false; const expectedErrors = []; const expectedErrorsAfterJasmineDone = []; - spyOn(jasmineUnderTest, 'getClearStack').and.returnValue(function(fn) { + spyOn(privateUnderTest, 'getClearStack').and.returnValue(function(fn) { clearStackCallCount++; const msg = `Error in clearStack #${clearStackCallCount}`; @@ -419,7 +419,7 @@ describe('Global error handling (integration)', function() { spyOn(console, 'error'); env.cleanup_(); - env = new jasmineUnderTest.Env(); + env = new privateUnderTest.Env(); const receivedErrors = []; function logErrors(event) { @@ -473,7 +473,7 @@ describe('Global error handling (integration)', function() { }; spyOn(jasmineUnderTest, 'getGlobal').and.returnValue(global); env.cleanup_(); - env = new jasmineUnderTest.Env(); + env = new privateUnderTest.Env(); const reporter = jasmine.createSpyObj('fakeReporter', [ 'specDone', 'suiteDone' @@ -516,10 +516,10 @@ describe('Global error handling (integration)', function() { }; spyOn(jasmineUnderTest, 'getGlobal').and.returnValue(global); - const realClearStack = jasmineUnderTest.getClearStack(global); + const realClearStack = privateUnderTest.getClearStack(global); const clearStackCallbacks = {}; let clearStackCallCount = 0; - spyOn(jasmineUnderTest, 'getClearStack').and.returnValue(function(fn) { + spyOn(privateUnderTest, 'getClearStack').and.returnValue(function(fn) { clearStackCallCount++; if (clearStackCallbacks[clearStackCallCount]) { @@ -530,7 +530,7 @@ describe('Global error handling (integration)', function() { }); env.cleanup_(); - env = new jasmineUnderTest.Env(); + env = new privateUnderTest.Env(); let suiteErrors = []; env.addReporter({ @@ -580,7 +580,7 @@ describe('Global error handling (integration)', function() { }; spyOn(jasmineUnderTest, 'getGlobal').and.returnValue(global); env.cleanup_(); - env = new jasmineUnderTest.Env(); + env = new privateUnderTest.Env(); const reporter = jasmine.createSpyObj('fakeReporter', [ 'specDone', 'suiteDone' @@ -635,10 +635,10 @@ describe('Global error handling (integration)', function() { }; spyOn(jasmineUnderTest, 'getGlobal').and.returnValue(global); - const realClearStack = jasmineUnderTest.getClearStack(global); + const realClearStack = privateUnderTest.getClearStack(global); const clearStackCallbacks = {}; let clearStackCallCount = 0; - spyOn(jasmineUnderTest, 'getClearStack').and.returnValue(function(fn) { + spyOn(privateUnderTest, 'getClearStack').and.returnValue(function(fn) { clearStackCallCount++; if (clearStackCallbacks[clearStackCallCount]) { @@ -649,7 +649,7 @@ describe('Global error handling (integration)', function() { }); env.cleanup_(); - env = new jasmineUnderTest.Env(); + env = new privateUnderTest.Env(); let suiteErrors = []; env.addReporter({ @@ -703,7 +703,7 @@ describe('Global error handling (integration)', function() { }; spyOn(jasmineUnderTest, 'getGlobal').and.returnValue(global); env.cleanup_(); - env = new jasmineUnderTest.Env(); + env = new privateUnderTest.Env(); spyOn(console, 'error'); @@ -748,12 +748,12 @@ describe('Global error handling (integration)', function() { }; spyOn(jasmineUnderTest, 'getGlobal').and.returnValue(global); - const realClearStack = jasmineUnderTest.getClearStack(global); + const realClearStack = privateUnderTest.getClearStack(global); let clearStackCallCount = 0; let jasmineDone = false; const expectedErrors = []; const expectedErrorsAfterJasmineDone = []; - spyOn(jasmineUnderTest, 'getClearStack').and.returnValue(function(fn) { + spyOn(privateUnderTest, 'getClearStack').and.returnValue(function(fn) { clearStackCallCount++; const reason = `Error in clearStack #${clearStackCallCount}`; const expectedMsg = `Unhandled promise rejection: ${reason} thrown`; @@ -770,7 +770,7 @@ describe('Global error handling (integration)', function() { spyOn(console, 'error'); env.cleanup_(); - env = new jasmineUnderTest.Env(); + env = new privateUnderTest.Env(); const receivedErrors = []; function logErrors(event) { @@ -833,7 +833,7 @@ describe('Global error handling (integration)', function() { }; spyOn(jasmineUnderTest, 'getGlobal').and.returnValue(global); env.cleanup_(); - env = new jasmineUnderTest.Env(); + env = new privateUnderTest.Env(); env.configure({ detectLateRejectionHandling: true }); reporter = jasmine.createSpyObj('fakeReporter', [ @@ -980,7 +980,7 @@ describe('Global error handling (integration)', function() { }; spyOn(jasmineUnderTest, 'getGlobal').and.returnValue(global); env.cleanup_(); - env = new jasmineUnderTest.Env(); + env = new privateUnderTest.Env(); env.configure({ detectLateRejectionHandling: true }); const reporter = jasmine.createSpyObj('fakeReporter', [ 'specDone', @@ -1026,7 +1026,7 @@ describe('Global error handling (integration)', function() { }; spyOn(jasmineUnderTest, 'getGlobal').and.returnValue(global); env.cleanup_(); - env = new jasmineUnderTest.Env(); + env = new privateUnderTest.Env(); env.configure({ autoCleanClosures: false }); const reporter = jasmine.createSpyObj('fakeReporter', ['specDone']); diff --git a/spec/core/integration/MatchersSpec.js b/spec/core/integration/MatchersSpec.js index 323114bd..f1987b69 100755 --- a/spec/core/integration/MatchersSpec.js +++ b/spec/core/integration/MatchersSpec.js @@ -2,7 +2,7 @@ describe('Matchers (Integration)', function() { let env; beforeEach(function() { - env = new jasmineUnderTest.Env(); + env = new privateUnderTest.Env(); }); afterEach(function() { @@ -143,7 +143,7 @@ describe('Matchers (Integration)', function() { function verifyFailsWithCustomObjectFormattersAsync(config) { it('uses custom object formatters', async function() { - const env = new jasmineUnderTest.Env(); + const env = new privateUnderTest.Env(); env.it('a spec', function() { env.addCustomObjectFormatter(config.formatter); return config.expectations(env); diff --git a/spec/core/integration/ParallelSpec.js b/spec/core/integration/ParallelSpec.js index 4381c225..4921478c 100644 --- a/spec/core/integration/ParallelSpec.js +++ b/spec/core/integration/ParallelSpec.js @@ -2,7 +2,7 @@ describe('Support for parallel execution', function() { let env; beforeEach(function() { - env = new jasmineUnderTest.Env(); + env = new privateUnderTest.Env(); }); afterEach(function() { diff --git a/spec/core/integration/SpecRunningSpec.js b/spec/core/integration/SpecRunningSpec.js index 06ae0552..932c6788 100644 --- a/spec/core/integration/SpecRunningSpec.js +++ b/spec/core/integration/SpecRunningSpec.js @@ -3,7 +3,7 @@ describe('spec running', function() { beforeEach(function() { specHelpers.registerIntegrationMatchers(); - env = new jasmineUnderTest.Env(); + env = new privateUnderTest.Env(); env.configure({ random: false }); }); diff --git a/spec/core/jasmineNamespaceSpec.js b/spec/core/jasmineNamespaceSpec.js new file mode 100644 index 00000000..95c7c0ed --- /dev/null +++ b/spec/core/jasmineNamespaceSpec.js @@ -0,0 +1,77 @@ +describe('The jasmine namespace', function() { + it('includes all expected properties', function() { + const actualKeys = new Set(Object.keys(jasmineUnderTest)); + // toEqual doesn't generate diffs for set comparisons. Check this way + // instead so we get readable failure output. + expect(setDifference(expectedKeys(), actualKeys)).toEqual(new Set()); + }); + + it('does not include any unexpected properties', function() { + const actualKeys = new Set(Object.keys(jasmineUnderTest)); + // toEqual doesn't generate diffs for set comparisons. Check this way + // instead so we get readable failure output. + expect(setDifference(actualKeys, expectedKeys())).toEqual(new Set()); + }); + + function expectedKeys() { + // Does not include properties added by requireInterface(), since that isn't + // called by defineJasmineUnderTest.js/nodeDefineJasmineUnderTest.js. + const result = new Set([ + 'MAX_PRETTY_PRINT_ARRAY_LENGTH', + 'MAX_PRETTY_PRINT_CHARS', + 'MAX_PRETTY_PRINT_DEPTH', + 'debugLog', + 'getEnv', + 'isSpy', + 'ParallelReportDispatcher', + 'private', + 'spyOnGlobalErrorsAsync', + 'Timer', + 'version', + + // Asymmetric equality testers + 'any', + 'anything', + 'arrayContaining', + 'arrayWithExactContents', + 'empty', + 'falsy', + 'is', + 'mapContaining', + 'notEmpty', + 'objectContaining', + 'setContaining', + 'stringContaining', + 'stringMatching', + 'truthy', + + // Currently undocumented but used in browser boot files, so it's + // effectively public + 'getGlobal' + ]); + + if (typeof window !== 'undefined') { + // jasmine-html.js + result.add('HtmlReporter'); + result.add('HtmlSpecFilter'); + result.add('HtmlExactSpecFilter'); + result.add('QueryString'); + } + + return result; + } + + // Can't use Set#difference yet because it isn't available in Node <22, + // Firefox <108, or Safari <17. + function setDifference(a, b) { + const result = new Set(); + + for (const v of a) { + if (!b.has(v)) { + result.add(v); + } + } + + return result; + } +}); diff --git a/spec/core/matchers/DiffBuilderSpec.js b/spec/core/matchers/DiffBuilderSpec.js index f134f214..f5bf1fa5 100644 --- a/spec/core/matchers/DiffBuilderSpec.js +++ b/spec/core/matchers/DiffBuilderSpec.js @@ -1,6 +1,6 @@ describe('DiffBuilder', function() { it('records the actual and expected objects', function() { - const diffBuilder = new jasmineUnderTest.DiffBuilder(); + const diffBuilder = new privateUnderTest.DiffBuilder(); diffBuilder.setRoots({ x: 'actual' }, { x: 'expected' }); diffBuilder.recordMismatch(); @@ -10,7 +10,7 @@ describe('DiffBuilder', function() { }); it('prints the path at which the difference was found', function() { - const diffBuilder = new jasmineUnderTest.DiffBuilder(); + const diffBuilder = new privateUnderTest.DiffBuilder(); diffBuilder.setRoots({ foo: { x: 'actual' } }, { foo: { x: 'expected' } }); diffBuilder.withPath('foo', function() { @@ -23,7 +23,7 @@ describe('DiffBuilder', function() { }); it('prints multiple messages, separated by newlines', function() { - const diffBuilder = new jasmineUnderTest.DiffBuilder(); + const diffBuilder = new privateUnderTest.DiffBuilder(); diffBuilder.setRoots({ foo: 1, bar: 3 }, { foo: 2, bar: 4 }); diffBuilder.withPath('foo', function() { @@ -40,7 +40,7 @@ describe('DiffBuilder', function() { }); it('allows customization of the message', function() { - const diffBuilder = new jasmineUnderTest.DiffBuilder(); + const diffBuilder = new privateUnderTest.DiffBuilder(); diffBuilder.setRoots({ x: 'bar' }, { x: 'foo' }); function darthVaderFormatter(actual, expected, path) { @@ -68,7 +68,7 @@ describe('DiffBuilder', function() { const prettyPrinter = function(val) { return '|' + val + '|'; }, - diffBuilder = new jasmineUnderTest.DiffBuilder({ + diffBuilder = new privateUnderTest.DiffBuilder({ prettyPrinter: prettyPrinter }); prettyPrinter.customFormat_ = function() {}; @@ -86,7 +86,7 @@ describe('DiffBuilder', function() { it('passes the injected pretty-printer to the diff formatter', function() { const diffFormatter = jasmine.createSpy('diffFormatter'), prettyPrinter = function() {}, - diffBuilder = new jasmineUnderTest.DiffBuilder({ + diffBuilder = new privateUnderTest.DiffBuilder({ prettyPrinter: prettyPrinter }); prettyPrinter.customFormat_ = function() {}; @@ -112,8 +112,8 @@ describe('DiffBuilder', function() { return '[number:' + x + ']'; } }; - const prettyPrinter = jasmineUnderTest.makePrettyPrinter([formatter]); - const diffBuilder = new jasmineUnderTest.DiffBuilder({ + const prettyPrinter = privateUnderTest.makePrettyPrinter([formatter]); + const diffBuilder = new privateUnderTest.DiffBuilder({ prettyPrinter: prettyPrinter }); @@ -131,8 +131,8 @@ describe('DiffBuilder', function() { return '[thing with a=' + x.a + ', b=' + JSON.stringify(x.b) + ']'; } }; - const prettyPrinter = jasmineUnderTest.makePrettyPrinter([formatter]); - const diffBuilder = new jasmineUnderTest.DiffBuilder({ + const prettyPrinter = privateUnderTest.makePrettyPrinter([formatter]); + const diffBuilder = new privateUnderTest.DiffBuilder({ prettyPrinter: prettyPrinter }); const expectedMsg = @@ -167,8 +167,8 @@ describe('DiffBuilder', function() { return '[number:' + x + ']'; } }; - const prettyPrinter = jasmineUnderTest.makePrettyPrinter([formatter]); - const diffBuilder = new jasmineUnderTest.DiffBuilder({ + const prettyPrinter = privateUnderTest.makePrettyPrinter([formatter]); + const diffBuilder = new privateUnderTest.DiffBuilder({ prettyPrinter: prettyPrinter }); @@ -186,8 +186,8 @@ describe('DiffBuilder', function() { return '[number:' + x + ']'; } }; - const prettyPrinter = jasmineUnderTest.makePrettyPrinter([formatter]); - const diffBuilder = new jasmineUnderTest.DiffBuilder({ + const prettyPrinter = privateUnderTest.makePrettyPrinter([formatter]); + const diffBuilder = new privateUnderTest.DiffBuilder({ prettyPrinter: prettyPrinter }); @@ -205,8 +205,8 @@ describe('DiffBuilder', function() { return '[number:' + x + ']'; } }; - const prettyPrinter = jasmineUnderTest.makePrettyPrinter([formatter]); - const diffBuilder = new jasmineUnderTest.DiffBuilder({ + const prettyPrinter = privateUnderTest.makePrettyPrinter([formatter]); + const diffBuilder = new privateUnderTest.DiffBuilder({ prettyPrinter: prettyPrinter }); @@ -219,8 +219,8 @@ describe('DiffBuilder', function() { }); it('builds diffs involving asymmetric equality testers that implement valuesForDiff_ at the root', function() { - const prettyPrinter = jasmineUnderTest.makePrettyPrinter([]), - diffBuilder = new jasmineUnderTest.DiffBuilder({ + const prettyPrinter = privateUnderTest.makePrettyPrinter([]), + diffBuilder = new privateUnderTest.DiffBuilder({ prettyPrinter: prettyPrinter }), expectedMsg = @@ -243,8 +243,8 @@ describe('DiffBuilder', function() { }); it('builds diffs involving asymmetric equality testers that implement valuesForDiff_ below the root', function() { - const prettyPrinter = jasmineUnderTest.makePrettyPrinter([]), - diffBuilder = new jasmineUnderTest.DiffBuilder({ + const prettyPrinter = privateUnderTest.makePrettyPrinter([]), + diffBuilder = new privateUnderTest.DiffBuilder({ prettyPrinter: prettyPrinter }), expectedMsg = diff --git a/spec/core/matchers/MismatchTreeSpec.js b/spec/core/matchers/MismatchTreeSpec.js index ad35ed84..28ef8220 100644 --- a/spec/core/matchers/MismatchTreeSpec.js +++ b/spec/core/matchers/MismatchTreeSpec.js @@ -2,25 +2,25 @@ describe('MismatchTree', function() { describe('#add', function() { describe('When the path is empty', function() { it('flags the root node as mismatched', function() { - const tree = new jasmineUnderTest.MismatchTree(); - tree.add(new jasmineUnderTest.ObjectPath([])); + const tree = new privateUnderTest.MismatchTree(); + tree.add(new privateUnderTest.ObjectPath([])); expect(tree.isMismatch).toBe(true); }); }); describe('When the path is not empty', function() { it('flags the node as mismatched', function() { - const tree = new jasmineUnderTest.MismatchTree(); + const tree = new privateUnderTest.MismatchTree(); - tree.add(new jasmineUnderTest.ObjectPath(['a', 'b'])); + tree.add(new privateUnderTest.ObjectPath(['a', 'b'])); expect(tree.child('a').child('b').isMismatch).toBe(true); }); it('does not flag ancestors as mismatched', function() { - const tree = new jasmineUnderTest.MismatchTree(); + const tree = new privateUnderTest.MismatchTree(); - tree.add(new jasmineUnderTest.ObjectPath(['a', 'b'])); + tree.add(new privateUnderTest.ObjectPath(['a', 'b'])); expect(tree.isMismatch).toBe(false); expect(tree.child('a').isMismatch).toBe(false); @@ -28,9 +28,9 @@ describe('MismatchTree', function() { }); it('stores the formatter on only the target node', function() { - const tree = new jasmineUnderTest.MismatchTree(); + const tree = new privateUnderTest.MismatchTree(); - tree.add(new jasmineUnderTest.ObjectPath(['a', 'b']), formatter); + tree.add(new privateUnderTest.ObjectPath(['a', 'b']), formatter); expect(tree.formatter).toBeFalsy(); expect(tree.child('a').formatter).toBeFalsy(); @@ -38,9 +38,9 @@ describe('MismatchTree', function() { }); it('stores the path to the node', function() { - const tree = new jasmineUnderTest.MismatchTree(); + const tree = new privateUnderTest.MismatchTree(); - tree.add(new jasmineUnderTest.ObjectPath(['a', 'b']), formatter); + tree.add(new privateUnderTest.ObjectPath(['a', 'b']), formatter); expect(tree.child('a').child('b').path.components).toEqual(['a', 'b']); }); @@ -48,37 +48,37 @@ describe('MismatchTree', function() { describe('#traverse', function() { it('calls the callback for all nodes that are or contain mismatches', function() { - const tree = new jasmineUnderTest.MismatchTree(); - tree.add(new jasmineUnderTest.ObjectPath(['a', 'b']), formatter); - tree.add(new jasmineUnderTest.ObjectPath(['c'])); + const tree = new privateUnderTest.MismatchTree(); + tree.add(new privateUnderTest.ObjectPath(['a', 'b']), formatter); + tree.add(new privateUnderTest.ObjectPath(['c'])); const visit = jasmine.createSpy('visit').and.returnValue(true); tree.traverse(visit); expect(visit).toHaveBeenCalledWith( - new jasmineUnderTest.ObjectPath([]), + new privateUnderTest.ObjectPath([]), false, undefined ); expect(visit).toHaveBeenCalledWith( - new jasmineUnderTest.ObjectPath(['a']), + new privateUnderTest.ObjectPath(['a']), false, undefined ); expect(visit).toHaveBeenCalledWith( - new jasmineUnderTest.ObjectPath(['a', 'b']), + new privateUnderTest.ObjectPath(['a', 'b']), true, formatter ); expect(visit).toHaveBeenCalledWith( - new jasmineUnderTest.ObjectPath(['c']), + new privateUnderTest.ObjectPath(['c']), true, undefined ); }); it('does not call the callback if there are no mismatches', function() { - const tree = new jasmineUnderTest.MismatchTree(); + const tree = new privateUnderTest.MismatchTree(); const visit = jasmine.createSpy('visit'); tree.traverse(visit); @@ -87,8 +87,8 @@ describe('MismatchTree', function() { }); it('visits parents before children', function() { - const tree = new jasmineUnderTest.MismatchTree(); - tree.add(new jasmineUnderTest.ObjectPath(['a', 'b'])); + const tree = new privateUnderTest.MismatchTree(); + tree.add(new privateUnderTest.ObjectPath(['a', 'b'])); const visited = []; tree.traverse(function(path) { @@ -97,16 +97,16 @@ describe('MismatchTree', function() { }); expect(visited).toEqual([ - new jasmineUnderTest.ObjectPath([]), - new jasmineUnderTest.ObjectPath(['a']), - new jasmineUnderTest.ObjectPath(['a', 'b']) + new privateUnderTest.ObjectPath([]), + new privateUnderTest.ObjectPath(['a']), + new privateUnderTest.ObjectPath(['a', 'b']) ]); }); it('visits children in the order they were recorded', function() { - const tree = new jasmineUnderTest.MismatchTree(); - tree.add(new jasmineUnderTest.ObjectPath(['length'])); - tree.add(new jasmineUnderTest.ObjectPath([1])); + const tree = new privateUnderTest.MismatchTree(); + tree.add(new privateUnderTest.ObjectPath(['length'])); + tree.add(new privateUnderTest.ObjectPath([1])); const visited = []; tree.traverse(function(path) { @@ -115,15 +115,15 @@ describe('MismatchTree', function() { }); expect(visited).toEqual([ - new jasmineUnderTest.ObjectPath([]), - new jasmineUnderTest.ObjectPath(['length']), - new jasmineUnderTest.ObjectPath([1]) + new privateUnderTest.ObjectPath([]), + new privateUnderTest.ObjectPath(['length']), + new privateUnderTest.ObjectPath([1]) ]); }); it('does not visit children if the callback returns falsy', function() { - const tree = new jasmineUnderTest.MismatchTree(); - tree.add(new jasmineUnderTest.ObjectPath(['a', 'b'])); + const tree = new privateUnderTest.MismatchTree(); + tree.add(new privateUnderTest.ObjectPath(['a', 'b'])); const visited = []; tree.traverse(function(path) { @@ -132,8 +132,8 @@ describe('MismatchTree', function() { }); expect(visited).toEqual([ - new jasmineUnderTest.ObjectPath([]), - new jasmineUnderTest.ObjectPath(['a']) + new privateUnderTest.ObjectPath([]), + new privateUnderTest.ObjectPath(['a']) ]); }); }); diff --git a/spec/core/matchers/NullDiffBuilderSpec.js b/spec/core/matchers/NullDiffBuilderSpec.js index 41fb1f97..8c782f81 100644 --- a/spec/core/matchers/NullDiffBuilderSpec.js +++ b/spec/core/matchers/NullDiffBuilderSpec.js @@ -1,7 +1,7 @@ describe('NullDiffBuilder', function() { it('responds to withPath() by calling the passed function', function() { const spy = jasmine.createSpy('callback'); - jasmineUnderTest.NullDiffBuilder().withPath('does not matter', spy); + privateUnderTest.NullDiffBuilder().withPath('does not matter', spy); expect(spy).toHaveBeenCalled(); }); }); diff --git a/spec/core/matchers/ObjectPathSpec.js b/spec/core/matchers/ObjectPathSpec.js index 80938f5a..4bf9356c 100644 --- a/spec/core/matchers/ObjectPathSpec.js +++ b/spec/core/matchers/ObjectPathSpec.js @@ -1,5 +1,5 @@ describe('ObjectPath', function() { - const ObjectPath = jasmineUnderTest.ObjectPath; + const ObjectPath = privateUnderTest.ObjectPath; it('represents the path to a node in an object tree', function() { expect(new ObjectPath(['foo', 'bar']).toString()).toEqual('$.foo.bar'); diff --git a/spec/core/matchers/async/toBePendingSpec.js b/spec/core/matchers/async/toBePendingSpec.js index 86cb5eb0..4445677e 100644 --- a/spec/core/matchers/async/toBePendingSpec.js +++ b/spec/core/matchers/async/toBePendingSpec.js @@ -1,7 +1,7 @@ describe('toBePending', function() { it('passes if the actual promise is pending', function() { - const matchersUtil = new jasmineUnderTest.MatchersUtil(), - matcher = jasmineUnderTest.asyncMatchers.toBePending(matchersUtil), + const matchersUtil = new privateUnderTest.MatchersUtil(), + matcher = privateUnderTest.asyncMatchers.toBePending(matchersUtil), actual = new Promise(function() {}); return matcher.compare(actual).then(function(result) { @@ -10,8 +10,8 @@ describe('toBePending', function() { }); it('fails if the actual promise is resolved', function() { - const matchersUtil = new jasmineUnderTest.MatchersUtil(), - matcher = jasmineUnderTest.asyncMatchers.toBePending(matchersUtil), + const matchersUtil = new privateUnderTest.MatchersUtil(), + matcher = privateUnderTest.asyncMatchers.toBePending(matchersUtil), actual = Promise.resolve(); return matcher.compare(actual).then(function(result) { @@ -20,8 +20,8 @@ describe('toBePending', function() { }); it('fails if the actual promise is rejected', function() { - const matchersUtil = new jasmineUnderTest.MatchersUtil(), - matcher = jasmineUnderTest.asyncMatchers.toBePending(matchersUtil), + const matchersUtil = new privateUnderTest.MatchersUtil(), + matcher = privateUnderTest.asyncMatchers.toBePending(matchersUtil), actual = Promise.reject(new Error('promise was rejected')); return matcher.compare(actual).then(function(result) { @@ -30,8 +30,8 @@ describe('toBePending', function() { }); it('fails if actual is not a promise', function() { - const matchersUtil = new jasmineUnderTest.MatchersUtil(), - matcher = jasmineUnderTest.asyncMatchers.toBePending(matchersUtil), + const matchersUtil = new privateUnderTest.MatchersUtil(), + matcher = privateUnderTest.asyncMatchers.toBePending(matchersUtil), actual = 'not a promise'; function f() { diff --git a/spec/core/matchers/async/toBeRejectedSpec.js b/spec/core/matchers/async/toBeRejectedSpec.js index 83c6bb17..fc52c67c 100644 --- a/spec/core/matchers/async/toBeRejectedSpec.js +++ b/spec/core/matchers/async/toBeRejectedSpec.js @@ -1,7 +1,7 @@ describe('toBeRejected', function() { it('passes if the actual is rejected', function() { - const matchersUtil = new jasmineUnderTest.MatchersUtil(), - matcher = jasmineUnderTest.asyncMatchers.toBeRejected(matchersUtil), + const matchersUtil = new privateUnderTest.MatchersUtil(), + matcher = privateUnderTest.asyncMatchers.toBeRejected(matchersUtil), actual = Promise.reject('AsyncExpectationSpec rejection'); return matcher.compare(actual).then(function(result) { @@ -10,8 +10,8 @@ describe('toBeRejected', function() { }); it('fails if the actual is resolved', function() { - const matchersUtil = new jasmineUnderTest.MatchersUtil(), - matcher = jasmineUnderTest.asyncMatchers.toBeRejected(matchersUtil), + const matchersUtil = new privateUnderTest.MatchersUtil(), + matcher = privateUnderTest.asyncMatchers.toBeRejected(matchersUtil), actual = Promise.resolve(); return matcher.compare(actual).then(function(result) { @@ -20,8 +20,8 @@ describe('toBeRejected', function() { }); it('fails if actual is not a promise', function() { - const matchersUtil = new jasmineUnderTest.MatchersUtil(), - matcher = jasmineUnderTest.asyncMatchers.toBeRejected(matchersUtil), + const matchersUtil = new privateUnderTest.MatchersUtil(), + matcher = privateUnderTest.asyncMatchers.toBeRejected(matchersUtil), actual = 'not a promise'; function f() { diff --git a/spec/core/matchers/async/toBeRejectedWithErrorSpec.js b/spec/core/matchers/async/toBeRejectedWithErrorSpec.js index ae36dae7..da6967ec 100644 --- a/spec/core/matchers/async/toBeRejectedWithErrorSpec.js +++ b/spec/core/matchers/async/toBeRejectedWithErrorSpec.js @@ -1,9 +1,9 @@ describe('#toBeRejectedWithError', function() { it('passes when Error type matches', function() { - const matchersUtil = new jasmineUnderTest.MatchersUtil({ - pp: jasmineUnderTest.makePrettyPrinter() + const matchersUtil = new privateUnderTest.MatchersUtil({ + pp: privateUnderTest.makePrettyPrinter() }), - matcher = jasmineUnderTest.asyncMatchers.toBeRejectedWithError( + matcher = privateUnderTest.asyncMatchers.toBeRejectedWithError( matchersUtil ), actual = Promise.reject(new TypeError('foo')); @@ -20,10 +20,10 @@ describe('#toBeRejectedWithError', function() { }); it('passes when Error type and message matches', function() { - const matchersUtil = new jasmineUnderTest.MatchersUtil({ - pp: jasmineUnderTest.makePrettyPrinter() + const matchersUtil = new privateUnderTest.MatchersUtil({ + pp: privateUnderTest.makePrettyPrinter() }), - matcher = jasmineUnderTest.asyncMatchers.toBeRejectedWithError( + matcher = privateUnderTest.asyncMatchers.toBeRejectedWithError( matchersUtil ), actual = Promise.reject(new TypeError('foo')); @@ -40,10 +40,10 @@ describe('#toBeRejectedWithError', function() { }); it('passes when Error matches and is exactly Error', function() { - const matchersUtil = new jasmineUnderTest.MatchersUtil({ - pp: jasmineUnderTest.makePrettyPrinter() + const matchersUtil = new privateUnderTest.MatchersUtil({ + pp: privateUnderTest.makePrettyPrinter() }), - matcher = jasmineUnderTest.asyncMatchers.toBeRejectedWithError( + matcher = privateUnderTest.asyncMatchers.toBeRejectedWithError( matchersUtil ), actual = Promise.reject(new Error()); @@ -60,10 +60,10 @@ describe('#toBeRejectedWithError', function() { }); it('passes when Error message matches a string', function() { - const matchersUtil = new jasmineUnderTest.MatchersUtil({ - pp: jasmineUnderTest.makePrettyPrinter() + const matchersUtil = new privateUnderTest.MatchersUtil({ + pp: privateUnderTest.makePrettyPrinter() }), - matcher = jasmineUnderTest.asyncMatchers.toBeRejectedWithError( + matcher = privateUnderTest.asyncMatchers.toBeRejectedWithError( matchersUtil ), actual = Promise.reject(new Error('foo')); @@ -80,10 +80,10 @@ describe('#toBeRejectedWithError', function() { }); it('passes when Error message matches a RegExp', function() { - const matchersUtil = new jasmineUnderTest.MatchersUtil({ - pp: jasmineUnderTest.makePrettyPrinter() + const matchersUtil = new privateUnderTest.MatchersUtil({ + pp: privateUnderTest.makePrettyPrinter() }), - matcher = jasmineUnderTest.asyncMatchers.toBeRejectedWithError( + matcher = privateUnderTest.asyncMatchers.toBeRejectedWithError( matchersUtil ), actual = Promise.reject(new Error('foo')); @@ -100,10 +100,10 @@ describe('#toBeRejectedWithError', function() { }); it('passes when Error message is empty', function() { - const matchersUtil = new jasmineUnderTest.MatchersUtil({ - pp: jasmineUnderTest.makePrettyPrinter() + const matchersUtil = new privateUnderTest.MatchersUtil({ + pp: privateUnderTest.makePrettyPrinter() }), - matcher = jasmineUnderTest.asyncMatchers.toBeRejectedWithError( + matcher = privateUnderTest.asyncMatchers.toBeRejectedWithError( matchersUtil ), actual = Promise.reject(new Error()); @@ -120,10 +120,10 @@ describe('#toBeRejectedWithError', function() { }); it('passes when no arguments', function() { - const matchersUtil = new jasmineUnderTest.MatchersUtil({ - pp: jasmineUnderTest.makePrettyPrinter() + const matchersUtil = new privateUnderTest.MatchersUtil({ + pp: privateUnderTest.makePrettyPrinter() }), - matcher = jasmineUnderTest.asyncMatchers.toBeRejectedWithError( + matcher = privateUnderTest.asyncMatchers.toBeRejectedWithError( matchersUtil ), actual = Promise.reject(new Error()); @@ -140,10 +140,10 @@ describe('#toBeRejectedWithError', function() { }); it('fails when resolved', function() { - const matchersUtil = new jasmineUnderTest.MatchersUtil({ - pp: jasmineUnderTest.makePrettyPrinter() + const matchersUtil = new privateUnderTest.MatchersUtil({ + pp: privateUnderTest.makePrettyPrinter() }), - matcher = jasmineUnderTest.asyncMatchers.toBeRejectedWithError( + matcher = privateUnderTest.asyncMatchers.toBeRejectedWithError( matchersUtil ), actual = Promise.resolve(new Error('foo')); @@ -159,10 +159,10 @@ describe('#toBeRejectedWithError', function() { }); it('fails when rejected with non Error type', function() { - const matchersUtil = new jasmineUnderTest.MatchersUtil({ - pp: jasmineUnderTest.makePrettyPrinter() + const matchersUtil = new privateUnderTest.MatchersUtil({ + pp: privateUnderTest.makePrettyPrinter() }), - matcher = jasmineUnderTest.asyncMatchers.toBeRejectedWithError( + matcher = privateUnderTest.asyncMatchers.toBeRejectedWithError( matchersUtil ), actual = Promise.reject('foo'); @@ -179,10 +179,10 @@ describe('#toBeRejectedWithError', function() { }); it('fails when Error type mismatches', function() { - const matchersUtil = new jasmineUnderTest.MatchersUtil({ - pp: jasmineUnderTest.makePrettyPrinter() + const matchersUtil = new privateUnderTest.MatchersUtil({ + pp: privateUnderTest.makePrettyPrinter() }), - matcher = jasmineUnderTest.asyncMatchers.toBeRejectedWithError( + matcher = privateUnderTest.asyncMatchers.toBeRejectedWithError( matchersUtil ), actual = Promise.reject(new Error('foo')); @@ -199,10 +199,10 @@ describe('#toBeRejectedWithError', function() { }); it('fails when Error message mismatches', function() { - const matchersUtil = new jasmineUnderTest.MatchersUtil({ - pp: jasmineUnderTest.makePrettyPrinter() + const matchersUtil = new privateUnderTest.MatchersUtil({ + pp: privateUnderTest.makePrettyPrinter() }), - matcher = jasmineUnderTest.asyncMatchers.toBeRejectedWithError( + matcher = privateUnderTest.asyncMatchers.toBeRejectedWithError( matchersUtil ), actual = Promise.reject(new Error('foo')); @@ -219,10 +219,10 @@ describe('#toBeRejectedWithError', function() { }); it('fails if actual is not a promise', function() { - const matchersUtil = new jasmineUnderTest.MatchersUtil({ - pp: jasmineUnderTest.makePrettyPrinter() + const matchersUtil = new privateUnderTest.MatchersUtil({ + pp: privateUnderTest.makePrettyPrinter() }), - matcher = jasmineUnderTest.asyncMatchers.toBeRejectedWithError( + matcher = privateUnderTest.asyncMatchers.toBeRejectedWithError( matchersUtil ), actual = 'not a promise'; diff --git a/spec/core/matchers/async/toBeRejectedWithSpec.js b/spec/core/matchers/async/toBeRejectedWithSpec.js index 02661e47..20a7d97b 100644 --- a/spec/core/matchers/async/toBeRejectedWithSpec.js +++ b/spec/core/matchers/async/toBeRejectedWithSpec.js @@ -1,7 +1,7 @@ describe('#toBeRejectedWith', function() { it('should return true if the promise is rejected with the expected value', function() { - const matchersUtil = new jasmineUnderTest.MatchersUtil(), - matcher = jasmineUnderTest.asyncMatchers.toBeRejectedWith(matchersUtil), + const matchersUtil = new privateUnderTest.MatchersUtil(), + matcher = privateUnderTest.asyncMatchers.toBeRejectedWith(matchersUtil), actual = Promise.reject({ error: 'PEBCAK' }); return matcher.compare(actual, { error: 'PEBCAK' }).then(function(result) { @@ -10,8 +10,8 @@ describe('#toBeRejectedWith', function() { }); it('should fail if the promise resolves', function() { - const matchersUtil = new jasmineUnderTest.MatchersUtil(), - matcher = jasmineUnderTest.asyncMatchers.toBeRejectedWith(matchersUtil), + const matchersUtil = new privateUnderTest.MatchersUtil(), + matcher = privateUnderTest.asyncMatchers.toBeRejectedWith(matchersUtil), actual = Promise.resolve(); return matcher.compare(actual, '').then(function(result) { @@ -20,10 +20,10 @@ describe('#toBeRejectedWith', function() { }); it('should fail if the promise is rejected with a different value', function() { - const matchersUtil = new jasmineUnderTest.MatchersUtil({ - pp: jasmineUnderTest.makePrettyPrinter() + const matchersUtil = new privateUnderTest.MatchersUtil({ + pp: privateUnderTest.makePrettyPrinter() }), - matcher = jasmineUnderTest.asyncMatchers.toBeRejectedWith(matchersUtil), + matcher = privateUnderTest.asyncMatchers.toBeRejectedWith(matchersUtil), actual = Promise.reject('A Bad Apple'); return matcher.compare(actual, 'Some Cool Thing').then(function(result) { @@ -38,10 +38,10 @@ describe('#toBeRejectedWith', function() { }); it('should build its error correctly when negated', function() { - const matchersUtil = new jasmineUnderTest.MatchersUtil({ - pp: jasmineUnderTest.makePrettyPrinter() + const matchersUtil = new privateUnderTest.MatchersUtil({ + pp: privateUnderTest.makePrettyPrinter() }), - matcher = jasmineUnderTest.asyncMatchers.toBeRejectedWith(matchersUtil), + matcher = privateUnderTest.asyncMatchers.toBeRejectedWith(matchersUtil), actual = Promise.reject(true); return matcher.compare(actual, true).then(function(result) { @@ -60,10 +60,10 @@ describe('#toBeRejectedWith', function() { return true; } ], - matchersUtil = new jasmineUnderTest.MatchersUtil({ + matchersUtil = new privateUnderTest.MatchersUtil({ customTesters: customEqualityTesters }), - matcher = jasmineUnderTest.asyncMatchers.toBeRejectedWith(matchersUtil), + matcher = privateUnderTest.asyncMatchers.toBeRejectedWith(matchersUtil), actual = Promise.reject('actual'); return matcher.compare(actual, 'expected').then(function(result) { @@ -72,10 +72,10 @@ describe('#toBeRejectedWith', function() { }); it('fails if actual is not a promise', function() { - const matchersUtil = new jasmineUnderTest.MatchersUtil({ - pp: jasmineUnderTest.makePrettyPrinter() + const matchersUtil = new privateUnderTest.MatchersUtil({ + pp: privateUnderTest.makePrettyPrinter() }), - matcher = jasmineUnderTest.asyncMatchers.toBeRejectedWith(matchersUtil), + matcher = privateUnderTest.asyncMatchers.toBeRejectedWith(matchersUtil), actual = 'not a promise'; function f() { diff --git a/spec/core/matchers/async/toBeResolvedSpec.js b/spec/core/matchers/async/toBeResolvedSpec.js index 6d6a784d..5d34af95 100644 --- a/spec/core/matchers/async/toBeResolvedSpec.js +++ b/spec/core/matchers/async/toBeResolvedSpec.js @@ -1,7 +1,7 @@ describe('toBeResolved', function() { it('passes if the actual is resolved', function() { - const matchersUtil = new jasmineUnderTest.MatchersUtil(), - matcher = jasmineUnderTest.asyncMatchers.toBeResolved(matchersUtil), + const matchersUtil = new privateUnderTest.MatchersUtil(), + matcher = privateUnderTest.asyncMatchers.toBeResolved(matchersUtil), actual = Promise.resolve(); return matcher.compare(actual).then(function(result) { @@ -10,10 +10,10 @@ describe('toBeResolved', function() { }); it('fails if the actual is rejected', function() { - const matchersUtil = new jasmineUnderTest.MatchersUtil({ - pp: jasmineUnderTest.makePrettyPrinter([]) + const matchersUtil = new privateUnderTest.MatchersUtil({ + pp: privateUnderTest.makePrettyPrinter([]) }), - matcher = jasmineUnderTest.asyncMatchers.toBeResolved(matchersUtil), + matcher = privateUnderTest.asyncMatchers.toBeResolved(matchersUtil), actual = Promise.reject(new Error('AsyncExpectationSpec rejection')); return matcher.compare(actual).then(function(result) { @@ -27,8 +27,8 @@ describe('toBeResolved', function() { }); it('fails if actual is not a promise', function() { - const matchersUtil = new jasmineUnderTest.MatchersUtil(), - matcher = jasmineUnderTest.asyncMatchers.toBeResolved(matchersUtil), + const matchersUtil = new privateUnderTest.MatchersUtil(), + matcher = privateUnderTest.asyncMatchers.toBeResolved(matchersUtil), actual = 'not a promise'; function f() { diff --git a/spec/core/matchers/async/toBeResolvedToSpec.js b/spec/core/matchers/async/toBeResolvedToSpec.js index a0c8ee6b..e0f1f57d 100644 --- a/spec/core/matchers/async/toBeResolvedToSpec.js +++ b/spec/core/matchers/async/toBeResolvedToSpec.js @@ -1,7 +1,7 @@ describe('#toBeResolvedTo', function() { it('passes if the promise is resolved to the expected value', function() { - const matchersUtil = new jasmineUnderTest.MatchersUtil(), - matcher = jasmineUnderTest.asyncMatchers.toBeResolvedTo(matchersUtil), + const matchersUtil = new privateUnderTest.MatchersUtil(), + matcher = privateUnderTest.asyncMatchers.toBeResolvedTo(matchersUtil), actual = Promise.resolve({ foo: 42 }); return matcher.compare(actual, { foo: 42 }).then(function(result) { @@ -10,10 +10,10 @@ describe('#toBeResolvedTo', function() { }); it('fails if the promise is rejected', function() { - const matchersUtil = new jasmineUnderTest.MatchersUtil({ - pp: jasmineUnderTest.makePrettyPrinter() + const matchersUtil = new privateUnderTest.MatchersUtil({ + pp: privateUnderTest.makePrettyPrinter() }), - matcher = jasmineUnderTest.asyncMatchers.toBeResolvedTo(matchersUtil), + matcher = privateUnderTest.asyncMatchers.toBeResolvedTo(matchersUtil), actual = Promise.reject(new Error('AsyncExpectationSpec error')); return matcher.compare(actual, '').then(function(result) { @@ -29,10 +29,10 @@ describe('#toBeResolvedTo', function() { }); it('fails if the promise is resolved to a different value', function() { - const matchersUtil = new jasmineUnderTest.MatchersUtil({ - pp: jasmineUnderTest.makePrettyPrinter() + const matchersUtil = new privateUnderTest.MatchersUtil({ + pp: privateUnderTest.makePrettyPrinter() }), - matcher = jasmineUnderTest.asyncMatchers.toBeResolvedTo(matchersUtil), + matcher = privateUnderTest.asyncMatchers.toBeResolvedTo(matchersUtil), actual = Promise.resolve({ foo: 17 }); return matcher.compare(actual, { foo: 42 }).then(function(result) { @@ -47,10 +47,10 @@ describe('#toBeResolvedTo', function() { }); it('builds its message correctly when negated', function() { - const matchersUtil = new jasmineUnderTest.MatchersUtil({ - pp: jasmineUnderTest.makePrettyPrinter() + const matchersUtil = new privateUnderTest.MatchersUtil({ + pp: privateUnderTest.makePrettyPrinter() }), - matcher = jasmineUnderTest.asyncMatchers.toBeResolvedTo(matchersUtil), + matcher = privateUnderTest.asyncMatchers.toBeResolvedTo(matchersUtil), actual = Promise.resolve(true); return matcher.compare(actual, true).then(function(result) { @@ -69,11 +69,11 @@ describe('#toBeResolvedTo', function() { return true; } ], - matchersUtil = new jasmineUnderTest.MatchersUtil({ + matchersUtil = new privateUnderTest.MatchersUtil({ customTesters: customEqualityTesters, - pp: jasmineUnderTest.makePrettyPrinter() + pp: privateUnderTest.makePrettyPrinter() }), - matcher = jasmineUnderTest.asyncMatchers.toBeResolvedTo(matchersUtil), + matcher = privateUnderTest.asyncMatchers.toBeResolvedTo(matchersUtil), actual = Promise.resolve('actual'); return matcher.compare(actual, 'expected').then(function(result) { @@ -82,10 +82,10 @@ describe('#toBeResolvedTo', function() { }); it('fails if actual is not a promise', function() { - const matchersUtil = new jasmineUnderTest.MatchersUtil({ - pp: jasmineUnderTest.makePrettyPrinter() + const matchersUtil = new privateUnderTest.MatchersUtil({ + pp: privateUnderTest.makePrettyPrinter() }), - matcher = jasmineUnderTest.asyncMatchers.toBeResolvedTo(matchersUtil), + matcher = privateUnderTest.asyncMatchers.toBeResolvedTo(matchersUtil), actual = 'not a promise'; function f() { diff --git a/spec/core/matchers/matchersUtilSpec.js b/spec/core/matchers/matchersUtilSpec.js index 747fca59..98656b37 100644 --- a/spec/core/matchers/matchersUtilSpec.js +++ b/spec/core/matchers/matchersUtilSpec.js @@ -1,79 +1,79 @@ describe('matchersUtil', function() { it('exposes the injected pretty-printer as .pp', function() { const pp = function() {}, - matchersUtil = new jasmineUnderTest.MatchersUtil({ pp: pp }); + matchersUtil = new privateUnderTest.MatchersUtil({ pp: pp }); expect(matchersUtil.pp).toBe(pp); }); describe('equals', function() { it('passes for literals that are triple-equal', function() { - const matchersUtil = new jasmineUnderTest.MatchersUtil(); + const matchersUtil = new privateUnderTest.MatchersUtil(); expect(matchersUtil.equals(null, null)).toBe(true); expect(matchersUtil.equals(void 0, void 0)).toBe(true); }); it('fails for things that are not equivalent', function() { - const matchersUtil = new jasmineUnderTest.MatchersUtil(); + const matchersUtil = new privateUnderTest.MatchersUtil(); expect(matchersUtil.equals({ a: 'foo' }, 1)).toBe(false); }); it('passes for Strings that are equivalent', function() { - const matchersUtil = new jasmineUnderTest.MatchersUtil(); + const matchersUtil = new privateUnderTest.MatchersUtil(); expect(matchersUtil.equals('foo', 'foo')).toBe(true); }); it('fails for Strings that are not equivalent', function() { - const matchersUtil = new jasmineUnderTest.MatchersUtil(); + const matchersUtil = new privateUnderTest.MatchersUtil(); expect(matchersUtil.equals('foo', 'bar')).toBe(false); }); it('passes for Numbers that are equivalent', function() { - const matchersUtil = new jasmineUnderTest.MatchersUtil(); + const matchersUtil = new privateUnderTest.MatchersUtil(); expect(matchersUtil.equals(123, 123)).toBe(true); }); it('fails for Numbers that are not equivalent', function() { - const matchersUtil = new jasmineUnderTest.MatchersUtil(); + const matchersUtil = new privateUnderTest.MatchersUtil(); expect(matchersUtil.equals(123, 456)).toBe(false); }); it('fails for a Number and a String that have equivalent values', function() { - const matchersUtil = new jasmineUnderTest.MatchersUtil(); + const matchersUtil = new privateUnderTest.MatchersUtil(); expect(matchersUtil.equals(123, '123')).toBe(false); }); it('passes for Dates that are equivalent', function() { - const matchersUtil = new jasmineUnderTest.MatchersUtil(); + const matchersUtil = new privateUnderTest.MatchersUtil(); expect( matchersUtil.equals(new Date('Jan 1, 1970'), new Date('Jan 1, 1970')) ).toBe(true); }); it('fails for Dates that are not equivalent', function() { - const matchersUtil = new jasmineUnderTest.MatchersUtil(); + const matchersUtil = new privateUnderTest.MatchersUtil(); expect( matchersUtil.equals(new Date('Jan 1, 1970'), new Date('Feb 3, 1991')) ).toBe(false); }); it('passes for Booleans that are equivalent', function() { - const matchersUtil = new jasmineUnderTest.MatchersUtil(); + const matchersUtil = new privateUnderTest.MatchersUtil(); expect(matchersUtil.equals(true, true)).toBe(true); }); it('fails for Booleans that are not equivalent', function() { - const matchersUtil = new jasmineUnderTest.MatchersUtil(); + const matchersUtil = new privateUnderTest.MatchersUtil(); expect(matchersUtil.equals(true, false)).toBe(false); }); it('passes for RegExps that are equivalent', function() { - const matchersUtil = new jasmineUnderTest.MatchersUtil(); + const matchersUtil = new privateUnderTest.MatchersUtil(); expect(matchersUtil.equals(/foo/, /foo/)).toBe(true); }); it('fails for RegExps that are not equivalent', function() { - const matchersUtil = new jasmineUnderTest.MatchersUtil(); + const matchersUtil = new privateUnderTest.MatchersUtil(); expect(matchersUtil.equals(/foo/, /bar/)).toBe(false); expect( matchersUtil.equals(new RegExp('foo', 'i'), new RegExp('foo')) @@ -81,32 +81,32 @@ describe('matchersUtil', function() { }); it('passes for Arrays that are equivalent', function() { - const matchersUtil = new jasmineUnderTest.MatchersUtil(); + const matchersUtil = new privateUnderTest.MatchersUtil(); expect(matchersUtil.equals([1, 2], [1, 2])).toBe(true); }); it('passes for Arrays that are equivalent, with elements added by changing length', function() { const foo = [], - matchersUtil = new jasmineUnderTest.MatchersUtil(); + matchersUtil = new privateUnderTest.MatchersUtil(); foo.length = 1; expect(matchersUtil.equals(foo, [undefined])).toBe(true); }); it('fails for Arrays that have different lengths', function() { - const matchersUtil = new jasmineUnderTest.MatchersUtil(); + const matchersUtil = new privateUnderTest.MatchersUtil(); expect(matchersUtil.equals([1, 2], [1, 2, 3])).toBe(false); }); it('fails for Arrays that have different elements', function() { - const matchersUtil = new jasmineUnderTest.MatchersUtil(); + const matchersUtil = new privateUnderTest.MatchersUtil(); expect(matchersUtil.equals([1, 2, 3], [1, 5, 3])).toBe(false); }); it('fails for Arrays whose contents are equivalent, but have differing properties', function() { const one = [1, 2, 3], two = [1, 2, 3], - matchersUtil = new jasmineUnderTest.MatchersUtil(); + matchersUtil = new privateUnderTest.MatchersUtil(); one.foo = 'bar'; two.foo = 'baz'; @@ -117,7 +117,7 @@ describe('matchersUtil', function() { it('passes for Arrays with equivalent contents and properties', function() { const one = [1, 2, 3], two = [1, 2, 3], - matchersUtil = new jasmineUnderTest.MatchersUtil(); + matchersUtil = new privateUnderTest.MatchersUtil(); one.foo = 'bar'; two.foo = 'bar'; @@ -126,7 +126,7 @@ describe('matchersUtil', function() { }); it('handles symbol keys in Arrays', function() { - const matchersUtil = new jasmineUnderTest.MatchersUtil(), + const matchersUtil = new privateUnderTest.MatchersUtil(), sym = Symbol('foo'), arr1 = []; let arr2 = []; @@ -148,21 +148,21 @@ describe('matchersUtil', function() { }); it('passes for Errors that are the same type and have the same message', function() { - const matchersUtil = new jasmineUnderTest.MatchersUtil(); + const matchersUtil = new privateUnderTest.MatchersUtil(); expect(matchersUtil.equals(new Error('foo'), new Error('foo'))).toBe( true ); }); it('fails for Errors that are the same type and have different messages', function() { - const matchersUtil = new jasmineUnderTest.MatchersUtil(); + const matchersUtil = new privateUnderTest.MatchersUtil(); expect(matchersUtil.equals(new Error('foo'), new Error('bar'))).toBe( false ); }); it('fails for objects with different constructors', function() { - const matchersUtil = new jasmineUnderTest.MatchersUtil(); + const matchersUtil = new privateUnderTest.MatchersUtil(); function One() {} function Two() {} @@ -170,17 +170,17 @@ describe('matchersUtil', function() { }); it('passes for Objects that are equivalent (simple case)', function() { - const matchersUtil = new jasmineUnderTest.MatchersUtil(); + const matchersUtil = new privateUnderTest.MatchersUtil(); expect(matchersUtil.equals({ a: 'foo' }, { a: 'foo' })).toBe(true); }); it('fails for Objects that are not equivalent (simple case)', function() { - const matchersUtil = new jasmineUnderTest.MatchersUtil(); + const matchersUtil = new privateUnderTest.MatchersUtil(); expect(matchersUtil.equals({ a: 'foo' }, { a: 'bar' })).toBe(false); }); it('passes for Objects that are equivalent (deep case)', function() { - const matchersUtil = new jasmineUnderTest.MatchersUtil(); + const matchersUtil = new privateUnderTest.MatchersUtil(); expect( matchersUtil.equals( { a: 'foo', b: { c: 'bar' } }, @@ -190,7 +190,7 @@ describe('matchersUtil', function() { }); it('fails for Objects that are not equivalent (deep case)', function() { - const matchersUtil = new jasmineUnderTest.MatchersUtil(); + const matchersUtil = new privateUnderTest.MatchersUtil(); expect( matchersUtil.equals( { a: 'foo', b: { c: 'baz' } }, @@ -202,7 +202,7 @@ describe('matchersUtil', function() { it('passes for Objects that are equivalent (with cycles)', function() { const actual = { a: 'foo' }, expected = { a: 'foo' }, - matchersUtil = new jasmineUnderTest.MatchersUtil(); + matchersUtil = new privateUnderTest.MatchersUtil(); actual.b = actual; expected.b = actual; @@ -213,7 +213,7 @@ describe('matchersUtil', function() { it('fails for Objects that are not equivalent (with cycles)', function() { const actual = { a: 'foo' }, expected = { a: 'bar' }, - matchersUtil = new jasmineUnderTest.MatchersUtil(); + matchersUtil = new privateUnderTest.MatchersUtil(); actual.b = actual; expected.b = actual; @@ -224,7 +224,7 @@ describe('matchersUtil', function() { it('fails for Objects that have the same number of keys, but different keys/values', function() { const expected = { a: undefined }, actual = { b: 1 }, - matchersUtil = new jasmineUnderTest.MatchersUtil(); + matchersUtil = new privateUnderTest.MatchersUtil(); expect(matchersUtil.equals(actual, expected)).toBe(false); }); @@ -232,7 +232,7 @@ describe('matchersUtil', function() { it('fails when comparing an empty object to an empty array (issue #114)', function() { const emptyObject = {}, emptyArray = [], - matchersUtil = new jasmineUnderTest.MatchersUtil(); + matchersUtil = new privateUnderTest.MatchersUtil(); expect(matchersUtil.equals(emptyObject, emptyArray)).toBe(false); expect(matchersUtil.equals(emptyArray, emptyObject)).toBe(false); @@ -241,7 +241,7 @@ describe('matchersUtil', function() { it('passes for equivalent frozen objects (GitHub issue #266)', function() { const a = { foo: 1 }, b = { foo: 1 }, - matchersUtil = new jasmineUnderTest.MatchersUtil(); + matchersUtil = new privateUnderTest.MatchersUtil(); Object.freeze(a); Object.freeze(b); @@ -252,7 +252,7 @@ describe('matchersUtil', function() { it('passes for equivalent Promises (GitHub issue #1314)', function() { const p1 = new Promise(function() {}), p2 = new Promise(function() {}), - matchersUtil = new jasmineUnderTest.MatchersUtil(); + matchersUtil = new privateUnderTest.MatchersUtil(); expect(matchersUtil.equals(p1, p1)).toBe(true); expect(matchersUtil.equals(p1, p2)).toBe(false); @@ -267,7 +267,7 @@ describe('matchersUtil', function() { it('passes for equivalent DOM nodes', function() { const a = document.createElement('div'); - const matchersUtil = new jasmineUnderTest.MatchersUtil(); + const matchersUtil = new privateUnderTest.MatchersUtil(); a.setAttribute('test-attr', 'attr-value'); a.appendChild(document.createTextNode('test')); @@ -280,7 +280,7 @@ describe('matchersUtil', function() { }); it('passes for equivalent objects from different frames', function() { - const matchersUtil = new jasmineUnderTest.MatchersUtil(); + const matchersUtil = new privateUnderTest.MatchersUtil(); const iframe = document.createElement('iframe'); document.body.appendChild(iframe); iframe.contentWindow.eval('window.testObject = {}'); @@ -291,7 +291,7 @@ describe('matchersUtil', function() { }); it('fails for DOM nodes with different attributes or child nodes', function() { - const matchersUtil = new jasmineUnderTest.MatchersUtil(); + const matchersUtil = new privateUnderTest.MatchersUtil(); const a = document.createElement('div'); a.setAttribute('test-attr', 'attr-value'); a.appendChild(document.createTextNode('test')); @@ -321,7 +321,7 @@ describe('matchersUtil', function() { }); it('passes for equivalent objects from different vm contexts', function() { - const matchersUtil = new jasmineUnderTest.MatchersUtil(); + const matchersUtil = new privateUnderTest.MatchersUtil(); const vm = require('vm'); const sandbox = { obj: null @@ -332,7 +332,7 @@ describe('matchersUtil', function() { }); it('passes for equivalent arrays from different vm contexts', function() { - const matchersUtil = new jasmineUnderTest.MatchersUtil(); + const matchersUtil = new privateUnderTest.MatchersUtil(); const vm = require('vm'); const sandbox = { arr: null @@ -345,8 +345,8 @@ describe('matchersUtil', function() { it('passes when Any is used', function() { const number = 3, - anyNumber = new jasmineUnderTest.Any(Number), - matchersUtil = new jasmineUnderTest.MatchersUtil(); + anyNumber = new privateUnderTest.Any(Number), + matchersUtil = new privateUnderTest.MatchersUtil(); expect(matchersUtil.equals(number, anyNumber)).toBe(true); expect(matchersUtil.equals(anyNumber, number)).toBe(true); @@ -354,8 +354,8 @@ describe('matchersUtil', function() { it('fails when Any is compared to something unexpected', function() { const number = 3, - anyString = new jasmineUnderTest.Any(String), - matchersUtil = new jasmineUnderTest.MatchersUtil(); + anyString = new privateUnderTest.Any(String), + matchersUtil = new privateUnderTest.MatchersUtil(); expect(matchersUtil.equals(number, anyString)).toBe(false); expect(matchersUtil.equals(anyString, number)).toBe(false); @@ -366,19 +366,19 @@ describe('matchersUtil', function() { foo: 3, bar: 7 }, - containing = new jasmineUnderTest.ObjectContaining({ foo: 3 }), - matchersUtil = new jasmineUnderTest.MatchersUtil(); + containing = new privateUnderTest.ObjectContaining({ foo: 3 }), + matchersUtil = new privateUnderTest.MatchersUtil(); expect(matchersUtil.equals(obj, containing)).toBe(true); expect(matchersUtil.equals(containing, obj)).toBe(true); }); it('passes when MapContaining is used', function() { - const matchersUtil = new jasmineUnderTest.MatchersUtil(); + const matchersUtil = new privateUnderTest.MatchersUtil(); const obj = new Map(); obj.set(1, 2); obj.set('foo', 'bar'); - const containing = new jasmineUnderTest.MapContaining(new Map()); + const containing = new privateUnderTest.MapContaining(new Map()); containing.sample.set('foo', 'bar'); expect(matchersUtil.equals(obj, containing)).toBe(true); @@ -386,11 +386,11 @@ describe('matchersUtil', function() { }); it('passes when SetContaining is used', function() { - const matchersUtil = new jasmineUnderTest.MatchersUtil(); + const matchersUtil = new privateUnderTest.MatchersUtil(); const obj = new Set(); obj.add(1); obj.add('foo'); - const containing = new jasmineUnderTest.SetContaining(new Set()); + const containing = new privateUnderTest.SetContaining(new Set()); containing.sample.add(1); expect(matchersUtil.equals(obj, containing)).toBe(true); @@ -403,7 +403,7 @@ describe('matchersUtil', function() { return true; } }, - matchersUtil = new jasmineUnderTest.MatchersUtil(); + matchersUtil = new privateUnderTest.MatchersUtil(); expect(matchersUtil.equals(false, tester)).toBe(true); expect(matchersUtil.equals(tester, false)).toBe(true); @@ -415,7 +415,7 @@ describe('matchersUtil', function() { return false; } }, - matchersUtil = new jasmineUnderTest.MatchersUtil(); + matchersUtil = new privateUnderTest.MatchersUtil(); expect(matchersUtil.equals(true, tester)).toBe(false); expect(matchersUtil.equals(tester, true)).toBe(false); @@ -423,10 +423,10 @@ describe('matchersUtil', function() { it('passes when ArrayContaining is used', function() { const arr = ['foo', 'bar'], - matchersUtil = new jasmineUnderTest.MatchersUtil(); + matchersUtil = new privateUnderTest.MatchersUtil(); expect( - matchersUtil.equals(arr, new jasmineUnderTest.ArrayContaining(['bar'])) + matchersUtil.equals(arr, new privateUnderTest.ArrayContaining(['bar'])) ).toBe(true); }); @@ -434,7 +434,7 @@ describe('matchersUtil', function() { const tester = function() { return true; }, - matchersUtil = new jasmineUnderTest.MatchersUtil({ + matchersUtil = new privateUnderTest.MatchersUtil({ customTesters: [tester], pp: function() {} }); @@ -443,7 +443,7 @@ describe('matchersUtil', function() { }); it('passes for two empty Objects', function() { - const matchersUtil = new jasmineUnderTest.MatchersUtil(); + const matchersUtil = new privateUnderTest.MatchersUtil(); expect(matchersUtil.equals({}, {})).toBe(true); }); @@ -453,7 +453,7 @@ describe('matchersUtil', function() { }; it('passes for two empty Objects', function() { - const matchersUtil = new jasmineUnderTest.MatchersUtil({ + const matchersUtil = new privateUnderTest.MatchersUtil({ customTesters: [tester], pp: function() {} }); @@ -465,7 +465,7 @@ describe('matchersUtil', function() { const tester = function() { return false; }, - matchersUtil = new jasmineUnderTest.MatchersUtil({ + matchersUtil = new privateUnderTest.MatchersUtil({ customTesters: [tester], pp: function() {} }); @@ -482,7 +482,7 @@ describe('matchersUtil', function() { symmetricTester = function() { return false; }, - matchersUtil = new jasmineUnderTest.MatchersUtil({ + matchersUtil = new privateUnderTest.MatchersUtil({ customTesters: [symmetricTester()], pp: function() {} }); @@ -492,9 +492,9 @@ describe('matchersUtil', function() { }); it('passes when an Any is compared to an Any that checks for the same type', function() { - const any1 = new jasmineUnderTest.Any(Function), - any2 = new jasmineUnderTest.Any(Function), - matchersUtil = new jasmineUnderTest.MatchersUtil(); + const any1 = new privateUnderTest.Any(Function), + any2 = new privateUnderTest.Any(Function), + matchersUtil = new privateUnderTest.MatchersUtil(); expect(matchersUtil.equals(any1, any2)).toBe(true); }); @@ -502,7 +502,7 @@ describe('matchersUtil', function() { it('passes for null prototype objects with same properties', function() { const objA = Object.create(null), objB = Object.create(null), - matchersUtil = new jasmineUnderTest.MatchersUtil(); + matchersUtil = new privateUnderTest.MatchersUtil(); objA.name = 'test'; objB.name = 'test'; @@ -513,7 +513,7 @@ describe('matchersUtil', function() { it('fails for null prototype objects with different properties', function() { const objA = Object.create(null), objB = Object.create(null), - matchersUtil = new jasmineUnderTest.MatchersUtil(); + matchersUtil = new privateUnderTest.MatchersUtil(); objA.name = 'test'; objB.test = 'name'; @@ -522,12 +522,12 @@ describe('matchersUtil', function() { }); it('passes when comparing two empty sets', function() { - const matchersUtil = new jasmineUnderTest.MatchersUtil(); + const matchersUtil = new privateUnderTest.MatchersUtil(); expect(matchersUtil.equals(new Set(), new Set())).toBe(true); }); it('passes when comparing identical sets', function() { - const matchersUtil = new jasmineUnderTest.MatchersUtil(); + const matchersUtil = new privateUnderTest.MatchersUtil(); const setA = new Set(); setA.add(6); setA.add(5); @@ -539,7 +539,7 @@ describe('matchersUtil', function() { }); it('passes when comparing identical sets with different insertion order and simple elements', function() { - const matchersUtil = new jasmineUnderTest.MatchersUtil(); + const matchersUtil = new privateUnderTest.MatchersUtil(); const setA = new Set(); setA.add(3); setA.add(6); @@ -551,7 +551,7 @@ describe('matchersUtil', function() { }); it('passes when comparing identical sets with different insertion order and complex elements 1', function() { - const matchersUtil = new jasmineUnderTest.MatchersUtil(); + const matchersUtil = new privateUnderTest.MatchersUtil(); const setA1 = new Set(); setA1.add(['a', 3]); setA1.add([6, 1]); @@ -576,7 +576,7 @@ describe('matchersUtil', function() { }); it('passes when comparing identical sets with different insertion order and complex elements 2', function() { - const matchersUtil = new jasmineUnderTest.MatchersUtil(); + const matchersUtil = new privateUnderTest.MatchersUtil(); const setA = new Set(); setA.add([[1, 2], [3, 4]]); setA.add([[5, 6], [7, 8]]); @@ -588,7 +588,7 @@ describe('matchersUtil', function() { }); it('fails for sets with different elements', function() { - const matchersUtil = new jasmineUnderTest.MatchersUtil(); + const matchersUtil = new privateUnderTest.MatchersUtil(); const setA = new Set(); setA.add(6); setA.add(3); @@ -602,7 +602,7 @@ describe('matchersUtil', function() { }); it('fails for sets of different size', function() { - const matchersUtil = new jasmineUnderTest.MatchersUtil(); + const matchersUtil = new privateUnderTest.MatchersUtil(); const setA = new Set(); setA.add(6); setA.add(3); @@ -615,12 +615,12 @@ describe('matchersUtil', function() { }); it('passes when comparing two empty maps', function() { - const matchersUtil = new jasmineUnderTest.MatchersUtil(); + const matchersUtil = new privateUnderTest.MatchersUtil(); expect(matchersUtil.equals(new Map(), new Map())).toBe(true); }); it('passes when comparing identical maps', function() { - const matchersUtil = new jasmineUnderTest.MatchersUtil(); + const matchersUtil = new privateUnderTest.MatchersUtil(); const mapA = new Map(); mapA.set(6, 5); const mapB = new Map(); @@ -629,7 +629,7 @@ describe('matchersUtil', function() { }); it('passes when comparing identical maps with different insertion order', function() { - const matchersUtil = new jasmineUnderTest.MatchersUtil(); + const matchersUtil = new privateUnderTest.MatchersUtil(); const mapA = new Map(); mapA.set('a', 3); mapA.set(6, 1); @@ -640,7 +640,7 @@ describe('matchersUtil', function() { }); it('fails for maps with different elements', function() { - const matchersUtil = new jasmineUnderTest.MatchersUtil(); + const matchersUtil = new privateUnderTest.MatchersUtil(); const mapA = new Map(); mapA.set(6, 3); mapA.set(5, 1); @@ -652,7 +652,7 @@ describe('matchersUtil', function() { }); it('fails for maps of different size', function() { - const matchersUtil = new jasmineUnderTest.MatchersUtil(); + const matchersUtil = new privateUnderTest.MatchersUtil(); const mapA = new Map(); mapA.set(6, 3); const mapB = new Map(); @@ -662,7 +662,7 @@ describe('matchersUtil', function() { }); it('passes when comparing two identical URLs', function() { - const matchersUtil = new jasmineUnderTest.MatchersUtil(); + const matchersUtil = new privateUnderTest.MatchersUtil(); expect( matchersUtil.equals( @@ -673,7 +673,7 @@ describe('matchersUtil', function() { }); it('fails when comparing two different URLs', function() { - const matchersUtil = new jasmineUnderTest.MatchersUtil(), + const matchersUtil = new privateUnderTest.MatchersUtil(), url1 = new URL('http://localhost/1'); expect(matchersUtil.equals(url1, new URL('http://localhost/2'))).toBe( @@ -699,7 +699,7 @@ describe('matchersUtil', function() { it('passes for ArrayBuffers with same length and content', function() { const buffer1 = new ArrayBuffer(4); const buffer2 = new ArrayBuffer(4); - const matchersUtil = new jasmineUnderTest.MatchersUtil(); + const matchersUtil = new privateUnderTest.MatchersUtil(); expect(matchersUtil.equals(buffer1, buffer2)).toBe(true); }); @@ -708,13 +708,13 @@ describe('matchersUtil', function() { const buffer2 = new ArrayBuffer(4); const array1 = new Uint8Array(buffer1); array1[0] = 1; - const matchersUtil = new jasmineUnderTest.MatchersUtil(); + const matchersUtil = new privateUnderTest.MatchersUtil(); expect(matchersUtil.equals(buffer1, buffer2)).toBe(false); }); describe('Typed arrays', function() { it('fails for typed arrays of same length and contents but different types', function() { - const matchersUtil = new jasmineUnderTest.MatchersUtil(); + const matchersUtil = new privateUnderTest.MatchersUtil(); const a1 = new Int8Array(1); const a2 = new Uint8Array(1); a1[0] = a2[0] = 0; @@ -737,23 +737,23 @@ describe('matchersUtil', function() { it( 'passes for ' + typeName + 's with same length and content', function() { - const matchersUtil = new jasmineUnderTest.MatchersUtil(); + const matchersUtil = new privateUnderTest.MatchersUtil(); const a1 = new TypedArrayCtor(2); const a2 = new TypedArrayCtor(2); a1[0] = a2[0] = 0; a1[1] = a2[1] = 1; - const diffBuilder = new jasmineUnderTest.DiffBuilder(); + const diffBuilder = new privateUnderTest.DiffBuilder(); expect(matchersUtil.equals(a1, a2, diffBuilder)).toBe(true); jasmine.debugLog('Diff: ' + diffBuilder.getMessage()); } ); it('fails for ' + typeName + 's with different length', function() { - const matchersUtil = new jasmineUnderTest.MatchersUtil(); + const matchersUtil = new privateUnderTest.MatchersUtil(); const a1 = new TypedArrayCtor(2); const a2 = new TypedArrayCtor(1); a1[0] = a1[1] = a2[0] = 0; - const diffBuilder = new jasmineUnderTest.DiffBuilder(); + const diffBuilder = new privateUnderTest.DiffBuilder(); expect(matchersUtil.equals(a1, a2, diffBuilder)).toBe(false); jasmine.debugLog('Diff: ' + diffBuilder.getMessage()); }); @@ -761,19 +761,19 @@ describe('matchersUtil', function() { it( 'fails for ' + typeName + 's with same length but different content', function() { - const matchersUtil = new jasmineUnderTest.MatchersUtil(); + const matchersUtil = new privateUnderTest.MatchersUtil(); const a1 = new TypedArrayCtor(1); const a2 = new TypedArrayCtor(1); a1[0] = 0; a2[0] = 1; - const diffBuilder = new jasmineUnderTest.DiffBuilder(); + const diffBuilder = new privateUnderTest.DiffBuilder(); expect(matchersUtil.equals(a1, a2, diffBuilder)).toBe(false); jasmine.debugLog('Diff: ' + diffBuilder.getMessage()); } ); it('checks nonstandard properties of ' + typeName, function() { - const matchersUtil = new jasmineUnderTest.MatchersUtil(); + const matchersUtil = new privateUnderTest.MatchersUtil(); const a1 = new TypedArrayCtor(1); const a2 = new TypedArrayCtor(1); a1[0] = a2[0] = 0; @@ -784,7 +784,7 @@ describe('matchersUtil', function() { it('works with custom equality testers with ' + typeName, function() { const a1 = new TypedArrayCtor(1); const a2 = new TypedArrayCtor(1); - const matchersUtil = new jasmineUnderTest.MatchersUtil({ + const matchersUtil = new privateUnderTest.MatchersUtil({ customTesters: [ function() { return true; @@ -812,7 +812,7 @@ describe('matchersUtil', function() { 'passes for ' + typeName + 's with same length and content', function() { const TypedArrayCtor = requireType(); - const matchersUtil = new jasmineUnderTest.MatchersUtil(); + const matchersUtil = new privateUnderTest.MatchersUtil(); const a1 = new TypedArrayCtor(2); const a2 = new TypedArrayCtor(2); a1[0] = a2[0] = BigInt(0); @@ -823,7 +823,7 @@ describe('matchersUtil', function() { it('fails for ' + typeName + 's with different length', function() { const TypedArrayCtor = requireType(); - const matchersUtil = new jasmineUnderTest.MatchersUtil(); + const matchersUtil = new privateUnderTest.MatchersUtil(); const a1 = new TypedArrayCtor(2); const a2 = new TypedArrayCtor(1); a1[0] = a1[1] = a2[0] = BigInt(0); @@ -834,7 +834,7 @@ describe('matchersUtil', function() { 'fails for ' + typeName + 's with same length but different content', function() { const TypedArrayCtor = requireType(); - const matchersUtil = new jasmineUnderTest.MatchersUtil(); + const matchersUtil = new privateUnderTest.MatchersUtil(); const a1 = new TypedArrayCtor(2); const a2 = new TypedArrayCtor(2); a1[0] = a1[1] = a2[0] = BigInt(0); @@ -922,7 +922,7 @@ describe('matchersUtil', function() { 'withPath', 'setRoots' ]), - matchersUtil = new jasmineUnderTest.MatchersUtil(); + matchersUtil = new privateUnderTest.MatchersUtil(); diffBuilder.withPath.and.callFake(function(p, block) { block(); @@ -950,7 +950,7 @@ describe('matchersUtil', function() { 'withPath', 'setRoots' ]), - matchersUtil = new jasmineUnderTest.MatchersUtil(); + matchersUtil = new privateUnderTest.MatchersUtil(); diffBuilder.withPath.and.callFake(function(p, block) { block(); @@ -967,8 +967,8 @@ describe('matchersUtil', function() { }); it('uses a diffBuilder if one is provided as the third argument', function() { - const diffBuilder = new jasmineUnderTest.DiffBuilder(), - matchersUtil = new jasmineUnderTest.MatchersUtil(); + const diffBuilder = new privateUnderTest.DiffBuilder(), + matchersUtil = new privateUnderTest.MatchersUtil(); spyOn(diffBuilder, 'recordMismatch'); spyOn(diffBuilder, 'withPath').and.callThrough(); @@ -988,27 +988,27 @@ describe('matchersUtil', function() { describe('contains', function() { it('passes when expected is a substring of actual', function() { - const matchersUtil = new jasmineUnderTest.MatchersUtil(); + const matchersUtil = new privateUnderTest.MatchersUtil(); expect(matchersUtil.contains('ABC', 'BC')).toBe(true); }); it('fails when expected is a not substring of actual', function() { - const matchersUtil = new jasmineUnderTest.MatchersUtil(); + const matchersUtil = new privateUnderTest.MatchersUtil(); expect(matchersUtil.contains('ABC', 'X')).toBe(false); }); it('passes when expected is an element in an actual array', function() { - const matchersUtil = new jasmineUnderTest.MatchersUtil(); + const matchersUtil = new privateUnderTest.MatchersUtil(); expect(matchersUtil.contains(['foo', 'bar'], 'foo')).toBe(true); }); it('fails when expected is not an element in an actual array', function() { - const matchersUtil = new jasmineUnderTest.MatchersUtil(); + const matchersUtil = new privateUnderTest.MatchersUtil(); expect(matchersUtil.contains(['foo', 'bar'], 'baz')).toBe(false); }); it('passes with mixed-element arrays', function() { - const matchersUtil = new jasmineUnderTest.MatchersUtil(); + const matchersUtil = new privateUnderTest.MatchersUtil(); expect(matchersUtil.contains(['foo', { some: 'bar' }], 'foo')).toBe(true); expect( matchersUtil.contains(['foo', { some: 'bar' }], { some: 'bar' }) @@ -1019,7 +1019,7 @@ describe('matchersUtil', function() { const customTester = function() { return true; }, - matchersUtil = new jasmineUnderTest.MatchersUtil({ + matchersUtil = new privateUnderTest.MatchersUtil({ customTesters: [customTester], pp: function() {} }); @@ -1028,18 +1028,18 @@ describe('matchersUtil', function() { }); it('fails when actual is undefined', function() { - const matchersUtil = new jasmineUnderTest.MatchersUtil(); + const matchersUtil = new privateUnderTest.MatchersUtil(); expect(matchersUtil.contains(undefined, 'A')).toBe(false); }); it('fails when actual is null', function() { - const matchersUtil = new jasmineUnderTest.MatchersUtil(); + const matchersUtil = new privateUnderTest.MatchersUtil(); expect(matchersUtil.contains(null, 'A')).toBe(false); }); it('works with array-like objects that implement iterable', function() { let capturedArgs = null; - const matchersUtil = new jasmineUnderTest.MatchersUtil(); + const matchersUtil = new privateUnderTest.MatchersUtil(); function testFunction() { capturedArgs = arguments; @@ -1056,14 +1056,14 @@ describe('matchersUtil', function() { 1: 'b', length: 2 }; - const matchersUtil = new jasmineUnderTest.MatchersUtil(); + const matchersUtil = new privateUnderTest.MatchersUtil(); expect(matchersUtil.contains(arrayLike, 'b')).toBe(true); expect(matchersUtil.contains(arrayLike, 'c')).toBe(false); }); it('passes for set members', function() { - const matchersUtil = new jasmineUnderTest.MatchersUtil(); + const matchersUtil = new privateUnderTest.MatchersUtil(); const setItem = { foo: 'bar' }; const set = new Set(); set.add(setItem); @@ -1072,7 +1072,7 @@ describe('matchersUtil', function() { }); it('passes for objects that equal to a set member', function() { - const matchersUtil = new jasmineUnderTest.MatchersUtil(); + const matchersUtil = new privateUnderTest.MatchersUtil(); const set = new Set(); set.add({ foo: 'bar' }); @@ -1084,8 +1084,8 @@ describe('matchersUtil', function() { it('builds an English sentence for a failure case', function() { const actual = 'foo', name = 'toBar', - pp = jasmineUnderTest.makePrettyPrinter(), - matchersUtil = new jasmineUnderTest.MatchersUtil({ pp: pp }), + pp = privateUnderTest.makePrettyPrinter(), + matchersUtil = new privateUnderTest.MatchersUtil({ pp: pp }), message = matchersUtil.buildFailureMessage(name, false, actual); expect(message).toEqual("Expected 'foo' to bar."); @@ -1095,8 +1095,8 @@ describe('matchersUtil', function() { const actual = 'foo', name = 'toBar', isNot = true, - pp = jasmineUnderTest.makePrettyPrinter(), - matchersUtil = new jasmineUnderTest.MatchersUtil({ pp: pp }), + pp = privateUnderTest.makePrettyPrinter(), + matchersUtil = new privateUnderTest.MatchersUtil({ pp: pp }), message = matchersUtil.buildFailureMessage(name, isNot, actual); expect(message).toEqual("Expected 'foo' not to bar."); @@ -1105,8 +1105,8 @@ describe('matchersUtil', function() { it('builds an English sentence for an arbitrary array of expected arguments', function() { const actual = 'foo', name = 'toBar', - pp = jasmineUnderTest.makePrettyPrinter(), - matchersUtil = new jasmineUnderTest.MatchersUtil({ pp: pp }), + pp = privateUnderTest.makePrettyPrinter(), + matchersUtil = new privateUnderTest.MatchersUtil({ pp: pp }), message = matchersUtil.buildFailureMessage( name, false, @@ -1127,7 +1127,7 @@ describe('matchersUtil', function() { pp = function(value) { return '<' + value + '>'; }, - matchersUtil = new jasmineUnderTest.MatchersUtil({ pp: pp }), + matchersUtil = new privateUnderTest.MatchersUtil({ pp: pp }), message = matchersUtil.buildFailureMessage( name, isNot, diff --git a/spec/core/matchers/nothingSpec.js b/spec/core/matchers/nothingSpec.js index 40beb9fe..4809255e 100644 --- a/spec/core/matchers/nothingSpec.js +++ b/spec/core/matchers/nothingSpec.js @@ -1,6 +1,6 @@ describe('nothing', function() { it('should pass', function() { - const matcher = jasmineUnderTest.matchers.nothing(), + const matcher = privateUnderTest.matchers.nothing(), result = matcher.compare(); expect(result.pass).toBe(true); diff --git a/spec/core/matchers/toBeCloseToSpec.js b/spec/core/matchers/toBeCloseToSpec.js index ceaa47e4..b019e7b0 100644 --- a/spec/core/matchers/toBeCloseToSpec.js +++ b/spec/core/matchers/toBeCloseToSpec.js @@ -1,6 +1,6 @@ describe('toBeCloseTo', function() { it('passes when within two decimal places by default', function() { - const matcher = jasmineUnderTest.matchers.toBeCloseTo(); + const matcher = privateUnderTest.matchers.toBeCloseTo(); let result; result = matcher.compare(0, 0); @@ -14,7 +14,7 @@ describe('toBeCloseTo', function() { }); it('fails when not within two decimal places by default', function() { - const matcher = jasmineUnderTest.matchers.toBeCloseTo(); + const matcher = privateUnderTest.matchers.toBeCloseTo(); let result; result = matcher.compare(0, 0.01); @@ -25,7 +25,7 @@ describe('toBeCloseTo', function() { }); it('accepts an optional precision argument', function() { - const matcher = jasmineUnderTest.matchers.toBeCloseTo(); + const matcher = privateUnderTest.matchers.toBeCloseTo(); let result; result = matcher.compare(0, 0.1, 0); @@ -48,7 +48,7 @@ describe('toBeCloseTo', function() { }); it('fails when one of the arguments is null', function() { - const matcher = jasmineUnderTest.matchers.toBeCloseTo(); + const matcher = privateUnderTest.matchers.toBeCloseTo(); expect(function() { matcher.compare(null, null); @@ -70,7 +70,7 @@ describe('toBeCloseTo', function() { }); it('rounds expected values', function() { - const matcher = jasmineUnderTest.matchers.toBeCloseTo(); + const matcher = privateUnderTest.matchers.toBeCloseTo(); let result; result = matcher.compare(1.23, 1.229); @@ -98,7 +98,7 @@ describe('toBeCloseTo', function() { }); it('handles edge cases with rounding', function() { - const matcher = jasmineUnderTest.matchers.toBeCloseTo(); + const matcher = privateUnderTest.matchers.toBeCloseTo(); let result; // these cases resulted in false negatives in version of V8 @@ -113,37 +113,37 @@ describe('toBeCloseTo', function() { describe('Infinity handling', function() { it('passes when the actual and expected are both Infinity', function() { - const matcher = jasmineUnderTest.matchers.toBeCloseTo(); + const matcher = privateUnderTest.matchers.toBeCloseTo(); const result = matcher.compare(Infinity, Infinity, 0); expect(result.pass).toBe(true); }); it('passes when the actual and expected are both -Infinity', function() { - const matcher = jasmineUnderTest.matchers.toBeCloseTo(); + const matcher = privateUnderTest.matchers.toBeCloseTo(); const result = matcher.compare(-Infinity, -Infinity, 0); expect(result.pass).toBe(true); }); it('fails when the actual is Infinity and the expected is -Infinity', function() { - const matcher = jasmineUnderTest.matchers.toBeCloseTo(); + const matcher = privateUnderTest.matchers.toBeCloseTo(); const result = matcher.compare(Infinity, -Infinity, 0); expect(result.pass).toBe(false); }); it('fails when the actual is -Infinity and the expected is Infinity', function() { - const matcher = jasmineUnderTest.matchers.toBeCloseTo(); + const matcher = privateUnderTest.matchers.toBeCloseTo(); const result = matcher.compare(-Infinity, Infinity, 0); expect(result.pass).toBe(false); }); it('fails when the actual is a number and the expected is Infinity', function() { - const matcher = jasmineUnderTest.matchers.toBeCloseTo(); + const matcher = privateUnderTest.matchers.toBeCloseTo(); const result = matcher.compare(42, Infinity, 0); expect(result.pass).toBe(false); }); it('fails when the actual is a number and the expected is -Infinity', function() { - const matcher = jasmineUnderTest.matchers.toBeCloseTo(); + const matcher = privateUnderTest.matchers.toBeCloseTo(); const result = matcher.compare(42, -Infinity, 0); expect(result.pass).toBe(false); }); diff --git a/spec/core/matchers/toBeDefinedSpec.js b/spec/core/matchers/toBeDefinedSpec.js index 9aa20288..90b3664d 100644 --- a/spec/core/matchers/toBeDefinedSpec.js +++ b/spec/core/matchers/toBeDefinedSpec.js @@ -1,12 +1,12 @@ describe('toBeDefined', function() { it('matches for defined values', function() { - const matcher = jasmineUnderTest.matchers.toBeDefined(); + const matcher = privateUnderTest.matchers.toBeDefined(); const result = matcher.compare('foo'); expect(result.pass).toBe(true); }); it('fails when matching undefined values', function() { - const matcher = jasmineUnderTest.matchers.toBeDefined(); + const matcher = privateUnderTest.matchers.toBeDefined(); const result = matcher.compare(void 0); expect(result.pass).toBe(false); }); diff --git a/spec/core/matchers/toBeFalseSpec.js b/spec/core/matchers/toBeFalseSpec.js index f4038e5c..191eb808 100644 --- a/spec/core/matchers/toBeFalseSpec.js +++ b/spec/core/matchers/toBeFalseSpec.js @@ -1,18 +1,18 @@ describe('toBeFalse', function() { it('passes for false', function() { - const matcher = jasmineUnderTest.matchers.toBeFalse(); + const matcher = privateUnderTest.matchers.toBeFalse(); const result = matcher.compare(false); expect(result.pass).toBe(true); }); it('fails for non-false', function() { - const matcher = jasmineUnderTest.matchers.toBeFalse(); + const matcher = privateUnderTest.matchers.toBeFalse(); const result = matcher.compare('foo'); expect(result.pass).toBe(false); }); it('fails for falsy', function() { - const matcher = jasmineUnderTest.matchers.toBeFalse(); + const matcher = privateUnderTest.matchers.toBeFalse(); const result = matcher.compare(undefined); expect(result.pass).toBe(false); }); diff --git a/spec/core/matchers/toBeFalsySpec.js b/spec/core/matchers/toBeFalsySpec.js index 4a516738..dcec4d01 100644 --- a/spec/core/matchers/toBeFalsySpec.js +++ b/spec/core/matchers/toBeFalsySpec.js @@ -1,6 +1,6 @@ describe('toBeFalsy', function() { it("passes for 'falsy' values", function() { - const matcher = jasmineUnderTest.matchers.toBeFalsy(); + const matcher = privateUnderTest.matchers.toBeFalsy(); let result; result = matcher.compare(false); @@ -23,7 +23,7 @@ describe('toBeFalsy', function() { }); it("fails for 'truthy' values", function() { - const matcher = jasmineUnderTest.matchers.toBeFalsy(); + const matcher = privateUnderTest.matchers.toBeFalsy(); let result; result = matcher.compare(true); diff --git a/spec/core/matchers/toBeGreaterThanOrEqualSpec.js b/spec/core/matchers/toBeGreaterThanOrEqualSpec.js index 7adda0e4..b91069f4 100644 --- a/spec/core/matchers/toBeGreaterThanOrEqualSpec.js +++ b/spec/core/matchers/toBeGreaterThanOrEqualSpec.js @@ -1,6 +1,6 @@ describe('toBeGreaterThanOrEqual', function() { it('passes when actual >= expected', function() { - const matcher = jasmineUnderTest.matchers.toBeGreaterThanOrEqual(); + const matcher = privateUnderTest.matchers.toBeGreaterThanOrEqual(); let result; result = matcher.compare(2, 1); @@ -17,7 +17,7 @@ describe('toBeGreaterThanOrEqual', function() { }); it('fails when actual < expected', function() { - const matcher = jasmineUnderTest.matchers.toBeGreaterThanOrEqual(); + const matcher = privateUnderTest.matchers.toBeGreaterThanOrEqual(); let result; result = matcher.compare(1, 2); diff --git a/spec/core/matchers/toBeGreaterThanSpec.js b/spec/core/matchers/toBeGreaterThanSpec.js index 1a2fb378..b070dc69 100644 --- a/spec/core/matchers/toBeGreaterThanSpec.js +++ b/spec/core/matchers/toBeGreaterThanSpec.js @@ -1,12 +1,12 @@ describe('toBeGreaterThan', function() { it('passes when actual > expected', function() { - const matcher = jasmineUnderTest.matchers.toBeGreaterThan(); + const matcher = privateUnderTest.matchers.toBeGreaterThan(); const result = matcher.compare(2, 1); expect(result.pass).toBe(true); }); it('fails when actual <= expected', function() { - const matcher = jasmineUnderTest.matchers.toBeGreaterThan(); + const matcher = privateUnderTest.matchers.toBeGreaterThan(); let result; result = matcher.compare(1, 1); diff --git a/spec/core/matchers/toBeInstanceOfSpec.js b/spec/core/matchers/toBeInstanceOfSpec.js index 13ba614a..7e5928ef 100644 --- a/spec/core/matchers/toBeInstanceOfSpec.js +++ b/spec/core/matchers/toBeInstanceOfSpec.js @@ -1,7 +1,7 @@ describe('toBeInstanceOf', function() { describe('when expecting Number', function() { it('passes for literal number', function() { - const matcher = jasmineUnderTest.matchers.toBeInstanceOf(); + const matcher = privateUnderTest.matchers.toBeInstanceOf(); const result = matcher.compare(3, Number); expect(result).toEqual({ pass: true, @@ -10,8 +10,8 @@ describe('toBeInstanceOf', function() { }); it('passes for NaN', function() { - const matcher = jasmineUnderTest.matchers.toBeInstanceOf({ - pp: jasmineUnderTest.makePrettyPrinter() + const matcher = privateUnderTest.matchers.toBeInstanceOf({ + pp: privateUnderTest.makePrettyPrinter() }); const result = matcher.compare(NaN, Number); expect(result).toEqual({ @@ -21,7 +21,7 @@ describe('toBeInstanceOf', function() { }); it('passes for Infinity', function() { - const matcher = jasmineUnderTest.matchers.toBeInstanceOf(); + const matcher = privateUnderTest.matchers.toBeInstanceOf(); const result = matcher.compare(Infinity, Number); expect(result).toEqual({ pass: true, @@ -30,7 +30,7 @@ describe('toBeInstanceOf', function() { }); it('fails for a non-number', function() { - const matcher = jasmineUnderTest.matchers.toBeInstanceOf(); + const matcher = privateUnderTest.matchers.toBeInstanceOf(); const result = matcher.compare('foo', Number); expect(result).toEqual({ pass: false, @@ -41,7 +41,7 @@ describe('toBeInstanceOf', function() { describe('when expecting String', function() { it('passes for a string', function() { - const matcher = jasmineUnderTest.matchers.toBeInstanceOf(); + const matcher = privateUnderTest.matchers.toBeInstanceOf(); const result = matcher.compare('foo', String); expect(result).toEqual({ pass: true, @@ -50,7 +50,7 @@ describe('toBeInstanceOf', function() { }); it('fails for a non-string', function() { - const matcher = jasmineUnderTest.matchers.toBeInstanceOf(); + const matcher = privateUnderTest.matchers.toBeInstanceOf(); const result = matcher.compare({}, String); expect(result).toEqual({ pass: false, @@ -61,7 +61,7 @@ describe('toBeInstanceOf', function() { describe('when expecting Boolean', function() { it('passes for a boolean', function() { - const matcher = jasmineUnderTest.matchers.toBeInstanceOf(); + const matcher = privateUnderTest.matchers.toBeInstanceOf(); const result = matcher.compare(true, Boolean); expect(result).toEqual({ pass: true, @@ -70,7 +70,7 @@ describe('toBeInstanceOf', function() { }); it('fails for a non-boolean', function() { - const matcher = jasmineUnderTest.matchers.toBeInstanceOf(); + const matcher = privateUnderTest.matchers.toBeInstanceOf(); const result = matcher.compare('false', Boolean); expect(result).toEqual({ pass: false, @@ -81,7 +81,7 @@ describe('toBeInstanceOf', function() { describe('when expecting RegExp', function() { it('passes for a literal regular expression', function() { - const matcher = jasmineUnderTest.matchers.toBeInstanceOf(); + const matcher = privateUnderTest.matchers.toBeInstanceOf(); const result = matcher.compare(/foo/, RegExp); expect(result).toEqual({ pass: true, @@ -94,7 +94,7 @@ describe('toBeInstanceOf', function() { it('passes for a function', function() { const fn = function() {}; - const matcher = jasmineUnderTest.matchers.toBeInstanceOf(); + const matcher = privateUnderTest.matchers.toBeInstanceOf(); const result = matcher.compare(fn, Function); expect(result).toEqual({ pass: true, @@ -108,7 +108,7 @@ describe('toBeInstanceOf', function() { return 'foo'; } - const matcher = jasmineUnderTest.matchers.toBeInstanceOf(); + const matcher = privateUnderTest.matchers.toBeInstanceOf(); const result = matcher.compare(fn, Function); expect(result).toEqual({ pass: true, @@ -122,7 +122,7 @@ describe('toBeInstanceOf', function() { function Animal() {} it('passes for any object', function() { - const matcher = jasmineUnderTest.matchers.toBeInstanceOf(); + const matcher = privateUnderTest.matchers.toBeInstanceOf(); const result = matcher.compare({ foo: 'bar' }, Object); expect(result).toEqual({ pass: true, @@ -131,7 +131,7 @@ describe('toBeInstanceOf', function() { }); it('passes for an Error object', function() { - const matcher = jasmineUnderTest.matchers.toBeInstanceOf(); + const matcher = privateUnderTest.matchers.toBeInstanceOf(); const result = matcher.compare(new Error('example'), Object); expect(result).toEqual({ pass: true, @@ -140,7 +140,7 @@ describe('toBeInstanceOf', function() { }); it('passes for a user-defined class', function() { - const matcher = jasmineUnderTest.matchers.toBeInstanceOf(); + const matcher = privateUnderTest.matchers.toBeInstanceOf(); const result = matcher.compare(new Animal(), Object); expect(result).toEqual({ pass: true, @@ -149,7 +149,7 @@ describe('toBeInstanceOf', function() { }); it('fails for a non-object', function() { - const matcher = jasmineUnderTest.matchers.toBeInstanceOf(); + const matcher = privateUnderTest.matchers.toBeInstanceOf(); const result = matcher.compare('foo', Object); expect(result).toEqual({ pass: false, @@ -160,8 +160,8 @@ describe('toBeInstanceOf', function() { it('passes for objects with no constructor', function() { const object = Object.create(null); - const matcher = jasmineUnderTest.matchers.toBeInstanceOf({ - pp: jasmineUnderTest.makePrettyPrinter() + const matcher = privateUnderTest.matchers.toBeInstanceOf({ + pp: privateUnderTest.makePrettyPrinter() }); const result = matcher.compare(object, Object); expect(result).toEqual({ @@ -190,7 +190,7 @@ describe('toBeInstanceOf', function() { Cat.prototype.constructor = Cat; it('passes for instances of that class', function() { - const matcher = jasmineUnderTest.matchers.toBeInstanceOf(); + const matcher = privateUnderTest.matchers.toBeInstanceOf(); const result = matcher.compare(new Animal(), Animal); expect(result).toEqual({ pass: true, @@ -199,7 +199,7 @@ describe('toBeInstanceOf', function() { }); it('passes for instances of a subclass', function() { - const matcher = jasmineUnderTest.matchers.toBeInstanceOf(); + const matcher = privateUnderTest.matchers.toBeInstanceOf(); const result = matcher.compare(new Cat(), Animal); expect(result).toEqual({ pass: true, @@ -208,7 +208,7 @@ describe('toBeInstanceOf', function() { }); it('does not pass for sibling classes', function() { - const matcher = jasmineUnderTest.matchers.toBeInstanceOf(); + const matcher = privateUnderTest.matchers.toBeInstanceOf(); const result = matcher.compare(new Dog(), Cat); expect(result).toEqual({ pass: false, @@ -218,7 +218,7 @@ describe('toBeInstanceOf', function() { }); it('raises an error if passed an invalid expected value', function() { - const matcher = jasmineUnderTest.matchers.toBeInstanceOf(); + const matcher = privateUnderTest.matchers.toBeInstanceOf(); expect(function() { matcher.compare({}, 'Error'); }).toThrowError( @@ -228,8 +228,8 @@ describe('toBeInstanceOf', function() { }); it('raises an error if missing an expected value', function() { - const matcher = jasmineUnderTest.matchers.toBeInstanceOf({ - pp: jasmineUnderTest.makePrettyPrinter() + const matcher = privateUnderTest.matchers.toBeInstanceOf({ + pp: privateUnderTest.makePrettyPrinter() }); expect(function() { matcher.compare({}, undefined); diff --git a/spec/core/matchers/toBeLessThanOrEqualSpec.js b/spec/core/matchers/toBeLessThanOrEqualSpec.js index 46777791..aacef891 100644 --- a/spec/core/matchers/toBeLessThanOrEqualSpec.js +++ b/spec/core/matchers/toBeLessThanOrEqualSpec.js @@ -1,6 +1,6 @@ describe('toBeLessThanOrEqual', function() { it('passes when actual <= expected', function() { - const matcher = jasmineUnderTest.matchers.toBeLessThanOrEqual(); + const matcher = privateUnderTest.matchers.toBeLessThanOrEqual(); let result; result = matcher.compare(1, 2); @@ -17,7 +17,7 @@ describe('toBeLessThanOrEqual', function() { }); it('fails when actual < expected', function() { - const matcher = jasmineUnderTest.matchers.toBeLessThanOrEqual(); + const matcher = privateUnderTest.matchers.toBeLessThanOrEqual(); let result; result = matcher.compare(2, 1); diff --git a/spec/core/matchers/toBeLessThanSpec.js b/spec/core/matchers/toBeLessThanSpec.js index 9b786375..b19ab6ff 100644 --- a/spec/core/matchers/toBeLessThanSpec.js +++ b/spec/core/matchers/toBeLessThanSpec.js @@ -1,12 +1,12 @@ describe('toBeLessThan', function() { it('passes when actual < expected', function() { - const matcher = jasmineUnderTest.matchers.toBeLessThan(); + const matcher = privateUnderTest.matchers.toBeLessThan(); const result = matcher.compare(1, 2); expect(result.pass).toBe(true); }); it('fails when actual <= expected', function() { - const matcher = jasmineUnderTest.matchers.toBeLessThan(); + const matcher = privateUnderTest.matchers.toBeLessThan(); let result; result = matcher.compare(1, 1); diff --git a/spec/core/matchers/toBeNaNSpec.js b/spec/core/matchers/toBeNaNSpec.js index b04c23f3..b7e0f51e 100644 --- a/spec/core/matchers/toBeNaNSpec.js +++ b/spec/core/matchers/toBeNaNSpec.js @@ -1,13 +1,13 @@ describe('toBeNaN', function() { it('passes for NaN with a custom .not fail', function() { - const matcher = jasmineUnderTest.matchers.toBeNaN(); + const matcher = privateUnderTest.matchers.toBeNaN(); const result = matcher.compare(Number.NaN); expect(result.pass).toBe(true); expect(result.message).toEqual('Expected actual not to be NaN.'); }); it('fails for anything not a NaN', function() { - const matcher = jasmineUnderTest.matchers.toBeNaN(); + const matcher = privateUnderTest.matchers.toBeNaN(); let result; result = matcher.compare(1); @@ -27,8 +27,8 @@ describe('toBeNaN', function() { }); it('has a custom message on failure', function() { - const matcher = jasmineUnderTest.matchers.toBeNaN({ - pp: jasmineUnderTest.makePrettyPrinter() + const matcher = privateUnderTest.matchers.toBeNaN({ + pp: privateUnderTest.makePrettyPrinter() }), result = matcher.compare(0); diff --git a/spec/core/matchers/toBeNegativeInfinitySpec.js b/spec/core/matchers/toBeNegativeInfinitySpec.js index 77cf0193..07fcdeb0 100644 --- a/spec/core/matchers/toBeNegativeInfinitySpec.js +++ b/spec/core/matchers/toBeNegativeInfinitySpec.js @@ -1,6 +1,6 @@ describe('toBeNegativeInfinity', function() { it("fails for anything that isn't -Infinity", function() { - const matcher = jasmineUnderTest.matchers.toBeNegativeInfinity(); + const matcher = privateUnderTest.matchers.toBeNegativeInfinity(); let result; result = matcher.compare(1); @@ -14,8 +14,8 @@ describe('toBeNegativeInfinity', function() { }); it('has a custom message on failure', function() { - const matcher = jasmineUnderTest.matchers.toBeNegativeInfinity({ - pp: jasmineUnderTest.makePrettyPrinter() + const matcher = privateUnderTest.matchers.toBeNegativeInfinity({ + pp: privateUnderTest.makePrettyPrinter() }), result = matcher.compare(0); @@ -23,7 +23,7 @@ describe('toBeNegativeInfinity', function() { }); it('succeeds for -Infinity', function() { - const matcher = jasmineUnderTest.matchers.toBeNegativeInfinity(), + const matcher = privateUnderTest.matchers.toBeNegativeInfinity(), result = matcher.compare(Number.NEGATIVE_INFINITY); expect(result.pass).toBe(true); diff --git a/spec/core/matchers/toBeNullSpec.js b/spec/core/matchers/toBeNullSpec.js index cae7c03b..8bbe0545 100644 --- a/spec/core/matchers/toBeNullSpec.js +++ b/spec/core/matchers/toBeNullSpec.js @@ -1,12 +1,12 @@ describe('toBeNull', function() { it('passes for null', function() { - const matcher = jasmineUnderTest.matchers.toBeNull(); + const matcher = privateUnderTest.matchers.toBeNull(); const result = matcher.compare(null); expect(result.pass).toBe(true); }); it('fails for non-null', function() { - const matcher = jasmineUnderTest.matchers.toBeNull(); + const matcher = privateUnderTest.matchers.toBeNull(); const result = matcher.compare('foo'); expect(result.pass).toBe(false); }); diff --git a/spec/core/matchers/toBeNullishSpec.js b/spec/core/matchers/toBeNullishSpec.js index 5f70d1a8..2ce5ba07 100644 --- a/spec/core/matchers/toBeNullishSpec.js +++ b/spec/core/matchers/toBeNullishSpec.js @@ -1,55 +1,55 @@ describe('toBeNullish', function() { it('passes for null values', function() { - const matcher = jasmineUnderTest.matchers.toBeNullish(); + const matcher = privateUnderTest.matchers.toBeNullish(); const result = matcher.compare(null); expect(result.pass).toBe(true); }); it('passes for undefined values', function() { - const matcher = jasmineUnderTest.matchers.toBeNullish(); + const matcher = privateUnderTest.matchers.toBeNullish(); const result = matcher.compare(void 0); expect(result.pass).toBe(true); }); it('fails when matching defined values', function() { - const matcher = jasmineUnderTest.matchers.toBeNullish(); + const matcher = privateUnderTest.matchers.toBeNullish(); const result = matcher.compare('foo'); expect(result.pass).toBe(false); }); describe('falsy values', () => { it('fails for 0', function() { - const matcher = jasmineUnderTest.matchers.toBeNullish(); + const matcher = privateUnderTest.matchers.toBeNullish(); const result = matcher.compare(0); expect(result.pass).toBe(false); }); it('fails for -0', function() { - const matcher = jasmineUnderTest.matchers.toBeNullish(); + const matcher = privateUnderTest.matchers.toBeNullish(); const result = matcher.compare(-0); expect(result.pass).toBe(false); }); it('fails for empty string', function() { - const matcher = jasmineUnderTest.matchers.toBeNullish(); + const matcher = privateUnderTest.matchers.toBeNullish(); const result = matcher.compare(''); expect(result.pass).toBe(false); }); it('fails for false', function() { - const matcher = jasmineUnderTest.matchers.toBeNullish(); + const matcher = privateUnderTest.matchers.toBeNullish(); const result = matcher.compare(false); expect(result.pass).toBe(false); }); it('fails for NaN', function() { - const matcher = jasmineUnderTest.matchers.toBeNullish(); + const matcher = privateUnderTest.matchers.toBeNullish(); const result = matcher.compare(NaN); expect(result.pass).toBe(false); }); it('fails for 0n', function() { - const matcher = jasmineUnderTest.matchers.toBeNullish(); + const matcher = privateUnderTest.matchers.toBeNullish(); const result = matcher.compare(BigInt(0)); expect(result.pass).toBe(false); }); diff --git a/spec/core/matchers/toBePositiveInfinitySpec.js b/spec/core/matchers/toBePositiveInfinitySpec.js index 6e5835de..7588c84a 100644 --- a/spec/core/matchers/toBePositiveInfinitySpec.js +++ b/spec/core/matchers/toBePositiveInfinitySpec.js @@ -1,6 +1,6 @@ describe('toBePositiveInfinity', function() { it("fails for anything that isn't Infinity", function() { - const matcher = jasmineUnderTest.matchers.toBePositiveInfinity(); + const matcher = privateUnderTest.matchers.toBePositiveInfinity(); let result; result = matcher.compare(1); @@ -14,8 +14,8 @@ describe('toBePositiveInfinity', function() { }); it('has a custom message on failure', function() { - const matcher = jasmineUnderTest.matchers.toBePositiveInfinity({ - pp: jasmineUnderTest.makePrettyPrinter() + const matcher = privateUnderTest.matchers.toBePositiveInfinity({ + pp: privateUnderTest.makePrettyPrinter() }), result = matcher.compare(0); @@ -23,7 +23,7 @@ describe('toBePositiveInfinity', function() { }); it('succeeds for Infinity', function() { - const matcher = jasmineUnderTest.matchers.toBePositiveInfinity(), + const matcher = privateUnderTest.matchers.toBePositiveInfinity(), result = matcher.compare(Number.POSITIVE_INFINITY); expect(result.pass).toBe(true); diff --git a/spec/core/matchers/toBeSpec.js b/spec/core/matchers/toBeSpec.js index dfa1011f..e1fe6bee 100644 --- a/spec/core/matchers/toBeSpec.js +++ b/spec/core/matchers/toBeSpec.js @@ -1,16 +1,16 @@ describe('toBe', function() { it('passes with no message when actual === expected', function() { - const matchersUtil = new jasmineUnderTest.MatchersUtil(), - matcher = jasmineUnderTest.matchers.toBe(matchersUtil), + const matchersUtil = new privateUnderTest.MatchersUtil(), + matcher = privateUnderTest.matchers.toBe(matchersUtil), result = matcher.compare(1, 1); expect(result.pass).toBe(true); }); it('passes with a custom message when expected is an array', function() { - const matchersUtil = new jasmineUnderTest.MatchersUtil({ - pp: jasmineUnderTest.makePrettyPrinter() + const matchersUtil = new privateUnderTest.MatchersUtil({ + pp: privateUnderTest.makePrettyPrinter() }), - matcher = jasmineUnderTest.matchers.toBe(matchersUtil), + matcher = privateUnderTest.matchers.toBe(matchersUtil), array = [1]; const result = matcher.compare(array, array); @@ -21,10 +21,10 @@ describe('toBe', function() { }); it('passes with a custom message when expected is an object', function() { - const matchersUtil = new jasmineUnderTest.MatchersUtil({ - pp: jasmineUnderTest.makePrettyPrinter() + const matchersUtil = new privateUnderTest.MatchersUtil({ + pp: privateUnderTest.makePrettyPrinter() }), - matcher = jasmineUnderTest.matchers.toBe(matchersUtil), + matcher = privateUnderTest.matchers.toBe(matchersUtil), obj = { foo: 'bar' }; const result = matcher.compare(obj, obj); @@ -35,18 +35,18 @@ describe('toBe', function() { }); it('fails with no message when actual !== expected', function() { - const matchersUtil = new jasmineUnderTest.MatchersUtil(), - matcher = jasmineUnderTest.matchers.toBe(matchersUtil), + const matchersUtil = new privateUnderTest.MatchersUtil(), + matcher = privateUnderTest.matchers.toBe(matchersUtil), result = matcher.compare(1, 2); expect(result.pass).toBe(false); expect(result.message).toBeUndefined(); }); it('fails with a custom message when expected is an array', function() { - const matchersUtil = new jasmineUnderTest.MatchersUtil({ - pp: jasmineUnderTest.makePrettyPrinter() + const matchersUtil = new privateUnderTest.MatchersUtil({ + pp: privateUnderTest.makePrettyPrinter() }), - matcher = jasmineUnderTest.matchers.toBe(matchersUtil), + matcher = privateUnderTest.matchers.toBe(matchersUtil), result = matcher.compare([1], [1]); expect(result.pass).toBe(false); @@ -56,10 +56,10 @@ describe('toBe', function() { }); it('fails with a custom message when expected is an object', function() { - const matchersUtil = new jasmineUnderTest.MatchersUtil({ - pp: jasmineUnderTest.makePrettyPrinter() + const matchersUtil = new privateUnderTest.MatchersUtil({ + pp: privateUnderTest.makePrettyPrinter() }), - matcher = jasmineUnderTest.matchers.toBe(matchersUtil), + matcher = privateUnderTest.matchers.toBe(matchersUtil), result = matcher.compare({ foo: 'bar' }, { foo: 'bar' }); expect(result.pass).toBe(false); @@ -72,9 +72,9 @@ describe('toBe', function() { const formatter = function(x) { return '<' + x.foo + '>'; }, - prettyPrinter = jasmineUnderTest.makePrettyPrinter([formatter]), - matchersUtil = new jasmineUnderTest.MatchersUtil({ pp: prettyPrinter }), - matcher = jasmineUnderTest.matchers.toBe(matchersUtil), + prettyPrinter = privateUnderTest.makePrettyPrinter([formatter]), + matchersUtil = new privateUnderTest.MatchersUtil({ pp: prettyPrinter }), + matcher = privateUnderTest.matchers.toBe(matchersUtil), result = matcher.compare({ foo: 'bar' }, { foo: 'bar' }); expect(result.pass).toBe(false); diff --git a/spec/core/matchers/toBeTrueSpec.js b/spec/core/matchers/toBeTrueSpec.js index b7a0cb48..c648ff1e 100644 --- a/spec/core/matchers/toBeTrueSpec.js +++ b/spec/core/matchers/toBeTrueSpec.js @@ -1,12 +1,12 @@ describe('toBeTrue', function() { it('passes for true', function() { - const matcher = jasmineUnderTest.matchers.toBeTrue(); + const matcher = privateUnderTest.matchers.toBeTrue(); const result = matcher.compare(true); expect(result.pass).toBe(true); }); it('fails for non-true', function() { - const matcher = jasmineUnderTest.matchers.toBeTrue(); + const matcher = privateUnderTest.matchers.toBeTrue(); const result = matcher.compare('foo'); expect(result.pass).toBe(false); }); diff --git a/spec/core/matchers/toBeTruthySpec.js b/spec/core/matchers/toBeTruthySpec.js index a1e128f4..0b2da5ec 100644 --- a/spec/core/matchers/toBeTruthySpec.js +++ b/spec/core/matchers/toBeTruthySpec.js @@ -1,6 +1,6 @@ describe('toBeTruthy', function() { it("passes for 'truthy' values", function() { - const matcher = jasmineUnderTest.matchers.toBeTruthy(); + const matcher = privateUnderTest.matchers.toBeTruthy(); let result; result = matcher.compare(true); @@ -23,7 +23,7 @@ describe('toBeTruthy', function() { }); it("fails for 'falsy' values", function() { - const matcher = jasmineUnderTest.matchers.toBeTruthy(); + const matcher = privateUnderTest.matchers.toBeTruthy(); let result; result = matcher.compare(false); diff --git a/spec/core/matchers/toBeUndefinedSpec.js b/spec/core/matchers/toBeUndefinedSpec.js index 40adb4e2..41b08990 100644 --- a/spec/core/matchers/toBeUndefinedSpec.js +++ b/spec/core/matchers/toBeUndefinedSpec.js @@ -1,12 +1,12 @@ describe('toBeUndefined', function() { it('passes for undefined values', function() { - const matcher = jasmineUnderTest.matchers.toBeUndefined(); + const matcher = privateUnderTest.matchers.toBeUndefined(); const result = matcher.compare(void 0); expect(result.pass).toBe(true); }); it('fails when matching defined values', function() { - const matcher = jasmineUnderTest.matchers.toBeUndefined(); + const matcher = privateUnderTest.matchers.toBeUndefined(); const result = matcher.compare('foo'); expect(result.pass).toBe(false); }); diff --git a/spec/core/matchers/toContainSpec.js b/spec/core/matchers/toContainSpec.js index d35f557c..2980a09f 100644 --- a/spec/core/matchers/toContainSpec.js +++ b/spec/core/matchers/toContainSpec.js @@ -1,9 +1,9 @@ describe('toContain', function() { - it('delegates to jasmineUnderTest.matchersUtil.contains', function() { + it('delegates to privateUnderTest.MatchersUtil.contains', function() { const matchersUtil = { contains: jasmine.createSpy('delegated-contains').and.returnValue(true) }, - matcher = jasmineUnderTest.matchers.toContain(matchersUtil); + matcher = privateUnderTest.matchers.toContain(matchersUtil); const result = matcher.compare('ABC', 'B'); expect(matchersUtil.contains).toHaveBeenCalledWith('ABC', 'B'); @@ -14,10 +14,10 @@ describe('toContain', function() { const tester = function(a, b) { return a.toString() === b.toString(); }, - matchersUtil = new jasmineUnderTest.MatchersUtil({ + matchersUtil = new privateUnderTest.MatchersUtil({ customTesters: [tester] }), - matcher = jasmineUnderTest.matchers.toContain(matchersUtil); + matcher = privateUnderTest.matchers.toContain(matchersUtil); const result = matcher.compare(['1', '2'], 2); expect(result.pass).toBe(true); diff --git a/spec/core/matchers/toEqualSpec.js b/spec/core/matchers/toEqualSpec.js index 16d24c71..fce13347 100644 --- a/spec/core/matchers/toEqualSpec.js +++ b/spec/core/matchers/toEqualSpec.js @@ -2,10 +2,10 @@ describe('toEqual', function() { 'use strict'; function compareEquals(actual, expected) { - const matchersUtil = new jasmineUnderTest.MatchersUtil({ - pp: jasmineUnderTest.makePrettyPrinter() + const matchersUtil = new privateUnderTest.MatchersUtil({ + pp: privateUnderTest.makePrettyPrinter() }), - matcher = jasmineUnderTest.matchers.toEqual(matchersUtil); + matcher = privateUnderTest.matchers.toEqual(matchersUtil); const result = matcher.compare(actual, expected); @@ -18,9 +18,9 @@ describe('toEqual', function() { buildFailureMessage: function() { return 'does not matter'; }, - DiffBuilder: new jasmineUnderTest.DiffBuilder() + DiffBuilder: new privateUnderTest.DiffBuilder() }, - matcher = jasmineUnderTest.matchers.toEqual(matchersUtil); + matcher = privateUnderTest.matchers.toEqual(matchersUtil); const result = matcher.compare(1, 1); @@ -32,10 +32,10 @@ describe('toEqual', function() { const tester = function(a, b) { return a.toString() === b.toString(); }, - matchersUtil = new jasmineUnderTest.MatchersUtil({ + matchersUtil = new privateUnderTest.MatchersUtil({ customTesters: [tester] }), - matcher = jasmineUnderTest.matchers.toEqual(matchersUtil); + matcher = privateUnderTest.matchers.toEqual(matchersUtil); const result = matcher.compare(1, '1'); @@ -148,9 +148,9 @@ describe('toEqual', function() { const actual = { x: { y: 1, z: 2, f: 4 } }, expected = { x: { y: 1, z: 2, g: 3 } }, - pp = jasmineUnderTest.makePrettyPrinter([formatter]), - matchersUtil = new jasmineUnderTest.MatchersUtil({ pp: pp }), - matcher = jasmineUnderTest.matchers.toEqual(matchersUtil), + pp = privateUnderTest.makePrettyPrinter([formatter]), + matchersUtil = new privateUnderTest.MatchersUtil({ pp: pp }), + matcher = privateUnderTest.matchers.toEqual(matchersUtil), message = 'Expected $.x to have properties\n' + ' g: |3|\n' + @@ -169,9 +169,9 @@ describe('toEqual', function() { const actual = [{ foo: 4 }], expected = [{ foo: 5 }], - prettyPrinter = jasmineUnderTest.makePrettyPrinter([formatter]), - matchersUtil = new jasmineUnderTest.MatchersUtil({ pp: prettyPrinter }), - matcher = jasmineUnderTest.matchers.toEqual(matchersUtil), + prettyPrinter = privateUnderTest.makePrettyPrinter([formatter]), + matchersUtil = new privateUnderTest.MatchersUtil({ pp: prettyPrinter }), + matcher = privateUnderTest.matchers.toEqual(matchersUtil), message = 'Expected $[0].foo = |4| to equal |5|.'; expect(matcher.compare(actual, expected).message).toEqual(message); @@ -196,9 +196,9 @@ describe('toEqual', function() { bar: "shouldn't be pretty printed" } ], - prettyPrinter = jasmineUnderTest.makePrettyPrinter([formatter]), - matchersUtil = new jasmineUnderTest.MatchersUtil({ pp: prettyPrinter }), - matcher = jasmineUnderTest.matchers.toEqual(matchersUtil), + prettyPrinter = privateUnderTest.makePrettyPrinter([formatter]), + matchersUtil = new privateUnderTest.MatchersUtil({ pp: prettyPrinter }), + matcher = privateUnderTest.matchers.toEqual(matchersUtil), message = 'Expected $[0].foo = [thing with a=1, b=2] to equal [thing with a=5, b=2].\n' + "Expected $[0].bar = 'should not be pretty printed' to equal 'shouldn't be pretty printed'."; @@ -390,9 +390,9 @@ describe('toEqual', function() { const actual = { x: new Foo() }, expected = { x: new Bar() }, message = 'Expected $.x to be a kind of Bar, but was |[object Object]|.', - pp = jasmineUnderTest.makePrettyPrinter([formatter]), - matchersUtil = new jasmineUnderTest.MatchersUtil({ pp: pp }), - matcher = jasmineUnderTest.matchers.toEqual(matchersUtil); + pp = privateUnderTest.makePrettyPrinter([formatter]), + matchersUtil = new privateUnderTest.MatchersUtil({ pp: pp }), + matcher = privateUnderTest.matchers.toEqual(matchersUtil); expect(matcher.compare(actual, expected).message).toEqual(message); }); @@ -939,9 +939,9 @@ describe('toEqual', function() { const actual = [1, 1, 2, 3, 5], expected = [1, 1, 2, 3], - pp = jasmineUnderTest.makePrettyPrinter([formatter]), - matchersUtil = new jasmineUnderTest.MatchersUtil({ pp: pp }), - matcher = jasmineUnderTest.matchers.toEqual(matchersUtil), + pp = privateUnderTest.makePrettyPrinter([formatter]), + matchersUtil = new privateUnderTest.MatchersUtil({ pp: pp }), + matcher = privateUnderTest.matchers.toEqual(matchersUtil), message = 'Expected $.length = |5| to equal |4|.\n' + 'Unexpected $[4] = |5| in array.'; diff --git a/spec/core/matchers/toHaveBeenCalledBeforeSpec.js b/spec/core/matchers/toHaveBeenCalledBeforeSpec.js index 34e4c5cc..d620a837 100644 --- a/spec/core/matchers/toHaveBeenCalledBeforeSpec.js +++ b/spec/core/matchers/toHaveBeenCalledBeforeSpec.js @@ -1,10 +1,10 @@ describe('toHaveBeenCalledBefore', function() { it('throws an exception when the actual is not a spy', function() { - const matcher = jasmineUnderTest.matchers.toHaveBeenCalledBefore({ - pp: jasmineUnderTest.makePrettyPrinter() + const matcher = privateUnderTest.matchers.toHaveBeenCalledBefore({ + pp: privateUnderTest.makePrettyPrinter() }), fn = function() {}, - spy = new jasmineUnderTest.Env().createSpy('a spy'); + spy = new privateUnderTest.Env().createSpy('a spy'); expect(function() { matcher.compare(fn, spy); @@ -12,10 +12,10 @@ describe('toHaveBeenCalledBefore', function() { }); it('throws an exception when the expected is not a spy', function() { - const matcher = jasmineUnderTest.matchers.toHaveBeenCalledBefore({ - pp: jasmineUnderTest.makePrettyPrinter() + const matcher = privateUnderTest.matchers.toHaveBeenCalledBefore({ + pp: privateUnderTest.makePrettyPrinter() }), - spy = new jasmineUnderTest.Env().createSpy('a spy'), + spy = new privateUnderTest.Env().createSpy('a spy'), fn = function() {}; expect(function() { @@ -24,9 +24,9 @@ describe('toHaveBeenCalledBefore', function() { }); it('fails when the actual was not called', function() { - const matcher = jasmineUnderTest.matchers.toHaveBeenCalledBefore(), - firstSpy = new jasmineUnderTest.Spy('first spy'), - secondSpy = new jasmineUnderTest.Spy('second spy'); + const matcher = privateUnderTest.matchers.toHaveBeenCalledBefore(), + firstSpy = new privateUnderTest.Spy('first spy'), + secondSpy = new privateUnderTest.Spy('second spy'); secondSpy(); @@ -38,9 +38,9 @@ describe('toHaveBeenCalledBefore', function() { }); it('fails when the expected was not called', function() { - const matcher = jasmineUnderTest.matchers.toHaveBeenCalledBefore(), - firstSpy = new jasmineUnderTest.Spy('first spy'), - secondSpy = new jasmineUnderTest.Spy('second spy'); + const matcher = privateUnderTest.matchers.toHaveBeenCalledBefore(), + firstSpy = new privateUnderTest.Spy('first spy'), + secondSpy = new privateUnderTest.Spy('second spy'); firstSpy(); @@ -52,9 +52,9 @@ describe('toHaveBeenCalledBefore', function() { }); it('fails when the actual is called after the expected', function() { - const matcher = jasmineUnderTest.matchers.toHaveBeenCalledBefore(), - firstSpy = new jasmineUnderTest.Spy('first spy'), - secondSpy = new jasmineUnderTest.Spy('second spy'); + const matcher = privateUnderTest.matchers.toHaveBeenCalledBefore(), + firstSpy = new privateUnderTest.Spy('first spy'), + secondSpy = new privateUnderTest.Spy('second spy'); secondSpy(); firstSpy(); @@ -67,9 +67,9 @@ describe('toHaveBeenCalledBefore', function() { }); it('fails when the actual is called before and after the expected', function() { - const matcher = jasmineUnderTest.matchers.toHaveBeenCalledBefore(), - firstSpy = new jasmineUnderTest.Spy('first spy'), - secondSpy = new jasmineUnderTest.Spy('second spy'); + const matcher = privateUnderTest.matchers.toHaveBeenCalledBefore(), + firstSpy = new privateUnderTest.Spy('first spy'), + secondSpy = new privateUnderTest.Spy('second spy'); firstSpy(); secondSpy(); @@ -83,9 +83,9 @@ describe('toHaveBeenCalledBefore', function() { }); it('fails when the expected is called before and after the actual', function() { - const matcher = jasmineUnderTest.matchers.toHaveBeenCalledBefore(), - firstSpy = new jasmineUnderTest.Spy('first spy'), - secondSpy = new jasmineUnderTest.Spy('second spy'); + const matcher = privateUnderTest.matchers.toHaveBeenCalledBefore(), + firstSpy = new privateUnderTest.Spy('first spy'), + secondSpy = new privateUnderTest.Spy('second spy'); secondSpy(); firstSpy(); @@ -99,9 +99,9 @@ describe('toHaveBeenCalledBefore', function() { }); it('passes when the actual is called before the expected', function() { - const matcher = jasmineUnderTest.matchers.toHaveBeenCalledBefore(), - firstSpy = new jasmineUnderTest.Spy('first spy'), - secondSpy = new jasmineUnderTest.Spy('second spy'); + const matcher = privateUnderTest.matchers.toHaveBeenCalledBefore(), + firstSpy = new privateUnderTest.Spy('first spy'), + secondSpy = new privateUnderTest.Spy('second spy'); firstSpy(); secondSpy(); @@ -114,9 +114,9 @@ describe('toHaveBeenCalledBefore', function() { }); it('set the correct calls as verified when passing', function() { - const matcher = jasmineUnderTest.matchers.toHaveBeenCalledBefore(), - firstSpy = new jasmineUnderTest.Spy('first spy'), - secondSpy = new jasmineUnderTest.Spy('second spy'); + const matcher = privateUnderTest.matchers.toHaveBeenCalledBefore(), + firstSpy = new privateUnderTest.Spy('first spy'), + secondSpy = new privateUnderTest.Spy('second spy'); firstSpy(); secondSpy(); diff --git a/spec/core/matchers/toHaveBeenCalledOnceWithSpec.js b/spec/core/matchers/toHaveBeenCalledOnceWithSpec.js index fb4bbc4b..d6aa854f 100644 --- a/spec/core/matchers/toHaveBeenCalledOnceWithSpec.js +++ b/spec/core/matchers/toHaveBeenCalledOnceWithSpec.js @@ -1,9 +1,9 @@ describe('toHaveBeenCalledOnceWith', function() { it('passes when the actual was called only once and with matching parameters', function() { - const pp = jasmineUnderTest.makePrettyPrinter(), - util = new jasmineUnderTest.MatchersUtil({ pp: pp }), - matcher = jasmineUnderTest.matchers.toHaveBeenCalledOnceWith(util), - calledSpy = new jasmineUnderTest.Spy('called-spy'); + const pp = privateUnderTest.makePrettyPrinter(), + util = new privateUnderTest.MatchersUtil({ pp: pp }), + matcher = privateUnderTest.matchers.toHaveBeenCalledOnceWith(util), + calledSpy = new privateUnderTest.Spy('called-spy'); calledSpy('a', 'b'); const result = matcher.compare(calledSpy, 'a', 'b'); @@ -20,13 +20,13 @@ describe('toHaveBeenCalledOnceWith', function() { return true; } ], - matchersUtil = new jasmineUnderTest.MatchersUtil({ + matchersUtil = new privateUnderTest.MatchersUtil({ customTesters: customEqualityTesters }), - matcher = jasmineUnderTest.matchers.toHaveBeenCalledOnceWith( + matcher = privateUnderTest.matchers.toHaveBeenCalledOnceWith( matchersUtil ), - calledSpy = new jasmineUnderTest.Spy('called-spy'); + calledSpy = new privateUnderTest.Spy('called-spy'); calledSpy('a', 'b'); const result = matcher.compare(calledSpy, 'a', 'a'); @@ -35,10 +35,10 @@ describe('toHaveBeenCalledOnceWith', function() { }); it('fails when the actual was never called', function() { - const pp = jasmineUnderTest.makePrettyPrinter(), - util = new jasmineUnderTest.MatchersUtil({ pp: pp }), - matcher = jasmineUnderTest.matchers.toHaveBeenCalledOnceWith(util), - calledSpy = new jasmineUnderTest.Spy('called-spy'); + const pp = privateUnderTest.makePrettyPrinter(), + util = new privateUnderTest.MatchersUtil({ pp: pp }), + matcher = privateUnderTest.matchers.toHaveBeenCalledOnceWith(util), + calledSpy = new privateUnderTest.Spy('called-spy'); const result = matcher.compare(calledSpy, 'a', 'b'); @@ -49,10 +49,10 @@ describe('toHaveBeenCalledOnceWith', function() { }); it('fails when the actual was called once with different parameters', function() { - const pp = jasmineUnderTest.makePrettyPrinter(), - util = new jasmineUnderTest.MatchersUtil({ pp: pp }), - matcher = jasmineUnderTest.matchers.toHaveBeenCalledOnceWith(util), - calledSpy = new jasmineUnderTest.Spy('called-spy'); + const pp = privateUnderTest.makePrettyPrinter(), + util = new privateUnderTest.MatchersUtil({ pp: pp }), + matcher = privateUnderTest.matchers.toHaveBeenCalledOnceWith(util), + calledSpy = new privateUnderTest.Spy('called-spy'); calledSpy('a', 'c'); const result = matcher.compare(calledSpy, 'a', 'b'); @@ -64,10 +64,10 @@ describe('toHaveBeenCalledOnceWith', function() { }); it('fails when the actual was called multiple times with expected parameters', function() { - const pp = jasmineUnderTest.makePrettyPrinter(), - util = new jasmineUnderTest.MatchersUtil({ pp: pp }), - matcher = jasmineUnderTest.matchers.toHaveBeenCalledOnceWith(util), - calledSpy = new jasmineUnderTest.Spy('called-spy'); + const pp = privateUnderTest.makePrettyPrinter(), + util = new privateUnderTest.MatchersUtil({ pp: pp }), + matcher = privateUnderTest.matchers.toHaveBeenCalledOnceWith(util), + calledSpy = new privateUnderTest.Spy('called-spy'); calledSpy('a', 'b'); calledSpy('a', 'b'); @@ -80,10 +80,10 @@ describe('toHaveBeenCalledOnceWith', function() { }); it('fails when the actual was called multiple times (one of them - with expected parameters)', function() { - const pp = jasmineUnderTest.makePrettyPrinter(), - util = new jasmineUnderTest.MatchersUtil({ pp: pp }), - matcher = jasmineUnderTest.matchers.toHaveBeenCalledOnceWith(util), - calledSpy = new jasmineUnderTest.Spy('called-spy'); + const pp = privateUnderTest.makePrettyPrinter(), + util = new privateUnderTest.MatchersUtil({ pp: pp }), + matcher = privateUnderTest.matchers.toHaveBeenCalledOnceWith(util), + calledSpy = new privateUnderTest.Spy('called-spy'); calledSpy('a', 'b'); calledSpy('a', 'c'); @@ -96,9 +96,9 @@ describe('toHaveBeenCalledOnceWith', function() { }); it('throws an exception when the actual is not a spy', function() { - const pp = jasmineUnderTest.makePrettyPrinter(), - util = new jasmineUnderTest.MatchersUtil({ pp: pp }), - matcher = jasmineUnderTest.matchers.toHaveBeenCalledOnceWith(util), + const pp = privateUnderTest.makePrettyPrinter(), + util = new privateUnderTest.MatchersUtil({ pp: pp }), + matcher = privateUnderTest.matchers.toHaveBeenCalledOnceWith(util), fn = function() {}; expect(function() { @@ -107,10 +107,10 @@ describe('toHaveBeenCalledOnceWith', function() { }); it('set the correct calls as verified when passing', function() { - const pp = jasmineUnderTest.makePrettyPrinter(), - util = new jasmineUnderTest.MatchersUtil({ pp: pp }), - matcher = jasmineUnderTest.matchers.toHaveBeenCalledOnceWith(util), - calledSpy = new jasmineUnderTest.Spy('called-spy'); + const pp = privateUnderTest.makePrettyPrinter(), + util = new privateUnderTest.MatchersUtil({ pp: pp }), + matcher = privateUnderTest.matchers.toHaveBeenCalledOnceWith(util), + calledSpy = new privateUnderTest.Spy('called-spy'); calledSpy('x'); diff --git a/spec/core/matchers/toHaveBeenCalledSpec.js b/spec/core/matchers/toHaveBeenCalledSpec.js index a12cde3f..93b72be3 100644 --- a/spec/core/matchers/toHaveBeenCalledSpec.js +++ b/spec/core/matchers/toHaveBeenCalledSpec.js @@ -1,7 +1,7 @@ describe('toHaveBeenCalled', function() { it('passes when the actual was called, with a custom .not fail message', function() { - const matcher = jasmineUnderTest.matchers.toHaveBeenCalled(), - calledSpy = new jasmineUnderTest.Spy('called-spy'); + const matcher = privateUnderTest.matchers.toHaveBeenCalled(), + calledSpy = new privateUnderTest.Spy('called-spy'); calledSpy(); @@ -13,16 +13,16 @@ describe('toHaveBeenCalled', function() { }); it('fails when the actual was not called', function() { - const matcher = jasmineUnderTest.matchers.toHaveBeenCalled(), - uncalledSpy = new jasmineUnderTest.Spy('uncalled spy'); + const matcher = privateUnderTest.matchers.toHaveBeenCalled(), + uncalledSpy = new privateUnderTest.Spy('uncalled spy'); const result = matcher.compare(uncalledSpy); expect(result.pass).toBe(false); }); it('throws an exception when the actual is not a spy', function() { - const matcher = jasmineUnderTest.matchers.toHaveBeenCalled({ - pp: jasmineUnderTest.makePrettyPrinter() + const matcher = privateUnderTest.matchers.toHaveBeenCalled({ + pp: privateUnderTest.makePrettyPrinter() }), fn = function() {}; @@ -32,8 +32,8 @@ describe('toHaveBeenCalled', function() { }); it('throws an exception when invoked with any arguments', function() { - const matcher = jasmineUnderTest.matchers.toHaveBeenCalled(), - spy = new jasmineUnderTest.Spy('sample spy'); + const matcher = privateUnderTest.matchers.toHaveBeenCalled(), + spy = new privateUnderTest.Spy('sample spy'); expect(function() { matcher.compare(spy, 'foo'); @@ -41,8 +41,8 @@ describe('toHaveBeenCalled', function() { }); it('has a custom message on failure', function() { - const matcher = jasmineUnderTest.matchers.toHaveBeenCalled(), - spy = new jasmineUnderTest.Spy('sample-spy'); + const matcher = privateUnderTest.matchers.toHaveBeenCalled(), + spy = new privateUnderTest.Spy('sample-spy'); const result = matcher.compare(spy); @@ -52,8 +52,8 @@ describe('toHaveBeenCalled', function() { }); it('set the correct calls as verified when passing', function() { - const matcher = jasmineUnderTest.matchers.toHaveBeenCalled(), - spy = new jasmineUnderTest.Spy('sample-spy'); + const matcher = privateUnderTest.matchers.toHaveBeenCalled(), + spy = new privateUnderTest.Spy('sample-spy'); spy(); diff --git a/spec/core/matchers/toHaveBeenCalledTimesSpec.js b/spec/core/matchers/toHaveBeenCalledTimesSpec.js index af1d1d26..7935d540 100644 --- a/spec/core/matchers/toHaveBeenCalledTimesSpec.js +++ b/spec/core/matchers/toHaveBeenCalledTimesSpec.js @@ -1,13 +1,13 @@ describe('toHaveBeenCalledTimes', function() { it('passes when the actual 0 matches the expected 0 ', function() { - const matcher = jasmineUnderTest.matchers.toHaveBeenCalledTimes(), - calledSpy = new jasmineUnderTest.Spy('called-spy'), + const matcher = privateUnderTest.matchers.toHaveBeenCalledTimes(), + calledSpy = new privateUnderTest.Spy('called-spy'), result = matcher.compare(calledSpy, 0); expect(result.pass).toBeTruthy(); }); it('passes when the actual matches the expected', function() { - const matcher = jasmineUnderTest.matchers.toHaveBeenCalledTimes(), - calledSpy = new jasmineUnderTest.Spy('called-spy'); + const matcher = privateUnderTest.matchers.toHaveBeenCalledTimes(), + calledSpy = new privateUnderTest.Spy('called-spy'); calledSpy(); const result = matcher.compare(calledSpy, 1); @@ -15,8 +15,8 @@ describe('toHaveBeenCalledTimes', function() { }); it('fails when expected numbers is not supplied', function() { - const matcher = jasmineUnderTest.matchers.toHaveBeenCalledTimes(), - spy = new jasmineUnderTest.Spy('spy'); + const matcher = privateUnderTest.matchers.toHaveBeenCalledTimes(), + spy = new privateUnderTest.Spy('spy'); spy(); expect(function() { @@ -27,16 +27,16 @@ describe('toHaveBeenCalledTimes', function() { }); it('fails when the actual was called less than the expected', function() { - const matcher = jasmineUnderTest.matchers.toHaveBeenCalledTimes(), - uncalledSpy = new jasmineUnderTest.Spy('uncalled spy'); + const matcher = privateUnderTest.matchers.toHaveBeenCalledTimes(), + uncalledSpy = new privateUnderTest.Spy('uncalled spy'); const result = matcher.compare(uncalledSpy, 2); expect(result.pass).toBe(false); }); it('fails when the actual was called more than expected', function() { - const matcher = jasmineUnderTest.matchers.toHaveBeenCalledTimes(), - uncalledSpy = new jasmineUnderTest.Spy('uncalled spy'); + const matcher = privateUnderTest.matchers.toHaveBeenCalledTimes(), + uncalledSpy = new privateUnderTest.Spy('uncalled spy'); uncalledSpy(); uncalledSpy(); @@ -46,8 +46,8 @@ describe('toHaveBeenCalledTimes', function() { }); it('throws an exception when the actual is not a spy', function() { - const matcher = jasmineUnderTest.matchers.toHaveBeenCalledTimes({ - pp: jasmineUnderTest.makePrettyPrinter() + const matcher = privateUnderTest.matchers.toHaveBeenCalledTimes({ + pp: privateUnderTest.makePrettyPrinter() }), fn = function() {}; @@ -57,8 +57,8 @@ describe('toHaveBeenCalledTimes', function() { }); it('has a custom message on failure that tells it was called only once', function() { - const matcher = jasmineUnderTest.matchers.toHaveBeenCalledTimes(), - spy = new jasmineUnderTest.Spy('sample-spy'); + const matcher = privateUnderTest.matchers.toHaveBeenCalledTimes(), + spy = new privateUnderTest.Spy('sample-spy'); spy(); spy(); spy(); @@ -73,8 +73,8 @@ describe('toHaveBeenCalledTimes', function() { }); it('has a custom message on failure that tells how many times it was called', function() { - const matcher = jasmineUnderTest.matchers.toHaveBeenCalledTimes(), - spy = new jasmineUnderTest.Spy('sample-spy'); + const matcher = privateUnderTest.matchers.toHaveBeenCalledTimes(), + spy = new privateUnderTest.Spy('sample-spy'); spy(); spy(); spy(); @@ -89,8 +89,8 @@ describe('toHaveBeenCalledTimes', function() { }); it('set the correct calls as verified when passing', function() { - const matcher = jasmineUnderTest.matchers.toHaveBeenCalledTimes(), - spy = new jasmineUnderTest.Spy('sample-spy'); + const matcher = privateUnderTest.matchers.toHaveBeenCalledTimes(), + spy = new privateUnderTest.Spy('sample-spy'); spy(); spy(); diff --git a/spec/core/matchers/toHaveBeenCalledWithSpec.js b/spec/core/matchers/toHaveBeenCalledWithSpec.js index ac7f3ad4..e1ee60e1 100644 --- a/spec/core/matchers/toHaveBeenCalledWithSpec.js +++ b/spec/core/matchers/toHaveBeenCalledWithSpec.js @@ -3,10 +3,10 @@ describe('toHaveBeenCalledWith', function() { const matchersUtil = { contains: jasmine.createSpy('delegated-contains').and.returnValue(true), equals: jasmine.createSpy('delegated-equals').and.returnValue(true), - pp: jasmineUnderTest.makePrettyPrinter() + pp: privateUnderTest.makePrettyPrinter() }, - matcher = jasmineUnderTest.matchers.toHaveBeenCalledWith(matchersUtil), - calledSpy = new jasmineUnderTest.Spy('called-spy'); + matcher = privateUnderTest.matchers.toHaveBeenCalledWith(matchersUtil), + calledSpy = new privateUnderTest.Spy('called-spy'); calledSpy('a', 'b'); const result = matcher.compare(calledSpy, 'a', 'b'); @@ -23,11 +23,11 @@ describe('toHaveBeenCalledWith', function() { return true; } ], - matchersUtil = new jasmineUnderTest.MatchersUtil({ + matchersUtil = new privateUnderTest.MatchersUtil({ customTesters: customEqualityTesters }), - matcher = jasmineUnderTest.matchers.toHaveBeenCalledWith(matchersUtil), - calledSpy = new jasmineUnderTest.Spy('called-spy'); + matcher = privateUnderTest.matchers.toHaveBeenCalledWith(matchersUtil), + calledSpy = new privateUnderTest.Spy('called-spy'); calledSpy('a', 'b'); const result = matcher.compare(calledSpy, 'a', 'b'); @@ -39,10 +39,10 @@ describe('toHaveBeenCalledWith', function() { contains: jasmine .createSpy('delegated-contains') .and.returnValue(false), - pp: jasmineUnderTest.makePrettyPrinter() + pp: privateUnderTest.makePrettyPrinter() }, - matcher = jasmineUnderTest.matchers.toHaveBeenCalledWith(matchersUtil), - uncalledSpy = new jasmineUnderTest.Spy('uncalled spy'); + matcher = privateUnderTest.matchers.toHaveBeenCalledWith(matchersUtil), + uncalledSpy = new privateUnderTest.Spy('uncalled spy'); const result = matcher.compare(uncalledSpy); expect(result.pass).toBe(false); @@ -52,11 +52,11 @@ describe('toHaveBeenCalledWith', function() { }); it('fails when the actual was called with different parameters', function() { - const matchersUtil = new jasmineUnderTest.MatchersUtil({ - pp: jasmineUnderTest.makePrettyPrinter() + const matchersUtil = new privateUnderTest.MatchersUtil({ + pp: privateUnderTest.makePrettyPrinter() }), - matcher = jasmineUnderTest.matchers.toHaveBeenCalledWith(matchersUtil), - calledSpy = new jasmineUnderTest.Spy('called spy'); + matcher = privateUnderTest.matchers.toHaveBeenCalledWith(matchersUtil), + calledSpy = new privateUnderTest.Spy('called spy'); calledSpy('a'); calledSpy('c', 'd'); @@ -84,8 +84,8 @@ describe('toHaveBeenCalledWith', function() { }); it('throws an exception when the actual is not a spy', function() { - const matcher = jasmineUnderTest.matchers.toHaveBeenCalledWith({ - pp: jasmineUnderTest.makePrettyPrinter() + const matcher = privateUnderTest.matchers.toHaveBeenCalledWith({ + pp: privateUnderTest.makePrettyPrinter() }), fn = function() {}; @@ -98,10 +98,10 @@ describe('toHaveBeenCalledWith', function() { const matchersUtil = { contains: jasmine.createSpy('delegated-contains').and.returnValue(true), equals: jasmine.createSpy('delegated-equals').and.returnValue(true), - pp: jasmineUnderTest.makePrettyPrinter() + pp: privateUnderTest.makePrettyPrinter() }, - matcher = jasmineUnderTest.matchers.toHaveBeenCalledWith(matchersUtil), - calledSpy = new jasmineUnderTest.Spy('called-spy'); + matcher = privateUnderTest.matchers.toHaveBeenCalledWith(matchersUtil), + calledSpy = new privateUnderTest.Spy('called-spy'); calledSpy('a', 'b'); matcher.compare(calledSpy, 'a', 'b'); diff --git a/spec/core/matchers/toHaveClassSpec.js b/spec/core/matchers/toHaveClassSpec.js index c997d3f6..0c9c566d 100644 --- a/spec/core/matchers/toHaveClassSpec.js +++ b/spec/core/matchers/toHaveClassSpec.js @@ -1,6 +1,6 @@ describe('toHaveClass', function() { it('fails for a DOM element that lacks the expected class', function() { - const matcher = jasmineUnderTest.matchers.toHaveClass(), + const matcher = privateUnderTest.matchers.toHaveClass(), result = matcher.compare( specHelpers.domHelpers.createElementWithClassName(''), 'foo' @@ -10,7 +10,7 @@ describe('toHaveClass', function() { }); it('passes for a DOM element that has the expected class', function() { - const matcher = jasmineUnderTest.matchers.toHaveClass(), + const matcher = privateUnderTest.matchers.toHaveClass(), el = specHelpers.domHelpers.createElementWithClassName('foo bar baz'); expect(matcher.compare(el, 'foo').pass).toBe(true); @@ -19,15 +19,15 @@ describe('toHaveClass', function() { }); it('fails for a DOM element that only has other classes', function() { - const matcher = jasmineUnderTest.matchers.toHaveClass(), + const matcher = privateUnderTest.matchers.toHaveClass(), el = specHelpers.domHelpers.createElementWithClassName('foo bar'); expect(matcher.compare(el, 'fo').pass).toBe(false); }); it('throws an exception when actual is not a DOM element', function() { - const matcher = jasmineUnderTest.matchers.toHaveClass({ - pp: jasmineUnderTest.makePrettyPrinter() + const matcher = privateUnderTest.matchers.toHaveClass({ + pp: privateUnderTest.makePrettyPrinter() }); expect(function() { diff --git a/spec/core/matchers/toHaveClassesSpec.js b/spec/core/matchers/toHaveClassesSpec.js index 0a55edc3..e31e6ad0 100644 --- a/spec/core/matchers/toHaveClassesSpec.js +++ b/spec/core/matchers/toHaveClassesSpec.js @@ -1,6 +1,6 @@ describe('toHaveClasses', function() { it('fails for a DOM element that lacks all the expected classes', function() { - const matcher = jasmineUnderTest.matchers.toHaveClasses(), + const matcher = privateUnderTest.matchers.toHaveClasses(), result = matcher.compare( specHelpers.domHelpers.createElementWithClassName(''), ['foo', 'bar'] @@ -10,22 +10,22 @@ describe('toHaveClasses', function() { }); it('passes for a DOM element that has all the expected classes', function() { - const matcher = jasmineUnderTest.matchers.toHaveClasses(), + const matcher = privateUnderTest.matchers.toHaveClasses(), el = specHelpers.domHelpers.createElementWithClassName('foo bar baz'); expect(matcher.compare(el, ['foo', 'bar']).pass).toBe(true); }); it('fails for a DOM element that only has some matching classes', function() { - const matcher = jasmineUnderTest.matchers.toHaveClasses(), + const matcher = privateUnderTest.matchers.toHaveClasses(), el = specHelpers.domHelpers.createElementWithClassName('foo bar'); expect(matcher.compare(el, ['foo', 'can']).pass).toBe(false); }); it('throws an exception when actual is not a DOM element', function() { - const matcher = jasmineUnderTest.matchers.toHaveClasses({ - pp: jasmineUnderTest.makePrettyPrinter() + const matcher = privateUnderTest.matchers.toHaveClasses({ + pp: privateUnderTest.makePrettyPrinter() }); expect(function() { diff --git a/spec/core/matchers/toHaveNoOtherSpyInteractionsSpec.js b/spec/core/matchers/toHaveNoOtherSpyInteractionsSpec.js index ddb669c4..96cc916e 100644 --- a/spec/core/matchers/toHaveNoOtherSpyInteractionsSpec.js +++ b/spec/core/matchers/toHaveNoOtherSpyInteractionsSpec.js @@ -1,6 +1,6 @@ describe('toHaveNoOtherSpyInteractions', function() { it('passes when there are no spy interactions', function() { - let matcher = jasmineUnderTest.matchers.toHaveNoOtherSpyInteractions(); + let matcher = privateUnderTest.matchers.toHaveNoOtherSpyInteractions(); let spyObj = jasmineUnderTest .getEnv() .createSpyObj('NewClass', ['spyA', 'spyB']); @@ -10,8 +10,8 @@ describe('toHaveNoOtherSpyInteractions', function() { }); it('passes when there are multiple spy interactions where checked by toHaveBeenCalled', function() { - let matcher = jasmineUnderTest.matchers.toHaveNoOtherSpyInteractions(); - let toHaveBeenCalledMatcher = jasmineUnderTest.matchers.toHaveBeenCalled(); + let matcher = privateUnderTest.matchers.toHaveNoOtherSpyInteractions(); + let toHaveBeenCalledMatcher = privateUnderTest.matchers.toHaveBeenCalled(); let spyObj = jasmineUnderTest .getEnv() .createSpyObj('NewClass', ['spyA', 'spyB']); @@ -26,10 +26,10 @@ describe('toHaveNoOtherSpyInteractions', function() { }); it('fails when there are spy interactions', function() { - const matchersUtil = new jasmineUnderTest.MatchersUtil({ - pp: jasmineUnderTest.makePrettyPrinter() + const matchersUtil = new privateUnderTest.MatchersUtil({ + pp: privateUnderTest.makePrettyPrinter() }); - let matcher = jasmineUnderTest.matchers.toHaveNoOtherSpyInteractions( + let matcher = privateUnderTest.matchers.toHaveNoOtherSpyInteractions( matchersUtil ); let spyObj = jasmineUnderTest @@ -47,10 +47,10 @@ describe('toHaveNoOtherSpyInteractions', function() { }); it('shows the right message is negated', function() { - const matchersUtil = new jasmineUnderTest.MatchersUtil({ - pp: jasmineUnderTest.makePrettyPrinter() + const matchersUtil = new privateUnderTest.MatchersUtil({ + pp: privateUnderTest.makePrettyPrinter() }); - let matcher = jasmineUnderTest.matchers.toHaveNoOtherSpyInteractions( + let matcher = privateUnderTest.matchers.toHaveNoOtherSpyInteractions( matchersUtil ); let spyObj = jasmineUnderTest @@ -70,7 +70,7 @@ describe('toHaveNoOtherSpyInteractions', function() { }); it('passes when only non-observed spy object interactions are interacted', function() { - let matcher = jasmineUnderTest.matchers.toHaveNoOtherSpyInteractions(); + let matcher = privateUnderTest.matchers.toHaveNoOtherSpyInteractions(); let spyObj = jasmineUnderTest .getEnv() .createSpyObj('NewClass', ['spyA', 'spyB']); @@ -86,7 +86,7 @@ describe('toHaveNoOtherSpyInteractions', function() { }); it('throws an error if a non-object is passed', function() { - let matcher = jasmineUnderTest.matchers.toHaveNoOtherSpyInteractions(); + let matcher = privateUnderTest.matchers.toHaveNoOtherSpyInteractions(); expect(function() { matcher.compare(true); @@ -102,7 +102,7 @@ describe('toHaveNoOtherSpyInteractions', function() { }); it('throws an error if arguments are passed', function() { - let matcher = jasmineUnderTest.matchers.toHaveNoOtherSpyInteractions(); + let matcher = privateUnderTest.matchers.toHaveNoOtherSpyInteractions(); let spyObj = jasmineUnderTest .getEnv() .createSpyObj('mySpyObj', ['spyA', 'spyB']); @@ -113,7 +113,7 @@ describe('toHaveNoOtherSpyInteractions', function() { }); it('throws an error if the spy object has no spies', function() { - let matcher = jasmineUnderTest.matchers.toHaveNoOtherSpyInteractions(); + let matcher = privateUnderTest.matchers.toHaveNoOtherSpyInteractions(); const spyObj = jasmineUnderTest .getEnv() .createSpyObj('mySpyObj', ['notSpy']); @@ -129,13 +129,13 @@ describe('toHaveNoOtherSpyInteractions', function() { }); it('handles multiple interactions with a single spy', function() { - const matchersUtil = new jasmineUnderTest.MatchersUtil({ - pp: jasmineUnderTest.makePrettyPrinter() + const matchersUtil = new privateUnderTest.MatchersUtil({ + pp: privateUnderTest.makePrettyPrinter() }), - matcher = jasmineUnderTest.matchers.toHaveNoOtherSpyInteractions( + matcher = privateUnderTest.matchers.toHaveNoOtherSpyInteractions( matchersUtil ), - toHaveBeenCalledWithMatcher = jasmineUnderTest.matchers.toHaveBeenCalledWith( + toHaveBeenCalledWithMatcher = privateUnderTest.matchers.toHaveBeenCalledWith( matchersUtil ), spyObj = jasmineUnderTest diff --git a/spec/core/matchers/toHaveSizeSpec.js b/spec/core/matchers/toHaveSizeSpec.js index 218b6178..0fddaa72 100644 --- a/spec/core/matchers/toHaveSizeSpec.js +++ b/spec/core/matchers/toHaveSizeSpec.js @@ -2,22 +2,22 @@ describe('toHaveSize', function() { 'use strict'; it('passes for an array whose length matches', function() { - const matcher = jasmineUnderTest.matchers.toHaveSize(), + const matcher = privateUnderTest.matchers.toHaveSize(), result = matcher.compare([1, 2], 2); expect(result.pass).toBe(true); }); it('fails for an array whose length does not match', function() { - const matcher = jasmineUnderTest.matchers.toHaveSize(), + const matcher = privateUnderTest.matchers.toHaveSize(), result = matcher.compare([1, 2, 3], 2); expect(result.pass).toBe(false); }); it('informs about the size of an array whose length does not match', function() { - const matcher = jasmineUnderTest.matchers.toHaveSize({ - pp: jasmineUnderTest.makePrettyPrinter() + const matcher = privateUnderTest.matchers.toHaveSize({ + pp: privateUnderTest.makePrettyPrinter() }), result = matcher.compare([1, 2, 3], 2); @@ -27,42 +27,42 @@ describe('toHaveSize', function() { }); it('passes for an object with the proper number of keys', function() { - const matcher = jasmineUnderTest.matchers.toHaveSize(), + const matcher = privateUnderTest.matchers.toHaveSize(), result = matcher.compare({ a: 1, b: 2 }, 2); expect(result.pass).toBe(true); }); it('fails for an object with a different number of keys', function() { - const matcher = jasmineUnderTest.matchers.toHaveSize(), + const matcher = privateUnderTest.matchers.toHaveSize(), result = matcher.compare({ a: 1, b: 2 }, 1); expect(result.pass).toBe(false); }); it('passes for an object with an explicit `length` property that matches', function() { - const matcher = jasmineUnderTest.matchers.toHaveSize(), + const matcher = privateUnderTest.matchers.toHaveSize(), result = matcher.compare({ a: 1, b: 2, length: 5 }, 5); expect(result.pass).toBe(true); }); it('fails for an object with an explicit `length` property that does not match', function() { - const matcher = jasmineUnderTest.matchers.toHaveSize(), + const matcher = privateUnderTest.matchers.toHaveSize(), result = matcher.compare({ a: 1, b: 2, length: 5 }, 1); expect(result.pass).toBe(false); }); it('passes for a string whose length matches', function() { - const matcher = jasmineUnderTest.matchers.toHaveSize(), + const matcher = privateUnderTest.matchers.toHaveSize(), result = matcher.compare('ab', 2); expect(result.pass).toBe(true); }); it('fails for a string whose length does not match', function() { - const matcher = jasmineUnderTest.matchers.toHaveSize(), + const matcher = privateUnderTest.matchers.toHaveSize(), result = matcher.compare('abc', 2); expect(result.pass).toBe(false); @@ -73,7 +73,7 @@ describe('toHaveSize', function() { map.set('a', 1); map.set('b', 2); - const matcher = jasmineUnderTest.matchers.toHaveSize(), + const matcher = privateUnderTest.matchers.toHaveSize(), result = matcher.compare(map, 2); expect(result.pass).toBe(true); @@ -84,7 +84,7 @@ describe('toHaveSize', function() { map.set('a', 1); map.set('b', 2); - const matcher = jasmineUnderTest.matchers.toHaveSize(), + const matcher = privateUnderTest.matchers.toHaveSize(), result = matcher.compare(map, 1); expect(result.pass).toBe(false); @@ -95,7 +95,7 @@ describe('toHaveSize', function() { set.add('a'); set.add('b'); - const matcher = jasmineUnderTest.matchers.toHaveSize(), + const matcher = privateUnderTest.matchers.toHaveSize(), result = matcher.compare(set, 2); expect(result.pass).toBe(true); @@ -106,14 +106,14 @@ describe('toHaveSize', function() { set.add('a'); set.add('b'); - const matcher = jasmineUnderTest.matchers.toHaveSize(), + const matcher = privateUnderTest.matchers.toHaveSize(), result = matcher.compare(set, 1); expect(result.pass).toBe(false); }); it('throws an error for WeakSet', function() { - const matcher = jasmineUnderTest.matchers.toHaveSize(); + const matcher = privateUnderTest.matchers.toHaveSize(); expect(function() { matcher.compare(new WeakSet(), 2); @@ -121,7 +121,7 @@ describe('toHaveSize', function() { }); it('throws an error for WeakMap', function() { - const matcher = jasmineUnderTest.matchers.toHaveSize(); + const matcher = privateUnderTest.matchers.toHaveSize(); expect(function() { matcher.compare(new WeakMap(), 2); @@ -129,7 +129,7 @@ describe('toHaveSize', function() { }); it('throws an error for DataView', function() { - const matcher = jasmineUnderTest.matchers.toHaveSize(); + const matcher = privateUnderTest.matchers.toHaveSize(); expect(function() { matcher.compare(new DataView(new ArrayBuffer(128)), 2); diff --git a/spec/core/matchers/toHaveSpyInteractionsSpec.js b/spec/core/matchers/toHaveSpyInteractionsSpec.js index d5b71f83..69678b6e 100755 --- a/spec/core/matchers/toHaveSpyInteractionsSpec.js +++ b/spec/core/matchers/toHaveSpyInteractionsSpec.js @@ -1,6 +1,6 @@ describe('toHaveSpyInteractions', function() { it('passes when there are spy interactions', function() { - let matcher = jasmineUnderTest.matchers.toHaveSpyInteractions(); + let matcher = privateUnderTest.matchers.toHaveSpyInteractions(); let spyObj = jasmineUnderTest .getEnv() .createSpyObj('NewClass', ['spyA', 'spyB']); @@ -12,7 +12,7 @@ describe('toHaveSpyInteractions', function() { }); it('passes when there are multiple spy interactions', function() { - let matcher = jasmineUnderTest.matchers.toHaveSpyInteractions(); + let matcher = privateUnderTest.matchers.toHaveSpyInteractions(); let spyObj = jasmineUnderTest .getEnv() .createSpyObj('NewClass', ['spyA', 'spyB']); @@ -26,7 +26,7 @@ describe('toHaveSpyInteractions', function() { }); it('fails when there are no spy interactions', function() { - let matcher = jasmineUnderTest.matchers.toHaveSpyInteractions(); + let matcher = privateUnderTest.matchers.toHaveSpyInteractions(); let spyObj = jasmineUnderTest .getEnv() .createSpyObj('NewClass', ['spyA', 'spyB']); @@ -39,7 +39,7 @@ describe('toHaveSpyInteractions', function() { }); it('shows the right message is negated', function() { - let matcher = jasmineUnderTest.matchers.toHaveSpyInteractions(); + let matcher = privateUnderTest.matchers.toHaveSpyInteractions(); let spyObj = jasmineUnderTest .getEnv() .createSpyObj('NewClass', ['spyA', 'spyB']); @@ -55,7 +55,7 @@ describe('toHaveSpyInteractions', function() { }); it('fails when only non-observed spy object interactions are interacted', function() { - let matcher = jasmineUnderTest.matchers.toHaveSpyInteractions(); + let matcher = privateUnderTest.matchers.toHaveSpyInteractions(); let spyObj = jasmineUnderTest .getEnv() .createSpyObj('NewClass', ['spyA', 'spyB']); @@ -71,7 +71,7 @@ describe('toHaveSpyInteractions', function() { }); it('throws an error if a non-object is passed', function() { - let matcher = jasmineUnderTest.matchers.toHaveSpyInteractions(); + let matcher = privateUnderTest.matchers.toHaveSpyInteractions(); expect(function() { matcher.compare(true); @@ -87,7 +87,7 @@ describe('toHaveSpyInteractions', function() { }); it('throws an error if arguments are passed', function() { - let matcher = jasmineUnderTest.matchers.toHaveSpyInteractions(); + let matcher = privateUnderTest.matchers.toHaveSpyInteractions(); let spyObj = jasmineUnderTest .getEnv() .createSpyObj('NewClass', ['spyA', 'spyB']); @@ -98,7 +98,7 @@ describe('toHaveSpyInteractions', function() { }); it('throws an error if the spy object has no spies', function() { - let matcher = jasmineUnderTest.matchers.toHaveSpyInteractions(); + let matcher = privateUnderTest.matchers.toHaveSpyInteractions(); const spyObj = jasmineUnderTest .getEnv() .createSpyObj('NewClass', ['notSpy']); diff --git a/spec/core/matchers/toMatchSpec.js b/spec/core/matchers/toMatchSpec.js index 0dd4840b..c25ba51c 100644 --- a/spec/core/matchers/toMatchSpec.js +++ b/spec/core/matchers/toMatchSpec.js @@ -1,34 +1,34 @@ describe('toMatch', function() { it('passes when RegExps are equivalent', function() { - const matcher = jasmineUnderTest.matchers.toMatch(); + const matcher = privateUnderTest.matchers.toMatch(); const result = matcher.compare(/foo/, /foo/); expect(result.pass).toBe(true); }); it('fails when RegExps are not equivalent', function() { - const matcher = jasmineUnderTest.matchers.toMatch(); + const matcher = privateUnderTest.matchers.toMatch(); const result = matcher.compare(/bar/, /foo/); expect(result.pass).toBe(false); }); it('passes when the actual matches the expected string as a pattern', function() { - const matcher = jasmineUnderTest.matchers.toMatch(); + const matcher = privateUnderTest.matchers.toMatch(); const result = matcher.compare('foosball', 'foo'); expect(result.pass).toBe(true); }); it('fails when the actual matches the expected string as a pattern', function() { - const matcher = jasmineUnderTest.matchers.toMatch(); + const matcher = privateUnderTest.matchers.toMatch(); const result = matcher.compare('bar', 'foo'); expect(result.pass).toBe(false); }); it('throws an Error when the expected is not a String or RegExp', function() { - const matcher = jasmineUnderTest.matchers.toMatch(); + const matcher = privateUnderTest.matchers.toMatch(); expect(function() { matcher.compare('foo', { bar: 'baz' }); diff --git a/spec/core/matchers/toThrowErrorSpec.js b/spec/core/matchers/toThrowErrorSpec.js index c74c020d..6ba2edda 100644 --- a/spec/core/matchers/toThrowErrorSpec.js +++ b/spec/core/matchers/toThrowErrorSpec.js @@ -1,6 +1,6 @@ describe('toThrowError', function() { it('throws an error when the actual is not a function', function() { - const matcher = jasmineUnderTest.matchers.toThrowError(); + const matcher = privateUnderTest.matchers.toThrowError(); expect(function() { matcher.compare({}); @@ -8,7 +8,7 @@ describe('toThrowError', function() { }); it('throws an error when the expected is not an Error, string, or RegExp', function() { - const matcher = jasmineUnderTest.matchers.toThrowError(), + const matcher = privateUnderTest.matchers.toThrowError(), fn = function() { throw new Error('foo'); }; @@ -19,7 +19,7 @@ describe('toThrowError', function() { }); it('throws an error when the expected error type is not an Error', function() { - const matcher = jasmineUnderTest.matchers.toThrowError(), + const matcher = privateUnderTest.matchers.toThrowError(), fn = function() { throw new Error('foo'); }; @@ -30,7 +30,7 @@ describe('toThrowError', function() { }); it('throws an error when the expected error message is not a string or RegExp', function() { - const matcher = jasmineUnderTest.matchers.toThrowError(), + const matcher = privateUnderTest.matchers.toThrowError(), fn = function() { throw new Error('foo'); }; @@ -41,7 +41,7 @@ describe('toThrowError', function() { }); it('fails if actual does not throw at all', function() { - const matcher = jasmineUnderTest.matchers.toThrowError(), + const matcher = privateUnderTest.matchers.toThrowError(), fn = function() { return true; }; @@ -53,8 +53,8 @@ describe('toThrowError', function() { }); it('fails if thrown is not an instanceof Error', function() { - const matcher = jasmineUnderTest.matchers.toThrowError({ - pp: jasmineUnderTest.makePrettyPrinter() + const matcher = privateUnderTest.matchers.toThrowError({ + pp: privateUnderTest.makePrettyPrinter() }), fn = function() { throw 4; @@ -85,7 +85,7 @@ describe('toThrowError', function() { pending('This test only runs in browsers.'); } - const matcher = jasmineUnderTest.matchers.toThrowError(); + const matcher = privateUnderTest.matchers.toThrowError(); iframe = document.body.appendChild(document.createElement('iframe')); iframe.src = 'about:blank'; const iframeDocument = iframe.contentWindow.document; @@ -103,8 +103,8 @@ describe('toThrowError', function() { }); it('fails with the correct message if thrown is a falsy value', function() { - const matcher = jasmineUnderTest.matchers.toThrowError({ - pp: jasmineUnderTest.makePrettyPrinter() + const matcher = privateUnderTest.matchers.toThrowError({ + pp: privateUnderTest.makePrettyPrinter() }), fn = function() { throw undefined; @@ -118,7 +118,7 @@ describe('toThrowError', function() { }); it('passes if thrown is a type of Error, but there is no expected error', function() { - const matcher = jasmineUnderTest.matchers.toThrowError(), + const matcher = privateUnderTest.matchers.toThrowError(), fn = function() { throw new TypeError(); }; @@ -132,8 +132,8 @@ describe('toThrowError', function() { }); it('passes if thrown is an Error and the expected is the same message', function() { - const matcher = jasmineUnderTest.matchers.toThrowError({ - pp: jasmineUnderTest.makePrettyPrinter() + const matcher = privateUnderTest.matchers.toThrowError({ + pp: privateUnderTest.makePrettyPrinter() }), fn = function() { throw new Error('foo'); @@ -148,8 +148,8 @@ describe('toThrowError', function() { }); it('fails if thrown is an Error and the expected is not the same message', function() { - const matcher = jasmineUnderTest.matchers.toThrowError({ - pp: jasmineUnderTest.makePrettyPrinter() + const matcher = privateUnderTest.matchers.toThrowError({ + pp: privateUnderTest.makePrettyPrinter() }), fn = function() { throw new Error('foo'); @@ -164,8 +164,8 @@ describe('toThrowError', function() { }); it('passes if thrown is an Error and the expected is a RegExp that matches the message', function() { - const matcher = jasmineUnderTest.matchers.toThrowError({ - pp: jasmineUnderTest.makePrettyPrinter() + const matcher = privateUnderTest.matchers.toThrowError({ + pp: privateUnderTest.makePrettyPrinter() }), fn = function() { throw new Error('a long message'); @@ -180,8 +180,8 @@ describe('toThrowError', function() { }); it('fails if thrown is an Error and the expected is a RegExp that does not match the message', function() { - const matcher = jasmineUnderTest.matchers.toThrowError({ - pp: jasmineUnderTest.makePrettyPrinter() + const matcher = privateUnderTest.matchers.toThrowError({ + pp: privateUnderTest.makePrettyPrinter() }), fn = function() { throw new Error('a long message'); @@ -196,7 +196,7 @@ describe('toThrowError', function() { }); it('passes if thrown is an Error and the expected the same Error', function() { - const matcher = jasmineUnderTest.matchers.toThrowError(), + const matcher = privateUnderTest.matchers.toThrowError(), fn = function() { throw new Error(); }; @@ -208,7 +208,7 @@ describe('toThrowError', function() { }); it('passes if thrown is a custom error that takes arguments and the expected is the same error', function() { - const matcher = jasmineUnderTest.matchers.toThrowError(), + const matcher = privateUnderTest.matchers.toThrowError(), CustomError = function CustomError(arg) { arg.x; }, @@ -227,7 +227,7 @@ describe('toThrowError', function() { }); it('fails if thrown is an Error and the expected is a different Error', function() { - const matcher = jasmineUnderTest.matchers.toThrowError(), + const matcher = privateUnderTest.matchers.toThrowError(), fn = function() { throw new Error(); }; @@ -243,9 +243,9 @@ describe('toThrowError', function() { it('passes if thrown is a type of Error and it is equal to the expected Error and message', function() { const matchersUtil = { equals: jasmine.createSpy('delegated-equal').and.returnValue(true), - pp: jasmineUnderTest.makePrettyPrinter() + pp: privateUnderTest.makePrettyPrinter() }, - matcher = jasmineUnderTest.matchers.toThrowError(matchersUtil), + matcher = privateUnderTest.matchers.toThrowError(matchersUtil), fn = function() { throw new TypeError('foo'); }; @@ -261,9 +261,9 @@ describe('toThrowError', function() { it('passes if thrown is a custom error that takes arguments and it is equal to the expected custom error and message', function() { const matchersUtil = { equals: jasmine.createSpy('delegated-equal').and.returnValue(true), - pp: jasmineUnderTest.makePrettyPrinter() + pp: privateUnderTest.makePrettyPrinter() }, - matcher = jasmineUnderTest.matchers.toThrowError(matchersUtil), + matcher = privateUnderTest.matchers.toThrowError(matchersUtil), CustomError = function CustomError(arg) { this.message = arg.message; }, @@ -285,9 +285,9 @@ describe('toThrowError', function() { it('fails if thrown is a type of Error and the expected is a different Error', function() { const matchersUtil = { equals: jasmine.createSpy('delegated-equal').and.returnValue(false), - pp: jasmineUnderTest.makePrettyPrinter() + pp: privateUnderTest.makePrettyPrinter() }, - matcher = jasmineUnderTest.matchers.toThrowError(matchersUtil), + matcher = privateUnderTest.matchers.toThrowError(matchersUtil), fn = function() { throw new TypeError('foo'); }; @@ -305,9 +305,9 @@ describe('toThrowError', function() { it('fails if thrown is a type of Error and the expected is a different Error', function() { const matchersUtil = { equals: jasmine.createSpy('delegated-equal').and.returnValue(false), - pp: jasmineUnderTest.makePrettyPrinter() + pp: privateUnderTest.makePrettyPrinter() }, - matcher = jasmineUnderTest.matchers.toThrowError(matchersUtil), + matcher = privateUnderTest.matchers.toThrowError(matchersUtil), fn = function() { throw new TypeError('foo'); }; @@ -324,9 +324,9 @@ describe('toThrowError', function() { it('passes if thrown is a type of Error and has the same type as the expected Error and the message matches the expected message', function() { const matchersUtil = { equals: jasmine.createSpy('delegated-equal').and.returnValue(true), - pp: jasmineUnderTest.makePrettyPrinter() + pp: privateUnderTest.makePrettyPrinter() }, - matcher = jasmineUnderTest.matchers.toThrowError(matchersUtil), + matcher = privateUnderTest.matchers.toThrowError(matchersUtil), fn = function() { throw new TypeError('foo'); }; diff --git a/spec/core/matchers/toThrowMatchingSpec.js b/spec/core/matchers/toThrowMatchingSpec.js index 1b5ed44c..7bfa8821 100644 --- a/spec/core/matchers/toThrowMatchingSpec.js +++ b/spec/core/matchers/toThrowMatchingSpec.js @@ -1,6 +1,6 @@ describe('toThrowMatching', function() { it('throws an error when the actual is not a function', function() { - const matcher = jasmineUnderTest.matchers.toThrowMatching(); + const matcher = privateUnderTest.matchers.toThrowMatching(); expect(function() { matcher.compare({}, function() { @@ -10,7 +10,7 @@ describe('toThrowMatching', function() { }); it('throws an error when the expected is not a function', function() { - const matcher = jasmineUnderTest.matchers.toThrowMatching(), + const matcher = privateUnderTest.matchers.toThrowMatching(), fn = function() { throw new Error('foo'); }; @@ -21,7 +21,7 @@ describe('toThrowMatching', function() { }); it('fails if actual does not throw at all', function() { - const matcher = jasmineUnderTest.matchers.toThrowMatching(), + const matcher = privateUnderTest.matchers.toThrowMatching(), fn = function() { return true; }; @@ -35,8 +35,8 @@ describe('toThrowMatching', function() { }); it('fails with the correct message if thrown is a falsy value', function() { - const matcher = jasmineUnderTest.matchers.toThrowMatching({ - pp: jasmineUnderTest.makePrettyPrinter() + const matcher = privateUnderTest.matchers.toThrowMatching({ + pp: privateUnderTest.makePrettyPrinter() }), fn = function() { throw undefined; @@ -52,7 +52,7 @@ describe('toThrowMatching', function() { }); it('passes if the argument is a function that returns true when called with the error', function() { - const matcher = jasmineUnderTest.matchers.toThrowMatching(), + const matcher = privateUnderTest.matchers.toThrowMatching(), predicate = function(e) { return e.message === 'nope'; }, @@ -69,8 +69,8 @@ describe('toThrowMatching', function() { }); it('fails if the argument is a function that returns false when called with the error', function() { - const matcher = jasmineUnderTest.matchers.toThrowMatching({ - pp: jasmineUnderTest.makePrettyPrinter() + const matcher = privateUnderTest.matchers.toThrowMatching({ + pp: privateUnderTest.makePrettyPrinter() }), predicate = function(e) { return e.message === 'oh no'; diff --git a/spec/core/matchers/toThrowSpec.js b/spec/core/matchers/toThrowSpec.js index 3f96010e..386a9dcc 100644 --- a/spec/core/matchers/toThrowSpec.js +++ b/spec/core/matchers/toThrowSpec.js @@ -1,6 +1,6 @@ describe('toThrow', function() { it('throws an error when the actual is not a function', function() { - const matcher = jasmineUnderTest.matchers.toThrow(); + const matcher = privateUnderTest.matchers.toThrow(); expect(function() { matcher.compare({}); @@ -9,7 +9,7 @@ describe('toThrow', function() { }); it('fails if actual does not throw', function() { - const matcher = jasmineUnderTest.matchers.toThrow(), + const matcher = privateUnderTest.matchers.toThrow(), fn = function() { return true; }; @@ -23,9 +23,9 @@ describe('toThrow', function() { it('passes if it throws but there is no expected', function() { const matchersUtil = { equals: jasmine.createSpy('delegated-equal').and.returnValue(true), - pp: jasmineUnderTest.makePrettyPrinter() + pp: privateUnderTest.makePrettyPrinter() }, - matcher = jasmineUnderTest.matchers.toThrow(matchersUtil), + matcher = privateUnderTest.matchers.toThrow(matchersUtil), fn = function() { throw 5; }; @@ -39,8 +39,8 @@ describe('toThrow', function() { }); it('passes even if what is thrown is falsy', function() { - const matcher = jasmineUnderTest.matchers.toThrow({ - pp: jasmineUnderTest.makePrettyPrinter() + const matcher = privateUnderTest.matchers.toThrow({ + pp: privateUnderTest.makePrettyPrinter() }), fn = function() { throw undefined; @@ -56,9 +56,9 @@ describe('toThrow', function() { it('passes if what is thrown is equivalent to what is expected', function() { const matchersUtil = { equals: jasmine.createSpy('delegated-equal').and.returnValue(true), - pp: jasmineUnderTest.makePrettyPrinter() + pp: privateUnderTest.makePrettyPrinter() }, - matcher = jasmineUnderTest.matchers.toThrow(matchersUtil), + matcher = privateUnderTest.matchers.toThrow(matchersUtil), fn = function() { throw 5; }; @@ -72,9 +72,9 @@ describe('toThrow', function() { it('fails if what is thrown is not equivalent to what is expected', function() { const matchersUtil = { equals: jasmine.createSpy('delegated-equal').and.returnValue(false), - pp: jasmineUnderTest.makePrettyPrinter() + pp: privateUnderTest.makePrettyPrinter() }, - matcher = jasmineUnderTest.matchers.toThrow(matchersUtil), + matcher = privateUnderTest.matchers.toThrow(matchersUtil), fn = function() { throw 5; }; @@ -90,9 +90,9 @@ describe('toThrow', function() { it('fails if what is thrown is not equivalent to undefined', function() { const matchersUtil = { equals: jasmine.createSpy('delegated-equal').and.returnValue(false), - pp: jasmineUnderTest.makePrettyPrinter() + pp: privateUnderTest.makePrettyPrinter() }, - matcher = jasmineUnderTest.matchers.toThrow(matchersUtil), + matcher = privateUnderTest.matchers.toThrow(matchersUtil), fn = function() { throw 5; }; diff --git a/spec/helpers/defineJasmineUnderTest.js b/spec/helpers/defineJasmineUnderTest.js index 4996387d..15d35dc6 100644 --- a/spec/helpers/defineJasmineUnderTest.js +++ b/spec/helpers/defineJasmineUnderTest.js @@ -3,4 +3,7 @@ // to the Jasmine source files (and not jasmine.js). So re-require window.jasmineUnderTest = jasmineRequire.core(jasmineRequire); jasmineRequire.html(jasmineUnderTest); + + // Alias the private namespace so tests can be less verbose + window.privateUnderTest = window.jasmineUnderTest.private; })(); diff --git a/spec/helpers/integrationMatchers.js b/spec/helpers/integrationMatchers.js index aea7cc4d..76254bf6 100644 --- a/spec/helpers/integrationMatchers.js +++ b/spec/helpers/integrationMatchers.js @@ -42,9 +42,9 @@ : 'Expected runnable "' + fullName + '" to have failures ' + - jasmine.basicPrettyPrinter_(expectedFailures) + + jasmine.private.basicPrettyPrinter(expectedFailures) + ' but it had ' + - jasmine.basicPrettyPrinter_(foundFailures) + jasmine.private.basicPrettyPrinter(foundFailures) }; } }; diff --git a/spec/helpers/nodeDefineJasmineUnderTest.js b/spec/helpers/nodeDefineJasmineUnderTest.js index 05b6c071..ca9382bf 100644 --- a/spec/helpers/nodeDefineJasmineUnderTest.js +++ b/spec/helpers/nodeDefineJasmineUnderTest.js @@ -24,4 +24,7 @@ global.jasmineUnderTest = jasmineUnderTestRequire.core( jasmineUnderTestRequire ); + + // Alias the private namespace so tests can be less verbose + global.privateUnderTest = global.jasmineUnderTest.private; })(); diff --git a/spec/helpers/resetEnv.js b/spec/helpers/resetEnv.js index af90b4b4..f0572c79 100644 --- a/spec/helpers/resetEnv.js +++ b/spec/helpers/resetEnv.js @@ -1,8 +1,8 @@ beforeEach(function() { // env is stateful. Ensure that it, and its global error event listeners, // do not leak between tests. - if (jasmineUnderTest.currentEnv_) { - jasmineUnderTest.currentEnv_.cleanup_(); - jasmineUnderTest.currentEnv_ = null; + if (privateUnderTest.currentEnv_) { + privateUnderTest.currentEnv_.cleanup_(); + privateUnderTest.currentEnv_ = null; } }); diff --git a/spec/html/HtmlReporterSpec.js b/spec/html/HtmlReporterSpec.js index a62fd187..9a682cb7 100644 --- a/spec/html/HtmlReporterSpec.js +++ b/spec/html/HtmlReporterSpec.js @@ -2,7 +2,7 @@ describe('HtmlReporter', function() { let env; beforeEach(function() { - env = new jasmineUnderTest.Env(); + env = new privateUnderTest.Env(); }); afterEach(function() { diff --git a/spec/html/PrettyPrintHtmlSpec.js b/spec/html/PrettyPrintHtmlSpec.js index e667da8f..120b219b 100644 --- a/spec/html/PrettyPrintHtmlSpec.js +++ b/spec/html/PrettyPrintHtmlSpec.js @@ -1,20 +1,20 @@ describe('PrettyPrinter (HTML Dependent)', function() { it('should stringify non-element HTML nodes properly', function() { const sampleNode = document.createTextNode(''); - const pp = jasmineUnderTest.makePrettyPrinter(); + const pp = privateUnderTest.makePrettyPrinter(); expect(pp(sampleNode)).toEqual('HTMLNode'); expect(pp({ foo: sampleNode })).toEqual('Object({ foo: HTMLNode })'); }); it('should stringify empty HTML elements as their opening tags', function() { const simple = document.createElement('div'); - const pp = jasmineUnderTest.makePrettyPrinter(); + const pp = privateUnderTest.makePrettyPrinter(); simple.className = 'foo'; expect(pp(simple)).toEqual('
'); }); it('should stringify non-empty HTML elements as tags with placeholders', function() { - const pp = jasmineUnderTest.makePrettyPrinter(); + const pp = privateUnderTest.makePrettyPrinter(); const nonEmpty = document.createElement('div'); nonEmpty.className = 'foo'; nonEmpty.innerHTML = '

Irrelevant

'; @@ -23,7 +23,7 @@ describe('PrettyPrinter (HTML Dependent)', function() { it("should print Firefox's wrapped native objects correctly", function() { if (specHelpers.firefoxVersion) { - const pp = jasmineUnderTest.makePrettyPrinter(); + const pp = privateUnderTest.makePrettyPrinter(); let err; try { new CustomEvent(); @@ -38,7 +38,7 @@ describe('PrettyPrinter (HTML Dependent)', function() { }); it('should stringify HTML element with text and attributes', function() { - const pp = jasmineUnderTest.makePrettyPrinter(); + const pp = privateUnderTest.makePrettyPrinter(); const el = document.createElement('div'); el.setAttribute('things', 'foo'); el.innerHTML = 'foo'; diff --git a/spec/html/ResultsNodeSpec.js b/spec/html/ResultsNodeSpec.js index 1869c4a4..f4474d69 100644 --- a/spec/html/ResultsNodeSpec.js +++ b/spec/html/ResultsNodeSpec.js @@ -4,7 +4,7 @@ describe('ResultsNode', function() { id: 123, message: 'foo' }, - node = new jasmineUnderTest.ResultsNode(fakeResult, 'suite', null); + node = new privateUnderTest.ResultsNode(fakeResult, 'suite', null); expect(node.result).toBe(fakeResult); expect(node.type).toEqual('suite'); @@ -19,7 +19,7 @@ describe('ResultsNode', function() { id: 456, message: 'bar' }, - node = new jasmineUnderTest.ResultsNode(fakeResult, 'suite', null); + node = new privateUnderTest.ResultsNode(fakeResult, 'suite', null); node.addChild(fakeChildResult, 'spec'); @@ -37,7 +37,7 @@ describe('ResultsNode', function() { id: 456, message: 'bar' }, - node = new jasmineUnderTest.ResultsNode(fakeResult, 'suite', null); + node = new privateUnderTest.ResultsNode(fakeResult, 'suite', null); node.addChild(fakeChildResult, 'spec'); @@ -53,7 +53,7 @@ describe('ResultsNode', function() { id: 456, message: 'bar' }, - node = new jasmineUnderTest.ResultsNode(fakeResult, 'suite', null); + node = new privateUnderTest.ResultsNode(fakeResult, 'suite', null); node.addChild(fakeChildResult, 'spec'); diff --git a/spec/html/SpyRegistryHtmlSpec.js b/spec/html/SpyRegistryHtmlSpec.js index 3298fedc..5347a6d1 100644 --- a/spec/html/SpyRegistryHtmlSpec.js +++ b/spec/html/SpyRegistryHtmlSpec.js @@ -1,11 +1,11 @@ describe('Spy Registry browser-specific behavior', function() { function createSpy(name, originalFn) { - return jasmineUnderTest.Spy(name, originalFn); + return privateUnderTest.Spy(name, originalFn); } it('can spy on and unspy window.onerror', function() { const spies = [], - spyRegistry = new jasmineUnderTest.SpyRegistry({ + spyRegistry = new privateUnderTest.SpyRegistry({ currentSpies: function() { return spies; }, diff --git a/src/core/CallTracker.js b/src/core/CallTracker.js index ac5f0763..403eaef4 100644 --- a/src/core/CallTracker.js +++ b/src/core/CallTracker.js @@ -123,7 +123,9 @@ 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$.util.cloneArgs) { + this.saveArgumentsByValue = function( + argsCloner = j$.private.util.cloneArgs + ) { opts.cloneArgs = true; opts.argsCloner = argsCloner; }; diff --git a/src/core/Deprecator.js b/src/core/Deprecator.js index 5d4e1f57..e4bff4e9 100644 --- a/src/core/Deprecator.js +++ b/src/core/Deprecator.js @@ -23,7 +23,7 @@ getJasmineRequireObj().Deprecator = function(j$) { ) { options = options || {}; - if (!this.verbose_ && !j$.isError_(deprecation)) { + if (!this.verbose_ && !j$.private.isError(deprecation)) { if (this.toSuppress_.indexOf(deprecation) !== -1) { return; } @@ -35,7 +35,7 @@ getJasmineRequireObj().Deprecator = function(j$) { }; Deprecator.prototype.log_ = function(runnable, deprecation, options) { - if (j$.isError_(deprecation)) { + if (j$.private.isError(deprecation)) { // eslint-disable-next-line no-console console.error(deprecation); return; @@ -64,7 +64,7 @@ getJasmineRequireObj().Deprecator = function(j$) { }; Deprecator.prototype.stackTrace_ = function() { - const formatter = new j$.ExceptionFormatter(); + const formatter = new j$.private.ExceptionFormatter(); return formatter.stack(new Error()).replace(/^Error\n/m, ''); }; @@ -73,7 +73,7 @@ getJasmineRequireObj().Deprecator = function(j$) { runnable = this.topSuite_; } - if (j$.isError_(deprecation)) { + if (j$.private.isError(deprecation)) { runnable.addDeprecationWarning(deprecation); return; } diff --git a/src/core/Env.js b/src/core/Env.js index 7cbc61fd..cf33696a 100644 --- a/src/core/Env.js +++ b/src/core/Env.js @@ -11,18 +11,18 @@ getJasmineRequireObj().Env = function(j$) { envOptions = envOptions || {}; const self = this; - const GlobalErrors = envOptions.GlobalErrors || j$.GlobalErrors; + const GlobalErrors = envOptions.GlobalErrors || j$.private.GlobalErrors; const global = envOptions.global || j$.getGlobal(); const realSetTimeout = global.setTimeout; const realClearTimeout = global.clearTimeout; - const clearStack = j$.getClearStack(global); - this.clock = new j$.Clock( + const clearStack = j$.private.getClearStack(global); + this.clock = new j$.private.Clock( global, function() { - return new j$.DelayedFunctionScheduler(); + return new j$.private.DelayedFunctionScheduler(); }, - new j$.MockDate(global) + new j$.private.MockDate(global) ); const globalErrors = new GlobalErrors( @@ -50,7 +50,7 @@ getJasmineRequireObj().Env = function(j$) { }; })(); - const runableResources = new j$.RunableResources({ + const runableResources = new j$.private.RunableResources({ getCurrentRunableId: function() { const r = runner.currentRunable(); return r ? r.id : null; @@ -63,7 +63,7 @@ getJasmineRequireObj().Env = function(j$) { let runner; let parallelLoadingState = null; // 'specs', 'helpers', or null for non-parallel - const config = new j$.Configuration(); + const config = new j$.private.Configuration(); if (!envOptions.suppressLoadErrors) { installGlobalErrors(); @@ -132,11 +132,11 @@ getJasmineRequireObj().Env = function(j$) { runableResources.customObjectFormatters().push(formatter); }; - j$.Expectation.addCoreMatchers(j$.matchers); - j$.Expectation.addAsyncCoreMatchers(j$.asyncMatchers); + j$.private.Expectation.addCoreMatchers(j$.private.matchers); + j$.private.Expectation.addAsyncCoreMatchers(j$.private.asyncMatchers); const expectationFactory = function(actual, spec) { - return j$.Expectation.factory({ + return j$.private.Expectation.factory({ matchersUtil: runableResources.makeMatchersUtil(), customMatchers: runableResources.customMatchers(), actual: actual, @@ -169,7 +169,7 @@ getJasmineRequireObj().Env = function(j$) { }; const throwUnlessFactory = function(actual, spec) { - return j$.Expectation.factory({ + return j$.private.Expectation.factory({ matchersUtil: runableResources.makeMatchersUtil(), customMatchers: runableResources.customMatchers(), actual: actual, @@ -178,7 +178,7 @@ getJasmineRequireObj().Env = function(j$) { }; const throwUnlessAsyncFactory = function(actual, spec) { - return j$.Expectation.asyncFactory({ + return j$.private.Expectation.asyncFactory({ matchersUtil: runableResources.makeMatchersUtil(), customAsyncMatchers: runableResources.customAsyncMatchers(), actual: actual, @@ -193,7 +193,7 @@ getJasmineRequireObj().Env = function(j$) { error.matcherName !== undefined && error.passed !== undefined; const result = isExpectationResult ? error - : j$.buildExpectationResult({ + : j$.private.buildExpectationResult({ error, passed: false, matcherName: '', @@ -254,7 +254,7 @@ getJasmineRequireObj().Env = function(j$) { } const asyncExpectationFactory = function(actual, spec, runableType) { - return j$.Expectation.asyncFactory({ + return j$.private.Expectation.asyncFactory({ matchersUtil: runableResources.makeMatchersUtil(), customAsyncMatchers: runableResources.customAsyncMatchers(), actual: actual, @@ -310,10 +310,10 @@ getJasmineRequireObj().Env = function(j$) { (runner.currentRunable() || topSuite).handleException(e); }; - new j$.QueueRunner(options).execute(); + new j$.private.QueueRunner(options).execute(); } - const suiteBuilder = new j$.SuiteBuilder({ + const suiteBuilder = new j$.private.SuiteBuilder({ env: this, expectationFactory, asyncExpectationFactory, @@ -321,7 +321,7 @@ getJasmineRequireObj().Env = function(j$) { runQueue }); topSuite = suiteBuilder.topSuite; - const deprecator = new j$.Deprecator(topSuite); + const deprecator = new j$.private.Deprecator(topSuite); /** * Provides the root suite, through which all suites and specs can be @@ -341,23 +341,23 @@ getJasmineRequireObj().Env = function(j$) { * @interface Reporter * @see custom_reporter */ - reportDispatcher = new j$.ReportDispatcher( - j$.reporterEvents, + reportDispatcher = new j$.private.ReportDispatcher( + j$.private.reporterEvents, function(options) { - options.SkipPolicy = j$.NeverSkipPolicy; + options.SkipPolicy = j$.private.NeverSkipPolicy; return runQueue(options); }, recordLateError ); - runner = new j$.Runner({ + runner = new j$.private.Runner({ topSuite, totalSpecsDefined: () => suiteBuilder.totalSpecsDefined, focusedRunables: () => suiteBuilder.focusedRunables, runableResources, reportDispatcher, runQueue, - TreeProcessor: j$.TreeProcessor, + TreeProcessor: j$.private.TreeProcessor, globalErrors, getConfig: () => config }); @@ -523,7 +523,7 @@ getJasmineRequireObj().Env = function(j$) { try { const maybePromise = fn(spy); - if (!j$.isPromiseLike(maybePromise)) { + if (!j$.private.isPromiseLike(maybePromise)) { throw new Error( 'The callback to spyOnGlobalErrorsAsync must be an async or promise-returning function' ); @@ -758,7 +758,7 @@ getJasmineRequireObj().Env = function(j$) { }; this.pending = function(message) { - let fullMessage = j$.Spec.pendingSpecExceptionMessage; + let fullMessage = j$.private.Spec.pendingSpecExceptionMessage; if (message) { fullMessage += message; } @@ -777,7 +777,7 @@ getJasmineRequireObj().Env = function(j$) { message += ': '; if (error.message) { message += error.message; - } else if (j$.isString_(error)) { + } else if (j$.private.isString(error)) { message += error; } else { // pretty print all kind of objects. This includes arrays. @@ -806,7 +806,7 @@ getJasmineRequireObj().Env = function(j$) { } function callerCallerFilename() { - const frames = new j$.StackTrace(new Error()).frames; + const frames = new j$.private.StackTrace(new Error()).frames; // frames[3] should always exist except in Jasmine's own tests, which bypass // the global it/describe layer, but don't crash if it doesn't. return frames[3] && frames[3].file; diff --git a/src/core/ExceptionFormatter.js b/src/core/ExceptionFormatter.js index c2d6710a..cedc76e3 100644 --- a/src/core/ExceptionFormatter.js +++ b/src/core/ExceptionFormatter.js @@ -14,7 +14,7 @@ getJasmineRequireObj().ExceptionFormatter = function(j$) { function ExceptionFormatter(options) { const jasmineFile = - (options && options.jasmineFile) || j$.util.jasmineFile(); + (options && options.jasmineFile) || j$.private.util.jasmineFile(); this.message = function(error) { let message = ''; @@ -58,7 +58,7 @@ getJasmineRequireObj().ExceptionFormatter = function(j$) { lines.pop(); } - const stackTrace = new j$.StackTrace(error); + const stackTrace = new j$.private.StackTrace(error); lines = lines.concat(filterJasmine(stackTrace)); if (messageHandling === 'require') { @@ -111,7 +111,9 @@ getJasmineRequireObj().ExceptionFormatter = function(j$) { } if (!empty) { - return 'error properties: ' + j$.basicPrettyPrinter_(result) + '\n'; + return ( + 'error properties: ' + j$.private.basicPrettyPrinter(result) + '\n' + ); } return ''; diff --git a/src/core/Expectation.js b/src/core/Expectation.js index 8d3950dc..00360404 100644 --- a/src/core/Expectation.js +++ b/src/core/Expectation.js @@ -4,7 +4,7 @@ getJasmineRequireObj().Expectation = function(j$) { * @namespace matchers */ function Expectation(options) { - this.expector = new j$.Expector(options); + this.expector = new j$.private.Expector(options); const customMatchers = options.customMatchers || {}; for (const matcherName in customMatchers) { @@ -80,7 +80,7 @@ getJasmineRequireObj().Expectation = function(j$) { * @namespace async-matchers */ function AsyncExpectation(options) { - this.expector = new j$.Expector(options); + this.expector = new j$.private.Expector(options); const customAsyncMatchers = options.customAsyncMatchers || {}; for (const matcherName in customAsyncMatchers) { @@ -173,7 +173,7 @@ getJasmineRequireObj().Expectation = function(j$) { function negatedFailureMessage(result, matcherName, args, matchersUtil) { if (result.message) { - if (j$.isFunction_(result.message)) { + if (j$.private.isFunction(result.message)) { return result.message(); } else { return result.message; @@ -218,7 +218,7 @@ getJasmineRequireObj().Expectation = function(j$) { return function(actual) { const matcherArgs = arguments; - return j$.isPending_(actual).then(function(isPending) { + return j$.private.isPending(actual).then(function(isPending) { if (isPending) { return { pass: false, diff --git a/src/core/Expector.js b/src/core/Expector.js index 01802f24..a5ddeabf 100644 --- a/src/core/Expector.js +++ b/src/core/Expector.js @@ -5,7 +5,7 @@ getJasmineRequireObj().Expector = function(j$) { }; this.actual = options.actual; this.addExpectationResult = options.addExpectationResult || function() {}; - this.filters = new j$.ExpectationFilterChain(); + this.filters = new j$.private.ExpectationFilterChain(); } Expector.prototype.instantiateMatcher = function( @@ -39,7 +39,7 @@ getJasmineRequireObj().Expector = function(j$) { this.matchersUtil, args ); - } else if (j$.isFunction_(result.message)) { + } else if (j$.private.isFunction(result.message)) { return result.message(); } else { return result.message; diff --git a/src/core/GlobalErrors.js b/src/core/GlobalErrors.js index 27af0128..ec167ae5 100644 --- a/src/core/GlobalErrors.js +++ b/src/core/GlobalErrors.js @@ -24,7 +24,7 @@ getJasmineRequireObj().GlobalErrors = function(j$) { if ( global.process && global.process.listeners && - j$.isFunction_(global.process.on) + j$.private.isFunction(global.process.on) ) { this.#adapter = new NodeAdapter(global, dispatch); } else { @@ -173,7 +173,7 @@ getJasmineRequireObj().GlobalErrors = function(j$) { const jasmineMessage = 'Unhandled promise rejection: ' + event.reason; let reason; - if (j$.isError_(event.reason)) { + if (j$.private.isError(event.reason)) { reason = event.reason; reason.jasmineMessage = jasmineMessage; } else { @@ -252,7 +252,7 @@ getJasmineRequireObj().GlobalErrors = function(j$) { jasmineMessagePrefix = 'Uncaught exception'; } - if (j$.isError_(error)) { + if (j$.private.isError(error)) { error.jasmineMessage = jasmineMessagePrefix + ': ' + error; return error; } else { diff --git a/src/core/ParallelReportDispatcher.js b/src/core/ParallelReportDispatcher.js index db673065..c6491d21 100644 --- a/src/core/ParallelReportDispatcher.js +++ b/src/core/ParallelReportDispatcher.js @@ -16,11 +16,12 @@ 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$.ReportDispatcher; - const QueueRunner = deps.QueueRunner || j$.QueueRunner; - const globalErrors = deps.globalErrors || new j$.GlobalErrors(); + const ReportDispatcher = + deps.ReportDispatcher || j$.private.ReportDispatcher; + const QueueRunner = deps.QueueRunner || j$.private.QueueRunner; + const globalErrors = deps.globalErrors || new j$.private.GlobalErrors(); const dispatcher = new ReportDispatcher( - j$.reporterEvents, + j$.private.reporterEvents, function(queueRunnerOptions) { queueRunnerOptions = { ...queueRunnerOptions, @@ -84,7 +85,7 @@ getJasmineRequireObj().ParallelReportDispatcher = function(j$) { } }; - for (const eventName of j$.reporterEvents) { + for (const eventName of j$.private.reporterEvents) { self[eventName] = dispatcher[eventName].bind(dispatcher); } diff --git a/src/core/PrettyPrinter.js b/src/core/PrettyPrinter.js index 5489f910..7ee38566 100644 --- a/src/core/PrettyPrinter.js +++ b/src/core/PrettyPrinter.js @@ -26,7 +26,7 @@ getJasmineRequireObj().makePrettyPrinter = function(j$) { this.emitScalar(''); } else if (value.jasmineToString) { this.emitScalar(value.jasmineToString(this.pp_)); - } else if (j$.isString_(value)) { + } else if (j$.private.isString(value)) { this.emitString(value); } else if (j$.isSpy(value)) { this.emitScalar('spy on ' + value.and.identity); @@ -40,7 +40,7 @@ getJasmineRequireObj().makePrettyPrinter = function(j$) { } else { this.emitScalar('Function'); } - } else if (j$.isDomNode(value)) { + } else if (j$.private.isDomNode(value)) { if (value.tagName) { this.emitDomElement(value); } else { @@ -48,16 +48,16 @@ getJasmineRequireObj().makePrettyPrinter = function(j$) { } } else if (value instanceof Date) { this.emitScalar('Date(' + value + ')'); - } else if (j$.isSet(value)) { + } else if (j$.private.isSet(value)) { this.emitSet(value); - } else if (j$.isMap(value)) { + } else if (j$.private.isMap(value)) { this.emitMap(value); - } else if (j$.isTypedArray_(value)) { + } else if (j$.private.isTypedArray(value)) { this.emitTypedArray(value); } else if ( value.toString && typeof value === 'object' && - !j$.isArray_(value) && + !j$.private.isArray(value) && hasCustomToString(value) ) { try { @@ -69,12 +69,15 @@ getJasmineRequireObj().makePrettyPrinter = function(j$) { } else if (this.seen.includes(value)) { this.emitScalar( '' ); - } else if (j$.isArray_(value) || j$.isA_('Object', value)) { + } else if ( + j$.private.isArray(value) || + j$.private.isA('Object', value) + ) { this.seen.push(value); - if (j$.isArray_(value)) { + if (j$.private.isArray(value)) { this.emitArray(value); } else { this.emitObject(value); @@ -97,7 +100,10 @@ getJasmineRequireObj().makePrettyPrinter = function(j$) { } iterateObject(obj, fn) { - const objKeys = j$.MatchersUtil.keys(obj, j$.isArray_(obj)); + const objKeys = j$.private.MatchersUtil.keys( + obj, + j$.private.isArray(obj) + ); const length = Math.min(objKeys.length, j$.MAX_PRETTY_PRINT_ARRAY_LENGTH); for (let i = 0; i < length; i++) { @@ -206,7 +212,7 @@ getJasmineRequireObj().makePrettyPrinter = function(j$) { const ctor = obj.constructor; const constructorName = typeof ctor === 'function' && obj instanceof ctor - ? j$.fnNameFor(obj.constructor) + ? j$.private.fnNameFor(obj.constructor) : 'null'; this.append(constructorName); @@ -236,7 +242,7 @@ getJasmineRequireObj().makePrettyPrinter = function(j$) { } emitTypedArray(arr) { - const constructorName = j$.fnNameFor(arr.constructor); + const constructorName = j$.private.fnNameFor(arr.constructor); const limitedArray = Array.prototype.slice.call( arr, 0, @@ -305,7 +311,7 @@ getJasmineRequireObj().makePrettyPrinter = function(j$) { // iframe, web worker) try { return ( - j$.isFunction_(value.toString) && + j$.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 87d3ee10..5a339157 100644 --- a/src/core/QueueRunner.js +++ b/src/core/QueueRunner.js @@ -3,7 +3,7 @@ getJasmineRequireObj().QueueRunner = function(j$) { function StopExecutionError() {} StopExecutionError.prototype = new Error(); - j$.StopExecutionError = StopExecutionError; + j$.private.StopExecutionError = StopExecutionError; function once(fn, onTwice) { let called = false; @@ -56,7 +56,7 @@ getJasmineRequireObj().QueueRunner = function(j$) { }; this.onException = attrs.onException || emptyFn; this.onMultipleDone = attrs.onMultipleDone || fallbackOnMultipleDone; - this.userContext = attrs.userContext || new j$.UserContext(); + this.userContext = attrs.userContext || new j$.private.UserContext(); this.timeout = attrs.timeout || { setTimeout: setTimeout, clearTimeout: clearTimeout @@ -67,7 +67,7 @@ getJasmineRequireObj().QueueRunner = function(j$) { popListener: emptyFn }; - const SkipPolicy = attrs.SkipPolicy || j$.NeverSkipPolicy; + const SkipPolicy = attrs.SkipPolicy || j$.private.NeverSkipPolicy; this.skipPolicy_ = new SkipPolicy(this.queueableFns); this.errored_ = false; @@ -190,7 +190,7 @@ getJasmineRequireObj().QueueRunner = function(j$) { if (queueableFn.fn.length === 0) { maybeThenable = queueableFn.fn.call(this.userContext); - if (maybeThenable && j$.isFunction_(maybeThenable.then)) { + if (maybeThenable && j$.private.isFunction(maybeThenable.then)) { maybeThenable.then( wrapInPromiseResolutionHandler(next), onPromiseRejection @@ -260,11 +260,11 @@ getJasmineRequireObj().QueueRunner = function(j$) { }; QueueRunner.prototype.diagnoseConflictingAsync_ = function(fn, retval) { - if (retval && j$.isFunction_(retval.then)) { + if (retval && j$.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$.isAsyncFunction_(fn)) { + if (j$.private.isAsyncFunction(fn)) { this.onException( new Error( 'An asynchronous before/it/after ' + @@ -288,7 +288,7 @@ getJasmineRequireObj().QueueRunner = function(j$) { function wrapInPromiseResolutionHandler(fn) { return function(maybeArg) { - if (j$.isError_(maybeArg)) { + if (j$.private.isError(maybeArg)) { fn(maybeArg); } else { fn(); diff --git a/src/core/RunableResources.js b/src/core/RunableResources.js index 33e8b025..ae1ce6a8 100644 --- a/src/core/RunableResources.js +++ b/src/core/RunableResources.js @@ -5,7 +5,7 @@ getJasmineRequireObj().RunableResources = function(j$) { this.getCurrentRunableId_ = options.getCurrentRunableId; this.globalErrors_ = options.globalErrors; - this.spyFactory = new j$.SpyFactory( + this.spyFactory = new j$.private.SpyFactory( () => { if (this.getCurrentRunableId_()) { return this.customSpyStrategies(); @@ -17,7 +17,7 @@ getJasmineRequireObj().RunableResources = function(j$) { () => this.makeMatchersUtil() ); - this.spyRegistry = new j$.SpyRegistry({ + this.spyRegistry = new j$.private.SpyRegistry({ currentSpies: () => this.spies(), createSpy: (name, originalFn) => this.spyFactory.createSpy(name, originalFn) @@ -48,7 +48,7 @@ getJasmineRequireObj().RunableResources = function(j$) { ]; for (const k of toClone) { - newRes[k] = j$.util.clone(parentRes[k]); + newRes[k] = j$.private.util.clone(parentRes[k]); } } } @@ -126,17 +126,19 @@ getJasmineRequireObj().RunableResources = function(j$) { } makePrettyPrinter() { - return j$.makePrettyPrinter(this.customObjectFormatters()); + return j$.private.makePrettyPrinter(this.customObjectFormatters()); } makeMatchersUtil() { if (this.getCurrentRunableId_()) { - return new j$.MatchersUtil({ + return new j$.private.MatchersUtil({ customTesters: this.customEqualityTesters(), pp: this.makePrettyPrinter() }); } else { - return new j$.MatchersUtil({ pp: j$.basicPrettyPrinter_ }); + return new j$.private.MatchersUtil({ + pp: j$.private.basicPrettyPrinter + }); } } diff --git a/src/core/Runner.js b/src/core/Runner.js index 8e06e8b6..9c71d7e5 100644 --- a/src/core/Runner.js +++ b/src/core/Runner.js @@ -24,7 +24,7 @@ getJasmineRequireObj().Runner = function(j$) { this.#reportDispatcher = options.reportDispatcher; this.#getConfig = options.getConfig; this.#executedBefore = false; - this.#currentRunableTracker = new j$.CurrentRunableTracker(); + this.#currentRunableTracker = new j$.private.CurrentRunableTracker(); } currentSpec() { @@ -64,9 +64,9 @@ getJasmineRequireObj().Runner = function(j$) { } } - const order = new j$.Order({ + const order = new j$.private.Order({ random: config.random, - seed: j$.isNumber_(config.seed) ? config.seed + '' : config.seed + seed: j$.private.isNumber(config.seed) ? config.seed + '' : config.seed }); const treeProcessor = new this.#TreeProcessor({ @@ -108,7 +108,7 @@ getJasmineRequireObj().Runner = function(j$) { }); this.#currentRunableTracker.pushSuite(this.#topSuite); - const treeRunner = new j$.TreeRunner({ + const treeRunner = new j$.private.TreeRunner({ executionTree: this.#executionTree, globalErrors: this.#globalErrors, runableResources: this.#runableResources, diff --git a/src/core/Spec.js b/src/core/Spec.js index 56d572bf..2f3202d8 100644 --- a/src/core/Spec.js +++ b/src/core/Spec.js @@ -43,7 +43,7 @@ getJasmineRequireObj().Spec = function(j$) { } addExpectationResult(passed, data, isError) { - const expectationResult = j$.buildExpectationResult(data); + const expectationResult = j$.private.buildExpectationResult(data); if (passed) { this.result.passedExpectations.push(expectationResult); @@ -60,7 +60,7 @@ getJasmineRequireObj().Spec = function(j$) { } if (this.#throwOnExpectationFailure && !isError) { - throw new j$.errors.ExpectationFailed(); + throw new j$.private.errors.ExpectationFailed(); } } } @@ -74,8 +74,8 @@ 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. - j$.util.assertStructuredCloneable(key, 'Key'); - j$.util.assertStructuredCloneable(value, 'Value'); + j$.private.util.assertStructuredCloneable(key, 'Key'); + j$.private.util.assertStructuredCloneable(value, 'Value'); this.result.properties = this.result.properties || {}; this.result.properties[key] = value; } @@ -194,7 +194,7 @@ getJasmineRequireObj().Spec = function(j$) { return; } - if (e instanceof j$.errors.ExpectationFailed) { + if (e instanceof j$.private.errors.ExpectationFailed) { return; } @@ -264,7 +264,7 @@ getJasmineRequireObj().Spec = function(j$) { deprecation = { message: deprecation }; } this.result.deprecationWarnings.push( - j$.buildExpectationResult(deprecation) + j$.private.buildExpectationResult(deprecation) ); } diff --git a/src/core/Spy.js b/src/core/Spy.js index 41180f42..73d7c248 100644 --- a/src/core/Spy.js +++ b/src/core/Spy.js @@ -53,7 +53,7 @@ getJasmineRequireObj().Spy = function(j$) { }, matchersUtil ), - callTracker = new j$.CallTracker(); + callTracker = new j$.private.CallTracker(); function makeFunc(length, fn) { switch (length) { @@ -145,9 +145,9 @@ getJasmineRequireObj().Spy = function(j$) { } function SpyStrategyDispatcher(strategyArgs, matchersUtil) { - const baseStrategy = new j$.SpyStrategy(strategyArgs); + const baseStrategy = new j$.private.SpyStrategy(strategyArgs); const argsStrategies = new StrategyDict(function() { - return new j$.SpyStrategy(strategyArgs); + return new j$.private.SpyStrategy(strategyArgs); }, matchersUtil); this.and = baseStrategy; diff --git a/src/core/SpyFactory.js b/src/core/SpyFactory.js index 512a8912..51f89400 100644 --- a/src/core/SpyFactory.js +++ b/src/core/SpyFactory.js @@ -5,12 +5,12 @@ getJasmineRequireObj().SpyFactory = function(j$) { getMatchersUtil ) { this.createSpy = function(name, originalFn) { - if (j$.isFunction_(name) && originalFn === undefined) { + if (j$.private.isFunction(name) && originalFn === undefined) { originalFn = name; name = originalFn.name; } - return j$.Spy(name, getMatchersUtil(), { + return j$.private.Spy(name, getMatchersUtil(), { originalFn, customStrategies: getCustomStrategies(), defaultStrategyFn: getDefaultStrategyFn() @@ -19,7 +19,7 @@ getJasmineRequireObj().SpyFactory = function(j$) { this.createSpyObj = function(baseName, methodNames, propertyNames) { const baseNameIsCollection = - j$.isObject_(baseName) || j$.isArray_(baseName); + j$.private.isObject(baseName) || j$.private.isArray(baseName); if (baseNameIsCollection) { propertyNames = methodNames; @@ -65,11 +65,11 @@ getJasmineRequireObj().SpyFactory = function(j$) { function normalizeKeyValues(object) { const result = []; - if (j$.isArray_(object)) { + if (j$.private.isArray(object)) { for (let i = 0; i < object.length; i++) { result.push([object[i]]); } - } else if (j$.isObject_(object)) { + } else if (j$.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 b4a246da..b4d06b69 100644 --- a/src/core/SpyRegistry.js +++ b/src/core/SpyRegistry.js @@ -1,9 +1,9 @@ getJasmineRequireObj().SpyRegistry = function(j$) { - const spyOnMsg = j$.formatErrorMsg( + const spyOnMsg = j$.private.formatErrorMsg( '', 'spyOn(, )' ); - const spyOnPropertyMsg = j$.formatErrorMsg( + const spyOnPropertyMsg = j$.private.formatErrorMsg( '', 'spyOnProperty(, , [accessType])' ); @@ -43,7 +43,10 @@ getJasmineRequireObj().SpyRegistry = function(j$) { // Spying on mock clock timing fns would prevent the real ones from being // restored. - if (obj[methodName] && obj[methodName][j$.Clock.IsMockClockTimingFn]) { + if ( + obj[methodName] && + obj[methodName][j$.private.Clock.IsMockClockTimingFn] + ) { throw new Error("Mock clock timing functions can't be spied on"); } @@ -94,7 +97,7 @@ getJasmineRequireObj().SpyRegistry = function(j$) { // localStorage in Firefox and later Safari versions, have no-op setters. if (obj[methodName] !== spiedMethod) { throw new Error( - j$.formatErrorMsg('')( + j$.private.formatErrorMsg('')( `Can't spy on ${methodName} because assigning to it had no effect` ) ); @@ -122,7 +125,10 @@ getJasmineRequireObj().SpyRegistry = function(j$) { throw new Error(getErrorMsg('No property name supplied')); } - const descriptor = j$.util.getPropertyDescriptor(obj, propertyName); + const descriptor = j$.private.util.getPropertyDescriptor( + obj, + propertyName + ); if (!descriptor) { throw new Error(getErrorMsg(propertyName + ' property does not exist')); @@ -157,7 +163,7 @@ getJasmineRequireObj().SpyRegistry = function(j$) { } } - const originalDescriptor = j$.util.clone(descriptor); + const originalDescriptor = j$.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 d2e50388..b3f79bb5 100644 --- a/src/core/SpyStrategy.js +++ b/src/core/SpyStrategy.js @@ -19,7 +19,7 @@ getJasmineRequireObj().SpyStrategy = function(j$) { const cs = options.customStrategies || {}; for (const k in cs) { - if (j$.util.has(cs, k) && !this[k]) { + if (j$.private.util.has(cs, k) && !this[k]) { this[k] = createCustomPlan(cs[k]); } } @@ -57,7 +57,7 @@ getJasmineRequireObj().SpyStrategy = function(j$) { return function() { const plan = factory.apply(null, arguments); - if (!j$.isFunction_(plan)) { + if (!j$.private.isFunction(plan)) { throw new Error('Spy strategy must return a function'); } @@ -129,7 +129,9 @@ getJasmineRequireObj().SpyStrategy = function(j$) { * @param {Error|Object|String} something Thing to throw */ SpyStrategy.prototype.throwError = function(something) { - const error = j$.isString_(something) ? new Error(something) : something; + const error = j$.private.isString(something) + ? new Error(something) + : something; this.plan = function() { throw error; }; @@ -146,9 +148,9 @@ getJasmineRequireObj().SpyStrategy = function(j$) { SpyStrategy.prototype.callFake = function(fn) { if ( !( - j$.isFunction_(fn) || - j$.isAsyncFunction_(fn) || - j$.isGeneratorFunction_(fn) + j$.private.isFunction(fn) || + j$.private.isAsyncFunction(fn) || + j$.private.isGeneratorFunction(fn) ) ) { throw new Error( diff --git a/src/core/Suite.js b/src/core/Suite.js index 4a75565f..62a91216 100644 --- a/src/core/Suite.js +++ b/src/core/Suite.js @@ -34,8 +34,8 @@ 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. - j$.util.assertStructuredCloneable(key, 'Key'); - j$.util.assertStructuredCloneable(value, 'Value'); + j$.private.util.assertStructuredCloneable(key, 'Key'); + j$.private.util.assertStructuredCloneable(value, 'Value'); this.result.properties = this.result.properties || {}; this.result.properties[key] = value; } @@ -170,18 +170,18 @@ getJasmineRequireObj().Suite = function(j$) { if (!this.sharedContext) { this.sharedContext = this.parentSuite ? this.parentSuite.clonedSharedUserContext() - : new j$.UserContext(); + : new j$.private.UserContext(); } return this.sharedContext; } clonedSharedUserContext() { - return j$.UserContext.fromExisting(this.sharedUserContext()); + return j$.private.UserContext.fromExisting(this.sharedUserContext()); } handleException() { - if (arguments[0] instanceof j$.errors.ExpectationFailed) { + if (arguments[0] instanceof j$.private.errors.ExpectationFailed) { return; } @@ -190,7 +190,7 @@ getJasmineRequireObj().Suite = function(j$) { passed: false, error: arguments[0] }; - const failedExpectation = j$.buildExpectationResult(data); + const failedExpectation = j$.private.buildExpectationResult(data); if (!this.parentSuite) { failedExpectation.globalErrorType = 'afterAll'; @@ -232,7 +232,7 @@ getJasmineRequireObj().Suite = function(j$) { return; } - const expectationResult = j$.buildExpectationResult(data); + const expectationResult = j$.private.buildExpectationResult(data); if (this.reportedDone) { this.onLateError(expectationResult); @@ -246,7 +246,7 @@ getJasmineRequireObj().Suite = function(j$) { } if (this.#throwOnExpectationFailure) { - throw new j$.errors.ExpectationFailed(); + throw new j$.private.errors.ExpectationFailed(); } } @@ -255,7 +255,7 @@ getJasmineRequireObj().Suite = function(j$) { deprecation = { message: deprecation }; } this.result.deprecationWarnings.push( - j$.buildExpectationResult(deprecation) + j$.private.buildExpectationResult(deprecation) ); } diff --git a/src/core/SuiteBuilder.js b/src/core/SuiteBuilder.js index 76b45b3d..d3738969 100644 --- a/src/core/SuiteBuilder.js +++ b/src/core/SuiteBuilder.js @@ -92,7 +92,7 @@ getJasmineRequireObj().SuiteBuilder = function(j$) { ensureIsFunctionOrAsync(fn, 'fit'); if (timeout) { - j$.util.validateTimeout(timeout); + j$.private.util.validateTimeout(timeout); } const spec = this.specFactory_(description, fn, timeout, filename); this.currentDeclarationSuite_.addChild(spec); @@ -105,7 +105,7 @@ getJasmineRequireObj().SuiteBuilder = function(j$) { ensureIsFunctionOrAsync(beforeEachFunction, 'beforeEach'); if (timeout) { - j$.util.validateTimeout(timeout); + j$.private.util.validateTimeout(timeout); } this.currentDeclarationSuite_.beforeEach({ @@ -118,7 +118,7 @@ getJasmineRequireObj().SuiteBuilder = function(j$) { ensureIsFunctionOrAsync(beforeAllFunction, 'beforeAll'); if (timeout) { - j$.util.validateTimeout(timeout); + j$.private.util.validateTimeout(timeout); } this.currentDeclarationSuite_.beforeAll({ @@ -131,7 +131,7 @@ getJasmineRequireObj().SuiteBuilder = function(j$) { ensureIsFunctionOrAsync(afterEachFunction, 'afterEach'); if (timeout) { - j$.util.validateTimeout(timeout); + j$.private.util.validateTimeout(timeout); } afterEachFunction.isCleanup = true; @@ -145,7 +145,7 @@ getJasmineRequireObj().SuiteBuilder = function(j$) { ensureIsFunctionOrAsync(afterAllFunction, 'afterAll'); if (timeout) { - j$.util.validateTimeout(timeout); + j$.private.util.validateTimeout(timeout); } this.currentDeclarationSuite_.afterAll({ @@ -156,7 +156,7 @@ getJasmineRequireObj().SuiteBuilder = function(j$) { it_(description, fn, timeout, filename) { if (timeout) { - j$.util.validateTimeout(timeout); + j$.private.util.validateTimeout(timeout); } this.checkDuplicate_(description, 'spec'); @@ -195,7 +195,7 @@ getJasmineRequireObj().SuiteBuilder = function(j$) { const parentSuite = this.currentDeclarationSuite_; const reportedParentSuiteId = parentSuite === this.topSuite ? null : parentSuite.id; - return new j$.Suite({ + return new j$.private.Suite({ id: 'suite' + this.nextSuiteId_++, description, filename, @@ -237,7 +237,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$.Spec({ + const spec = new j$.private.Spec({ id: 'spec' + this.nextSpecId_++, filename, parentSuiteId, @@ -300,17 +300,21 @@ getJasmineRequireObj().SuiteBuilder = function(j$) { } function ensureIsFunction(fn, caller) { - if (!j$.isFunction_(fn)) { + if (!j$.private.isFunction(fn)) { throw new Error( - caller + ' expects a function argument; received ' + j$.getType_(fn) + caller + + ' expects a function argument; received ' + + j$.private.getType(fn) ); } } function ensureIsFunctionOrAsync(fn, caller) { - if (!j$.isFunction_(fn) && !j$.isAsyncFunction_(fn)) { + if (!j$.private.isFunction(fn) && !j$.private.isAsyncFunction(fn)) { throw new Error( - caller + ' expects a function argument; received ' + j$.getType_(fn) + caller + + ' expects a function argument; received ' + + j$.private.getType(fn) ); } } diff --git a/src/core/TreeRunner.js b/src/core/TreeRunner.js index 1412a1c6..5d96d4da 100644 --- a/src/core/TreeRunner.js +++ b/src/core/TreeRunner.js @@ -78,14 +78,14 @@ getJasmineRequireObj().TreeRunner = function(j$) { }, onComplete: () => { if (spec.result.status === 'failed') { - specOverallDone(new j$.StopExecutionError('spec failed')); + specOverallDone(new j$.private.StopExecutionError('spec failed')); } else { specOverallDone(); } }, userContext: spec.userContext(), runnableName: spec.getFullName.bind(spec), - SkipPolicy: j$.CompleteOnFirstErrorSkipPolicy + SkipPolicy: j$.private.CompleteOnFirstErrorSkipPolicy }); } @@ -260,7 +260,7 @@ getJasmineRequireObj().TreeRunner = function(j$) { async #reportChildrenOfBeforeAllFailure(suite) { for (const child of suite.children) { - if (child instanceof j$.Suite) { + if (child instanceof j$.private.Suite) { await this.#reportDispatcher.suiteStarted(child.result); await this.#reportChildrenOfBeforeAllFailure(child); @@ -292,9 +292,9 @@ getJasmineRequireObj().TreeRunner = function(j$) { #suiteSkipPolicy() { if (this.#getConfig().stopOnSpecFailure) { - return j$.CompleteOnFirstErrorSkipPolicy; + return j$.private.CompleteOnFirstErrorSkipPolicy; } else { - return j$.SkipAfterBeforeAllErrorPolicy; + return j$.private.SkipAfterBeforeAllErrorPolicy; } } } diff --git a/src/core/asymmetric_equality/Any.js b/src/core/asymmetric_equality/Any.js index abc3207c..ee634e9e 100644 --- a/src/core/asymmetric_equality/Any.js +++ b/src/core/asymmetric_equality/Any.js @@ -38,7 +38,7 @@ getJasmineRequireObj().Any = function(j$) { }; Any.prototype.jasmineToString = function() { - return ''; + return ''; }; return Any; diff --git a/src/core/asymmetric_equality/ArrayContaining.js b/src/core/asymmetric_equality/ArrayContaining.js index 3eddacde..c22046ef 100644 --- a/src/core/asymmetric_equality/ArrayContaining.js +++ b/src/core/asymmetric_equality/ArrayContaining.js @@ -4,10 +4,10 @@ getJasmineRequireObj().ArrayContaining = function(j$) { } ArrayContaining.prototype.asymmetricMatch = function(other, matchersUtil) { - if (!j$.isArray_(this.sample)) { + if (!j$.private.isArray(this.sample)) { throw new Error( 'You must provide an array to arrayContaining, not ' + - j$.basicPrettyPrinter_(this.sample) + + j$.private.basicPrettyPrinter(this.sample) + '.' ); } @@ -15,7 +15,7 @@ getJasmineRequireObj().ArrayContaining = function(j$) { // If the actual parameter is not an array, we can fail immediately, since it couldn't // possibly be an "array containing" anything. However, we also want an empty sample // array to match anything, so we need to double-check we aren't in that case - if (!j$.isArray_(other) && this.sample.length > 0) { + if (!j$.private.isArray(other) && this.sample.length > 0) { return false; } diff --git a/src/core/asymmetric_equality/ArrayWithExactContents.js b/src/core/asymmetric_equality/ArrayWithExactContents.js index ad241c1d..c49f92d3 100644 --- a/src/core/asymmetric_equality/ArrayWithExactContents.js +++ b/src/core/asymmetric_equality/ArrayWithExactContents.js @@ -7,10 +7,10 @@ getJasmineRequireObj().ArrayWithExactContents = function(j$) { other, matchersUtil ) { - if (!j$.isArray_(this.sample)) { + if (!j$.private.isArray(this.sample)) { throw new Error( 'You must provide an array to arrayWithExactContents, not ' + - j$.basicPrettyPrinter_(this.sample) + + j$.private.basicPrettyPrinter(this.sample) + '.' ); } diff --git a/src/core/asymmetric_equality/Empty.js b/src/core/asymmetric_equality/Empty.js index 1dd28948..7bc3d52e 100644 --- a/src/core/asymmetric_equality/Empty.js +++ b/src/core/asymmetric_equality/Empty.js @@ -2,15 +2,19 @@ getJasmineRequireObj().Empty = function(j$) { function Empty() {} Empty.prototype.asymmetricMatch = function(other) { - if (j$.isString_(other) || j$.isArray_(other) || j$.isTypedArray_(other)) { + if ( + j$.private.isString(other) || + j$.private.isArray(other) || + j$.private.isTypedArray(other) + ) { return other.length === 0; } - if (j$.isMap(other) || j$.isSet(other)) { + if (j$.private.isMap(other) || j$.private.isSet(other)) { return other.size === 0; } - if (j$.isObject_(other)) { + if (j$.private.isObject(other)) { return Object.keys(other).length === 0; } return false; diff --git a/src/core/asymmetric_equality/MapContaining.js b/src/core/asymmetric_equality/MapContaining.js index 6e7bf8d2..4afe50d6 100644 --- a/src/core/asymmetric_equality/MapContaining.js +++ b/src/core/asymmetric_equality/MapContaining.js @@ -1,9 +1,9 @@ getJasmineRequireObj().MapContaining = function(j$) { function MapContaining(sample) { - if (!j$.isMap(sample)) { + if (!j$.private.isMap(sample)) { throw new Error( 'You must provide a map to `mapContaining`, not ' + - j$.basicPrettyPrinter_(sample) + j$.private.basicPrettyPrinter(sample) ); } @@ -11,7 +11,7 @@ getJasmineRequireObj().MapContaining = function(j$) { } MapContaining.prototype.asymmetricMatch = function(other, matchersUtil) { - if (!j$.isMap(other)) { + if (!j$.private.isMap(other)) { return false; } diff --git a/src/core/asymmetric_equality/NotEmpty.js b/src/core/asymmetric_equality/NotEmpty.js index 361b6978..4a13fe81 100644 --- a/src/core/asymmetric_equality/NotEmpty.js +++ b/src/core/asymmetric_equality/NotEmpty.js @@ -2,15 +2,19 @@ getJasmineRequireObj().NotEmpty = function(j$) { function NotEmpty() {} NotEmpty.prototype.asymmetricMatch = function(other) { - if (j$.isString_(other) || j$.isArray_(other) || j$.isTypedArray_(other)) { + if ( + j$.private.isString(other) || + j$.private.isArray(other) || + j$.private.isTypedArray(other) + ) { return other.length !== 0; } - if (j$.isMap(other) || j$.isSet(other)) { + if (j$.private.isMap(other) || j$.private.isSet(other)) { return other.size !== 0; } - if (j$.isObject_(other)) { + if (j$.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 04a86694..77b48428 100644 --- a/src/core/asymmetric_equality/ObjectContaining.js +++ b/src/core/asymmetric_equality/ObjectContaining.js @@ -40,7 +40,7 @@ getJasmineRequireObj().ObjectContaining = function(j$) { }; ObjectContaining.prototype.valuesForDiff_ = function(other, pp) { - if (!j$.isObject_(other)) { + if (!j$.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 490af878..cf373fd9 100644 --- a/src/core/asymmetric_equality/SetContaining.js +++ b/src/core/asymmetric_equality/SetContaining.js @@ -1,9 +1,9 @@ getJasmineRequireObj().SetContaining = function(j$) { function SetContaining(sample) { - if (!j$.isSet(sample)) { + if (!j$.private.isSet(sample)) { throw new Error( 'You must provide a set to `setContaining`, not ' + - j$.basicPrettyPrinter_(sample) + j$.private.basicPrettyPrinter(sample) ); } @@ -11,7 +11,7 @@ getJasmineRequireObj().SetContaining = function(j$) { } SetContaining.prototype.asymmetricMatch = function(other, matchersUtil) { - if (!j$.isSet(other)) { + if (!j$.private.isSet(other)) { return false; } diff --git a/src/core/asymmetric_equality/StringContaining.js b/src/core/asymmetric_equality/StringContaining.js index 16f0c4e6..b0e899f2 100644 --- a/src/core/asymmetric_equality/StringContaining.js +++ b/src/core/asymmetric_equality/StringContaining.js @@ -1,6 +1,6 @@ getJasmineRequireObj().StringContaining = function(j$) { function StringContaining(expected) { - if (!j$.isString_(expected)) { + if (!j$.private.isString(expected)) { throw new Error('Expected is not a String'); } @@ -8,7 +8,7 @@ getJasmineRequireObj().StringContaining = function(j$) { } StringContaining.prototype.asymmetricMatch = function(other) { - if (!j$.isString_(other)) { + if (!j$.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 ebcc1738..89b627cd 100644 --- a/src/core/asymmetric_equality/StringMatching.js +++ b/src/core/asymmetric_equality/StringMatching.js @@ -1,6 +1,6 @@ getJasmineRequireObj().StringMatching = function(j$) { function StringMatching(expected) { - if (!j$.isString_(expected) && !j$.isA_('RegExp', expected)) { + if (!j$.private.isString(expected) && !j$.private.isA('RegExp', expected)) { throw new Error('Expected is not a String or a RegExp'); } diff --git a/src/core/base.js b/src/core/base.js index 2b32ffb2..c5ac348d 100644 --- a/src/core/base.js +++ b/src/core/base.js @@ -45,7 +45,10 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) { return DEFAULT_TIMEOUT_INTERVAL; }, set: function(newValue) { - j$.util.validateTimeout(newValue, 'jasmine.DEFAULT_TIMEOUT_INTERVAL'); + j$.private.util.validateTimeout( + newValue, + 'jasmine.DEFAULT_TIMEOUT_INTERVAL' + ); DEFAULT_TIMEOUT_INTERVAL = newValue; } }); @@ -63,58 +66,61 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) { * @return {Env} */ j$.getEnv = function(options) { - const env = (j$.currentEnv_ = j$.currentEnv_ || new j$.Env(options)); + const env = (j$.private.currentEnv_ = + j$.private.currentEnv_ || new j$.private.Env(options)); //jasmine. singletons in here (setTimeout blah blah). return env; }; - j$.isArray_ = function(value) { - return j$.isA_('Array', value); + j$.private.isArray = function(value) { + return j$.private.isA('Array', value); }; - j$.isObject_ = function(value) { - return value !== undefined && value !== null && j$.isA_('Object', value); - }; - - j$.isString_ = function(value) { - return j$.isA_('String', value); - }; - - j$.isNumber_ = function(value) { - return j$.isA_('Number', value); - }; - - j$.isFunction_ = function(value) { - return j$.isA_('Function', value); - }; - - j$.isAsyncFunction_ = function(value) { - return j$.isA_('AsyncFunction', value); - }; - - j$.isGeneratorFunction_ = function(value) { - return j$.isA_('GeneratorFunction', value); - }; - - j$.isTypedArray_ = function(value) { + j$.private.isObject = function(value) { return ( - j$.isA_('Float32Array', value) || - j$.isA_('Float64Array', value) || - j$.isA_('Int16Array', value) || - j$.isA_('Int32Array', value) || - j$.isA_('Int8Array', value) || - j$.isA_('Uint16Array', value) || - j$.isA_('Uint32Array', value) || - j$.isA_('Uint8Array', value) || - j$.isA_('Uint8ClampedArray', value) + value !== undefined && value !== null && j$.private.isA('Object', value) ); }; - j$.isA_ = function(typeName, value) { - return j$.getType_(value) === '[object ' + typeName + ']'; + j$.private.isString = function(value) { + return j$.private.isA('String', value); }; - j$.isError_ = function(value) { + j$.private.isNumber = function(value) { + return j$.private.isA('Number', value); + }; + + j$.private.isFunction = function(value) { + return j$.private.isA('Function', value); + }; + + j$.private.isAsyncFunction = function(value) { + return j$.private.isA('AsyncFunction', value); + }; + + j$.private.isGeneratorFunction = function(value) { + return j$.private.isA('GeneratorFunction', value); + }; + + j$.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) + ); + }; + + j$.private.isA = function(typeName, value) { + return j$.private.getType(value) === '[object ' + typeName + ']'; + }; + + j$.private.isError = function(value) { if (!value) { return false; } @@ -126,15 +132,15 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) { return typeof value.stack === 'string' && typeof value.message === 'string'; }; - j$.isAsymmetricEqualityTester_ = function(obj) { - return obj ? j$.isA_('Function', obj.asymmetricMatch) : false; + j$.private.isAsymmetricEqualityTester = function(obj) { + return obj ? j$.private.isA('Function', obj.asymmetricMatch) : false; }; - j$.getType_ = function(value) { + j$.private.getType = function(value) { return Object.prototype.toString.apply(value); }; - j$.isDomNode = function(obj) { + j$.private.isDomNode = function(obj) { // Node is a function, because constructors return typeof jasmineGlobal.Node !== 'undefined' ? obj instanceof jasmineGlobal.Node @@ -145,7 +151,7 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) { // return obj.nodeType > 0; }; - j$.isMap = function(obj) { + j$.private.isMap = function(obj) { return ( obj !== null && typeof obj !== 'undefined' && @@ -153,7 +159,7 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) { ); }; - j$.isSet = function(obj) { + j$.private.isSet = function(obj) { return ( obj !== null && typeof obj !== 'undefined' && @@ -161,7 +167,7 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) { ); }; - j$.isWeakMap = function(obj) { + j$.private.isWeakMap = function(obj) { return ( obj !== null && typeof obj !== 'undefined' && @@ -169,7 +175,7 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) { ); }; - j$.isURL = function(obj) { + j$.private.isURL = function(obj) { return ( obj !== null && typeof obj !== 'undefined' && @@ -177,11 +183,11 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) { ); }; - j$.isIterable_ = function(value) { + j$.private.isIterable = function(value) { return value && !!value[Symbol.iterator]; }; - j$.isDataView = function(obj) { + j$.private.isDataView = function(obj) { return ( obj !== null && typeof obj !== 'undefined' && @@ -189,15 +195,15 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) { ); }; - j$.isPromise = function(obj) { + j$.private.isPromise = function(obj) { return !!obj && obj.constructor === jasmineGlobal.Promise; }; - j$.isPromiseLike = function(obj) { - return !!obj && j$.isFunction_(obj.then); + j$.private.isPromiseLike = function(obj) { + return !!obj && j$.private.isFunction(obj.then); }; - j$.fnNameFor = function(func) { + j$.private.fnNameFor = function(func) { if (func.name) { return func.name; } @@ -209,7 +215,7 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) { return matches ? matches[1] : ''; }; - j$.isPending_ = function(promise) { + j$.private.isPending = function(promise) { const sentinel = {}; return Promise.race([promise, Promise.resolve(sentinel)]).then( function(result) { @@ -231,7 +237,7 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) { * @param {Constructor} clazz - The constructor to check against. */ j$.any = function(clazz) { - return new j$.Any(clazz); + return new j$.private.Any(clazz); }; /** @@ -243,7 +249,7 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) { * @function */ j$.anything = function() { - return new j$.Anything(); + return new j$.private.Anything(); }; /** @@ -255,7 +261,7 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) { * @function */ j$.truthy = function() { - return new j$.Truthy(); + return new j$.private.Truthy(); }; /** @@ -268,7 +274,7 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) { * @function */ j$.falsy = function() { - return new j$.Falsy(); + return new j$.private.Falsy(); }; /** @@ -280,7 +286,7 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) { * @function */ j$.empty = function() { - return new j$.Empty(); + return new j$.private.Empty(); }; /** @@ -292,7 +298,7 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) { * @param {Object} sample - The value to compare the actual to. */ j$.is = function(sample) { - return new j$.Is(sample); + return new j$.private.Is(sample); }; /** @@ -304,7 +310,7 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) { * @function */ j$.notEmpty = function() { - return new j$.NotEmpty(); + return new j$.private.NotEmpty(); }; /** @@ -317,7 +323,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$.ObjectContaining(sample); + return new j$.private.ObjectContaining(sample); }; /** @@ -330,7 +336,7 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) { * @param {RegExp|String} expected */ j$.stringMatching = function(expected) { - return new j$.StringMatching(expected); + return new j$.private.StringMatching(expected); }; /** @@ -343,7 +349,7 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) { * @param {String} expected */ j$.stringContaining = function(expected) { - return new j$.StringContaining(expected); + return new j$.private.StringContaining(expected); }; /** @@ -356,7 +362,7 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) { * @param {Array} sample */ j$.arrayContaining = function(sample) { - return new j$.ArrayContaining(sample); + return new j$.private.ArrayContaining(sample); }; /** @@ -370,7 +376,7 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) { * @param {Array} sample */ j$.arrayWithExactContents = function(sample) { - return new j$.ArrayWithExactContents(sample); + return new j$.private.ArrayWithExactContents(sample); }; /** @@ -384,7 +390,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$.MapContaining(sample); + return new j$.private.MapContaining(sample); }; /** @@ -398,7 +404,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$.SetContaining(sample); + return new j$.private.SetContaining(sample); }; /** @@ -414,8 +420,8 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) { return false; } return ( - putativeSpy.and instanceof j$.SpyStrategy && - putativeSpy.calls instanceof j$.CallTracker + putativeSpy.and instanceof j$.private.SpyStrategy && + putativeSpy.calls instanceof j$.private.CallTracker ); }; diff --git a/src/core/buildExpectationResult.js b/src/core/buildExpectationResult.js index 513741af..78a102da 100644 --- a/src/core/buildExpectationResult.js +++ b/src/core/buildExpectationResult.js @@ -1,7 +1,7 @@ //TODO: expectation result may make more sense as a presentation of an expectation. getJasmineRequireObj().buildExpectationResult = function(j$) { function buildExpectationResult(options) { - const exceptionFormatter = new j$.ExceptionFormatter(); + const exceptionFormatter = new j$.private.ExceptionFormatter(); /** * Describes the result of evaluating an expectation @@ -24,7 +24,7 @@ getJasmineRequireObj().buildExpectationResult = function(j$) { }; if (!result.passed) { - if (options.error && !j$.isString_(options.error)) { + if (options.error && !j$.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 3aed1916..489f12c9 100644 --- a/src/core/matchers/DiffBuilder.js +++ b/src/core/matchers/DiffBuilder.js @@ -2,9 +2,9 @@ getJasmineRequireObj().DiffBuilder = function(j$) { class DiffBuilder { constructor(config) { this.prettyPrinter_ = - (config || {}).prettyPrinter || j$.makePrettyPrinter(); - this.mismatches_ = new j$.MismatchTree(); - this.path_ = new j$.ObjectPath(); + (config || {}).prettyPrinter || j$.private.makePrettyPrinter(); + this.mismatches_ = new j$.private.MismatchTree(); + this.path_ = new j$.private.ObjectPath(); this.actualRoot_ = undefined; this.expectedRoot_ = undefined; } @@ -65,8 +65,8 @@ getJasmineRequireObj().DiffBuilder = function(j$) { const handleAsymmetricExpected = () => { if ( - j$.isAsymmetricEqualityTester_(expected) && - j$.isFunction_(expected.valuesForDiff_) + j$.private.isAsymmetricEqualityTester(expected) && + j$.private.isFunction(expected.valuesForDiff_) ) { const asymmetricResult = expected.valuesForDiff_( actual, diff --git a/src/core/matchers/MismatchTree.js b/src/core/matchers/MismatchTree.js index 85176563..504fc600 100644 --- a/src/core/matchers/MismatchTree.js +++ b/src/core/matchers/MismatchTree.js @@ -8,7 +8,7 @@ getJasmineRequireObj().MismatchTree = function(j$) { */ class MismatchTree { constructor(path) { - this.path = path || new j$.ObjectPath([]); + this.path = path || new j$.private.ObjectPath([]); this.formatter = undefined; this.children = []; this.isMismatch = false; diff --git a/src/core/matchers/async/toBePending.js b/src/core/matchers/async/toBePending.js index 23ad8d47..bd5549f6 100644 --- a/src/core/matchers/async/toBePending.js +++ b/src/core/matchers/async/toBePending.js @@ -11,7 +11,7 @@ getJasmineRequireObj().toBePending = function(j$) { return function toBePending() { return { compare: function(actual) { - if (!j$.isPromiseLike(actual)) { + if (!j$.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 31d025c0..57e6d71b 100644 --- a/src/core/matchers/async/toBeRejected.js +++ b/src/core/matchers/async/toBeRejected.js @@ -13,7 +13,7 @@ getJasmineRequireObj().toBeRejected = function(j$) { return function toBeRejected() { return { compare: function(actual) { - if (!j$.isPromiseLike(actual)) { + if (!j$.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 b114a13c..d640c901 100644 --- a/src/core/matchers/async/toBeRejectedWith.js +++ b/src/core/matchers/async/toBeRejectedWith.js @@ -14,7 +14,7 @@ getJasmineRequireObj().toBeRejectedWith = function(j$) { return function toBeRejectedWith(matchersUtil) { return { compare: function(actualPromise, expectedValue) { - if (!j$.isPromiseLike(actualPromise)) { + if (!j$.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 0bb3b58a..1ef90713 100644 --- a/src/core/matchers/async/toBeRejectedWithError.js +++ b/src/core/matchers/async/toBeRejectedWithError.js @@ -17,7 +17,7 @@ getJasmineRequireObj().toBeRejectedWithError = function(j$) { return function toBeRejectedWithError(matchersUtil) { return { compare: function(actualPromise, arg1, arg2) { - if (!j$.isPromiseLike(actualPromise)) { + if (!j$.private.isPromiseLike(actualPromise)) { throw new Error( `Expected toBeRejectedWithError to be called on a promise but was on a ${typeof actualPromise}.` ); @@ -41,14 +41,14 @@ getJasmineRequireObj().toBeRejectedWithError = function(j$) { }; function matchError(actual, expected, matchersUtil) { - if (!j$.isError_(actual)) { + if (!j$.private.isError(actual)) { return fail(expected, 'rejected with ' + matchersUtil.pp(actual)); } if (!(actual instanceof expected.error)) { return fail( expected, - 'rejected with type ' + j$.fnNameFor(actual.constructor) + 'rejected with type ' + j$.private.fnNameFor(actual.constructor) ); } @@ -108,7 +108,7 @@ getJasmineRequireObj().toBeRejectedWithError = function(j$) { error: error, message: message, printValue: - j$.fnNameFor(error) + + j$.private.fnNameFor(error) + (typeof message === 'undefined' ? '' : ': ' + matchersUtil.pp(message)) }; } @@ -116,7 +116,7 @@ getJasmineRequireObj().toBeRejectedWithError = function(j$) { function isErrorConstructor(value) { return ( typeof value === 'function' && - (value === Error || j$.isError_(value.prototype)) + (value === Error || j$.private.isError(value.prototype)) ); } }; diff --git a/src/core/matchers/async/toBeResolved.js b/src/core/matchers/async/toBeResolved.js index 4badc198..1bfb7476 100644 --- a/src/core/matchers/async/toBeResolved.js +++ b/src/core/matchers/async/toBeResolved.js @@ -13,7 +13,7 @@ getJasmineRequireObj().toBeResolved = function(j$) { return function toBeResolved(matchersUtil) { return { compare: function(actual) { - if (!j$.isPromiseLike(actual)) { + if (!j$.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 acb12551..21426b82 100644 --- a/src/core/matchers/async/toBeResolvedTo.js +++ b/src/core/matchers/async/toBeResolvedTo.js @@ -14,7 +14,7 @@ getJasmineRequireObj().toBeResolvedTo = function(j$) { return function toBeResolvedTo(matchersUtil) { return { compare: function(actualPromise, expectedValue) { - if (!j$.isPromiseLike(actualPromise)) { + if (!j$.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 58f035c2..d6054aa9 100644 --- a/src/core/matchers/matchersUtil.js +++ b/src/core/matchers/matchersUtil.js @@ -36,7 +36,7 @@ getJasmineRequireObj().MatchersUtil = function(j$) { return false; } - if (j$.isSet(haystack)) { + if (j$.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. @@ -45,7 +45,7 @@ getJasmineRequireObj().MatchersUtil = function(j$) { } } - if (j$.isIterable_(haystack) && !j$.isString_(haystack)) { + if (j$.private.isIterable(haystack) && !j$.private.isString(haystack)) { // Arrays, Sets, etc. for (const candidate of haystack) { if (this.equals(candidate, needle)) { @@ -61,7 +61,7 @@ getJasmineRequireObj().MatchersUtil = function(j$) { return haystack.indexOf(needle) >= 0; } - if (j$.isNumber_(haystack.length)) { + if (j$.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)) { @@ -108,7 +108,7 @@ getJasmineRequireObj().MatchersUtil = function(j$) { bStack, diffBuilder ) { - if (j$.isFunction_(b.valuesForDiff_)) { + if (j$.private.isFunction(b.valuesForDiff_)) { const values = b.valuesForDiff_(a, this.pp); this.eq_(values.other, values.self, aStack, bStack, diffBuilder); } else { @@ -123,8 +123,8 @@ getJasmineRequireObj().MatchersUtil = function(j$) { bStack, diffBuilder ) { - const asymmetricA = j$.isAsymmetricEqualityTester_(a); - const asymmetricB = j$.isAsymmetricEqualityTester_(b); + const asymmetricA = j$.private.isAsymmetricEqualityTester(a); + const asymmetricB = j$.private.isAsymmetricEqualityTester(b); if (asymmetricA === asymmetricB) { return undefined; @@ -159,7 +159,7 @@ getJasmineRequireObj().MatchersUtil = function(j$) { * @returns {boolean} True if the values are equal */ MatchersUtil.prototype.equals = function(a, b, diffBuilder) { - diffBuilder = diffBuilder || j$.NullDiffBuilder(); + diffBuilder = diffBuilder || j$.private.NullDiffBuilder(); diffBuilder.setRoots(a, b); return this.eq_(a, b, [], [], diffBuilder); @@ -274,8 +274,8 @@ getJasmineRequireObj().MatchersUtil = function(j$) { return false; } - const aIsDomNode = j$.isDomNode(a); - const bIsDomNode = j$.isDomNode(b); + const aIsDomNode = j$.private.isDomNode(a); + const bIsDomNode = j$.private.isDomNode(b); if (aIsDomNode && bIsDomNode) { // At first try to use DOM3 method isEqualNode result = a.isEqualNode(b); @@ -289,8 +289,8 @@ getJasmineRequireObj().MatchersUtil = function(j$) { return false; } - const aIsPromise = j$.isPromise(a); - const bIsPromise = j$.isPromise(b); + const aIsPromise = j$.private.isPromise(a); + const bIsPromise = j$.private.isPromise(b); if (aIsPromise && bIsPromise) { return a === b; } @@ -344,7 +344,7 @@ getJasmineRequireObj().MatchersUtil = function(j$) { if (!result) { return false; } - } else if (j$.isMap(a) && j$.isMap(b)) { + } else if (j$.private.isMap(a) && j$.private.isMap(b)) { if (a.size != b.size) { diffBuilder.recordMismatch(); return false; @@ -377,9 +377,15 @@ 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$.isAsymmetricEqualityTester_(mapKey) || - (j$.isAsymmetricEqualityTester_(cmpKey) && - this.eq_(mapKey, cmpKey, aStack, bStack, j$.NullDiffBuilder())) + j$.private.isAsymmetricEqualityTester(mapKey) || + (j$.private.isAsymmetricEqualityTester(cmpKey) && + this.eq_( + mapKey, + cmpKey, + aStack, + bStack, + j$.private.NullDiffBuilder() + )) ) { mapValueB = b.get(cmpKey); } else { @@ -390,7 +396,7 @@ getJasmineRequireObj().MatchersUtil = function(j$) { mapValueB, aStack, bStack, - j$.NullDiffBuilder() + j$.private.NullDiffBuilder() ); } } @@ -399,7 +405,7 @@ getJasmineRequireObj().MatchersUtil = function(j$) { diffBuilder.recordMismatch(); return false; } - } else if (j$.isSet(a) && j$.isSet(b)) { + } else if (j$.private.isSet(a) && j$.private.isSet(b)) { if (a.size != b.size) { diffBuilder.recordMismatch(); return false; @@ -435,7 +441,7 @@ getJasmineRequireObj().MatchersUtil = function(j$) { otherValue, baseStack, otherStack, - j$.NullDiffBuilder() + j$.private.NullDiffBuilder() ); if (!found && prevStackSize !== baseStack.length) { baseStack.splice(prevStackSize); @@ -450,7 +456,7 @@ getJasmineRequireObj().MatchersUtil = function(j$) { diffBuilder.recordMismatch(); return false; } - } else if (j$.isURL(a) && j$.isURL(b)) { + } else if (j$.private.isURL(a) && j$.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(); @@ -488,7 +494,7 @@ getJasmineRequireObj().MatchersUtil = function(j$) { for (const key of aKeys) { // Deep compare each member - if (!j$.util.has(b, key)) { + if (!j$.private.util.has(b, key)) { diffBuilder.recordMismatch( objectKeysAreDifferentFormatter.bind(null, this.pp) ); @@ -518,7 +524,7 @@ getJasmineRequireObj().MatchersUtil = function(j$) { const allKeys = (function(o) { const keys = []; for (const key in o) { - if (j$.util.has(o, key)) { + if (j$.private.util.has(o, key)) { keys.push(key); } } @@ -559,7 +565,7 @@ getJasmineRequireObj().MatchersUtil = function(j$) { // and not in objB. function extraKeysAndValues(objA, objB) { return MatchersUtil.keys(objA) - .filter(key => !j$.util.has(objB, key)) + .filter(key => !j$.private.util.has(objB, key)) .map(key => [key, objA[key]]); } @@ -598,7 +604,7 @@ getJasmineRequireObj().MatchersUtil = function(j$) { 'Expected ' + path + ' to be a kind of ' + - j$.fnNameFor(expected.constructor) + + j$.private.fnNameFor(expected.constructor) + ', but was ' + pp(actual) + '.' diff --git a/src/core/matchers/toBeInstanceOf.js b/src/core/matchers/toBeInstanceOf.js index fba86e9c..a58cb32c 100644 --- a/src/core/matchers/toBeInstanceOf.js +++ b/src/core/matchers/toBeInstanceOf.js @@ -1,5 +1,5 @@ getJasmineRequireObj().toBeInstanceOf = function(j$) { - const usageError = j$.formatErrorMsg( + const usageError = j$.private.formatErrorMsg( '', 'expect(value).toBeInstanceOf()' ); @@ -20,16 +20,16 @@ getJasmineRequireObj().toBeInstanceOf = function(j$) { compare: function(actual, expected) { const actualType = actual && actual.constructor - ? j$.fnNameFor(actual.constructor) + ? j$.private.fnNameFor(actual.constructor) : matchersUtil.pp(actual); const expectedType = expected - ? j$.fnNameFor(expected) + ? j$.private.fnNameFor(expected) : matchersUtil.pp(expected); let expectedMatcher; let pass; try { - expectedMatcher = new j$.Any(expected); + expectedMatcher = new j$.private.Any(expected); pass = expectedMatcher.asymmetricMatch(actual); // eslint-disable-next-line no-unused-vars } catch (error) { diff --git a/src/core/matchers/toEqual.js b/src/core/matchers/toEqual.js index 04a67bda..688c1dd1 100644 --- a/src/core/matchers/toEqual.js +++ b/src/core/matchers/toEqual.js @@ -14,7 +14,9 @@ getJasmineRequireObj().toEqual = function(j$) { const result = { pass: false }, - diffBuilder = new j$.DiffBuilder({ prettyPrinter: matchersUtil.pp }); + diffBuilder = new j$.private.DiffBuilder({ + prettyPrinter: matchersUtil.pp + }); result.pass = matchersUtil.equals(actual, expected, diffBuilder); diff --git a/src/core/matchers/toHaveBeenCalled.js b/src/core/matchers/toHaveBeenCalled.js index bb544410..4e836d4a 100644 --- a/src/core/matchers/toHaveBeenCalled.js +++ b/src/core/matchers/toHaveBeenCalled.js @@ -1,5 +1,5 @@ getJasmineRequireObj().toHaveBeenCalled = function(j$) { - const getErrorMsg = j$.formatErrorMsg( + const getErrorMsg = j$.private.formatErrorMsg( '', 'expect().toHaveBeenCalled()' ); diff --git a/src/core/matchers/toHaveBeenCalledBefore.js b/src/core/matchers/toHaveBeenCalledBefore.js index 85a0af99..fb0b1496 100644 --- a/src/core/matchers/toHaveBeenCalledBefore.js +++ b/src/core/matchers/toHaveBeenCalledBefore.js @@ -1,5 +1,5 @@ getJasmineRequireObj().toHaveBeenCalledBefore = function(j$) { - const getErrorMsg = j$.formatErrorMsg( + const getErrorMsg = j$.private.formatErrorMsg( '', 'expect().toHaveBeenCalledBefore()' ); diff --git a/src/core/matchers/toHaveBeenCalledOnceWith.js b/src/core/matchers/toHaveBeenCalledOnceWith.js index d8d4373f..91d8924c 100644 --- a/src/core/matchers/toHaveBeenCalledOnceWith.js +++ b/src/core/matchers/toHaveBeenCalledOnceWith.js @@ -1,5 +1,5 @@ getJasmineRequireObj().toHaveBeenCalledOnceWith = function(j$) { - const getErrorMsg = j$.formatErrorMsg( + const getErrorMsg = j$.private.formatErrorMsg( '', 'expect().toHaveBeenCalledOnceWith(...arguments)' ); @@ -62,7 +62,7 @@ getJasmineRequireObj().toHaveBeenCalledOnceWith = function(j$) { function getDiffs() { return actual.calls.allArgs().map(function(argsForCall, callIx) { - const diffBuilder = new j$.DiffBuilder(); + const diffBuilder = new j$.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 4a16995c..2bb8b02f 100644 --- a/src/core/matchers/toHaveBeenCalledTimes.js +++ b/src/core/matchers/toHaveBeenCalledTimes.js @@ -1,5 +1,5 @@ getJasmineRequireObj().toHaveBeenCalledTimes = function(j$) { - const getErrorMsg = j$.formatErrorMsg( + const getErrorMsg = j$.private.formatErrorMsg( '', 'expect().toHaveBeenCalledTimes()' ); @@ -27,7 +27,7 @@ getJasmineRequireObj().toHaveBeenCalledTimes = function(j$) { const args = Array.prototype.slice.call(arguments, 0), result = { pass: false }; - if (!j$.isNumber_(expected)) { + if (!j$.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 da2d1074..666b504a 100644 --- a/src/core/matchers/toHaveBeenCalledWith.js +++ b/src/core/matchers/toHaveBeenCalledWith.js @@ -1,5 +1,5 @@ getJasmineRequireObj().toHaveBeenCalledWith = function(j$) { - const getErrorMsg = j$.formatErrorMsg( + const getErrorMsg = j$.private.formatErrorMsg( '', 'expect().toHaveBeenCalledWith(...arguments)' ); @@ -71,7 +71,7 @@ getJasmineRequireObj().toHaveBeenCalledWith = function(j$) { const diffs = actual.calls .allArgs() .map(function(argsForCall, callIx) { - const diffBuilder = new j$.DiffBuilder(); + const diffBuilder = new j$.private.DiffBuilder(); matchersUtil.equals(argsForCall, expectedArgs, diffBuilder); return ( 'Call ' + diff --git a/src/core/matchers/toHaveClass.js b/src/core/matchers/toHaveClass.js index 034b6f29..7d497868 100644 --- a/src/core/matchers/toHaveClass.js +++ b/src/core/matchers/toHaveClass.js @@ -26,7 +26,9 @@ getJasmineRequireObj().toHaveClass = function(j$) { function isElement(maybeEl) { return ( - maybeEl && maybeEl.classList && j$.isFunction_(maybeEl.classList.contains) + maybeEl && + maybeEl.classList && + j$.private.isFunction(maybeEl.classList.contains) ); } diff --git a/src/core/matchers/toHaveClasses.js b/src/core/matchers/toHaveClasses.js index e8275b35..39a840d0 100644 --- a/src/core/matchers/toHaveClasses.js +++ b/src/core/matchers/toHaveClasses.js @@ -26,7 +26,9 @@ getJasmineRequireObj().toHaveClasses = function(j$) { function isElement(maybeEl) { return ( - maybeEl && maybeEl.classList && j$.isFunction_(maybeEl.classList.contains) + maybeEl && + maybeEl.classList && + j$.private.isFunction(maybeEl.classList.contains) ); } diff --git a/src/core/matchers/toHaveNoOtherSpyInteractions.js b/src/core/matchers/toHaveNoOtherSpyInteractions.js index a1bc3c29..1457476c 100644 --- a/src/core/matchers/toHaveNoOtherSpyInteractions.js +++ b/src/core/matchers/toHaveNoOtherSpyInteractions.js @@ -1,5 +1,5 @@ getJasmineRequireObj().toHaveNoOtherSpyInteractions = function(j$) { - const getErrorMsg = j$.formatErrorMsg( + const getErrorMsg = j$.private.formatErrorMsg( '', 'expect().toHaveNoOtherSpyInteractions()' ); @@ -17,7 +17,7 @@ getJasmineRequireObj().toHaveNoOtherSpyInteractions = function(j$) { compare: function(actual) { const result = {}; - if (!j$.isObject_(actual)) { + if (!j$.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 8a653448..d215d703 100644 --- a/src/core/matchers/toHaveSize.js +++ b/src/core/matchers/toHaveSize.js @@ -17,15 +17,15 @@ getJasmineRequireObj().toHaveSize = function(j$) { }; if ( - j$.isA_('WeakSet', actual) || - j$.isWeakMap(actual) || - j$.isDataView(actual) + j$.private.isA('WeakSet', actual) || + j$.private.isWeakMap(actual) || + j$.private.isDataView(actual) ) { throw new Error('Cannot get size of ' + actual + '.'); } let actualSize; - if (j$.isSet(actual) || j$.isMap(actual)) { + if (j$.private.isSet(actual) || j$.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 139d24e1..b71baff5 100755 --- a/src/core/matchers/toHaveSpyInteractions.js +++ b/src/core/matchers/toHaveSpyInteractions.js @@ -1,5 +1,5 @@ getJasmineRequireObj().toHaveSpyInteractions = function(j$) { - const getErrorMsg = j$.formatErrorMsg( + const getErrorMsg = j$.private.formatErrorMsg( '', 'expect().toHaveSpyInteractions()' ); @@ -18,7 +18,7 @@ getJasmineRequireObj().toHaveSpyInteractions = function(j$) { compare: function(actual) { const result = {}; - if (!j$.isObject_(actual)) { + if (!j$.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 571304c9..1475d930 100644 --- a/src/core/matchers/toMatch.js +++ b/src/core/matchers/toMatch.js @@ -1,5 +1,5 @@ getJasmineRequireObj().toMatch = function(j$) { - const getErrorMsg = j$.formatErrorMsg( + const getErrorMsg = j$.private.formatErrorMsg( '', 'expect().toMatch( || )' ); @@ -17,7 +17,10 @@ getJasmineRequireObj().toMatch = function(j$) { function toMatch() { return { compare: function(actual, expected) { - if (!j$.isString_(expected) && !j$.isA_('RegExp', expected)) { + if ( + !j$.private.isString(expected) && + !j$.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 9f8e2240..db230097 100644 --- a/src/core/matchers/toThrow.js +++ b/src/core/matchers/toThrow.js @@ -1,5 +1,5 @@ getJasmineRequireObj().toThrow = function(j$) { - const getErrorMsg = j$.formatErrorMsg( + const getErrorMsg = j$.private.formatErrorMsg( '', 'expect(function() {}).toThrow()' ); diff --git a/src/core/matchers/toThrowError.js b/src/core/matchers/toThrowError.js index 4ddd78b3..46554220 100644 --- a/src/core/matchers/toThrowError.js +++ b/src/core/matchers/toThrowError.js @@ -1,5 +1,5 @@ getJasmineRequireObj().toThrowError = function(j$) { - const getErrorMsg = j$.formatErrorMsg( + const getErrorMsg = j$.private.formatErrorMsg( '', 'expect(function() {}).toThrowError(, )' ); @@ -36,7 +36,7 @@ getJasmineRequireObj().toThrowError = function(j$) { thrown = e; } - if (!j$.isError_(thrown)) { + if (!j$.private.isError(thrown)) { return fail(function() { return ( 'Expected function to throw an Error, but it threw ' + @@ -79,7 +79,7 @@ getJasmineRequireObj().toThrowError = function(j$) { match: function(error) { return pass( 'Expected function not to throw an Error, but it threw ' + - j$.fnNameFor(error) + + j$.private.fnNameFor(error) + '.' ); } @@ -108,12 +108,12 @@ getJasmineRequireObj().toThrowError = function(j$) { } const errorTypeDescription = errorType - ? j$.fnNameFor(errorType) + ? j$.private.fnNameFor(errorType) : 'an exception'; function thrownDescription(thrown) { const thrownName = errorType - ? j$.fnNameFor(thrown.constructor) + ? j$.private.fnNameFor(thrown.constructor) : 'an exception'; let thrownMessage = ''; @@ -179,7 +179,7 @@ getJasmineRequireObj().toThrowError = function(j$) { const Surrogate = function() {}; Surrogate.prototype = type.prototype; - return j$.isError_(new Surrogate()); + return j$.private.isError(new Surrogate()); } } diff --git a/src/core/matchers/toThrowMatching.js b/src/core/matchers/toThrowMatching.js index 4e9ea406..508fa226 100644 --- a/src/core/matchers/toThrowMatching.js +++ b/src/core/matchers/toThrowMatching.js @@ -1,5 +1,5 @@ getJasmineRequireObj().toThrowMatching = function(j$) { - const usageError = j$.formatErrorMsg( + const usageError = j$.private.formatErrorMsg( '', 'expect(function() {}).toThrowMatching()' ); @@ -53,7 +53,7 @@ getJasmineRequireObj().toThrowMatching = function(j$) { function thrownDescription(thrown) { if (thrown && thrown.constructor) { return ( - j$.fnNameFor(thrown.constructor) + + j$.private.fnNameFor(thrown.constructor) + ' with message ' + matchersUtil.pp(thrown.message) ); diff --git a/src/core/reporterEvents.js b/src/core/reporterEvents.js index e073494a..4f563d94 100644 --- a/src/core/reporterEvents.js +++ b/src/core/reporterEvents.js @@ -1,4 +1,4 @@ -getJasmineRequireObj().reporterEvents = function() { +getJasmineRequireObj().reporterEvents = function(j$) { /** * Used to tell Jasmine what optional or uncommonly implemented features * the reporter supports. If not specified, the defaults described in diff --git a/src/core/requireCore.js b/src/core/requireCore.js index 669bd244..63925f61 100644 --- a/src/core/requireCore.js +++ b/src/core/requireCore.js @@ -29,92 +29,79 @@ var getJasmineRequireObj = (function(jasmineGlobal) { } getJasmineRequire().core = function(jRequire) { - const j$ = {}; + const j$ = { private: {} }; jRequire.base(j$, jasmineGlobal); - j$.util = jRequire.util(j$); - j$.errors = jRequire.errors(); - j$.formatErrorMsg = jRequire.formatErrorMsg(); - j$.Any = jRequire.Any(j$); - j$.Anything = jRequire.Anything(j$); - j$.CallTracker = jRequire.CallTracker(j$); - j$.MockDate = jRequire.MockDate(j$); - j$.getClearStack = jRequire.clearStack(j$); - j$.Clock = jRequire.Clock(); - j$.DelayedFunctionScheduler = jRequire.DelayedFunctionScheduler(j$); - j$.Deprecator = jRequire.Deprecator(j$); - j$.Configuration = jRequire.Configuration(j$); - j$.Env = jRequire.Env(j$); - j$.StackTrace = jRequire.StackTrace(j$); - j$.ExceptionFormatter = jRequire.ExceptionFormatter(j$); - j$.ExpectationFilterChain = jRequire.ExpectationFilterChain(); - j$.Expector = jRequire.Expector(j$); - j$.Expectation = jRequire.Expectation(j$); - j$.buildExpectationResult = jRequire.buildExpectationResult(j$); - j$.JsApiReporter = jRequire.JsApiReporter(j$); - j$.makePrettyPrinter = jRequire.makePrettyPrinter(j$); - j$.basicPrettyPrinter_ = j$.makePrettyPrinter(); - j$.MatchersUtil = jRequire.MatchersUtil(j$); - j$.ObjectContaining = jRequire.ObjectContaining(j$); - j$.ArrayContaining = jRequire.ArrayContaining(j$); - j$.ArrayWithExactContents = jRequire.ArrayWithExactContents(j$); - j$.MapContaining = jRequire.MapContaining(j$); - j$.SetContaining = jRequire.SetContaining(j$); - j$.QueueRunner = jRequire.QueueRunner(j$); - j$.NeverSkipPolicy = jRequire.NeverSkipPolicy(j$); - j$.SkipAfterBeforeAllErrorPolicy = jRequire.SkipAfterBeforeAllErrorPolicy( + j$.private.util = jRequire.util(j$); + j$.private.errors = jRequire.errors(); + j$.private.formatErrorMsg = jRequire.formatErrorMsg(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.getClearStack = jRequire.clearStack(j$); + j$.private.Clock = jRequire.Clock(); + 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.JsApiReporter = jRequire.JsApiReporter(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( j$ ); - j$.CompleteOnFirstErrorSkipPolicy = jRequire.CompleteOnFirstErrorSkipPolicy( + j$.private.CompleteOnFirstErrorSkipPolicy = jRequire.CompleteOnFirstErrorSkipPolicy( j$ ); - j$.reporterEvents = jRequire.reporterEvents(j$); - j$.ReportDispatcher = jRequire.ReportDispatcher(j$); + j$.private.reporterEvents = jRequire.reporterEvents(j$); + j$.private.ReportDispatcher = jRequire.ReportDispatcher(j$); j$.ParallelReportDispatcher = jRequire.ParallelReportDispatcher(j$); - j$.CurrentRunableTracker = jRequire.CurrentRunableTracker(); - j$.RunableResources = jRequire.RunableResources(j$); - j$.Runner = jRequire.Runner(j$); - j$.Spec = jRequire.Spec(j$); - j$.Spy = jRequire.Spy(j$); - j$.SpyFactory = jRequire.SpyFactory(j$); - j$.SpyRegistry = jRequire.SpyRegistry(j$); - j$.SpyStrategy = jRequire.SpyStrategy(j$); - j$.StringMatching = jRequire.StringMatching(j$); - j$.StringContaining = jRequire.StringContaining(j$); - j$.UserContext = jRequire.UserContext(j$); - j$.Suite = jRequire.Suite(j$); - j$.SuiteBuilder = jRequire.SuiteBuilder(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$); j$.Timer = jRequire.Timer(); - j$.TreeProcessor = jRequire.TreeProcessor(j$); - j$.TreeRunner = jRequire.TreeRunner(j$); + j$.private.TreeProcessor = jRequire.TreeProcessor(j$); + j$.private.TreeRunner = jRequire.TreeRunner(j$); j$.version = jRequire.version(); - j$.Order = jRequire.Order(); - j$.DiffBuilder = jRequire.DiffBuilder(j$); - j$.NullDiffBuilder = jRequire.NullDiffBuilder(j$); - j$.ObjectPath = jRequire.ObjectPath(j$); - j$.MismatchTree = jRequire.MismatchTree(j$); + 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$); - // zone.js tries to monkey patch GlobalErrors in a way that is either a - // no-op or causes Jasmine to crash, depending on whether it's done before - // or after env creation. Prevent that. - const GlobalErrors = jRequire.GlobalErrors(j$); - Object.defineProperty(j$, 'GlobalErrors', { - enumerable: true, - configurable: false, - get() { - return GlobalErrors; - }, - set() {} - }); - - j$.Truthy = jRequire.Truthy(j$); - j$.Falsy = jRequire.Falsy(j$); - j$.Empty = jRequire.Empty(j$); - j$.NotEmpty = jRequire.NotEmpty(j$); - j$.Is = jRequire.Is(j$); - - j$.matchers = jRequire.requireMatchers(jRequire, j$); - j$.asyncMatchers = jRequire.requireAsyncMatchers(jRequire, j$); + j$.private.matchers = jRequire.requireMatchers(jRequire, j$); + j$.private.asyncMatchers = jRequire.requireAsyncMatchers(jRequire, j$); return j$; }; diff --git a/src/core/requireInterface.js b/src/core/requireInterface.js index 507ba14d..45f0f721 100644 --- a/src/core/requireInterface.js +++ b/src/core/requireInterface.js @@ -352,7 +352,7 @@ getJasmineRequireObj().interface = function(jasmine, env) { return env.spyOnAllFunctions(obj, includeNonEnumerable); }, - jsApiReporter: new jasmine.JsApiReporter({ + jsApiReporter: new jasmine.private.JsApiReporter({ timer: new jasmine.Timer() }), diff --git a/src/core/util.js b/src/core/util.js index f824df1d..e0e9edbd 100644 --- a/src/core/util.js +++ b/src/core/util.js @@ -27,7 +27,7 @@ getJasmineRequireObj().util = function(j$) { } else if (str === '[object Date]') { return new Date(arg.valueOf()); } else { - return j$.util.clone(arg); + return j$.private.util.clone(arg); } }); }; @@ -49,7 +49,7 @@ getJasmineRequireObj().util = function(j$) { }; function callerFile() { - const trace = new j$.StackTrace(new Error()); + const trace = new j$.private.StackTrace(new Error()); return trace.frames[1].file; } diff --git a/src/html/HtmlReporter.js b/src/html/HtmlReporter.js index 88cafae1..33a2f165 100644 --- a/src/html/HtmlReporter.js +++ b/src/html/HtmlReporter.js @@ -1,6 +1,6 @@ jasmineRequire.HtmlReporter = function(j$) { function ResultsStateBuilder() { - this.topResults = new j$.ResultsNode({}, '', null); + this.topResults = new j$.private.ResultsNode({}, '', null); this.currentParent = this.topResults; this.specsExecuted = 0; this.failureCount = 0; @@ -758,7 +758,7 @@ jasmineRequire.HtmlReporter = function(j$) { const el = createElement(type); let children; - if (j$.isArray_(childrenArrayOrVarArgs)) { + if (j$.private.isArray(childrenArrayOrVarArgs)) { children = childrenArrayOrVarArgs; } else { children = []; diff --git a/src/html/requireHtml.js b/src/html/requireHtml.js index 522db07f..dd3b5a47 100644 --- a/src/html/requireHtml.js +++ b/src/html/requireHtml.js @@ -2,7 +2,7 @@ var jasmineRequire = window.jasmineRequire || require('./jasmine.js'); jasmineRequire.html = function(j$) { - j$.ResultsNode = jasmineRequire.ResultsNode(); + j$.private.ResultsNode = jasmineRequire.ResultsNode(); j$.HtmlReporter = jasmineRequire.HtmlReporter(j$); j$.QueryString = jasmineRequire.QueryString(); j$.HtmlSpecFilter = jasmineRequire.HtmlSpecFilter(); From 4598e4049c125ea2687a34ddf702e3721083493a Mon Sep 17 00:00:00 2001 From: Steve Gravrock Date: Sat, 27 Sep 2025 13:22:51 -0700 Subject: [PATCH 32/95] Revert accidental change to 3.9 release notes --- release_notes/3.9.0.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/release_notes/3.9.0.md b/release_notes/3.9.0.md index 79ec1111..ca12f32b 100644 --- a/release_notes/3.9.0.md +++ b/release_notes/3.9.0.md @@ -2,7 +2,7 @@ ## New features and bug fixes -* Fixed Trusted Types error in `j$.private.isError` in Chromium-based browsers +* Fixed Trusted Types error in `j$.isError_` in Chromium-based browsers * Merges [#1921](https://github.com/jasmine/jasmine/pull/1921) from @bjarkler * Fixes [#1910](https://github.com/jasmine/jasmine/issues/1910) * Fixes [#1653](https://github.com/jasmine/jasmine/issues/1653) From c2ce55580c4246173c664e6c9760aaddf1c5e484 Mon Sep 17 00:00:00 2001 From: Steve Gravrock Date: Sat, 27 Sep 2025 13:33:25 -0700 Subject: [PATCH 33/95] Remove support for excution orders that re-enter suites --- lib/jasmine-core/jasmine.js | 30 ++---- spec/core/RunnerSpec.js | 131 ----------------------- spec/core/TreeProcessorSpec.js | 48 +++------ spec/core/TreeRunnerSpec.js | 12 +-- spec/core/integration/SpecRunningSpec.js | 63 +---------- src/core/TreeProcessor.js | 22 ++-- src/core/TreeRunner.js | 8 +- 7 files changed, 42 insertions(+), 272 deletions(-) diff --git a/lib/jasmine-core/jasmine.js b/lib/jasmine-core/jasmine.js index 3d927b00..9a614a5d 100644 --- a/lib/jasmine-core/jasmine.js +++ b/lib/jasmine-core/jasmine.js @@ -11336,8 +11336,7 @@ getJasmineRequireObj().TreeProcessor = function(j$) { const defaultMax = 1 - Infinity; // Transforms the suite tree into an execution tree, which represents the set - // of specs and (possibly interleaved) suites to be run in the order they are - // to be run in. + // of specs and suites to be run in the order they are to be run in. class TreeProcessor { #tree; #runnableIds; @@ -11419,15 +11418,7 @@ getJasmineRequireObj().TreeProcessor = function(j$) { segmentChildren(node, orderedChildren, this.#stats, executableIndex); if (this.#stats[node.id].segments.length > 1) { - if (node.canBeReentered()) { - j$.getEnv().deprecated( - 'The specified spec/suite order splits up a suite, running unrelated specs in the middle of it. This will become an error in a future release.' - ); - } else { - throw new Error( - 'Invalid order: would cause a beforeAll or afterAll to be run multiple times' - ); - } + throw new Error('Invalid order: would split up a suite'); } } } @@ -11445,15 +11436,14 @@ getJasmineRequireObj().TreeProcessor = function(j$) { } childrenOfTopSuite() { - return this.childrenOfSuiteSegment(this.topSuite, 0); + return this.childrenOfSuite(this.topSuite); } - childrenOfSuiteSegment(suite, segmentNumber) { - const segmentChildren = this.#stats[suite.id].segments[segmentNumber] - .nodes; + childrenOfSuite(suite) { + const segmentChildren = this.#stats[suite.id].segments[0].nodes; return segmentChildren.map(function(child) { if (child.owner.children) { - return { suite: child.owner, segmentNumber: child.index }; + return { suite: child.owner }; } else { return { spec: child.owner }; } @@ -11574,7 +11564,7 @@ getJasmineRequireObj().TreeRunner = function(j$) { async execute() { this.#hasFailures = false; await new Promise(resolve => { - this.#executeSuiteSegment(this.#executionTree.topSuite, 0, resolve); + this.#executeSuite(this.#executionTree.topSuite, resolve); }); return { hasFailures: this.#hasFailures }; } @@ -11584,7 +11574,7 @@ getJasmineRequireObj().TreeRunner = function(j$) { return { fn: done => { if (node.suite) { - this.#executeSuiteSegment(node.suite, node.segmentNumber, done); + this.#executeSuite(node.suite, done); } else { this._executeSpec(node.spec, done); } @@ -11674,7 +11664,7 @@ getJasmineRequireObj().TreeRunner = function(j$) { return fns; } - #executeSuiteSegment(suite, segmentNumber, done) { + #executeSuite(suite, done) { const isTopSuite = suite === this.#executionTree.topSuite; const isExcluded = this.#executionTree.isExcluded(suite); let befores = []; @@ -11696,7 +11686,7 @@ getJasmineRequireObj().TreeRunner = function(j$) { const children = isTopSuite ? this.#executionTree.childrenOfTopSuite() - : this.#executionTree.childrenOfSuiteSegment(suite, segmentNumber); + : this.#executionTree.childrenOfSuite(suite); const queueableFns = [ ...befores, ...this.#wrapNodes(children), diff --git a/spec/core/RunnerSpec.js b/spec/core/RunnerSpec.js index b4170886..c3cb65b0 100644 --- a/spec/core/RunnerSpec.js +++ b/spec/core/RunnerSpec.js @@ -470,137 +470,6 @@ describe('Runner', function() { await expectAsync(promise).toBePending(); }); - it('runs a suite multiple times if the order specified leaves and re-enters it', async function() { - const spec1 = new StubSpec(); - const spec2 = new StubSpec(); - const spec3 = new StubSpec(); - const spec4 = new StubSpec(); - const spec5 = new StubSpec(); - const reentered = new StubSuite({ children: [spec1, spec2, spec3] }); - const topSuite = new StubSuite({ children: [reentered, spec4, spec5] }); - const subject = makeRunner(topSuite); - - spyOn(jasmineUnderTest.getEnv(), 'deprecated'); - const promise = subject.execute([ - spec1.id, - spec4.id, - spec2.id, - spec5.id, - spec3.id - ]); - await Promise.resolve(); - expect(runQueue).toHaveBeenCalledTimes(1); - const queueableFns = runQueue.calls.mostRecent().args[0].queueableFns; - - queueableFns[0].fn(); - expect(runQueue.calls.mostRecent().args[0].queueableFns.length).toBe(2); - runQueue.calls.mostRecent().args[0].queueableFns[1].fn('done'); - expect( - privateUnderTest.TreeRunner.prototype._executeSpec - ).toHaveBeenCalledWith(spec1, 'done'); - - queueableFns[1].fn('done'); - expect( - privateUnderTest.TreeRunner.prototype._executeSpec - ).toHaveBeenCalledWith(spec4, 'done'); - - queueableFns[2].fn(); - expect(runQueue.calls.count()).toBe(3); - expect(runQueue.calls.mostRecent().args[0].queueableFns.length).toBe(2); - runQueue.calls.mostRecent().args[0].queueableFns[1].fn('done'); - expect( - privateUnderTest.TreeRunner.prototype._executeSpec - ).toHaveBeenCalledWith(spec2, 'done'); - - queueableFns[3].fn('done'); - expect( - privateUnderTest.TreeRunner.prototype._executeSpec - ).toHaveBeenCalledWith(spec5, 'done'); - - queueableFns[4].fn(); - expect(runQueue.calls.count()).toBe(4); - expect(runQueue.calls.mostRecent().args[0].queueableFns.length).toBe(2); - runQueue.calls.mostRecent().args[0].queueableFns[1].fn('done'); - expect( - privateUnderTest.TreeRunner.prototype._executeSpec - ).toHaveBeenCalledWith(spec3, 'done'); - - await expectAsync(promise).toBePending(); - }); - - it('runs a parent of a suite with multiple segments correctly', async function() { - const spec1 = new StubSpec(); - const spec2 = new StubSpec(); - const spec3 = new StubSpec(); - const spec4 = new StubSpec(); - const spec5 = new StubSpec(); - const parent = new StubSuite({ children: [spec1, spec2, spec3] }); - const grandparent = new StubSuite({ children: [parent] }); - const topSuite = new StubSuite({ children: [grandparent, spec4, spec5] }); - const subject = makeRunner(topSuite); - - spyOn(jasmineUnderTest.getEnv(), 'deprecated'); - const promise = subject.execute([ - spec1.id, - spec4.id, - spec2.id, - spec5.id, - spec3.id - ]); - await Promise.resolve(); - expect(runQueue).toHaveBeenCalledTimes(1); - const queueableFns = runQueue.calls.mostRecent().args[0].queueableFns; - expect(queueableFns.length).toBe(5); - - queueableFns[0].fn(); - expect(runQueue.calls.count()).toBe(2); - expect(runQueue.calls.mostRecent().args[0].queueableFns.length).toBe(2); - - runQueue.calls.mostRecent().args[0].queueableFns[1].fn(); - expect(runQueue.calls.count()).toBe(3); - - runQueue.calls.mostRecent().args[0].queueableFns[1].fn('done'); - expect( - privateUnderTest.TreeRunner.prototype._executeSpec - ).toHaveBeenCalledWith(spec1, 'done'); - - queueableFns[1].fn('done'); - expect( - privateUnderTest.TreeRunner.prototype._executeSpec - ).toHaveBeenCalledWith(spec4, 'done'); - - queueableFns[2].fn(); - expect(runQueue.calls.count()).toBe(4); - expect(runQueue.calls.mostRecent().args[0].queueableFns.length).toBe(2); - - runQueue.calls.mostRecent().args[0].queueableFns[1].fn(); - expect(runQueue.calls.count()).toBe(5); - - runQueue.calls.mostRecent().args[0].queueableFns[1].fn('done'); - expect( - privateUnderTest.TreeRunner.prototype._executeSpec - ).toHaveBeenCalledWith(spec2, 'done'); - - queueableFns[3].fn('done'); - expect( - privateUnderTest.TreeRunner.prototype._executeSpec - ).toHaveBeenCalledWith(spec5, 'done'); - - queueableFns[4].fn(); - expect(runQueue.calls.count()).toBe(6); - expect(runQueue.calls.mostRecent().args[0].queueableFns.length).toBe(2); - - runQueue.calls.mostRecent().args[0].queueableFns[1].fn(); - expect(runQueue.calls.count()).toBe(7); - - runQueue.calls.mostRecent().args[0].queueableFns[1].fn('done'); - expect( - privateUnderTest.TreeRunner.prototype._executeSpec - ).toHaveBeenCalledWith(spec3, 'done'); - - await expectAsync(promise).toBePending(); - }); - it('runs large segments of nodes in the order they were declared', async function() { const specs = []; diff --git a/spec/core/TreeProcessorSpec.js b/spec/core/TreeProcessorSpec.js index ceabd5fc..699be65c 100644 --- a/spec/core/TreeProcessorSpec.js +++ b/spec/core/TreeProcessorSpec.js @@ -135,11 +135,9 @@ describe('TreeProcessor', function() { const result = processor.processTree(); - expect(result.childrenOfTopSuite()).toEqual([ - { suite: node, segmentNumber: 0 } - ]); + expect(result.childrenOfTopSuite()).toEqual([{ suite: node }]); expect(result.isExcluded(node)).toEqual(true); - expect(result.childrenOfSuiteSegment(node, 0)).toEqual([{ spec: leaf1 }]); + expect(result.childrenOfSuite(node)).toEqual([{ spec: leaf1 }]); expect(result.isExcluded(node)).toEqual(true); }); @@ -167,37 +165,37 @@ describe('TreeProcessor', function() { expect(result.isExcluded(parent)).toEqual(false); expect(result.childrenOfTopSuite()).toEqual([ - { suite: parent, segmentNumber: 0 }, - { suite: parentOfPendings, segmentNumber: 0 } + { suite: parent }, + { suite: parentOfPendings } ]); expect(result.isExcluded(parentOfPendings)).toEqual(true); - expect(result.childrenOfSuiteSegment(parentOfPendings, 0)).toEqual([ - { suite: childless, segmentNumber: 0 }, - { suite: pendingNode, segmentNumber: 0 } + expect(result.childrenOfSuite(parentOfPendings)).toEqual([ + { suite: childless }, + { suite: pendingNode } ]); expect(result.isExcluded(childless)).toEqual(true); - expect(result.childrenOfSuiteSegment(childless, 0)).toEqual([]); + expect(result.childrenOfSuite(childless)).toEqual([]); expect(result.isExcluded(pendingLeaf)).toEqual(false); expect(result.isExcluded(executableLeaf)).toEqual(false); expect(result.isExcluded(parent)).toEqual(false); - expect(result.childrenOfSuiteSegment(parent, 0)).toEqual([ + expect(result.childrenOfSuite(parent)).toEqual([ { spec: pendingLeaf }, { spec: executableLeaf } ]); expect(result.isExcluded(pendingNode)).toEqual(true); - expect(result.childrenOfSuiteSegment(pendingNode, 0)).toEqual([ + expect(result.childrenOfSuite(pendingNode)).toEqual([ { spec: childOfPending } ]); expect(result.isExcluded(childOfPending)).toEqual(false); }); - it('throws if the specified order would re-enter a node that does not allow re-entry', function() { + it('throws if the specified order would re-enter a node', function() { const leaf1 = new Leaf(), leaf2 = new Leaf(), leaf3 = new Leaf(), @@ -210,29 +208,7 @@ describe('TreeProcessor', function() { expect(function() { processor.processTree(); - }).toThrowError( - 'Invalid order: would cause a beforeAll or afterAll to be run multiple times' - ); - }); - - it('does not throw if a node being re-entered allows re-entry', function() { - const leaf1 = new Leaf(); - const leaf2 = new Leaf(); - const leaf3 = new Leaf(); - const reentered = new Node({ children: [leaf1, leaf2] }); - const root = new Node({ children: [reentered, leaf3] }); - const processor = new privateUnderTest.TreeProcessor({ - tree: root, - runnableIds: [leaf1.id, leaf3.id, leaf2.id] - }); - const env = jasmineUnderTest.getEnv(); - spyOn(env, 'deprecated'); - - processor.processTree(); - - expect(env.deprecated).toHaveBeenCalledWith( - 'The specified spec/suite order splits up a suite, running unrelated specs in the middle of it. This will become an error in a future release.' - ); + }).toThrowError('Invalid order: would split up a suite'); }); it("does not throw if a node which can't be re-entered is only entered once", function() { diff --git a/spec/core/TreeRunnerSpec.js b/spec/core/TreeRunnerSpec.js index 634098df..d9771a2c 100644 --- a/spec/core/TreeRunnerSpec.js +++ b/spec/core/TreeRunnerSpec.js @@ -180,7 +180,7 @@ describe('TreeRunner', function() { childrenOfTopSuite() { return [{ suite }]; }, - childrenOfSuiteSegment() { + childrenOfSuite() { return []; }, isExcluded() { @@ -240,7 +240,7 @@ describe('TreeRunner', function() { childrenOfTopSuite() { return [{ suite: failingSuite }, { suite: passingSuite }]; }, - childrenOfSuiteSegment() { + childrenOfSuite() { return []; }, isExcluded() { @@ -308,7 +308,7 @@ describe('TreeRunner', function() { childrenOfTopSuite() { return [{ suite }]; }, - childrenOfSuiteSegment() { + childrenOfSuite() { return [{ spec }]; }, isExcluded() { @@ -371,7 +371,7 @@ describe('TreeRunner', function() { childrenOfTopSuite() { return [{ suite }]; }, - childrenOfSuiteSegment() { + childrenOfSuite() { return [{ spec }]; }, isExcluded() { @@ -519,7 +519,7 @@ describe('TreeRunner', function() { childrenOfTopSuite() { return [{ suite }]; }, - childrenOfSuiteSegment() { + childrenOfSuite() { return [{ spec }]; }, isExcluded() { @@ -588,7 +588,7 @@ describe('TreeRunner', function() { childrenOfTopSuite() { return [{ suite }]; }, - childrenOfSuiteSegment() { + childrenOfSuite() { return [{ spec }]; }, isExcluded() { diff --git a/spec/core/integration/SpecRunningSpec.js b/spec/core/integration/SpecRunningSpec.js index 932c6788..355d0407 100644 --- a/spec/core/integration/SpecRunningSpec.js +++ b/spec/core/integration/SpecRunningSpec.js @@ -601,37 +601,7 @@ describe('spec running', function() { ]); }); - it('re-enters suites that have no *Alls', async function() { - const actions = []; - let spec1; - let spec2; - let spec3; - - env.describe('top', function() { - spec1 = env.it('spec1', function() { - actions.push('spec1'); - }); - - spec2 = env.it('spec2', function() { - actions.push('spec2'); - }); - }); - - spec3 = env.it('spec3', function() { - actions.push('spec3'); - }); - - spyOn(jasmineUnderTest.getEnv(), 'deprecated'); - - await env.execute([spec2.id, spec3.id, spec1.id]); - - expect(actions).toEqual(['spec2', 'spec3', 'spec1']); - expect(jasmineUnderTest.getEnv().deprecated).toHaveBeenCalledWith( - 'The specified spec/suite order splits up a suite, running unrelated specs in the middle of it. This will become an error in a future release.' - ); - }); - - it('refuses to re-enter suites with a beforeAll', async function() { + it('refuses to re-enter suites', async function() { const actions = []; let spec1; let spec2; @@ -654,34 +624,9 @@ describe('spec running', function() { }); const promise = env.execute([spec2.id, spec3.id, spec1.id]); - await expectAsync(promise).toBeRejectedWithError(/beforeAll/); - expect(actions).toEqual([]); - }); - - it('refuses to re-enter suites with a afterAll', async function() { - const actions = []; - let spec1; - let spec2; - let spec3; - - env.describe('top', function() { - env.afterAll(function() {}); - - spec1 = env.it('spec1', function() { - actions.push('spec1'); - }); - - spec2 = env.it('spec2', function() { - actions.push('spec2'); - }); - }); - - spec3 = env.it('spec3', function() { - actions.push('spec3'); - }); - - const promise = env.execute([spec2.id, spec3.id, spec1.id]); - await expectAsync(promise).toBeRejectedWithError(/afterAll/); + await expectAsync(promise).toBeRejectedWithError( + 'Invalid order: would split up a suite' + ); expect(actions).toEqual([]); }); diff --git a/src/core/TreeProcessor.js b/src/core/TreeProcessor.js index a26a80b6..72f7bfec 100644 --- a/src/core/TreeProcessor.js +++ b/src/core/TreeProcessor.js @@ -3,8 +3,7 @@ getJasmineRequireObj().TreeProcessor = function(j$) { const defaultMax = 1 - Infinity; // Transforms the suite tree into an execution tree, which represents the set - // of specs and (possibly interleaved) suites to be run in the order they are - // to be run in. + // of specs and suites to be run in the order they are to be run in. class TreeProcessor { #tree; #runnableIds; @@ -86,15 +85,7 @@ getJasmineRequireObj().TreeProcessor = function(j$) { segmentChildren(node, orderedChildren, this.#stats, executableIndex); if (this.#stats[node.id].segments.length > 1) { - if (node.canBeReentered()) { - j$.getEnv().deprecated( - 'The specified spec/suite order splits up a suite, running unrelated specs in the middle of it. This will become an error in a future release.' - ); - } else { - throw new Error( - 'Invalid order: would cause a beforeAll or afterAll to be run multiple times' - ); - } + throw new Error('Invalid order: would split up a suite'); } } } @@ -112,15 +103,14 @@ getJasmineRequireObj().TreeProcessor = function(j$) { } childrenOfTopSuite() { - return this.childrenOfSuiteSegment(this.topSuite, 0); + return this.childrenOfSuite(this.topSuite); } - childrenOfSuiteSegment(suite, segmentNumber) { - const segmentChildren = this.#stats[suite.id].segments[segmentNumber] - .nodes; + childrenOfSuite(suite) { + const segmentChildren = this.#stats[suite.id].segments[0].nodes; return segmentChildren.map(function(child) { if (child.owner.children) { - return { suite: child.owner, segmentNumber: child.index }; + return { suite: child.owner }; } else { return { spec: child.owner }; } diff --git a/src/core/TreeRunner.js b/src/core/TreeRunner.js index 5d96d4da..ece555d9 100644 --- a/src/core/TreeRunner.js +++ b/src/core/TreeRunner.js @@ -24,7 +24,7 @@ getJasmineRequireObj().TreeRunner = function(j$) { async execute() { this.#hasFailures = false; await new Promise(resolve => { - this.#executeSuiteSegment(this.#executionTree.topSuite, 0, resolve); + this.#executeSuite(this.#executionTree.topSuite, resolve); }); return { hasFailures: this.#hasFailures }; } @@ -34,7 +34,7 @@ getJasmineRequireObj().TreeRunner = function(j$) { return { fn: done => { if (node.suite) { - this.#executeSuiteSegment(node.suite, node.segmentNumber, done); + this.#executeSuite(node.suite, done); } else { this._executeSpec(node.spec, done); } @@ -124,7 +124,7 @@ getJasmineRequireObj().TreeRunner = function(j$) { return fns; } - #executeSuiteSegment(suite, segmentNumber, done) { + #executeSuite(suite, done) { const isTopSuite = suite === this.#executionTree.topSuite; const isExcluded = this.#executionTree.isExcluded(suite); let befores = []; @@ -146,7 +146,7 @@ getJasmineRequireObj().TreeRunner = function(j$) { const children = isTopSuite ? this.#executionTree.childrenOfTopSuite() - : this.#executionTree.childrenOfSuiteSegment(suite, segmentNumber); + : this.#executionTree.childrenOfSuite(suite); const queueableFns = [ ...befores, ...this.#wrapNodes(children), From e11f320df334b66031f41a09be0637f6396a20f1 Mon Sep 17 00:00:00 2001 From: Steve Gravrock Date: Sat, 27 Sep 2025 15:40:19 -0700 Subject: [PATCH 34/95] Also require setSpecProperty/setSuiteProperty args to be JSON serializable --- lib/jasmine-core/jasmine.js | 15 +++++++++------ spec/core/SpecSpec.js | 24 ++++++++++++++++++++++++ src/core/Spec.js | 4 ++-- src/core/Suite.js | 4 ++-- src/core/util.js | 7 +++++-- 5 files changed, 42 insertions(+), 12 deletions(-) diff --git a/lib/jasmine-core/jasmine.js b/lib/jasmine-core/jasmine.js index 9a614a5d..d890cc0b 100644 --- a/lib/jasmine-core/jasmine.js +++ b/lib/jasmine-core/jasmine.js @@ -761,9 +761,12 @@ getJasmineRequireObj().util = function(j$) { } }; - util.assertStructuredCloneable = function(v, msgPrefix) { + util.assertReporterCloneable = function(v, msgPrefix) { try { - structuredClone(v); + // Reporter events are cloned internally via structuredClone, and it's + // common for reporters (including jasmine-browser-runner's) to JSON + // serialize them. + JSON.stringify(structuredClone(v)); } catch (e) { throw new Error(`${msgPrefix} can't be cloned`, { cause: e }); } @@ -848,8 +851,8 @@ 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. - j$.private.util.assertStructuredCloneable(key, 'Key'); - j$.private.util.assertStructuredCloneable(value, 'Value'); + j$.private.util.assertReporterCloneable(key, 'Key'); + j$.private.util.assertReporterCloneable(value, 'Value'); this.result.properties = this.result.properties || {}; this.result.properties[key] = value; } @@ -10631,8 +10634,8 @@ 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. - j$.private.util.assertStructuredCloneable(key, 'Key'); - j$.private.util.assertStructuredCloneable(value, 'Value'); + j$.private.util.assertReporterCloneable(key, 'Key'); + j$.private.util.assertReporterCloneable(value, 'Value'); this.result.properties = this.result.properties || {}; this.result.properties[key] = value; } diff --git a/spec/core/SpecSpec.js b/spec/core/SpecSpec.js index 13bcddf7..12370d6d 100644 --- a/spec/core/SpecSpec.js +++ b/spec/core/SpecSpec.js @@ -113,6 +113,18 @@ describe('Spec', function() { }).toThrowError("Key can't be cloned"); }); + it('throws if the key is not JSON-serializable', function() { + const spec = new privateUnderTest.Spec({ + queueableFn: { fn: () => {} } + }); + + expect(function() { + const k = {}; + k.self = k; + spec.setSpecProperty(k, ''); + }).toThrowError("Key can't be cloned"); + }); + it('throws if the value is not structured-cloneable', function() { const spec = new privateUnderTest.Spec({ queueableFn: { fn: () => {} } @@ -122,6 +134,18 @@ describe('Spec', function() { spec.setSpecProperty('k', new Promise(() => {})); }).toThrowError("Value can't be cloned"); }); + + it('throws if the value is not JSON-serializable', function() { + const spec = new privateUnderTest.Spec({ + queueableFn: { fn: () => {} } + }); + + expect(function() { + const v = {}; + v.self = v; + spec.setSpecProperty('k', v); + }).toThrowError("Value can't be cloned"); + }); }); describe('status', function() { diff --git a/src/core/Spec.js b/src/core/Spec.js index 2f3202d8..1a990cc9 100644 --- a/src/core/Spec.js +++ b/src/core/Spec.js @@ -74,8 +74,8 @@ 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. - j$.private.util.assertStructuredCloneable(key, 'Key'); - j$.private.util.assertStructuredCloneable(value, 'Value'); + j$.private.util.assertReporterCloneable(key, 'Key'); + j$.private.util.assertReporterCloneable(value, 'Value'); this.result.properties = this.result.properties || {}; this.result.properties[key] = value; } diff --git a/src/core/Suite.js b/src/core/Suite.js index 62a91216..96eabe2c 100644 --- a/src/core/Suite.js +++ b/src/core/Suite.js @@ -34,8 +34,8 @@ 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. - j$.private.util.assertStructuredCloneable(key, 'Key'); - j$.private.util.assertStructuredCloneable(value, 'Value'); + j$.private.util.assertReporterCloneable(key, 'Key'); + j$.private.util.assertReporterCloneable(value, 'Value'); this.result.properties = this.result.properties || {}; this.result.properties[key] = value; } diff --git a/src/core/util.js b/src/core/util.js index e0e9edbd..52ef4a74 100644 --- a/src/core/util.js +++ b/src/core/util.js @@ -80,9 +80,12 @@ getJasmineRequireObj().util = function(j$) { } }; - util.assertStructuredCloneable = function(v, msgPrefix) { + util.assertReporterCloneable = function(v, msgPrefix) { try { - structuredClone(v); + // Reporter events are cloned internally via structuredClone, and it's + // common for reporters (including jasmine-browser-runner's) to JSON + // serialize them. + JSON.stringify(structuredClone(v)); } catch (e) { throw new Error(`${msgPrefix} can't be cloned`, { cause: e }); } From dbcc1c924ade7316ab4c0964de67da78fcece78c Mon Sep 17 00:00:00 2001 From: Steve Gravrock Date: Mon, 29 Sep 2025 18:45:30 -0700 Subject: [PATCH 35/95] Bump version to 6.0.0-alpha.0 --- lib/jasmine-core/jasmine.js | 2 +- package.json | 2 +- release_notes/6.0.0-alpha.0.md | 100 +++++++++++++++++++++++++++++++++ 3 files changed, 102 insertions(+), 2 deletions(-) create mode 100644 release_notes/6.0.0-alpha.0.md diff --git a/lib/jasmine-core/jasmine.js b/lib/jasmine-core/jasmine.js index 6f3fd05a..f1363687 100644 --- a/lib/jasmine-core/jasmine.js +++ b/lib/jasmine-core/jasmine.js @@ -11864,5 +11864,5 @@ getJasmineRequireObj().UserContext = function(j$) { }; getJasmineRequireObj().version = function() { - return '5.11.0'; + return '6.0.0-alpha.0'; }; diff --git a/package.json b/package.json index 3818d41e..53ce688c 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "jasmine-core", "license": "MIT", - "version": "5.11.0", + "version": "6.0.0-alpha.0", "repository": { "type": "git", "url": "https://github.com/jasmine/jasmine.git" diff --git a/release_notes/6.0.0-alpha.0.md b/release_notes/6.0.0-alpha.0.md new file mode 100644 index 00000000..93d954dd --- /dev/null +++ b/release_notes/6.0.0-alpha.0.md @@ -0,0 +1,100 @@ +# Jasmine Core 6.0.0-alpha.0 Release Notes + +This is a pre-release, intended to offer a preview of breaking changes and to +solicit feedback. + +## A Note About Pre-Release Compatibility + +There may be additional breaking changes in future 6.0 pre-releases or in the +final 6.0 release. That's allowed by the semver specification, but users are +sometimes unpleasantly surprised by it. + +NPM's implementation of carat version ranges assumes that subsequent +pre-releases and final releases are fully compatible with earlier pre-releases. +If your package.json contains `"jasmine-core": "^6.0.0-alpha.0`, +NPM might install any later 6.x version even though there is no guarantee of +compatibility. If that isn't ok, you should specify an exact pre-release version: +`"jasmine-core": "6.0.0-alpha.0`. + +## Changes to supported environments + +* Node 18 is no longer supported. + +## Breaking changes + +### General + +* Private APIs have been removed from the `jasmine` namespace. + + The purpose of this change is to reduce the risk of users inadvertently + depending on private APIs. Anything that's not covered by + [the documentation](https://jasmine.github.io/pages/docs_home.html) remains + private regardless of namespacing. Private APIs may be changed or removed in + any release. This change is being made in a major release as a courtesy to users of + libraries that depend on private APIs. + +* Arguments to `setSpecProperty`/`setSuiteProperty` must be both + structured-cloneable and JSON-serializable. +* Mock clock timing functions cannot be spied on. Previously this "worked" but + prevented the mock clock from uninstalling itself. +* The default value of the `forbidDuplicateNames` config option has been + changed to true. +* The mock clock no longer supports the eval forms of `setTimeout` and + `setInterval`. +* If an execution order is passed to `Env#execute`, it must not enter any suite + more than once. +* The argument passed to spec filters is a + [spec metadata](https://jasmine.github.io/api/6.0.0-alpha.0/Spec.html) + instance, not the internal spec object. + +### Changes that affect reporters + +This release includes changes that are intended to streamline and clarify the +reporter interface, prevent sharing of mutable state, and prevent bugs involving +non-serializable objects. These changes should be compatible with most existing +reporters but could break reporters that manage their internal state in unusual +ways. Please [open an issue](https://github.com/jasmine/jasmine/issues/new?template=bug_report.yml) +if you find a published reporter package that works with jasmine-core 5.x but +not with this release. + +* Irrelevant properties such as `status` and `failedExpectations` are omitted + from [the event passed to specStarted](https://jasmine.github.io/api/6.0.0-alpha.0/global.html#SpecStartedEvent). +* Reporter events are deep-cloned before being passed to each reporter. This + protects reporters against later mutation by jasmine-core or other reporters. +* The `expected` and `actual` properties of + [passed and failed expectations](https://jasmine.github.io/api/6.0.0-alpha.0/global.html#ExpectationResult) + have been removed. +* The [order](https://jasmine.github.io/api/6.0.0-alpha.0/global.html#Order) + property of the`jasmineStarted` and `jasmineDone` reporter events no longer + includes undocumented properties. + +### Changes to Node boot functions + +* [boot](https://jasmine.github.io/api/6.0.0-alpha.0/module-jasmine-core.html#.boot) + defaults to creating a new core instance each time it's called. This restores + the pre-5.0 default behavior. +* [noGlobals](https://jasmine.github.io/api/6.0.0-alpha.0/module-jasmine-core.html#.noGlobals) + no longer takes a parameter. It always returns the same object when called + repeatedly. + +## Supported environments + +This version has been tested in the following environments. + +| Environment | Supported versions | +|-------------------|--------------------------------| +| Node | 20, 22, 24 | +| Safari | 16**, 17** | +| Chrome | 140* | +| Firefox | 102**, 115**, 128**, 140, 143* | +| Edge | 140* | + +\* Evergreen browser. Each version of Jasmine is tested against the latest +version available at release time.
+\** Supported on a best-effort basis. Support for these versions may be dropped +if it becomes impractical, and bugs affecting only these versions may not be +treated as release blockers. + +------ + +_Release Notes generated with _[Anchorman](http://github.com/infews/anchorman)_ From bca56032e0b0252d5e6745fad306ba0b9a26164d Mon Sep 17 00:00:00 2001 From: Steve Gravrock Date: Sat, 4 Oct 2025 12:11:14 -0700 Subject: [PATCH 36/95] Expose browser errors uniformly outside of GlobalErrors --- lib/jasmine-core/jasmine.js | 89 +++++++++--------- spec/core/GlobalErrorsSpec.js | 91 ++++++++++--------- spec/core/QueueRunnerSpec.js | 59 ------------ .../integration/GlobalErrorHandlingSpec.js | 2 +- src/core/Env.js | 10 +- src/core/GlobalErrors.js | 60 ++++++------ src/core/QueueRunner.js | 19 +--- 7 files changed, 135 insertions(+), 195 deletions(-) diff --git a/lib/jasmine-core/jasmine.js b/lib/jasmine-core/jasmine.js index f1363687..76d40626 100644 --- a/lib/jasmine-core/jasmine.js +++ b/lib/jasmine-core/jasmine.js @@ -1251,14 +1251,14 @@ getJasmineRequireObj().Env = function(j$) { if (!envOptions.suppressLoadErrors) { installGlobalErrors(); - globalErrors.pushListener(function loadtimeErrorHandler(error, event) { + globalErrors.pushListener(function loadtimeErrorHandler(error) { topSuite.result.failedExpectations.push({ passed: false, globalErrorType: 'load', - message: error ? error.message : event.message, - stack: error && error.stack, - filename: event && event.filename, - lineno: event && event.lineno + message: error.message, + stack: error.stack, + filename: error.filename, + lineno: error.lineno }); }); } @@ -4433,13 +4433,6 @@ getJasmineRequireObj().GlobalErrors = function(j$) { this.#adapter.uninstall(); } - // The listener at the top of the stack will be called with two arguments: - // the error and the event. Either of them may be falsy. - // The error will normally be provided, but will be falsy in the case of - // some browser load-time errors. The event will normally be provided in - // browsers but will be falsy in Node. - // Listeners that are pushed after spec files have been loaded should be - // able to just use the error parameter. pushListener(listener) { this.#handlers.push(listener); } @@ -4471,29 +4464,23 @@ getJasmineRequireObj().GlobalErrors = function(j$) { } reportUnhandledRejections() { - for (const { - reason, - event - } of this.#pendingUnhandledRejections.values()) { - this.#dispatchError(reason, event); + for (const { reason } of this.#pendingUnhandledRejections.values()) { + this.#dispatchError(reason); } this.#pendingUnhandledRejections.clear(); } - // Either error or event may be undefined - #onUncaughtException(error, event) { - this.#dispatchError(error, event); + #onUncaughtException(error) { + this.#dispatchError(error); } - // event or promise may be undefined - // event is passed through for backwards compatibility reasons. It's probably - // unnecessary, but user code could depend on it. - #onUnhandledRejection(reason, promise, event) { + // promise may be undefined + #onUnhandledRejection(reason, promise) { if (this.#detectLateRejectionHandling() && promise) { - this.#pendingUnhandledRejections.set(promise, { reason, event }); + this.#pendingUnhandledRejections.set(promise, { reason }); } else { - this.#dispatchError(reason, event); + this.#dispatchError(reason); } } @@ -4505,8 +4492,7 @@ getJasmineRequireObj().GlobalErrors = function(j$) { this.#pendingUnhandledRejections.delete(promise); } - // Either error or event may be undefined - #dispatchError(error, event) { + #dispatchError(error) { if (this.#overrideHandler) { // See discussion of spyOnGlobalErrorsAsync in base.js this.#overrideHandler(error); @@ -4516,7 +4502,7 @@ getJasmineRequireObj().GlobalErrors = function(j$) { const handler = this.#handlers[this.#handlers.length - 1]; if (handler) { - handler(error, event); + handler(error); } else { throw error; } @@ -4533,7 +4519,7 @@ getJasmineRequireObj().GlobalErrors = function(j$) { constructor(global, dispatch) { this.#global = global; this.#dispatch = dispatch; - this.#onError = event => dispatch.onUncaughtException(event.error, event); + this.#onError = this.#errorHandler.bind(this); this.#onUnhandledRejection = this.#unhandledRejectionHandler.bind(this); this.#onRejectionHandled = this.#rejectionHandledHandler.bind(this); } @@ -4562,6 +4548,28 @@ getJasmineRequireObj().GlobalErrors = function(j$) { ); } + #errorHandler(event) { + let error = event.error; + + // event.error isn't guaranteed to be present in all browser load-time + // error events. + if (!error) { + error = { + message: event.message, + stack: `@${event.filename}:${event.lineno}` + }; + } + + if (event.filename) { + // filename and lineno can be more convenient than stack when reporting + // things like syntax errors. Pass them along. + error.filename = event.filename; + error.lineno = event.lineno; + } + + this.#dispatch.onUncaughtException(error); + } + #unhandledRejectionHandler(event) { const jasmineMessage = 'Unhandled promise rejection: ' + event.reason; let reason; @@ -4573,7 +4581,7 @@ getJasmineRequireObj().GlobalErrors = function(j$) { reason = jasmineMessage; } - this.#dispatch.onUnhandledRejection(reason, event.promise, event); + this.#dispatch.onUnhandledRejection(reason, event.promise); } #rejectionHandledHandler(event) { @@ -8387,8 +8395,8 @@ getJasmineRequireObj().QueueRunner = function(j$) { } QueueRunner.prototype.execute = function() { - this.handleFinalError = (error, event) => { - this.onException(errorOrMsgForGlobalError(error, event)); + this.handleFinalError = error => { + this.onException(error); }; this.globalErrors.pushListener(this.handleFinalError); this.run(0); @@ -8418,8 +8426,8 @@ getJasmineRequireObj().QueueRunner = function(j$) { this.recordError_(iterativeIndex); }; - function handleError(error, event) { - onException(errorOrMsgForGlobalError(error, event)); + function handleError(error) { + onException(error); } const cleanup = once(() => { if (timeoutId !== void 0) { @@ -8606,17 +8614,6 @@ getJasmineRequireObj().QueueRunner = function(j$) { }; } - function errorOrMsgForGlobalError(error, event) { - // TODO: In cases where error is a string or undefined, the error message - // that gets sent to reporters will be `${message} thrown`, which could - // be improved to not say "thrown" when the cause wasn't necessarily - // an exception or to provide hints about throwing Errors rather than - // strings. - return ( - error || (event && event.message) || 'Global error event with no message' - ); - } - return QueueRunner; }; diff --git a/spec/core/GlobalErrorsSpec.js b/spec/core/GlobalErrorsSpec.js index d53695ad..f795f25b 100644 --- a/spec/core/GlobalErrorsSpec.js +++ b/spec/core/GlobalErrorsSpec.js @@ -13,10 +13,7 @@ describe('GlobalErrors', function() { const error = new Error('nope'); dispatchEvent(globals.listeners, 'error', { error }); - expect(handler).toHaveBeenCalledWith( - jasmine.is(error), - jasmine.objectContaining({ error: jasmine.is(error) }) - ); + expect(handler).toHaveBeenCalledWith(jasmine.is(error)); }); it('is not affected by overriding global.onerror', function() { @@ -35,10 +32,7 @@ describe('GlobalErrors', function() { const error = new Error('nope'); dispatchEvent(globals.listeners, 'error', { error }); - expect(handler).toHaveBeenCalledWith( - jasmine.is(error), - jasmine.objectContaining({ error: jasmine.is(error) }) - ); + expect(handler).toHaveBeenCalledWith(jasmine.is(error)); }); it('only calls the most recent handler', function() { @@ -58,10 +52,7 @@ describe('GlobalErrors', function() { dispatchEvent(globals.listeners, 'error', { error }); expect(handler1).not.toHaveBeenCalled(); - expect(handler2).toHaveBeenCalledWith( - jasmine.is(error), - jasmine.objectContaining({ error: jasmine.is(error) }) - ); + expect(handler2).toHaveBeenCalledWith(jasmine.is(error)); }); it('calls previous handlers when one is removed', function() { @@ -82,10 +73,7 @@ describe('GlobalErrors', function() { const error = new Error('nope'); dispatchEvent(globals.listeners, 'error', { error }); - expect(handler1).toHaveBeenCalledWith( - jasmine.is(error), - jasmine.objectContaining({ error: jasmine.is(error) }) - ); + expect(handler1).toHaveBeenCalledWith(jasmine.is(error)); expect(handler2).not.toHaveBeenCalled(); }); @@ -130,6 +118,32 @@ describe('GlobalErrors', function() { errors.uninstall(); }); + it("reports browser error events that don't have errors", function() { + const globals = browserGlobals(); + const handler = jasmine.createSpy('errorHandler'); + const errors = new privateUnderTest.GlobalErrors( + globals.global, + () => ({}) + ); + errors.install(); + errors.pushListener(handler); + + const event = { + message: 'Uncaught SyntaxError: Unexpected end of input', + error: undefined, + filename: 'borkenSpec.js', + lineno: 42 + }; + dispatchEvent(globals.listeners, 'error', event); + + expect(handler).toHaveBeenCalledWith({ + message: 'Uncaught SyntaxError: Unexpected end of input', + filename: 'borkenSpec.js', + lineno: 42, + stack: '@borkenSpec.js:42' + }); + }); + it('reports uncaught exceptions in node.js', function() { const globals = nodeGlobals(); const errors = new privateUnderTest.GlobalErrors( @@ -152,7 +166,7 @@ describe('GlobalErrors', function() { dispatchEvent(globals.listeners, 'uncaughtException', new Error('bar')); - expect(handler).toHaveBeenCalledWith(new Error('bar'), undefined); + expect(handler).toHaveBeenCalledWith(new Error('bar')); expect(handler.calls.argsFor(0)[0].jasmineMessage).toBe( 'Uncaught exception: Error: bar' ); @@ -185,7 +199,7 @@ describe('GlobalErrors', function() { dispatchEvent(globals.listeners, 'unhandledRejection', new Error('bar')); - expect(handler).toHaveBeenCalledWith(new Error('bar'), undefined); + expect(handler).toHaveBeenCalledWith(new Error('bar')); expect(handler.calls.argsFor(0)[0].jasmineMessage).toBe( 'Unhandled promise rejection: Error: bar' ); @@ -213,8 +227,7 @@ describe('GlobalErrors', function() { 'Unhandled promise rejection: 17\n' + '(Tip: to get a useful stack trace, use ' + 'Promise.reject(new Error(...)) instead of Promise.reject(...).)' - ), - undefined + ) ); }); @@ -236,8 +249,7 @@ describe('GlobalErrors', function() { 'Unhandled promise rejection with no error or message\n' + '(Tip: to get a useful stack trace, use ' + 'Promise.reject(new Error(...)) instead of Promise.reject().)' - ), - undefined + ) ); }); @@ -281,7 +293,7 @@ describe('GlobalErrors', function() { undefined ); - expect(handler).toHaveBeenCalledWith(new Error('nope'), undefined); + expect(handler).toHaveBeenCalledWith(new Error('nope')); expect(handler.calls.argsFor(0)[0].jasmineMessage).toBe( 'Unhandled promise rejection: Error: nope' ); @@ -324,7 +336,7 @@ describe('GlobalErrors', function() { ); errors.reportUnhandledRejections(); - expect(handler).toHaveBeenCalledWith(new Error('nope'), undefined); + expect(handler).toHaveBeenCalledWith(new Error('nope')); expect(handler.calls.argsFor(0)[0].jasmineMessage).toBe( 'Unhandled promise rejection: Error: nope' ); @@ -407,10 +419,7 @@ describe('GlobalErrors', function() { const event = { reason: 'nope' }; dispatchEvent(globals.listeners, 'unhandledrejection', event); - expect(handler).toHaveBeenCalledWith( - 'Unhandled promise rejection: nope', - event - ); + expect(handler).toHaveBeenCalledWith('Unhandled promise rejection: nope'); }); it('reports rejections whose reason is an Error', function() { @@ -428,13 +437,15 @@ describe('GlobalErrors', function() { const event = { reason }; dispatchEvent(globals.listeners, 'unhandledrejection', event); - expect(handler).toHaveBeenCalledWith( + expect(handler).toHaveBeenCalledTimes(1); + const received = handler.calls.argsFor(0)[0]; + expect(received).toBeInstanceOf(Error); + expect(received).toEqual( jasmine.objectContaining({ jasmineMessage: 'Unhandled promise rejection: Error: bar', message: reason.message, stack: reason.stack - }), - event + }) ); }); @@ -469,8 +480,7 @@ describe('GlobalErrors', function() { dispatchEvent(globals.listeners, 'unhandledrejection', event); expect(handler).toHaveBeenCalledWith( - 'Unhandled promise rejection: nope', - event + 'Unhandled promise rejection: nope' ); }); }); @@ -507,8 +517,7 @@ describe('GlobalErrors', function() { errors.reportUnhandledRejections(); expect(handler).toHaveBeenCalledWith( - 'Unhandled promise rejection: nope', - { reason: 'nope', promise } + 'Unhandled promise rejection: nope' ); }); @@ -567,10 +576,7 @@ describe('GlobalErrors', function() { dispatchEvent(globals.listeners, 'uncaughtException', 17); - expect(handler).toHaveBeenCalledWith( - new Error('Uncaught exception: 17'), - undefined - ); + expect(handler).toHaveBeenCalledWith(new Error('Uncaught exception: 17')); }); it('substitutes a descriptive message when the error is falsy', function() { @@ -587,8 +593,7 @@ describe('GlobalErrors', function() { dispatchEvent(globals.listeners, 'uncaughtException', undefined); expect(handler).toHaveBeenCalledWith( - new Error('Uncaught exception with no error or message'), - undefined + new Error('Uncaught exception with no error or message') ); }); }); @@ -619,7 +624,7 @@ describe('GlobalErrors', function() { const event = { error: 'baz' }; dispatchEvent(globals.listeners, 'error', event); expect(overrideHandler).not.toHaveBeenCalledWith('baz'); - expect(handler1).toHaveBeenCalledWith('baz', event); + expect(handler1).toHaveBeenCalledWith('baz'); }); it('overrides the existing handlers in Node until removed', function() { @@ -648,7 +653,7 @@ describe('GlobalErrors', function() { dispatchEvent(globals.listeners, 'uncaughtException', new Error('bar')); expect(overrideHandler).not.toHaveBeenCalled(); - expect(handler1).toHaveBeenCalledWith(new Error('bar'), undefined); + expect(handler1).toHaveBeenCalledWith(new Error('bar')); }); it('handles unhandled promise rejections in browsers', function() { diff --git a/spec/core/QueueRunnerSpec.js b/spec/core/QueueRunnerSpec.js index 9d5a3673..26004d33 100644 --- a/spec/core/QueueRunnerSpec.js +++ b/spec/core/QueueRunnerSpec.js @@ -471,31 +471,6 @@ describe('QueueRunner', function() { expect(nextQueueableFn.fn).toHaveBeenCalled(); }); - it('handles a global error event with a message but no error', function() { - const queueableFn = { - fn: function(done) { - const currentHandler = globalErrors.pushListener.calls.mostRecent() - .args[0]; - currentHandler(undefined, { message: 'nope' }); - }, - timeout: 1 - }; - const onException = jasmine.createSpy('onException'); - const globalErrors = { - pushListener: jasmine.createSpy('pushListener'), - popListener: jasmine.createSpy('popListener') - }; - const queueRunner = new privateUnderTest.QueueRunner({ - queueableFns: [queueableFn], - onException: onException, - globalErrors: globalErrors - }); - - queueRunner.execute(); - - expect(onException).toHaveBeenCalledWith('nope'); - }); - it('handles exceptions thrown while waiting for the stack to clear', function() { const queueableFn = { fn: function(done) { @@ -529,40 +504,6 @@ describe('QueueRunner', function() { clearStack.calls.argsFor(0)[0](); expect(onException).toHaveBeenCalledWith(error); }); - - it('handles a global error event with no error while waiting for the stack to clear', function() { - const queueableFn = { - fn: function(done) { - done(); - } - }; - const errorListeners = []; - const globalErrors = { - pushListener: function(f) { - errorListeners.push(f); - }, - popListener: function() { - errorListeners.pop(); - } - }; - const clearStack = jasmine.createSpy('clearStack'); - const onException = jasmine.createSpy('onException'); - const queueRunner = new privateUnderTest.QueueRunner({ - queueableFns: [queueableFn], - globalErrors: globalErrors, - clearStack: clearStack, - onException: onException - }); - - queueRunner.execute(); - jasmine.clock().tick(); - expect(clearStack).toHaveBeenCalled(); - expect(errorListeners.length).toEqual(1); - errorListeners[0](undefined, { message: 'nope' }); - - clearStack.calls.argsFor(0)[0](); - expect(onException).toHaveBeenCalledWith('nope'); - }); }); describe('with a function that returns a promise', function() { diff --git a/spec/core/integration/GlobalErrorHandlingSpec.js b/spec/core/integration/GlobalErrorHandlingSpec.js index ef60ea5e..caf59b38 100644 --- a/spec/core/integration/GlobalErrorHandlingSpec.js +++ b/spec/core/integration/GlobalErrorHandlingSpec.js @@ -53,7 +53,7 @@ describe('Global error handling (integration)', function() { passed: false, globalErrorType: 'load', message: 'Uncaught SyntaxError: Unexpected end of input', - stack: undefined, + stack: '@borkenSpec.js:42', filename: 'borkenSpec.js', lineno: 42 }, diff --git a/src/core/Env.js b/src/core/Env.js index cf33696a..c542b2df 100644 --- a/src/core/Env.js +++ b/src/core/Env.js @@ -67,14 +67,14 @@ getJasmineRequireObj().Env = function(j$) { if (!envOptions.suppressLoadErrors) { installGlobalErrors(); - globalErrors.pushListener(function loadtimeErrorHandler(error, event) { + globalErrors.pushListener(function loadtimeErrorHandler(error) { topSuite.result.failedExpectations.push({ passed: false, globalErrorType: 'load', - message: error ? error.message : event.message, - stack: error && error.stack, - filename: event && event.filename, - lineno: event && event.lineno + message: error.message, + stack: error.stack, + filename: error.filename, + lineno: error.lineno }); }); } diff --git a/src/core/GlobalErrors.js b/src/core/GlobalErrors.js index ec167ae5..c489f72e 100644 --- a/src/core/GlobalErrors.js +++ b/src/core/GlobalErrors.js @@ -40,13 +40,6 @@ getJasmineRequireObj().GlobalErrors = function(j$) { this.#adapter.uninstall(); } - // The listener at the top of the stack will be called with two arguments: - // the error and the event. Either of them may be falsy. - // The error will normally be provided, but will be falsy in the case of - // some browser load-time errors. The event will normally be provided in - // browsers but will be falsy in Node. - // Listeners that are pushed after spec files have been loaded should be - // able to just use the error parameter. pushListener(listener) { this.#handlers.push(listener); } @@ -78,29 +71,23 @@ getJasmineRequireObj().GlobalErrors = function(j$) { } reportUnhandledRejections() { - for (const { - reason, - event - } of this.#pendingUnhandledRejections.values()) { - this.#dispatchError(reason, event); + for (const { reason } of this.#pendingUnhandledRejections.values()) { + this.#dispatchError(reason); } this.#pendingUnhandledRejections.clear(); } - // Either error or event may be undefined - #onUncaughtException(error, event) { - this.#dispatchError(error, event); + #onUncaughtException(error) { + this.#dispatchError(error); } - // event or promise may be undefined - // event is passed through for backwards compatibility reasons. It's probably - // unnecessary, but user code could depend on it. - #onUnhandledRejection(reason, promise, event) { + // promise may be undefined + #onUnhandledRejection(reason, promise) { if (this.#detectLateRejectionHandling() && promise) { - this.#pendingUnhandledRejections.set(promise, { reason, event }); + this.#pendingUnhandledRejections.set(promise, { reason }); } else { - this.#dispatchError(reason, event); + this.#dispatchError(reason); } } @@ -112,8 +99,7 @@ getJasmineRequireObj().GlobalErrors = function(j$) { this.#pendingUnhandledRejections.delete(promise); } - // Either error or event may be undefined - #dispatchError(error, event) { + #dispatchError(error) { if (this.#overrideHandler) { // See discussion of spyOnGlobalErrorsAsync in base.js this.#overrideHandler(error); @@ -123,7 +109,7 @@ getJasmineRequireObj().GlobalErrors = function(j$) { const handler = this.#handlers[this.#handlers.length - 1]; if (handler) { - handler(error, event); + handler(error); } else { throw error; } @@ -140,7 +126,7 @@ getJasmineRequireObj().GlobalErrors = function(j$) { constructor(global, dispatch) { this.#global = global; this.#dispatch = dispatch; - this.#onError = event => dispatch.onUncaughtException(event.error, event); + this.#onError = this.#errorHandler.bind(this); this.#onUnhandledRejection = this.#unhandledRejectionHandler.bind(this); this.#onRejectionHandled = this.#rejectionHandledHandler.bind(this); } @@ -169,6 +155,28 @@ getJasmineRequireObj().GlobalErrors = function(j$) { ); } + #errorHandler(event) { + let error = event.error; + + // event.error isn't guaranteed to be present in all browser load-time + // error events. + if (!error) { + error = { + message: event.message, + stack: `@${event.filename}:${event.lineno}` + }; + } + + if (event.filename) { + // filename and lineno can be more convenient than stack when reporting + // things like syntax errors. Pass them along. + error.filename = event.filename; + error.lineno = event.lineno; + } + + this.#dispatch.onUncaughtException(error); + } + #unhandledRejectionHandler(event) { const jasmineMessage = 'Unhandled promise rejection: ' + event.reason; let reason; @@ -180,7 +188,7 @@ getJasmineRequireObj().GlobalErrors = function(j$) { reason = jasmineMessage; } - this.#dispatch.onUnhandledRejection(reason, event.promise, event); + this.#dispatch.onUnhandledRejection(reason, event.promise); } #rejectionHandledHandler(event) { diff --git a/src/core/QueueRunner.js b/src/core/QueueRunner.js index 5a339157..5dff3ee7 100644 --- a/src/core/QueueRunner.js +++ b/src/core/QueueRunner.js @@ -77,8 +77,8 @@ getJasmineRequireObj().QueueRunner = function(j$) { } QueueRunner.prototype.execute = function() { - this.handleFinalError = (error, event) => { - this.onException(errorOrMsgForGlobalError(error, event)); + this.handleFinalError = error => { + this.onException(error); }; this.globalErrors.pushListener(this.handleFinalError); this.run(0); @@ -108,8 +108,8 @@ getJasmineRequireObj().QueueRunner = function(j$) { this.recordError_(iterativeIndex); }; - function handleError(error, event) { - onException(errorOrMsgForGlobalError(error, event)); + function handleError(error) { + onException(error); } const cleanup = once(() => { if (timeoutId !== void 0) { @@ -296,16 +296,5 @@ getJasmineRequireObj().QueueRunner = function(j$) { }; } - function errorOrMsgForGlobalError(error, event) { - // TODO: In cases where error is a string or undefined, the error message - // that gets sent to reporters will be `${message} thrown`, which could - // be improved to not say "thrown" when the cause wasn't necessarily - // an exception or to provide hints about throwing Errors rather than - // strings. - return ( - error || (event && event.message) || 'Global error event with no message' - ); - } - return QueueRunner; }; From 2a83f5cc303eb4bc0afa90cdbc4a16a7c296798e Mon Sep 17 00:00:00 2001 From: Steve Gravrock Date: Sun, 5 Oct 2025 05:57:56 -0700 Subject: [PATCH 37/95] Don't mutate suite's failedExpectations from env --- lib/jasmine-core/jasmine.js | 9 ++++++++- spec/core/integration/GlobalErrorHandlingSpec.js | 10 +++++----- src/core/Env.js | 2 +- src/core/buildExpectationResult.js | 7 +++++++ 4 files changed, 21 insertions(+), 7 deletions(-) diff --git a/lib/jasmine-core/jasmine.js b/lib/jasmine-core/jasmine.js index 76d40626..4d88e1d7 100644 --- a/lib/jasmine-core/jasmine.js +++ b/lib/jasmine-core/jasmine.js @@ -1252,7 +1252,7 @@ getJasmineRequireObj().Env = function(j$) { if (!envOptions.suppressLoadErrors) { installGlobalErrors(); globalErrors.pushListener(function loadtimeErrorHandler(error) { - topSuite.result.failedExpectations.push({ + topSuite.addExpectationResult(false, { passed: false, globalErrorType: 'load', message: error.message, @@ -2597,6 +2597,13 @@ getJasmineRequireObj().buildExpectationResult = function(j$) { globalErrorType: options.globalErrorType }; + if (options.filename !== undefined) { + result.filename = options.filename; + } + if (options.lineno !== undefined) { + result.lineno = options.lineno; + } + if (!result.passed) { if (options.error && !j$.private.isString(options.error)) { if ('code' in options.error) { diff --git a/spec/core/integration/GlobalErrorHandlingSpec.js b/spec/core/integration/GlobalErrorHandlingSpec.js index caf59b38..95d206eb 100644 --- a/spec/core/integration/GlobalErrorHandlingSpec.js +++ b/spec/core/integration/GlobalErrorHandlingSpec.js @@ -53,17 +53,17 @@ describe('Global error handling (integration)', function() { passed: false, globalErrorType: 'load', message: 'Uncaught SyntaxError: Unexpected end of input', - stack: '@borkenSpec.js:42', filename: 'borkenSpec.js', - lineno: 42 + lineno: 42, + matcherName: undefined, + stack: jasmine.any(String) }, { passed: false, globalErrorType: 'load', message: 'ENOCHEESE', - stack: error.stack, - filename: undefined, - lineno: undefined + matcherName: undefined, + stack: jasmine.any(String) } ]); }); diff --git a/src/core/Env.js b/src/core/Env.js index c542b2df..ba69fc66 100644 --- a/src/core/Env.js +++ b/src/core/Env.js @@ -68,7 +68,7 @@ getJasmineRequireObj().Env = function(j$) { if (!envOptions.suppressLoadErrors) { installGlobalErrors(); globalErrors.pushListener(function loadtimeErrorHandler(error) { - topSuite.result.failedExpectations.push({ + topSuite.addExpectationResult(false, { passed: false, globalErrorType: 'load', message: error.message, diff --git a/src/core/buildExpectationResult.js b/src/core/buildExpectationResult.js index 78a102da..442a5b25 100644 --- a/src/core/buildExpectationResult.js +++ b/src/core/buildExpectationResult.js @@ -23,6 +23,13 @@ getJasmineRequireObj().buildExpectationResult = function(j$) { globalErrorType: options.globalErrorType }; + if (options.filename !== undefined) { + result.filename = options.filename; + } + if (options.lineno !== undefined) { + result.lineno = options.lineno; + } + if (!result.passed) { if (options.error && !j$.private.isString(options.error)) { if ('code' in options.error) { From 418393c496b22872934ea7ea54334833bafa01c8 Mon Sep 17 00:00:00 2001 From: Steve Gravrock Date: Sun, 28 Sep 2025 08:55:47 -0700 Subject: [PATCH 38/95] rm more vestiges of suite re-entry support --- lib/jasmine-core/jasmine.js | 4 ---- spec/core/RunnerSpec.js | 3 --- spec/core/TreeProcessorSpec.js | 44 ---------------------------------- src/core/Suite.js | 4 ---- 4 files changed, 55 deletions(-) diff --git a/lib/jasmine-core/jasmine.js b/lib/jasmine-core/jasmine.js index 4d88e1d7..f4d804e5 100644 --- a/lib/jasmine-core/jasmine.js +++ b/lib/jasmine-core/jasmine.js @@ -10766,10 +10766,6 @@ getJasmineRequireObj().Suite = function(j$) { return this.result; } - canBeReentered() { - return this.beforeAllFns.length === 0 && this.afterAllFns.length === 0; - } - sharedUserContext() { if (!this.sharedContext) { this.sharedContext = this.parentSuite diff --git a/spec/core/RunnerSpec.js b/spec/core/RunnerSpec.js index c3cb65b0..83f324b0 100644 --- a/spec/core/RunnerSpec.js +++ b/spec/core/RunnerSpec.js @@ -33,9 +33,6 @@ describe('Runner', function() { attrs = attrs || {}; this.id = 'suite' + suiteNumber++; this.children = attrs.children || []; - this.canBeReentered = function() { - return !attrs.noReenter; - }; this.markedPending = attrs.markedPending || false; this.sharedUserContext = function() { return attrs.userContext || {}; diff --git a/spec/core/TreeProcessorSpec.js b/spec/core/TreeProcessorSpec.js index 699be65c..b4ac43c4 100644 --- a/spec/core/TreeProcessorSpec.js +++ b/spec/core/TreeProcessorSpec.js @@ -6,9 +6,6 @@ describe('TreeProcessor', function() { attrs = attrs || {}; this.id = 'node' + nodeNumber++; this.children = attrs.children || []; - this.canBeReentered = function() { - return !attrs.noReenter; - }; this.markedPending = attrs.markedPending || false; this.sharedUserContext = function() { return attrs.userContext || {}; @@ -195,47 +192,6 @@ describe('TreeProcessor', function() { expect(result.isExcluded(childOfPending)).toEqual(false); }); - it('throws if the specified order would re-enter a node', function() { - const leaf1 = new Leaf(), - leaf2 = new Leaf(), - leaf3 = new Leaf(), - reentered = new Node({ noReenter: true, children: [leaf1, leaf2] }), - root = new Node({ children: [reentered, leaf3] }), - processor = new privateUnderTest.TreeProcessor({ - tree: root, - runnableIds: [leaf1.id, leaf3.id, leaf2.id] - }); - - expect(function() { - processor.processTree(); - }).toThrowError('Invalid order: would split up a suite'); - }); - - it("does not throw if a node which can't be re-entered is only entered once", function() { - const leaf1 = new Leaf(), - leaf2 = new Leaf(), - leaf3 = new Leaf(), - noReentry = new Node({ noReenter: true }), - root = new Node({ children: [noReentry] }), - processor = new privateUnderTest.TreeProcessor({ - tree: root, - runnableIds: [leaf2.id, leaf1.id, leaf3.id] - }); - - processor.processTree(); - }); - - it("does not throw if a node which can't be re-entered is run directly", function() { - const noReentry = new Node({ noReenter: true }), - root = new Node({ children: [noReentry] }), - processor = new privateUnderTest.TreeProcessor({ - tree: root, - runnableIds: [root.id] - }); - - processor.processTree(); - }); - it('orders children according to orderChildren when specified', function() { const leaf1 = new Leaf(); const leaf2 = new Leaf(); diff --git a/src/core/Suite.js b/src/core/Suite.js index 96eabe2c..c7b63e56 100644 --- a/src/core/Suite.js +++ b/src/core/Suite.js @@ -162,10 +162,6 @@ getJasmineRequireObj().Suite = function(j$) { return this.result; } - canBeReentered() { - return this.beforeAllFns.length === 0 && this.afterAllFns.length === 0; - } - sharedUserContext() { if (!this.sharedContext) { this.sharedContext = this.parentSuite From d99bc3ab58c320988a1cf26fb23b523bce505b6a Mon Sep 17 00:00:00 2001 From: Steve Gravrock Date: Sun, 21 Sep 2025 16:22:54 -0700 Subject: [PATCH 39/95] Encapsulate spec status --- lib/jasmine-core/jasmine.js | 64 ++++++++++++++-------------- spec/core/SpecSpec.js | 83 ++++++++++++++++++++++++++++++++++--- spec/core/TreeRunnerSpec.js | 8 ++-- src/core/Env.js | 2 +- src/core/Spec.js | 42 +++++++++++++------ src/core/TreeRunner.js | 20 ++------- 6 files changed, 150 insertions(+), 69 deletions(-) diff --git a/lib/jasmine-core/jasmine.js b/lib/jasmine-core/jasmine.js index f4d804e5..7e91e3ec 100644 --- a/lib/jasmine-core/jasmine.js +++ b/lib/jasmine-core/jasmine.js @@ -781,6 +781,9 @@ getJasmineRequireObj().Spec = function(j$) { #throwOnExpectationFailure; #timer; #metadata; + // TODO: better naming. Don't make 'excluded' mean two things. + #dynamicallyExcluded; + #requireExpectations; constructor(attrs) { this.expectationFactory = attrs.expectationFactory; @@ -829,11 +832,6 @@ getJasmineRequireObj().Spec = function(j$) { this.onLateError(expectationResult); } else { this.result.failedExpectations.push(expectationResult); - - // TODO: refactor so that we don't need to override cached status - if (this.result.status) { - this.result.status = 'failed'; - } } if (this.#throwOnExpectationFailure && !isError) { @@ -862,18 +860,34 @@ getJasmineRequireObj().Spec = function(j$) { } executionFinished(excluded, failSpecWithNoExp) { + this.#dynamicallyExcluded = excluded; + this.#requireExpectations = failSpecWithNoExp; + if (this.#autoCleanClosures) { this.queueableFn.fn = null; } - this.result.status = this.#status(excluded, failSpecWithNoExp); this.result.duration = this.#timer.elapsed(); - if (this.result.status !== 'failed') { + if (this.status() !== 'failed') { this.result.debugLogs = null; } } + hadBeforeAllFailure() { + this.addExpectationResult( + false, + { + passed: false, + message: + 'Not run because a beforeAll function failed. The ' + + 'beforeAll failure will be reported on the suite that ' + + 'caused it.' + }, + true + ); + } + reset() { this.result = { id: this.id, @@ -891,6 +905,8 @@ getJasmineRequireObj().Spec = function(j$) { }; this.markedPending = this.markedExcluding; this.reportedDone = false; + this.#dynamicallyExcluded = false; + this.#requireExpectations = false; } startedEvent() { @@ -935,14 +951,14 @@ getJasmineRequireObj().Spec = function(j$) { * @since 6.0.0 */ const event = { - ...this.#commonEventFields() + ...this.#commonEventFields(), + status: this.status() }; const toCopy = [ 'failedExpectations', 'passedExpectations', 'deprecationWarnings', 'pendingReason', - 'status', 'duration', 'properties', 'debugLogs' @@ -1005,13 +1021,13 @@ getJasmineRequireObj().Spec = function(j$) { // TODO: ensure that all access to result goes through .getResult() // so that the status is correct. + // Step 1: fix things so getResult() always returns correct status getResult() { - this.result.status = this.#status(); return this.result; } - #status(excluded, failSpecWithNoExpectations) { - if (excluded === true) { + status() { + if (this.#dynamicallyExcluded) { return 'excluded'; } @@ -1021,7 +1037,7 @@ getJasmineRequireObj().Spec = function(j$) { if ( this.result.failedExpectations.length > 0 || - (failSpecWithNoExpectations && + (this.#requireExpectations && this.result.failedExpectations.length + this.result.passedExpectations.length === 0) @@ -1424,7 +1440,7 @@ getJasmineRequireObj().Env = function(j$) { expectationResult.globalErrorType = 'lateError'; } - r.result.failedExpectations.push(expectationResult); + r.addExpectationResult(false, expectationResult); return; } } @@ -11620,7 +11636,7 @@ getJasmineRequireObj().TreeRunner = function(j$) { ); }, onComplete: () => { - if (spec.result.status === 'failed') { + if (spec.status() === 'failed') { specOverallDone(new j$.private.StopExecutionError('spec failed')); } else { specOverallDone(); @@ -11652,7 +11668,7 @@ getJasmineRequireObj().TreeRunner = function(j$) { const complete = { fn(done) { spec.executionFinished(excluded, config.failSpecWithNoExpectations); - resultCallback(spec.result, done); + resultCallback(spec.doneEvent(), done); }, type: 'specCleanup' }; @@ -11789,7 +11805,7 @@ getJasmineRequireObj().TreeRunner = function(j$) { this.#runableResources.clearForRunable(spec.id); this.#currentRunableTracker.setCurrentSpec(null); - if (spec.result.status === 'failed') { + if (spec.status() === 'failed') { this.#hasFailures = true; } @@ -11815,19 +11831,7 @@ getJasmineRequireObj().TreeRunner = function(j$) { } else { /* a spec */ await this.#reportDispatcher.specStarted(child.startedEvent()); - - child.addExpectationResult( - false, - { - passed: false, - message: - 'Not run because a beforeAll function failed. The ' + - 'beforeAll failure will be reported on the suite that ' + - 'caused it.' - }, - true - ); - child.result.status = 'failed'; + child.hadBeforeAllFailure(); await this.#reportSpecDone(child); } } diff --git a/spec/core/SpecSpec.js b/spec/core/SpecSpec.js index 12370d6d..a15cf9d9 100644 --- a/spec/core/SpecSpec.js +++ b/spec/core/SpecSpec.js @@ -149,11 +149,16 @@ describe('Spec', function() { }); describe('status', function() { - it('is "passed" by default', function() { + it('returns "passed" by default', function() { const spec = new privateUnderTest.Spec({ queueableFn: { fn: () => {} } }); - expect(spec.getResult().status).toBe('passed'); + expect(spec.status()) + .withContext('status()') + .toBe('passed'); + expect(spec.doneEvent().status) + .withContext('doneEvent().status') + .toBe('passed'); }); it('is "passed" if all expectations passed', function() { @@ -163,7 +168,12 @@ describe('Spec', function() { spec.addExpectationResult(true, {}); - expect(spec.getResult().status).toBe('passed'); + expect(spec.status()) + .withContext('status()') + .toBe('passed'); + expect(spec.doneEvent().status) + .withContext('doneEvent().status') + .toBe('passed'); }); it('is "failed" if any expectation failed', function() { @@ -174,7 +184,12 @@ describe('Spec', function() { spec.addExpectationResult(true, {}); spec.addExpectationResult(false, {}); - expect(spec.getResult().status).toBe('failed'); + expect(spec.status()) + .withContext('status()') + .toBe('failed'); + expect(spec.doneEvent().status) + .withContext('doneEvent().status') + .toBe('failed'); }); it('is "pending" if created without a function body', function() { @@ -186,7 +201,65 @@ describe('Spec', function() { resultCallback: resultCallback }); - expect(spec.getResult().status).toBe('pending'); + expect(spec.status()) + .withContext('status()') + .toBe('pending'); + expect(spec.doneEvent().status) + .withContext('doneEvent().status') + .toBe('pending'); + }); + + describe('after a call to executionFinished()', function() { + describe('with excluded true', function() { + it("is 'excluded'", function() { + const spec = new privateUnderTest.Spec({ + queueableFn: { fn: () => {} } + }); + + spec.executionFinished(true, false); + + expect(spec.status()) + .withContext('status()') + .toBe('excluded'); + expect(spec.doneEvent().status) + .withContext('doneEvent().status') + .toBe('excluded'); + }); + }); + + describe('with failSpecWithNoExp true', function() { + it("is 'failed' if there were no expectations", function() { + const spec = new privateUnderTest.Spec({ + queueableFn: { fn: () => {} } + }); + + spec.executionFinished(false, true); + + expect(spec.status()) + .withContext('status()') + .toBe('failed'); + expect(spec.doneEvent().status) + .withContext('doneEvent().status') + .toBe('failed'); + }); + }); + }); + + describe('after a call to hadBeforeAllFailure()', function() { + it("is 'failed'", function() { + const spec = new privateUnderTest.Spec({ + queueableFn: { fn: () => {} } + }); + + spec.hadBeforeAllFailure(); + + expect(spec.status()) + .withContext('status()') + .toBe('failed'); + expect(spec.doneEvent().status) + .withContext('doneEvent().status') + .toBe('failed'); + }); }); }); diff --git a/spec/core/TreeRunnerSpec.js b/spec/core/TreeRunnerSpec.js index d9771a2c..6241b9e2 100644 --- a/spec/core/TreeRunnerSpec.js +++ b/spec/core/TreeRunnerSpec.js @@ -116,8 +116,8 @@ describe('TreeRunner', function() { expect(specRunQueueArgs.queueableFns[1]).toEqual(queueableFn); queueableFn.fn(); - expect(spec.getResult().status).toEqual('pending'); - expect(spec.getResult().pendingReason).toEqual(''); + expect(spec.doneEvent().status).toEqual('pending'); + expect(spec.doneEvent().pendingReason).toEqual(''); }); it('marks specs pending at runtime with a message', function() { @@ -137,8 +137,8 @@ describe('TreeRunner', function() { expect(specRunQueueArgs.queueableFns[1]).toEqual(queueableFn); queueableFn.fn(); - expect(spec.getResult().status).toEqual('pending'); - expect(spec.getResult().pendingReason).toEqual('some reason'); + expect(spec.doneEvent().status).toEqual('pending'); + expect(spec.doneEvent().pendingReason).toEqual('some reason'); }); it('passes failSpecWithNoExp to Spec#executionFinished', async function() { diff --git a/src/core/Env.js b/src/core/Env.js index ba69fc66..3b189bf2 100644 --- a/src/core/Env.js +++ b/src/core/Env.js @@ -240,7 +240,7 @@ getJasmineRequireObj().Env = function(j$) { expectationResult.globalErrorType = 'lateError'; } - r.result.failedExpectations.push(expectationResult); + r.addExpectationResult(false, expectationResult); return; } } diff --git a/src/core/Spec.js b/src/core/Spec.js index 1a990cc9..618cff3e 100644 --- a/src/core/Spec.js +++ b/src/core/Spec.js @@ -4,6 +4,9 @@ getJasmineRequireObj().Spec = function(j$) { #throwOnExpectationFailure; #timer; #metadata; + // TODO: better naming. Don't make 'excluded' mean two things. + #dynamicallyExcluded; + #requireExpectations; constructor(attrs) { this.expectationFactory = attrs.expectationFactory; @@ -52,11 +55,6 @@ getJasmineRequireObj().Spec = function(j$) { this.onLateError(expectationResult); } else { this.result.failedExpectations.push(expectationResult); - - // TODO: refactor so that we don't need to override cached status - if (this.result.status) { - this.result.status = 'failed'; - } } if (this.#throwOnExpectationFailure && !isError) { @@ -85,18 +83,34 @@ getJasmineRequireObj().Spec = function(j$) { } executionFinished(excluded, failSpecWithNoExp) { + this.#dynamicallyExcluded = excluded; + this.#requireExpectations = failSpecWithNoExp; + if (this.#autoCleanClosures) { this.queueableFn.fn = null; } - this.result.status = this.#status(excluded, failSpecWithNoExp); this.result.duration = this.#timer.elapsed(); - if (this.result.status !== 'failed') { + if (this.status() !== 'failed') { this.result.debugLogs = null; } } + hadBeforeAllFailure() { + this.addExpectationResult( + false, + { + passed: false, + message: + 'Not run because a beforeAll function failed. The ' + + 'beforeAll failure will be reported on the suite that ' + + 'caused it.' + }, + true + ); + } + reset() { this.result = { id: this.id, @@ -114,6 +128,8 @@ getJasmineRequireObj().Spec = function(j$) { }; this.markedPending = this.markedExcluding; this.reportedDone = false; + this.#dynamicallyExcluded = false; + this.#requireExpectations = false; } startedEvent() { @@ -158,14 +174,14 @@ getJasmineRequireObj().Spec = function(j$) { * @since 6.0.0 */ const event = { - ...this.#commonEventFields() + ...this.#commonEventFields(), + status: this.status() }; const toCopy = [ 'failedExpectations', 'passedExpectations', 'deprecationWarnings', 'pendingReason', - 'status', 'duration', 'properties', 'debugLogs' @@ -228,13 +244,13 @@ getJasmineRequireObj().Spec = function(j$) { // TODO: ensure that all access to result goes through .getResult() // so that the status is correct. + // Step 1: fix things so getResult() always returns correct status getResult() { - this.result.status = this.#status(); return this.result; } - #status(excluded, failSpecWithNoExpectations) { - if (excluded === true) { + status() { + if (this.#dynamicallyExcluded) { return 'excluded'; } @@ -244,7 +260,7 @@ getJasmineRequireObj().Spec = function(j$) { if ( this.result.failedExpectations.length > 0 || - (failSpecWithNoExpectations && + (this.#requireExpectations && this.result.failedExpectations.length + this.result.passedExpectations.length === 0) diff --git a/src/core/TreeRunner.js b/src/core/TreeRunner.js index ece555d9..628b1500 100644 --- a/src/core/TreeRunner.js +++ b/src/core/TreeRunner.js @@ -77,7 +77,7 @@ getJasmineRequireObj().TreeRunner = function(j$) { ); }, onComplete: () => { - if (spec.result.status === 'failed') { + if (spec.status() === 'failed') { specOverallDone(new j$.private.StopExecutionError('spec failed')); } else { specOverallDone(); @@ -109,7 +109,7 @@ getJasmineRequireObj().TreeRunner = function(j$) { const complete = { fn(done) { spec.executionFinished(excluded, config.failSpecWithNoExpectations); - resultCallback(spec.result, done); + resultCallback(spec.doneEvent(), done); }, type: 'specCleanup' }; @@ -246,7 +246,7 @@ getJasmineRequireObj().TreeRunner = function(j$) { this.#runableResources.clearForRunable(spec.id); this.#currentRunableTracker.setCurrentSpec(null); - if (spec.result.status === 'failed') { + if (spec.status() === 'failed') { this.#hasFailures = true; } @@ -272,19 +272,7 @@ getJasmineRequireObj().TreeRunner = function(j$) { } else { /* a spec */ await this.#reportDispatcher.specStarted(child.startedEvent()); - - child.addExpectationResult( - false, - { - passed: false, - message: - 'Not run because a beforeAll function failed. The ' + - 'beforeAll failure will be reported on the suite that ' + - 'caused it.' - }, - true - ); - child.result.status = 'failed'; + child.hadBeforeAllFailure(); await this.#reportSpecDone(child); } } From 712f9bac29ca3b1b9db6ce7965e5e8ba5f6014e0 Mon Sep 17 00:00:00 2001 From: Steve Gravrock Date: Sun, 21 Sep 2025 16:53:13 -0700 Subject: [PATCH 40/95] Encapsulate spec result --- lib/jasmine-core/jasmine.js | 79 ++++++++++++++++--------------------- spec/core/SpecSpec.js | 32 +++++++-------- spec/core/TreeRunnerSpec.js | 2 +- src/core/Spec.js | 79 ++++++++++++++++--------------------- 4 files changed, 87 insertions(+), 105 deletions(-) diff --git a/lib/jasmine-core/jasmine.js b/lib/jasmine-core/jasmine.js index 7e91e3ec..f5eb6b5c 100644 --- a/lib/jasmine-core/jasmine.js +++ b/lib/jasmine-core/jasmine.js @@ -781,9 +781,7 @@ getJasmineRequireObj().Spec = function(j$) { #throwOnExpectationFailure; #timer; #metadata; - // TODO: better naming. Don't make 'excluded' mean two things. - #dynamicallyExcluded; - #requireExpectations; + #executionState; constructor(attrs) { this.expectationFactory = attrs.expectationFactory; @@ -815,23 +813,23 @@ getJasmineRequireObj().Spec = function(j$) { this.#throwOnExpectationFailure = !!attrs.throwOnExpectationFailure; this.#timer = attrs.timer || new j$.Timer(); + this.reset(); + if (!this.queueableFn.fn) { this.exclude(); } - - this.reset(); } addExpectationResult(passed, data, isError) { const expectationResult = j$.private.buildExpectationResult(data); if (passed) { - this.result.passedExpectations.push(expectationResult); + this.#executionState.passedExpectations.push(expectationResult); } else { if (this.reportedDone) { this.onLateError(expectationResult); } else { - this.result.failedExpectations.push(expectationResult); + this.#executionState.failedExpectations.push(expectationResult); } if (this.#throwOnExpectationFailure && !isError) { @@ -841,8 +839,8 @@ getJasmineRequireObj().Spec = function(j$) { } getSpecProperty(key) { - this.result.properties = this.result.properties || {}; - return this.result.properties[key]; + this.#executionState.properties = this.#executionState.properties || {}; + return this.#executionState.properties[key]; } setSpecProperty(key, value) { @@ -851,8 +849,8 @@ getJasmineRequireObj().Spec = function(j$) { // Throw a better one now. j$.private.util.assertReporterCloneable(key, 'Key'); j$.private.util.assertReporterCloneable(value, 'Value'); - this.result.properties = this.result.properties || {}; - this.result.properties[key] = value; + this.#executionState.properties = this.#executionState.properties || {}; + this.#executionState.properties[key] = value; } executionStarted() { @@ -860,17 +858,17 @@ getJasmineRequireObj().Spec = function(j$) { } executionFinished(excluded, failSpecWithNoExp) { - this.#dynamicallyExcluded = excluded; - this.#requireExpectations = failSpecWithNoExp; + this.#executionState.dynamicallyExcluded = excluded; + this.#executionState.requireExpectations = failSpecWithNoExp; if (this.#autoCleanClosures) { this.queueableFn.fn = null; } - this.result.duration = this.#timer.elapsed(); + this.#executionState.duration = this.#timer.elapsed(); if (this.status() !== 'failed') { - this.result.debugLogs = null; + this.#executionState.debugLogs = null; } } @@ -889,24 +887,20 @@ getJasmineRequireObj().Spec = function(j$) { } reset() { - this.result = { - id: this.id, - description: this.description, - fullName: this.getFullName(), - parentSuiteId: this.parentSuiteId, - filename: this.filename, + this.#executionState = { failedExpectations: [], passedExpectations: [], deprecationWarnings: [], pendingReason: this.excludeMessage || '', duration: null, properties: null, - debugLogs: null + debugLogs: null, + // TODO: better naming. Don't make 'excluded' mean two things. + dynamicallyExcluded: false, + requireExpectations: false, + markedPending: this.markedExcluding }; - this.markedPending = this.markedExcluding; this.reportedDone = false; - this.#dynamicallyExcluded = false; - this.#requireExpectations = false; } startedEvent() { @@ -965,7 +959,7 @@ getJasmineRequireObj().Spec = function(j$) { ]; for (const k of toCopy) { - event[k] = this.result[k]; + event[k] = this.#executionState[k]; } return event; @@ -1003,12 +997,16 @@ getJasmineRequireObj().Spec = function(j$) { } pend(message) { - this.markedPending = true; + this.#executionState.markedPending = true; if (message) { - this.result.pendingReason = message; + this.#executionState.pendingReason = message; } } + get markedPending() { + return this.#executionState.markedPending; + } + // Like pend(), but pending state will survive reset(). // Useful for fit, xit, where pending state remains. exclude(message) { @@ -1019,15 +1017,8 @@ getJasmineRequireObj().Spec = function(j$) { this.pend(message); } - // TODO: ensure that all access to result goes through .getResult() - // so that the status is correct. - // Step 1: fix things so getResult() always returns correct status - getResult() { - return this.result; - } - status() { - if (this.#dynamicallyExcluded) { + if (this.#executionState.dynamicallyExcluded) { return 'excluded'; } @@ -1036,10 +1027,10 @@ getJasmineRequireObj().Spec = function(j$) { } if ( - this.result.failedExpectations.length > 0 || - (this.#requireExpectations && - this.result.failedExpectations.length + - this.result.passedExpectations.length === + this.#executionState.failedExpectations.length > 0 || + (this.#executionState.requireExpectations && + this.#executionState.failedExpectations.length + + this.#executionState.passedExpectations.length === 0) ) { return 'failed'; @@ -1056,14 +1047,14 @@ getJasmineRequireObj().Spec = function(j$) { if (typeof deprecation === 'string') { deprecation = { message: deprecation }; } - this.result.deprecationWarnings.push( + this.#executionState.deprecationWarnings.push( j$.private.buildExpectationResult(deprecation) ); } debugLog(msg) { - if (!this.result.debugLogs) { - this.result.debugLogs = []; + if (!this.#executionState.debugLogs) { + this.#executionState.debugLogs = []; } /** @@ -1072,7 +1063,7 @@ getJasmineRequireObj().Spec = function(j$) { * @property {number} timestamp - The time when the entry was added, in * milliseconds from the spec's start time */ - this.result.debugLogs.push({ + this.#executionState.debugLogs.push({ message: msg, timestamp: this.#timer.elapsed() }); diff --git a/spec/core/SpecSpec.js b/spec/core/SpecSpec.js index a15cf9d9..8969acf0 100644 --- a/spec/core/SpecSpec.js +++ b/spec/core/SpecSpec.js @@ -85,7 +85,7 @@ describe('Spec', function() { spec.setSpecProperty('a', 4); - expect(spec.result.properties).toEqual({ a: 4 }); + expect(spec.doneEvent().properties).toEqual({ a: 4 }); }); it('replace the property result when it was previously set', function() { @@ -97,7 +97,7 @@ describe('Spec', function() { spec.setSpecProperty('b', 'original-value'); spec.setSpecProperty('a', 'new-value'); - expect(spec.result.properties).toEqual({ + expect(spec.doneEvent().properties).toEqual({ a: 'new-value', b: 'original-value' }); @@ -272,10 +272,10 @@ describe('Spec', function() { spec.addExpectationResult(true, { message: 'expectation1' }); spec.addExpectationResult(false, { message: 'expectation2' }); - expect(spec.result.passedExpectations).toEqual([ + expect(spec.doneEvent().passedExpectations).toEqual([ jasmine.objectContaining({ message: 'expectation1' }) ]); - expect(spec.result.failedExpectations).toEqual([ + expect(spec.doneEvent().failedExpectations).toEqual([ jasmine.objectContaining({ message: 'expectation2' }) ]); }); @@ -292,7 +292,7 @@ describe('Spec', function() { spec.addExpectationResult(false, { message: 'failed' }); }).toThrowError(jasmineUnderTest.private.errors.ExpectationFailed); - expect(spec.result.failedExpectations).toEqual([ + expect(spec.doneEvent().failedExpectations).toEqual([ jasmine.objectContaining({ message: 'failed' }) ]); }); @@ -306,7 +306,7 @@ describe('Spec', function() { spec.addExpectationResult(false, { message: 'failed' }); - expect(spec.result.failedExpectations).toEqual([ + expect(spec.doneEvent().failedExpectations).toEqual([ jasmine.objectContaining({ message: 'failed' }) ]); }); @@ -335,7 +335,7 @@ describe('Spec', function() { message: jasmine.stringMatching(/^Error: nope/) }) ); - expect(spec.result.failedExpectations).toEqual([]); + expect(spec.doneEvent().failedExpectations).toEqual([]); }); it('does not forward non-late expectation failures to onLateError', function() { @@ -372,7 +372,7 @@ describe('Spec', function() { message: jasmine.stringMatching(/^Error: oops/) }) ); - expect(spec.result.failedExpectations).toEqual([]); + expect(spec.doneEvent().failedExpectations).toEqual([]); }); it('does not forward non-late handleException calls to onLateError', function() { @@ -386,7 +386,7 @@ describe('Spec', function() { spec.handleException(error); expect(onLateError).not.toHaveBeenCalled(); - expect(spec.result.failedExpectations.length).toEqual(1); + expect(spec.doneEvent().failedExpectations.length).toEqual(1); }); it('clears the reportedDone flag when reset', function() { @@ -449,7 +449,7 @@ describe('Spec', function() { spec.handleException('foo'); - expect(spec.result.failedExpectations).toEqual([ + expect(spec.doneEvent().failedExpectations).toEqual([ { message: 'foo thrown', matcherName: '', @@ -469,7 +469,7 @@ describe('Spec', function() { new jasmineUnderTest.private.errors.ExpectationFailed() ); - expect(spec.result.failedExpectations).toEqual([]); + expect(spec.doneEvent().failedExpectations).toEqual([]); }); }); @@ -483,15 +483,15 @@ describe('Spec', function() { const t1 = 123; const t2 = 456; - expect(spec.result.debugLogs).toBeNull(); + expect(spec.doneEvent().debugLogs).toBeNull(); timer.elapsed.and.returnValue(t1); spec.debugLog('msg 1'); - expect(spec.result.debugLogs).toEqual([ + expect(spec.doneEvent().debugLogs).toEqual([ { message: 'msg 1', timestamp: t1 } ]); timer.elapsed.and.returnValue(t2); spec.debugLog('msg 2'); - expect(spec.result.debugLogs).toEqual([ + expect(spec.doneEvent().debugLogs).toEqual([ { message: 'msg 1', timestamp: t1 }, { message: 'msg 2', timestamp: t2 } ]); @@ -506,7 +506,7 @@ describe('Spec', function() { spec.debugLog('msg'); spec.executionFinished(); - expect(spec.result.debugLogs).toBeNull(); + expect(spec.doneEvent().debugLogs).toBeNull(); }); }); @@ -525,7 +525,7 @@ describe('Spec', function() { spec.handleException(new Error('nope')); spec.executionFinished(); - expect(spec.result.debugLogs).toEqual([ + expect(spec.doneEvent().debugLogs).toEqual([ { message: 'msg', timestamp: timestamp } ]); }); diff --git a/spec/core/TreeRunnerSpec.js b/spec/core/TreeRunnerSpec.js index 6241b9e2..fa8677ef 100644 --- a/spec/core/TreeRunnerSpec.js +++ b/spec/core/TreeRunnerSpec.js @@ -64,7 +64,7 @@ describe('TreeRunner', function() { expect(currentRunableTracker.currentSpec()).toBeFalsy(); expect(runableResources.clearForRunable).toHaveBeenCalledWith(spec.id); expect(reportDispatcher.specDone).toHaveBeenCalledWith(spec.doneEvent()); - expect(spec.result.duration).toEqual('the elapsed time'); + expect(spec.doneEvent().duration).toEqual('the elapsed time'); expect(spec.reportedDone).toEqual(true); await Promise.resolve(); await Promise.resolve(); diff --git a/src/core/Spec.js b/src/core/Spec.js index 618cff3e..02fc561c 100644 --- a/src/core/Spec.js +++ b/src/core/Spec.js @@ -4,9 +4,7 @@ getJasmineRequireObj().Spec = function(j$) { #throwOnExpectationFailure; #timer; #metadata; - // TODO: better naming. Don't make 'excluded' mean two things. - #dynamicallyExcluded; - #requireExpectations; + #executionState; constructor(attrs) { this.expectationFactory = attrs.expectationFactory; @@ -38,23 +36,23 @@ getJasmineRequireObj().Spec = function(j$) { this.#throwOnExpectationFailure = !!attrs.throwOnExpectationFailure; this.#timer = attrs.timer || new j$.Timer(); + this.reset(); + if (!this.queueableFn.fn) { this.exclude(); } - - this.reset(); } addExpectationResult(passed, data, isError) { const expectationResult = j$.private.buildExpectationResult(data); if (passed) { - this.result.passedExpectations.push(expectationResult); + this.#executionState.passedExpectations.push(expectationResult); } else { if (this.reportedDone) { this.onLateError(expectationResult); } else { - this.result.failedExpectations.push(expectationResult); + this.#executionState.failedExpectations.push(expectationResult); } if (this.#throwOnExpectationFailure && !isError) { @@ -64,8 +62,8 @@ getJasmineRequireObj().Spec = function(j$) { } getSpecProperty(key) { - this.result.properties = this.result.properties || {}; - return this.result.properties[key]; + this.#executionState.properties = this.#executionState.properties || {}; + return this.#executionState.properties[key]; } setSpecProperty(key, value) { @@ -74,8 +72,8 @@ getJasmineRequireObj().Spec = function(j$) { // Throw a better one now. j$.private.util.assertReporterCloneable(key, 'Key'); j$.private.util.assertReporterCloneable(value, 'Value'); - this.result.properties = this.result.properties || {}; - this.result.properties[key] = value; + this.#executionState.properties = this.#executionState.properties || {}; + this.#executionState.properties[key] = value; } executionStarted() { @@ -83,17 +81,17 @@ getJasmineRequireObj().Spec = function(j$) { } executionFinished(excluded, failSpecWithNoExp) { - this.#dynamicallyExcluded = excluded; - this.#requireExpectations = failSpecWithNoExp; + this.#executionState.dynamicallyExcluded = excluded; + this.#executionState.requireExpectations = failSpecWithNoExp; if (this.#autoCleanClosures) { this.queueableFn.fn = null; } - this.result.duration = this.#timer.elapsed(); + this.#executionState.duration = this.#timer.elapsed(); if (this.status() !== 'failed') { - this.result.debugLogs = null; + this.#executionState.debugLogs = null; } } @@ -112,24 +110,20 @@ getJasmineRequireObj().Spec = function(j$) { } reset() { - this.result = { - id: this.id, - description: this.description, - fullName: this.getFullName(), - parentSuiteId: this.parentSuiteId, - filename: this.filename, + this.#executionState = { failedExpectations: [], passedExpectations: [], deprecationWarnings: [], pendingReason: this.excludeMessage || '', duration: null, properties: null, - debugLogs: null + debugLogs: null, + // TODO: better naming. Don't make 'excluded' mean two things. + dynamicallyExcluded: false, + requireExpectations: false, + markedPending: this.markedExcluding }; - this.markedPending = this.markedExcluding; this.reportedDone = false; - this.#dynamicallyExcluded = false; - this.#requireExpectations = false; } startedEvent() { @@ -188,7 +182,7 @@ getJasmineRequireObj().Spec = function(j$) { ]; for (const k of toCopy) { - event[k] = this.result[k]; + event[k] = this.#executionState[k]; } return event; @@ -226,12 +220,16 @@ getJasmineRequireObj().Spec = function(j$) { } pend(message) { - this.markedPending = true; + this.#executionState.markedPending = true; if (message) { - this.result.pendingReason = message; + this.#executionState.pendingReason = message; } } + get markedPending() { + return this.#executionState.markedPending; + } + // Like pend(), but pending state will survive reset(). // Useful for fit, xit, where pending state remains. exclude(message) { @@ -242,15 +240,8 @@ getJasmineRequireObj().Spec = function(j$) { this.pend(message); } - // TODO: ensure that all access to result goes through .getResult() - // so that the status is correct. - // Step 1: fix things so getResult() always returns correct status - getResult() { - return this.result; - } - status() { - if (this.#dynamicallyExcluded) { + if (this.#executionState.dynamicallyExcluded) { return 'excluded'; } @@ -259,10 +250,10 @@ getJasmineRequireObj().Spec = function(j$) { } if ( - this.result.failedExpectations.length > 0 || - (this.#requireExpectations && - this.result.failedExpectations.length + - this.result.passedExpectations.length === + this.#executionState.failedExpectations.length > 0 || + (this.#executionState.requireExpectations && + this.#executionState.failedExpectations.length + + this.#executionState.passedExpectations.length === 0) ) { return 'failed'; @@ -279,14 +270,14 @@ getJasmineRequireObj().Spec = function(j$) { if (typeof deprecation === 'string') { deprecation = { message: deprecation }; } - this.result.deprecationWarnings.push( + this.#executionState.deprecationWarnings.push( j$.private.buildExpectationResult(deprecation) ); } debugLog(msg) { - if (!this.result.debugLogs) { - this.result.debugLogs = []; + if (!this.#executionState.debugLogs) { + this.#executionState.debugLogs = []; } /** @@ -295,7 +286,7 @@ getJasmineRequireObj().Spec = function(j$) { * @property {number} timestamp - The time when the entry was added, in * milliseconds from the spec's start time */ - this.result.debugLogs.push({ + this.#executionState.debugLogs.push({ message: msg, timestamp: this.#timer.elapsed() }); From 0738ba64620040d9415c05ebb5b2b4feb82410f3 Mon Sep 17 00:00:00 2001 From: Steve Gravrock Date: Mon, 22 Sep 2025 17:21:10 -0700 Subject: [PATCH 41/95] Omit irrelevant properties from suiteStarted --- lib/jasmine-core/jasmine.js | 98 ++++++++++++++++++++++++-------- spec/core/RunnerSpec.js | 21 +++++-- spec/core/SuiteSpec.js | 30 ++++++++++ spec/core/integration/EnvSpec.js | 12 ++-- src/core/Runner.js | 2 +- src/core/Spec.js | 4 +- src/core/Suite.js | 75 ++++++++++++++++++++---- src/core/TreeRunner.js | 20 +++---- src/core/reporterEvents.js | 4 +- 9 files changed, 206 insertions(+), 60 deletions(-) diff --git a/lib/jasmine-core/jasmine.js b/lib/jasmine-core/jasmine.js index f5eb6b5c..b3199f52 100644 --- a/lib/jasmine-core/jasmine.js +++ b/lib/jasmine-core/jasmine.js @@ -916,7 +916,7 @@ getJasmineRequireObj().Spec = function(j$) { * same call stack height as the originals. This property may be removed in * a future version unless there is enough user interest in keeping it. * See {@link https://github.com/jasmine/jasmine/issues/2065}. - * @since 6.0.0 + * @since 2.0.0 */ return this.#commonEventFields(); } @@ -942,7 +942,7 @@ getJasmineRequireObj().Spec = function(j$) { * @property {number} duration - The time in ms used by the spec execution, including any before/afterEach. * @property {Object} properties - User-supplied properties, if any, that were set using {@link Env#setSpecProperty} * @property {DebugLogEntry[]|null} debugLogs - Messages, if any, that were logged using {@link jasmine.debugLog} during a failing spec. - * @since 6.0.0 + * @since 2.0.0 */ const event = { ...this.#commonEventFields(), @@ -8766,7 +8766,7 @@ getJasmineRequireObj().reporterEvents = function(j$) { * `suiteStarted` is invoked when a `describe` starts to run * @function * @name Reporter#suiteStarted - * @param {SuiteResult} result Information about the individual {@link describe} being run + * @param {SuiteStartedEvent} result Information about the individual {@link describe} being run * @param {Function} [done] Used to specify to Jasmine that this callback is asynchronous and Jasmine should wait until it has been called before moving on. * @returns {} Optionally return a Promise instead of using `done` to cause Jasmine to wait for completion. * @see async @@ -8778,7 +8778,7 @@ getJasmineRequireObj().reporterEvents = function(j$) { * While jasmine doesn't require any specific functions, not defining a `suiteDone` will make it impossible for a reporter to know when a suite has failures in an `afterAll`. * @function * @name Reporter#suiteDone - * @param {SuiteResult} result + * @param {SuiteDoneEvent} result * @param {Function} [done] Used to specify to Jasmine that this callback is asynchronous and Jasmine should wait until it has been called before moving on. * @returns {} Optionally return a Promise instead of using `done` to cause Jasmine to wait for completion. * @see async @@ -9617,7 +9617,7 @@ getJasmineRequireObj().Runner = function(j$) { this.#currentRunableTracker.popSuite(); let overallStatus, incompleteReason, incompleteCode; - if (hasFailures || this.#topSuite.result.failedExpectations.length > 0) { + if (hasFailures || this.#topSuite.hasOwnFailedExpectations()) { overallStatus = 'failed'; } else if (this.#getFocusedRunables().length > 0) { overallStatus = 'incomplete'; @@ -10711,8 +10711,45 @@ getJasmineRequireObj().Suite = function(j$) { } reset() { + this.result = { + id: this.id, + description: this.description, + fullName: this.getFullName(), + parentSuiteId: this.#reportedParentSuiteId, + filename: this.filename, + failedExpectations: [], + deprecationWarnings: [], + duration: null, + properties: null + }; + this.markedPending = this.markedExcluding; + this.children.forEach(function(child) { + child.reset(); + }); + this.reportedDone = false; + } + + startedEvent() { /** - * @typedef SuiteResult + * @typedef SuiteStartedEvent + * @property {String} id - The unique id of this suite. + * @property {String} description - The description text passed to the {@link describe} that made this suite. + * @property {String} fullName - The full description including all ancestors of this suite. + * @property {String|null} parentSuiteId - The ID of the suite containing this suite, or null if this is not in another describe(). + * @property {String} filename - Deprecated. The name of the file the suite was defined in. + * Note: The value may be incorrect if zone.js is installed or + * `describe`/`fdescribe`/`xdescribe` have been replaced with versions that + * don't maintain the same call stack height as the originals. This property + * may be removed in a future version unless there is enough user interest + * in keeping it. See {@link https://github.com/jasmine/jasmine/issues/2065}. + * @since 6.0.0 + */ + return this.#commonEventFields(); + } + + doneEvent() { + /** + * @typedef SuiteDoneEvent * @property {String} id - The unique id of this suite. * @property {String} description - The description text passed to the {@link describe} that made this suite. * @property {String} fullName - The full description including all ancestors of this suite. @@ -10730,22 +10767,32 @@ getJasmineRequireObj().Suite = function(j$) { * @property {Object} properties - User-supplied properties, if any, that were set using {@link Env#setSuiteProperty} * @since 2.0.0 */ - this.result = { + const event = { + ...this.#commonEventFields(), + status: this.#status() + }; + const toCopy = [ + 'failedExpectations', + 'deprecationWarnings', + 'duration', + 'properties' + ]; + + for (const k of toCopy) { + event[k] = this.result[k]; + } + + return event; + } + + #commonEventFields() { + return { id: this.id, description: this.description, fullName: this.getFullName(), parentSuiteId: this.#reportedParentSuiteId, - filename: this.filename, - failedExpectations: [], - deprecationWarnings: [], - duration: null, - properties: null + filename: this.filename }; - this.markedPending = this.markedExcluding; - this.children.forEach(function(child) { - child.reset(); - }); - this.reportedDone = false; } removeChildren() { @@ -10768,6 +10815,10 @@ getJasmineRequireObj().Suite = function(j$) { } } + hasOwnFailedExpectations() { + return this.result.failedExpectations.length > 0; + } + getResult() { this.result.status = this.#status(); return this.result; @@ -11713,7 +11764,7 @@ getJasmineRequireObj().TreeRunner = function(j$) { this.#runQueue({ onComplete: maybeError => { - this.#suiteSegmentComplete(suite, suite.getResult(), () => { + this.#suiteSegmentComplete(suite, () => { done(maybeError); }); }, @@ -11750,11 +11801,13 @@ getJasmineRequireObj().TreeRunner = function(j$) { #suiteSegmentStart(suite, next) { this.#currentRunableTracker.pushSuite(suite); this.#runableResources.initForRunable(suite.id, suite.parentSuite.id); - this.#reportDispatcher.suiteStarted(suite.result).then(next); + this.#reportDispatcher.suiteStarted(suite.startedEvent()).then(next); suite.startTimer(); } - #suiteSegmentComplete(suite, result, next) { + #suiteSegmentComplete(suite, next) { + suite.endTimer(); + const result = suite.doneEvent(); const isTopSuite = suite === this.#executionTree.topSuite; if (!isTopSuite) { @@ -11773,7 +11826,6 @@ getJasmineRequireObj().TreeRunner = function(j$) { if (result.status === 'failed') { this.#hasFailures = true; } - suite.endTimer(); } const finish = isTopSuite @@ -11811,14 +11863,14 @@ getJasmineRequireObj().TreeRunner = function(j$) { async #reportChildrenOfBeforeAllFailure(suite) { for (const child of suite.children) { if (child instanceof j$.private.Suite) { - await this.#reportDispatcher.suiteStarted(child.result); + await this.#reportDispatcher.suiteStarted(child.startedEvent()); await this.#reportChildrenOfBeforeAllFailure(child); // Marking the suite passed is consistent with how suites that // contain failed specs but no suite-level failures are reported. child.result.status = 'passed'; - await this.#reportDispatcher.suiteDone(child.result); + await this.#reportDispatcher.suiteDone(child.doneEvent()); } else { /* a spec */ await this.#reportDispatcher.specStarted(child.startedEvent()); diff --git a/spec/core/RunnerSpec.js b/spec/core/RunnerSpec.js index 83f324b0..433f117d 100644 --- a/spec/core/RunnerSpec.js +++ b/spec/core/RunnerSpec.js @@ -37,11 +37,16 @@ describe('Runner', function() { this.sharedUserContext = function() { return attrs.userContext || {}; }; + // TODO remove this.result = { id: this.id, failedExpectations: [] }; - this.getResult = jasmine.createSpy('getResult'); + this.startedEvent = jasmine.createSpy('startedEvent'); + this.doneEvent = jasmine.createSpy('doneEvent'); + this.hasOwnFailedExpectations = jasmine.createSpy( + 'hasOwnFailedExpectations' + ); this.beforeAllFns = attrs.beforeAllFns || []; this.afterAllFns = attrs.afterAllFns || []; this.cleanupBeforeAfter = function() {}; @@ -182,10 +187,13 @@ describe('Runner', function() { SkipPolicy: privateUnderTest.SkipAfterBeforeAllErrorPolicy }); + suite.startedEvent.and.returnValue('suite started event'); runQueue.calls.mostRecent().args[0].queueableFns[0].fn('foo'); - expect(reportDispatcher.suiteStarted).toHaveBeenCalledWith(suite.result); + expect(reportDispatcher.suiteStarted).toHaveBeenCalledWith( + 'suite started event' + ); - suite.getResult.and.returnValue({ my: 'result' }); + suite.doneEvent.and.returnValue({ my: 'result' }); runQueue.calls.mostRecent().args[0].onComplete(); expect(reportDispatcher.suiteDone).toHaveBeenCalledWith({ my: 'result' }); @@ -233,12 +241,15 @@ describe('Runner', function() { queueableFns = runQueue.calls.mostRecent().args[0].queueableFns; expect(queueableFns.length).toBe(2); + parent.startedEvent.and.returnValue('parent suite started event'); queueableFns[0].fn(); - expect(reportDispatcher.suiteStarted).toHaveBeenCalledWith(parent.result); + expect(reportDispatcher.suiteStarted).toHaveBeenCalledWith( + 'parent suite started event' + ); verifyAndFinishSpec(spec, queueableFns[1], true); - parent.getResult.and.returnValue(parent.result); + parent.doneEvent.and.returnValue(parent.result); runQueue.calls.argsFor(1)[0].onComplete(); expect(reportDispatcher.suiteDone).toHaveBeenCalledWith(parent.result); await expectAsync(promise).toBePending(); diff --git a/spec/core/SuiteSpec.js b/spec/core/SuiteSpec.js index 4a32fab1..117d5ca4 100644 --- a/spec/core/SuiteSpec.js +++ b/spec/core/SuiteSpec.js @@ -425,4 +425,34 @@ describe('Suite', function() { }).toThrowError("Value can't be cloned"); }); }); + + describe('#startedEvent', function() { + it('includes only properties that are known before execution', function() { + const topSuite = new privateUnderTest.Suite({}); + const parentSuite = new privateUnderTest.Suite({ + id: 'suite1', + parentSuite: topSuite, + description: 'a parent suite' + }); + const suite = new privateUnderTest.Suite({ + id: 'suite2', + parentSuite, + reportedParentSuiteId: parentSuite.id, + description: 'a suite', + filename: 'somefile.js', + getPath() { + return ['a parent suite', 'a spec']; + }, + queueableFn: { fn: () => {} } + }); + + expect(suite.startedEvent()).toEqual({ + id: 'suite2', + parentSuiteId: 'suite1', + description: 'a suite', + fullName: 'a parent suite a suite', + filename: 'somefile.js' + }); + }); + }); }); diff --git a/spec/core/integration/EnvSpec.js b/spec/core/integration/EnvSpec.js index 55e8fd67..f37c0bba 100644 --- a/spec/core/integration/EnvSpec.js +++ b/spec/core/integration/EnvSpec.js @@ -1765,10 +1765,12 @@ describe('Env integration', function() { const baseSuiteEvent = { id: jasmine.any(String), - filename: jasmine.any(String), + filename: jasmine.any(String) + }; + const baseSuiteDoneEvent = { + ...baseSuiteEvent, failedExpectations: [], deprecationWarnings: [], - duration: null, properties: null }; @@ -1779,7 +1781,7 @@ describe('Env integration', function() { parentSuiteId: null }); expect(reporter.suiteDone.calls.argsFor(2)[0]).toEqual({ - ...baseSuiteEvent, + ...baseSuiteDoneEvent, description: 'A Suite', fullName: 'A Suite', status: 'passed', @@ -1794,7 +1796,7 @@ describe('Env integration', function() { parentSuiteId: suiteFullNameToId['A Suite'] }); expect(reporter.suiteDone.calls.argsFor(0)[0]).toEqual({ - ...baseSuiteEvent, + ...baseSuiteDoneEvent, description: 'with a nested suite', status: 'passed', fullName: 'A Suite with a nested suite', @@ -1809,7 +1811,7 @@ describe('Env integration', function() { parentSuiteId: suiteFullNameToId['A Suite'] }); expect(reporter.suiteDone.calls.argsFor(1)[0]).toEqual({ - ...baseSuiteEvent, + ...baseSuiteDoneEvent, description: 'with only non-executable specs', status: 'passed', fullName: 'A Suite with only non-executable specs', diff --git a/src/core/Runner.js b/src/core/Runner.js index 9c71d7e5..5f5d7381 100644 --- a/src/core/Runner.js +++ b/src/core/Runner.js @@ -123,7 +123,7 @@ getJasmineRequireObj().Runner = function(j$) { this.#currentRunableTracker.popSuite(); let overallStatus, incompleteReason, incompleteCode; - if (hasFailures || this.#topSuite.result.failedExpectations.length > 0) { + if (hasFailures || this.#topSuite.hasOwnFailedExpectations()) { overallStatus = 'failed'; } else if (this.#getFocusedRunables().length > 0) { overallStatus = 'incomplete'; diff --git a/src/core/Spec.js b/src/core/Spec.js index 02fc561c..2a284aab 100644 --- a/src/core/Spec.js +++ b/src/core/Spec.js @@ -139,7 +139,7 @@ getJasmineRequireObj().Spec = function(j$) { * same call stack height as the originals. This property may be removed in * a future version unless there is enough user interest in keeping it. * See {@link https://github.com/jasmine/jasmine/issues/2065}. - * @since 6.0.0 + * @since 2.0.0 */ return this.#commonEventFields(); } @@ -165,7 +165,7 @@ getJasmineRequireObj().Spec = function(j$) { * @property {number} duration - The time in ms used by the spec execution, including any before/afterEach. * @property {Object} properties - User-supplied properties, if any, that were set using {@link Env#setSpecProperty} * @property {DebugLogEntry[]|null} debugLogs - Messages, if any, that were logged using {@link jasmine.debugLog} during a failing spec. - * @since 6.0.0 + * @since 2.0.0 */ const event = { ...this.#commonEventFields(), diff --git a/src/core/Suite.js b/src/core/Suite.js index c7b63e56..dd5cff31 100644 --- a/src/core/Suite.js +++ b/src/core/Suite.js @@ -100,8 +100,45 @@ getJasmineRequireObj().Suite = function(j$) { } reset() { + this.result = { + id: this.id, + description: this.description, + fullName: this.getFullName(), + parentSuiteId: this.#reportedParentSuiteId, + filename: this.filename, + failedExpectations: [], + deprecationWarnings: [], + duration: null, + properties: null + }; + this.markedPending = this.markedExcluding; + this.children.forEach(function(child) { + child.reset(); + }); + this.reportedDone = false; + } + + startedEvent() { /** - * @typedef SuiteResult + * @typedef SuiteStartedEvent + * @property {String} id - The unique id of this suite. + * @property {String} description - The description text passed to the {@link describe} that made this suite. + * @property {String} fullName - The full description including all ancestors of this suite. + * @property {String|null} parentSuiteId - The ID of the suite containing this suite, or null if this is not in another describe(). + * @property {String} filename - Deprecated. The name of the file the suite was defined in. + * Note: The value may be incorrect if zone.js is installed or + * `describe`/`fdescribe`/`xdescribe` have been replaced with versions that + * don't maintain the same call stack height as the originals. This property + * may be removed in a future version unless there is enough user interest + * in keeping it. See {@link https://github.com/jasmine/jasmine/issues/2065}. + * @since 6.0.0 + */ + return this.#commonEventFields(); + } + + doneEvent() { + /** + * @typedef SuiteDoneEvent * @property {String} id - The unique id of this suite. * @property {String} description - The description text passed to the {@link describe} that made this suite. * @property {String} fullName - The full description including all ancestors of this suite. @@ -119,22 +156,32 @@ getJasmineRequireObj().Suite = function(j$) { * @property {Object} properties - User-supplied properties, if any, that were set using {@link Env#setSuiteProperty} * @since 2.0.0 */ - this.result = { + const event = { + ...this.#commonEventFields(), + status: this.#status() + }; + const toCopy = [ + 'failedExpectations', + 'deprecationWarnings', + 'duration', + 'properties' + ]; + + for (const k of toCopy) { + event[k] = this.result[k]; + } + + return event; + } + + #commonEventFields() { + return { id: this.id, description: this.description, fullName: this.getFullName(), parentSuiteId: this.#reportedParentSuiteId, - filename: this.filename, - failedExpectations: [], - deprecationWarnings: [], - duration: null, - properties: null + filename: this.filename }; - this.markedPending = this.markedExcluding; - this.children.forEach(function(child) { - child.reset(); - }); - this.reportedDone = false; } removeChildren() { @@ -157,6 +204,10 @@ getJasmineRequireObj().Suite = function(j$) { } } + hasOwnFailedExpectations() { + return this.result.failedExpectations.length > 0; + } + getResult() { this.result.status = this.#status(); return this.result; diff --git a/src/core/TreeRunner.js b/src/core/TreeRunner.js index 628b1500..fd30a6ef 100644 --- a/src/core/TreeRunner.js +++ b/src/core/TreeRunner.js @@ -163,7 +163,7 @@ getJasmineRequireObj().TreeRunner = function(j$) { this.#runQueue({ onComplete: maybeError => { - this.#suiteSegmentComplete(suite, suite.getResult(), () => { + this.#suiteSegmentComplete(suite, () => { done(maybeError); }); }, @@ -200,11 +200,12 @@ getJasmineRequireObj().TreeRunner = function(j$) { #suiteSegmentStart(suite, next) { this.#currentRunableTracker.pushSuite(suite); this.#runableResources.initForRunable(suite.id, suite.parentSuite.id); - this.#reportDispatcher.suiteStarted(suite.result).then(next); + this.#reportDispatcher.suiteStarted(suite.startedEvent()).then(next); suite.startTimer(); } - #suiteSegmentComplete(suite, result, next) { + #suiteSegmentComplete(suite, next) { + suite.endTimer(); const isTopSuite = suite === this.#executionTree.topSuite; if (!isTopSuite) { @@ -220,15 +221,14 @@ getJasmineRequireObj().TreeRunner = function(j$) { this.#runableResources.clearForRunable(suite.id); this.#currentRunableTracker.popSuite(); - if (result.status === 'failed') { + if (suite.doneEvent().status === 'failed') { this.#hasFailures = true; } - suite.endTimer(); } const finish = isTopSuite ? next - : () => this.#reportSuiteDone(suite, result, next); + : () => this.#reportSuiteDone(suite, next); if (suite.hadBeforeAllFailure) { this.#reportChildrenOfBeforeAllFailure(suite).then(finish); @@ -237,9 +237,9 @@ getJasmineRequireObj().TreeRunner = function(j$) { } } - #reportSuiteDone(suite, result, next) { + #reportSuiteDone(suite, next) { suite.reportedDone = true; - this.#reportDispatcher.suiteDone(result).then(next); + this.#reportDispatcher.suiteDone(suite.doneEvent()).then(next); } async #specComplete(spec) { @@ -261,14 +261,14 @@ getJasmineRequireObj().TreeRunner = function(j$) { async #reportChildrenOfBeforeAllFailure(suite) { for (const child of suite.children) { if (child instanceof j$.private.Suite) { - await this.#reportDispatcher.suiteStarted(child.result); + await this.#reportDispatcher.suiteStarted(child.startedEvent()); await this.#reportChildrenOfBeforeAllFailure(child); // Marking the suite passed is consistent with how suites that // contain failed specs but no suite-level failures are reported. child.result.status = 'passed'; - await this.#reportDispatcher.suiteDone(child.result); + await this.#reportDispatcher.suiteDone(child.doneEvent()); } else { /* a spec */ await this.#reportDispatcher.specStarted(child.startedEvent()); diff --git a/src/core/reporterEvents.js b/src/core/reporterEvents.js index 4f563d94..e215c324 100644 --- a/src/core/reporterEvents.js +++ b/src/core/reporterEvents.js @@ -50,7 +50,7 @@ getJasmineRequireObj().reporterEvents = function(j$) { * `suiteStarted` is invoked when a `describe` starts to run * @function * @name Reporter#suiteStarted - * @param {SuiteResult} result Information about the individual {@link describe} being run + * @param {SuiteStartedEvent} result Information about the individual {@link describe} being run * @param {Function} [done] Used to specify to Jasmine that this callback is asynchronous and Jasmine should wait until it has been called before moving on. * @returns {} Optionally return a Promise instead of using `done` to cause Jasmine to wait for completion. * @see async @@ -62,7 +62,7 @@ getJasmineRequireObj().reporterEvents = function(j$) { * While jasmine doesn't require any specific functions, not defining a `suiteDone` will make it impossible for a reporter to know when a suite has failures in an `afterAll`. * @function * @name Reporter#suiteDone - * @param {SuiteResult} result + * @param {SuiteDoneEvent} result * @param {Function} [done] Used to specify to Jasmine that this callback is asynchronous and Jasmine should wait until it has been called before moving on. * @returns {} Optionally return a Promise instead of using `done` to cause Jasmine to wait for completion. * @see async From 18491e9b842019f4c3015cf64ed707f11928fcc8 Mon Sep 17 00:00:00 2001 From: Steve Gravrock Date: Sat, 4 Oct 2025 09:40:10 -0700 Subject: [PATCH 42/95] Encapsulate suite result --- lib/jasmine-core/jasmine.js | 50 +++++++++++++---------------------- spec/core/RunnerSpec.js | 13 +++++---- spec/core/SuiteBuilderSpec.js | 3 ++- spec/core/SuiteSpec.js | 28 ++++++++++---------- spec/core/TreeRunnerSpec.js | 2 +- src/core/Runner.js | 5 ++-- src/core/Suite.js | 31 ++++++++-------------- src/core/TreeRunner.js | 5 ---- 8 files changed, 55 insertions(+), 82 deletions(-) diff --git a/lib/jasmine-core/jasmine.js b/lib/jasmine-core/jasmine.js index b3199f52..c64be6e3 100644 --- a/lib/jasmine-core/jasmine.js +++ b/lib/jasmine-core/jasmine.js @@ -9631,6 +9631,7 @@ getJasmineRequireObj().Runner = function(j$) { overallStatus = 'passed'; } + const topSuiteResult = this.#topSuite.doneEvent(); /** * Information passed to the {@link Reporter#jasmineDone} event. * @typedef JasmineDoneInfo @@ -9650,8 +9651,8 @@ getJasmineRequireObj().Runner = function(j$) { incompleteReason: incompleteReason, incompleteCode: incompleteCode, order: orderForReporting(order), - failedExpectations: this.#topSuite.result.failedExpectations, - deprecationWarnings: this.#topSuite.result.deprecationWarnings + failedExpectations: topSuiteResult.failedExpectations, + deprecationWarnings: topSuiteResult.deprecationWarnings }; this.#topSuite.reportedDone = true; await this.#reportDispatcher.jasmineDone(jasmineDoneInfo); @@ -10615,6 +10616,7 @@ getJasmineRequireObj().Suite = function(j$) { #throwOnExpectationFailure; #autoCleanClosures; #timer; + #result; constructor(attrs) { this.id = attrs.id; @@ -10647,8 +10649,8 @@ getJasmineRequireObj().Suite = function(j$) { // Throw a better one now. j$.private.util.assertReporterCloneable(key, 'Key'); j$.private.util.assertReporterCloneable(value, 'Value'); - this.result.properties = this.result.properties || {}; - this.result.properties[key] = value; + this.#result.properties = this.#result.properties || {}; + this.#result.properties[key] = value; } getFullName() { @@ -10698,7 +10700,7 @@ getJasmineRequireObj().Suite = function(j$) { } endTimer() { - this.result.duration = this.#timer.elapsed(); + this.#result.duration = this.#timer.elapsed(); } cleanupBeforeAfter() { @@ -10711,7 +10713,7 @@ getJasmineRequireObj().Suite = function(j$) { } reset() { - this.result = { + this.#result = { id: this.id, description: this.description, fullName: this.getFullName(), @@ -10779,7 +10781,7 @@ getJasmineRequireObj().Suite = function(j$) { ]; for (const k of toCopy) { - event[k] = this.result[k]; + event[k] = this.#result[k]; } return event; @@ -10808,7 +10810,7 @@ getJasmineRequireObj().Suite = function(j$) { return 'pending'; } - if (this.result.failedExpectations.length > 0) { + if (this.#result.failedExpectations.length > 0) { return 'failed'; } else { return 'passed'; @@ -10816,12 +10818,7 @@ getJasmineRequireObj().Suite = function(j$) { } hasOwnFailedExpectations() { - return this.result.failedExpectations.length > 0; - } - - getResult() { - this.result.status = this.#status(); - return this.result; + return this.#result.failedExpectations.length > 0; } sharedUserContext() { @@ -10857,7 +10854,7 @@ getJasmineRequireObj().Suite = function(j$) { if (this.reportedDone) { this.onLateError(failedExpectation); } else { - this.result.failedExpectations.push(failedExpectation); + this.#result.failedExpectations.push(failedExpectation); } } @@ -10895,12 +10892,7 @@ getJasmineRequireObj().Suite = function(j$) { if (this.reportedDone) { this.onLateError(expectationResult); } else { - this.result.failedExpectations.push(expectationResult); - - // TODO: refactor so that we don't need to override cached status - if (this.result.status) { - this.result.status = 'failed'; - } + this.#result.failedExpectations.push(expectationResult); } if (this.#throwOnExpectationFailure) { @@ -10912,7 +10904,7 @@ getJasmineRequireObj().Suite = function(j$) { if (typeof deprecation === 'string') { deprecation = { message: deprecation }; } - this.result.deprecationWarnings.push( + this.#result.deprecationWarnings.push( j$.private.buildExpectationResult(deprecation) ); } @@ -11807,7 +11799,6 @@ getJasmineRequireObj().TreeRunner = function(j$) { #suiteSegmentComplete(suite, next) { suite.endTimer(); - const result = suite.doneEvent(); const isTopSuite = suite === this.#executionTree.topSuite; if (!isTopSuite) { @@ -11823,14 +11814,14 @@ getJasmineRequireObj().TreeRunner = function(j$) { this.#runableResources.clearForRunable(suite.id); this.#currentRunableTracker.popSuite(); - if (result.status === 'failed') { + if (suite.doneEvent().status === 'failed') { this.#hasFailures = true; } } const finish = isTopSuite ? next - : () => this.#reportSuiteDone(suite, result, next); + : () => this.#reportSuiteDone(suite, next); if (suite.hadBeforeAllFailure) { this.#reportChildrenOfBeforeAllFailure(suite).then(finish); @@ -11839,9 +11830,9 @@ getJasmineRequireObj().TreeRunner = function(j$) { } } - #reportSuiteDone(suite, result, next) { + #reportSuiteDone(suite, next) { suite.reportedDone = true; - this.#reportDispatcher.suiteDone(result).then(next); + this.#reportDispatcher.suiteDone(suite.doneEvent()).then(next); } async #specComplete(spec) { @@ -11865,11 +11856,6 @@ getJasmineRequireObj().TreeRunner = function(j$) { if (child instanceof j$.private.Suite) { await this.#reportDispatcher.suiteStarted(child.startedEvent()); await this.#reportChildrenOfBeforeAllFailure(child); - - // Marking the suite passed is consistent with how suites that - // contain failed specs but no suite-level failures are reported. - child.result.status = 'passed'; - await this.#reportDispatcher.suiteDone(child.doneEvent()); } else { /* a spec */ diff --git a/spec/core/RunnerSpec.js b/spec/core/RunnerSpec.js index 433f117d..84667e53 100644 --- a/spec/core/RunnerSpec.js +++ b/spec/core/RunnerSpec.js @@ -37,11 +37,6 @@ describe('Runner', function() { this.sharedUserContext = function() { return attrs.userContext || {}; }; - // TODO remove - this.result = { - id: this.id, - failedExpectations: [] - }; this.startedEvent = jasmine.createSpy('startedEvent'); this.doneEvent = jasmine.createSpy('doneEvent'); this.hasOwnFailedExpectations = jasmine.createSpy( @@ -132,6 +127,7 @@ describe('Runner', function() { children: [spec], userContext: { root: 'context' } }); + topSuite.doneEvent.and.returnValue({}); detectLateRejectionHandling = true; const subject = makeRunner(topSuite); @@ -159,6 +155,7 @@ describe('Runner', function() { children: [suite], userContext: { for: 'topSuite' } }); + topSuite.doneEvent.and.returnValue({}); suite.parentSuite = topSuite; const subject = makeRunner(topSuite); @@ -249,9 +246,11 @@ describe('Runner', function() { verifyAndFinishSpec(spec, queueableFns[1], true); - parent.doneEvent.and.returnValue(parent.result); + parent.doneEvent.and.returnValue('parent suite done event'); runQueue.calls.argsFor(1)[0].onComplete(); - expect(reportDispatcher.suiteDone).toHaveBeenCalledWith(parent.result); + expect(reportDispatcher.suiteDone).toHaveBeenCalledWith( + 'parent suite done event' + ); await expectAsync(promise).toBePending(); }); diff --git a/spec/core/SuiteBuilderSpec.js b/spec/core/SuiteBuilderSpec.js index 613144ef..4f482bb8 100644 --- a/spec/core/SuiteBuilderSpec.js +++ b/spec/core/SuiteBuilderSpec.js @@ -311,10 +311,11 @@ describe('SuiteBuilder', function() { suiteBuilder.topSuite.handleException(new Error('nope')); suiteBuilder.parallelReset(); - expect(suiteBuilder.topSuite.result).toEqual({ + expect(suiteBuilder.topSuite.doneEvent()).toEqual({ id: suiteBuilder.topSuite.id, description: 'Jasmine__TopLevel__Suite', fullName: '', + status: 'passed', failedExpectations: [], deprecationWarnings: [], duration: null, diff --git a/spec/core/SuiteSpec.js b/spec/core/SuiteSpec.js index 117d5ca4..8c8065cd 100644 --- a/spec/core/SuiteSpec.js +++ b/spec/core/SuiteSpec.js @@ -115,20 +115,20 @@ describe('Suite', function() { const suite = new privateUnderTest.Suite({}); suite.addExpectationResult(false, {}); - expect(suite.getResult().status).toBe('failed'); + expect(suite.doneEvent().status).toBe('failed'); }); it('retrieves a result with updated status', function() { const suite = new privateUnderTest.Suite({}); - expect(suite.getResult().status).toBe('passed'); + expect(suite.doneEvent().status).toBe('passed'); }); it('retrieves a result with pending status', function() { const suite = new privateUnderTest.Suite({}); suite.pend(); - expect(suite.getResult().status).toBe('pending'); + expect(suite.doneEvent().status).toBe('pending'); }); it('throws an ExpectationFailed when receiving a failed expectation when throwOnExpectationFailure is set', function() { @@ -140,8 +140,8 @@ describe('Suite', function() { suite.addExpectationResult(false, { message: 'failed' }); }).toThrowError(jasmineUnderTest.private.errors.ExpectationFailed); - expect(suite.getResult().status).toBe('failed'); - expect(suite.result.failedExpectations).toEqual([ + expect(suite.doneEvent().status).toBe('failed'); + expect(suite.doneEvent().failedExpectations).toEqual([ jasmine.objectContaining({ message: 'failed' }) ]); }); @@ -153,7 +153,7 @@ describe('Suite', function() { new jasmineUnderTest.private.errors.ExpectationFailed() ); - expect(suite.getResult().failedExpectations).toEqual([]); + expect(suite.doneEvent().failedExpectations).toEqual([]); }); it('forwards late expectation failures to onLateError', function() { @@ -175,7 +175,7 @@ describe('Suite', function() { message: jasmine.stringMatching(/^Error: nope/) }) ); - expect(suite.result.failedExpectations).toEqual([]); + expect(suite.doneEvent().failedExpectations).toEqual([]); }); it('does not forward non-late expectation failures to onLateError', function() { @@ -194,7 +194,7 @@ describe('Suite', function() { suite.addExpectationResult(false, data, true); expect(onLateError).not.toHaveBeenCalled(); - expect(suite.result.failedExpectations.length).toEqual(1); + expect(suite.doneEvent().failedExpectations.length).toEqual(1); }); it('forwards late handleException calls to onLateError', function() { @@ -212,7 +212,7 @@ describe('Suite', function() { message: jasmine.stringMatching(/^Error: oops/) }) ); - expect(suite.result.failedExpectations).toEqual([]); + expect(suite.doneEvent().failedExpectations).toEqual([]); }); it('does not forward non-late handleException calls to onLateError', function() { @@ -225,7 +225,7 @@ describe('Suite', function() { suite.handleException(error); expect(onLateError).not.toHaveBeenCalled(); - expect(suite.result.failedExpectations.length).toEqual(1); + expect(suite.doneEvent().failedExpectations.length).toEqual(1); }); it('clears the reportedDone flag when reset', function() { @@ -248,7 +248,7 @@ describe('Suite', function() { }); suite.startTimer(); suite.endTimer(); - expect(suite.getResult().duration).toEqual(77000); + expect(suite.doneEvent().duration).toEqual(77000); }); describe('#sharedUserContext', function() { @@ -306,14 +306,14 @@ describe('Suite', function() { const suite = new privateUnderTest.Suite({}); suite.pend(); suite.reset(); - expect(suite.getResult().status).toBe('passed'); + expect(suite.doneEvent().status).toBe('passed'); }); it('should not reset the "pending" status when the suite was excluded', function() { const suite = new privateUnderTest.Suite({}); suite.exclude(); suite.reset(); - expect(suite.getResult().status).toBe('pending'); + expect(suite.doneEvent().status).toBe('pending'); }); it('should also reset the children', function() { @@ -335,7 +335,7 @@ describe('Suite', function() { suite.reset(); - const result = suite.getResult(); + const result = suite.doneEvent(); expect(result.status).toBe('passed'); expect(result.failedExpectations).toHaveSize(0); }); diff --git a/spec/core/TreeRunnerSpec.js b/spec/core/TreeRunnerSpec.js index fa8677ef..fc56fb7a 100644 --- a/spec/core/TreeRunnerSpec.js +++ b/spec/core/TreeRunnerSpec.js @@ -218,7 +218,7 @@ describe('TreeRunner', function() { timer.elapsed.and.returnValue('the duration'); suiteRunQueueOpts.onComplete(); expect(timer.elapsed).toHaveBeenCalled(); - const result = suite.getResult(); + const result = suite.doneEvent(); expect(result.duration).toEqual('the duration'); expect(reportDispatcher.suiteDone).toHaveBeenCalledWith(result); diff --git a/src/core/Runner.js b/src/core/Runner.js index 5f5d7381..c2d4914d 100644 --- a/src/core/Runner.js +++ b/src/core/Runner.js @@ -137,6 +137,7 @@ getJasmineRequireObj().Runner = function(j$) { overallStatus = 'passed'; } + const topSuiteResult = this.#topSuite.doneEvent(); /** * Information passed to the {@link Reporter#jasmineDone} event. * @typedef JasmineDoneInfo @@ -156,8 +157,8 @@ getJasmineRequireObj().Runner = function(j$) { incompleteReason: incompleteReason, incompleteCode: incompleteCode, order: orderForReporting(order), - failedExpectations: this.#topSuite.result.failedExpectations, - deprecationWarnings: this.#topSuite.result.deprecationWarnings + failedExpectations: topSuiteResult.failedExpectations, + deprecationWarnings: topSuiteResult.deprecationWarnings }; this.#topSuite.reportedDone = true; await this.#reportDispatcher.jasmineDone(jasmineDoneInfo); diff --git a/src/core/Suite.js b/src/core/Suite.js index dd5cff31..1ca477d1 100644 --- a/src/core/Suite.js +++ b/src/core/Suite.js @@ -4,6 +4,7 @@ getJasmineRequireObj().Suite = function(j$) { #throwOnExpectationFailure; #autoCleanClosures; #timer; + #result; constructor(attrs) { this.id = attrs.id; @@ -36,8 +37,8 @@ getJasmineRequireObj().Suite = function(j$) { // Throw a better one now. j$.private.util.assertReporterCloneable(key, 'Key'); j$.private.util.assertReporterCloneable(value, 'Value'); - this.result.properties = this.result.properties || {}; - this.result.properties[key] = value; + this.#result.properties = this.#result.properties || {}; + this.#result.properties[key] = value; } getFullName() { @@ -87,7 +88,7 @@ getJasmineRequireObj().Suite = function(j$) { } endTimer() { - this.result.duration = this.#timer.elapsed(); + this.#result.duration = this.#timer.elapsed(); } cleanupBeforeAfter() { @@ -100,7 +101,7 @@ getJasmineRequireObj().Suite = function(j$) { } reset() { - this.result = { + this.#result = { id: this.id, description: this.description, fullName: this.getFullName(), @@ -168,7 +169,7 @@ getJasmineRequireObj().Suite = function(j$) { ]; for (const k of toCopy) { - event[k] = this.result[k]; + event[k] = this.#result[k]; } return event; @@ -197,7 +198,7 @@ getJasmineRequireObj().Suite = function(j$) { return 'pending'; } - if (this.result.failedExpectations.length > 0) { + if (this.#result.failedExpectations.length > 0) { return 'failed'; } else { return 'passed'; @@ -205,12 +206,7 @@ getJasmineRequireObj().Suite = function(j$) { } hasOwnFailedExpectations() { - return this.result.failedExpectations.length > 0; - } - - getResult() { - this.result.status = this.#status(); - return this.result; + return this.#result.failedExpectations.length > 0; } sharedUserContext() { @@ -246,7 +242,7 @@ getJasmineRequireObj().Suite = function(j$) { if (this.reportedDone) { this.onLateError(failedExpectation); } else { - this.result.failedExpectations.push(failedExpectation); + this.#result.failedExpectations.push(failedExpectation); } } @@ -284,12 +280,7 @@ getJasmineRequireObj().Suite = function(j$) { if (this.reportedDone) { this.onLateError(expectationResult); } else { - this.result.failedExpectations.push(expectationResult); - - // TODO: refactor so that we don't need to override cached status - if (this.result.status) { - this.result.status = 'failed'; - } + this.#result.failedExpectations.push(expectationResult); } if (this.#throwOnExpectationFailure) { @@ -301,7 +292,7 @@ getJasmineRequireObj().Suite = function(j$) { if (typeof deprecation === 'string') { deprecation = { message: deprecation }; } - this.result.deprecationWarnings.push( + this.#result.deprecationWarnings.push( j$.private.buildExpectationResult(deprecation) ); } diff --git a/src/core/TreeRunner.js b/src/core/TreeRunner.js index fd30a6ef..8710b9a5 100644 --- a/src/core/TreeRunner.js +++ b/src/core/TreeRunner.js @@ -263,11 +263,6 @@ getJasmineRequireObj().TreeRunner = function(j$) { if (child instanceof j$.private.Suite) { await this.#reportDispatcher.suiteStarted(child.startedEvent()); await this.#reportChildrenOfBeforeAllFailure(child); - - // Marking the suite passed is consistent with how suites that - // contain failed specs but no suite-level failures are reported. - child.result.status = 'passed'; - await this.#reportDispatcher.suiteDone(child.doneEvent()); } else { /* a spec */ From 73a30ffc3eeea3a081ddcb8ce4c790a1e580bb8f Mon Sep 17 00:00:00 2001 From: Steve Gravrock Date: Sun, 5 Oct 2025 06:53:23 -0700 Subject: [PATCH 43/95] Made SpyRegistry compatible with strict mode --- lib/jasmine-core/jasmine.js | 7 ++++++- src/core/SpyRegistry.js | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/lib/jasmine-core/jasmine.js b/lib/jasmine-core/jasmine.js index c64be6e3..ba0dd4a3 100644 --- a/lib/jasmine-core/jasmine.js +++ b/lib/jasmine-core/jasmine.js @@ -10017,6 +10017,8 @@ getJasmineRequireObj().SpyFactory = function(j$) { }; getJasmineRequireObj().SpyRegistry = function(j$) { + 'use strict'; + const spyOnMsg = j$.private.formatErrorMsg( '', 'spyOn(, )' @@ -10099,7 +10101,10 @@ getJasmineRequireObj().SpyRegistry = function(j$) { }; } else { restoreStrategy = function() { - if (!delete obj[methodName]) { + try { + delete obj[methodName]; + // eslint-disable-next-line no-unused-vars + } catch (e) { obj[methodName] = originalMethod; } }; diff --git a/src/core/SpyRegistry.js b/src/core/SpyRegistry.js index b4d06b69..85723f33 100644 --- a/src/core/SpyRegistry.js +++ b/src/core/SpyRegistry.js @@ -1,4 +1,6 @@ getJasmineRequireObj().SpyRegistry = function(j$) { + 'use strict'; + const spyOnMsg = j$.private.formatErrorMsg( '', 'spyOn(, )' @@ -81,7 +83,10 @@ getJasmineRequireObj().SpyRegistry = function(j$) { }; } else { restoreStrategy = function() { - if (!delete obj[methodName]) { + try { + delete obj[methodName]; + // eslint-disable-next-line no-unused-vars + } catch (e) { obj[methodName] = originalMethod; } }; From 68a7cbb991e16e08753fff94a69200ec2893a158 Mon Sep 17 00:00:00 2001 From: Steve Gravrock Date: Sun, 5 Oct 2025 06:53:54 -0700 Subject: [PATCH 44/95] Adopt strict mode throughout the codebase --- lib/jasmine-core.js | 2 + lib/jasmine-core/boot0.js | 2 + lib/jasmine-core/boot1.js | 2 + lib/jasmine-core/jasmine-html.js | 10 + lib/jasmine-core/jasmine.js | 205 ++++++++++++++++++ src/boot/boot0.js | 2 + src/boot/boot1.js | 2 + src/boot/jasmine-core.js | 2 + src/core/CallTracker.js | 2 + src/core/ClearStack.js | 2 + src/core/Clock.js | 2 + src/core/CompleteOnFirstErrorSkipPolicy.js | 2 + src/core/Configuration.js | 2 + src/core/CurrentRunableTracker.js | 2 + src/core/Deprecator.js | 2 + src/core/Env.js | 2 + src/core/ExceptionFormatter.js | 2 + src/core/Expectation.js | 2 + src/core/ExpectationFilterChain.js | 2 + src/core/Expector.js | 2 + src/core/GlobalErrors.js | 2 + src/core/JsApiReporter.js | 2 + src/core/MockDate.js | 2 + src/core/NeverSkipPolicy.js | 2 + src/core/Order.js | 2 + src/core/PrettyPrinter.js | 2 + src/core/QueueRunner.js | 2 + src/core/RunableResources.js | 2 + src/core/Runner.js | 2 + src/core/SkipAfterBeforeAllErrorPolicy.js | 2 + src/core/Spec.js | 2 + src/core/Spy.js | 2 + src/core/SpyFactory.js | 2 + src/core/SpyStrategy.js | 2 + src/core/StackTrace.js | 2 + src/core/Suite.js | 2 + src/core/SuiteBuilder.js | 2 + src/core/Timer.js | 2 + src/core/TreeProcessor.js | 2 + src/core/TreeRunner.js | 2 + src/core/UserContext.js | 2 + src/core/asymmetric_equality/Any.js | 2 + src/core/asymmetric_equality/Anything.js | 2 + .../asymmetric_equality/ArrayContaining.js | 2 + .../ArrayWithExactContents.js | 2 + src/core/asymmetric_equality/Empty.js | 2 + src/core/asymmetric_equality/Falsy.js | 2 + src/core/asymmetric_equality/Is.js | 2 + src/core/asymmetric_equality/MapContaining.js | 2 + src/core/asymmetric_equality/NotEmpty.js | 2 + .../asymmetric_equality/ObjectContaining.js | 2 + src/core/asymmetric_equality/SetContaining.js | 2 + .../asymmetric_equality/StringContaining.js | 2 + .../asymmetric_equality/StringMatching.js | 2 + src/core/asymmetric_equality/Truthy.js | 2 + src/core/base.js | 2 + src/core/buildExpectationResult.js | 2 + src/core/errors.js | 2 + src/core/formatErrorMsg.js | 2 + src/core/matchers/DiffBuilder.js | 2 + src/core/matchers/MismatchTree.js | 2 + src/core/matchers/NullDiffBuilder.js | 2 + src/core/matchers/ObjectPath.js | 2 + src/core/matchers/async/toBePending.js | 2 + src/core/matchers/async/toBeRejected.js | 2 + src/core/matchers/async/toBeRejectedWith.js | 2 + .../matchers/async/toBeRejectedWithError.js | 2 + src/core/matchers/async/toBeResolved.js | 2 + src/core/matchers/async/toBeResolvedTo.js | 2 + src/core/matchers/matchersUtil.js | 2 + src/core/matchers/nothing.js | 2 + src/core/matchers/requireAsyncMatchers.js | 2 + src/core/matchers/requireMatchers.js | 2 + src/core/matchers/toBe.js | 2 + src/core/matchers/toBeCloseTo.js | 2 + src/core/matchers/toBeDefined.js | 2 + src/core/matchers/toBeFalse.js | 2 + src/core/matchers/toBeFalsy.js | 2 + src/core/matchers/toBeGreaterThan.js | 2 + src/core/matchers/toBeGreaterThanOrEqual.js | 2 + src/core/matchers/toBeInstanceOf.js | 2 + src/core/matchers/toBeLessThan.js | 2 + src/core/matchers/toBeLessThanOrEqual.js | 2 + src/core/matchers/toBeNaN.js | 2 + src/core/matchers/toBeNegativeInfinity.js | 2 + src/core/matchers/toBeNull.js | 2 + src/core/matchers/toBeNullish.js | 2 + src/core/matchers/toBePositiveInfinity.js | 2 + src/core/matchers/toBeTrue.js | 2 + src/core/matchers/toBeTruthy.js | 2 + src/core/matchers/toBeUndefined.js | 2 + src/core/matchers/toContain.js | 2 + src/core/matchers/toEqual.js | 2 + src/core/matchers/toHaveBeenCalled.js | 2 + src/core/matchers/toHaveBeenCalledBefore.js | 2 + src/core/matchers/toHaveBeenCalledOnceWith.js | 2 + src/core/matchers/toHaveBeenCalledTimes.js | 2 + src/core/matchers/toHaveBeenCalledWith.js | 2 + src/core/matchers/toHaveClass.js | 2 + src/core/matchers/toHaveClasses.js | 2 + .../matchers/toHaveNoOtherSpyInteractions.js | 2 + src/core/matchers/toHaveSize.js | 2 + src/core/matchers/toHaveSpyInteractions.js | 2 + src/core/matchers/toMatch.js | 2 + src/core/matchers/toThrow.js | 2 + src/core/matchers/toThrowError.js | 2 + src/core/matchers/toThrowMatching.js | 2 + src/core/reporterEvents.js | 2 + src/core/requireCore.js | 1 + src/core/requireInterface.js | 2 + src/core/util.js | 2 + src/html/HtmlExactSpecFilter.js | 2 + src/html/HtmlReporter.js | 2 + src/html/HtmlSpecFilter.js | 2 + src/html/QueryString.js | 2 + src/html/ResultsNode.js | 2 + 116 files changed, 442 insertions(+) diff --git a/lib/jasmine-core.js b/lib/jasmine-core.js index 326ccab1..6efa2367 100644 --- a/lib/jasmine-core.js +++ b/lib/jasmine-core.js @@ -22,6 +22,8 @@ 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'; + /** * Note: Only available on Node. * @module jasmine-core diff --git a/lib/jasmine-core/boot0.js b/lib/jasmine-core/boot0.js index 5403bdf3..53887758 100644 --- a/lib/jasmine-core/boot0.js +++ b/lib/jasmine-core/boot0.js @@ -22,6 +22,8 @@ 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 diff --git a/lib/jasmine-core/boot1.js b/lib/jasmine-core/boot1.js index c1bf086b..b91a1a75 100644 --- a/lib/jasmine-core/boot1.js +++ b/lib/jasmine-core/boot1.js @@ -22,6 +22,8 @@ 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 finishes 'booting' Jasmine, performing all of the necessary initialization before executing the loaded environment and all of a project's diff --git a/lib/jasmine-core/jasmine-html.js b/lib/jasmine-core/jasmine-html.js index 767951a4..1a45ff0d 100644 --- a/lib/jasmine-core/jasmine-html.js +++ b/lib/jasmine-core/jasmine-html.js @@ -34,6 +34,8 @@ jasmineRequire.html = function(j$) { }; jasmineRequire.HtmlReporter = function(j$) { + 'use strict'; + function ResultsStateBuilder() { this.topResults = new j$.private.ResultsNode({}, '', null); this.currentParent = this.topResults; @@ -907,6 +909,8 @@ jasmineRequire.HtmlReporter = function(j$) { }; jasmineRequire.HtmlSpecFilter = function() { + 'use strict'; + /** * @name HtmlSpecFilter * @classdesc Legacy HTML spec filter, for backward compatibility @@ -946,6 +950,8 @@ jasmineRequire.HtmlSpecFilter = function() { }; jasmineRequire.ResultsNode = function() { + 'use strict'; + function ResultsNode(result, type, parent) { this.result = result; this.type = type; @@ -970,6 +976,8 @@ jasmineRequire.ResultsNode = function() { }; jasmineRequire.QueryString = function() { + 'use strict'; + /** * Reads and manipulates the query string. * @since 2.0.0 @@ -1054,6 +1062,8 @@ jasmineRequire.QueryString = function() { }; jasmineRequire.HtmlExactSpecFilter = function() { + 'use strict'; + /** * Spec filter for use with {@link HtmlReporter} * diff --git a/lib/jasmine-core/jasmine.js b/lib/jasmine-core/jasmine.js index ba0dd4a3..5220ab23 100644 --- a/lib/jasmine-core/jasmine.js +++ b/lib/jasmine-core/jasmine.js @@ -24,6 +24,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // eslint-disable-next-line no-unused-vars,no-var var getJasmineRequireObj = (function(jasmineGlobal) { + 'use strict'; let jasmineRequire; if ( @@ -134,6 +135,8 @@ var getJasmineRequireObj = (function(jasmineGlobal) { })(this); getJasmineRequireObj().requireMatchers = function(jRequire, j$) { + 'use strict'; + const availableMatchers = [ 'nothing', 'toBe', @@ -181,6 +184,8 @@ getJasmineRequireObj().requireMatchers = function(jRequire, j$) { }; getJasmineRequireObj().base = function(j$, jasmineGlobal) { + 'use strict'; + /** * Maximum object depth the pretty printer will print to. * Set this to a lower value to speed up pretty printing if you have large objects. @@ -680,6 +685,8 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) { }; getJasmineRequireObj().util = function(j$) { + 'use strict'; + const util = {}; util.clone = function(obj) { @@ -776,6 +783,8 @@ getJasmineRequireObj().util = function(j$) { }; getJasmineRequireObj().Spec = function(j$) { + 'use strict'; + class Spec { #autoCleanClosures; #throwOnExpectationFailure; @@ -1146,6 +1155,8 @@ getJasmineRequireObj().Spec = function(j$) { }; getJasmineRequireObj().Order = function() { + 'use strict'; + function Order(options) { this.random = 'random' in options ? options.random : true; const seed = (this.seed = options.seed || generateSeed()); @@ -1190,6 +1201,8 @@ getJasmineRequireObj().Order = function() { }; getJasmineRequireObj().Env = function(j$) { + 'use strict'; + /** * @class Env * @since 2.0.0 @@ -2007,6 +2020,8 @@ getJasmineRequireObj().Env = function(j$) { }; getJasmineRequireObj().JsApiReporter = function(j$) { + 'use strict'; + /** * @name jsApiReporter * @classdesc {@link Reporter} added by default in `boot.js` to record results for retrieval in javascript code. An instance is made available as `jsApiReporter` on the global object. @@ -2137,6 +2152,8 @@ getJasmineRequireObj().JsApiReporter = function(j$) { }; getJasmineRequireObj().Any = function(j$) { + 'use strict'; + function Any(expectedObject) { if (typeof expectedObject === 'undefined') { throw new TypeError( @@ -2183,6 +2200,8 @@ getJasmineRequireObj().Any = function(j$) { }; getJasmineRequireObj().Anything = function(j$) { + 'use strict'; + function Anything() {} Anything.prototype.asymmetricMatch = function(other) { @@ -2197,6 +2216,8 @@ getJasmineRequireObj().Anything = function(j$) { }; getJasmineRequireObj().ArrayContaining = function(j$) { + 'use strict'; + function ArrayContaining(sample) { this.sample = sample; } @@ -2234,6 +2255,8 @@ getJasmineRequireObj().ArrayContaining = function(j$) { }; getJasmineRequireObj().ArrayWithExactContents = function(j$) { + 'use strict'; + function ArrayWithExactContents(sample) { this.sample = sample; } @@ -2271,6 +2294,8 @@ getJasmineRequireObj().ArrayWithExactContents = function(j$) { }; getJasmineRequireObj().Empty = function(j$) { + 'use strict'; + function Empty() {} Empty.prototype.asymmetricMatch = function(other) { @@ -2300,6 +2325,8 @@ getJasmineRequireObj().Empty = function(j$) { }; getJasmineRequireObj().Falsy = function(j$) { + 'use strict'; + function Falsy() {} Falsy.prototype.asymmetricMatch = function(other) { @@ -2314,6 +2341,8 @@ getJasmineRequireObj().Falsy = function(j$) { }; getJasmineRequireObj().Is = function(j$) { + 'use strict'; + class Is { constructor(expected) { this.expected_ = expected; @@ -2332,6 +2361,8 @@ getJasmineRequireObj().Is = function(j$) { }; getJasmineRequireObj().MapContaining = function(j$) { + 'use strict'; + function MapContaining(sample) { if (!j$.private.isMap(sample)) { throw new Error( @@ -2378,6 +2409,8 @@ getJasmineRequireObj().MapContaining = function(j$) { }; getJasmineRequireObj().NotEmpty = function(j$) { + 'use strict'; + function NotEmpty() {} NotEmpty.prototype.asymmetricMatch = function(other) { @@ -2408,6 +2441,8 @@ getJasmineRequireObj().NotEmpty = function(j$) { }; getJasmineRequireObj().ObjectContaining = function(j$) { + 'use strict'; + function ObjectContaining(sample) { this.sample = sample; } @@ -2477,6 +2512,8 @@ getJasmineRequireObj().ObjectContaining = function(j$) { }; getJasmineRequireObj().SetContaining = function(j$) { + 'use strict'; + function SetContaining(sample) { if (!j$.private.isSet(sample)) { throw new Error( @@ -2521,6 +2558,8 @@ getJasmineRequireObj().SetContaining = function(j$) { }; getJasmineRequireObj().StringContaining = function(j$) { + 'use strict'; + function StringContaining(expected) { if (!j$.private.isString(expected)) { throw new Error('Expected is not a String'); @@ -2546,6 +2585,8 @@ getJasmineRequireObj().StringContaining = function(j$) { }; getJasmineRequireObj().StringMatching = function(j$) { + 'use strict'; + function StringMatching(expected) { if (!j$.private.isString(expected) && !j$.private.isA('RegExp', expected)) { throw new Error('Expected is not a String or a RegExp'); @@ -2566,6 +2607,8 @@ getJasmineRequireObj().StringMatching = function(j$) { }; getJasmineRequireObj().Truthy = function(j$) { + 'use strict'; + function Truthy() {} Truthy.prototype.asymmetricMatch = function(other) { @@ -2581,6 +2624,8 @@ getJasmineRequireObj().Truthy = function(j$) { //TODO: expectation result may make more sense as a presentation of an expectation. getJasmineRequireObj().buildExpectationResult = function(j$) { + 'use strict'; + function buildExpectationResult(options) { const exceptionFormatter = new j$.private.ExceptionFormatter(); @@ -2662,6 +2707,8 @@ getJasmineRequireObj().buildExpectationResult = function(j$) { }; getJasmineRequireObj().CallTracker = function(j$) { + 'use strict'; + /** * @namespace Spy#calls * @since 2.0.0 @@ -2802,6 +2849,8 @@ getJasmineRequireObj().CallTracker = function(j$) { }; getJasmineRequireObj().clearStack = function(j$) { + 'use strict'; + const maxInlineCallCount = 10; function browserQueueMicrotaskImpl(global) { @@ -2925,6 +2974,8 @@ getJasmineRequireObj().clearStack = function(j$) { }; getJasmineRequireObj().Clock = function() { + 'use strict'; + /* global process */ const NODE_JS = typeof process !== 'undefined' && @@ -3272,6 +3323,8 @@ callbacks to execute _before_ running the next one. }; getJasmineRequireObj().CompleteOnFirstErrorSkipPolicy = function(j$) { + 'use strict'; + function CompleteOnFirstErrorSkipPolicy(queueableFns) { this.queueableFns_ = queueableFns; this.erroredFnIx_ = null; @@ -3324,6 +3377,8 @@ getJasmineRequireObj().CompleteOnFirstErrorSkipPolicy = function(j$) { }; getJasmineRequireObj().Configuration = function(j$) { + 'use strict'; + /** * This represents the available options to configure Jasmine. * Options that are not provided will use their default values. @@ -3506,6 +3561,8 @@ getJasmineRequireObj().Configuration = function(j$) { }; getJasmineRequireObj().CurrentRunableTracker = function() { + 'use strict'; + class CurrentRunableTracker { #currentSpec; #currentlyExecutingSuites; @@ -3755,6 +3812,8 @@ getJasmineRequireObj().DelayedFunctionScheduler = function(j$) { }; getJasmineRequireObj().Deprecator = function(j$) { + 'use strict'; + function Deprecator(topSuite) { this.topSuite_ = topSuite; this.verbose_ = false; @@ -3848,6 +3907,8 @@ getJasmineRequireObj().Deprecator = function(j$) { }; getJasmineRequireObj().errors = function() { + 'use strict'; + function ExpectationFailed() {} ExpectationFailed.prototype = new Error(); @@ -3859,6 +3920,8 @@ getJasmineRequireObj().errors = function() { }; getJasmineRequireObj().ExceptionFormatter = function(j$) { + 'use strict'; + const ignoredProperties = [ 'name', 'message', @@ -3984,6 +4047,8 @@ getJasmineRequireObj().ExceptionFormatter = function(j$) { }; getJasmineRequireObj().Expectation = function(j$) { + 'use strict'; + /** * Matchers that come with Jasmine out of the box. * @namespace matchers @@ -4252,6 +4317,8 @@ getJasmineRequireObj().Expectation = function(j$) { }; getJasmineRequireObj().ExpectationFilterChain = function() { + 'use strict'; + function ExpectationFilterChain(maybeFilter, prev) { this.filter_ = maybeFilter; this.prev_ = prev; @@ -4302,6 +4369,8 @@ getJasmineRequireObj().ExpectationFilterChain = function() { }; getJasmineRequireObj().Expector = function(j$) { + 'use strict'; + function Expector(options) { this.matchersUtil = options.matchersUtil || { buildFailureMessage: function() {} @@ -4394,6 +4463,8 @@ getJasmineRequireObj().Expector = function(j$) { }; getJasmineRequireObj().formatErrorMsg = function() { + 'use strict'; + function generateErrorMsg(domain, usage) { const usageDefinition = usage ? '\nUsage: ' + usage : ''; @@ -4406,6 +4477,8 @@ getJasmineRequireObj().formatErrorMsg = function() { }; getJasmineRequireObj().GlobalErrors = function(j$) { + 'use strict'; + class GlobalErrors { #getConfig; #adapter; @@ -4708,6 +4781,8 @@ getJasmineRequireObj().GlobalErrors = function(j$) { }; getJasmineRequireObj().toBePending = function(j$) { + 'use strict'; + /** * Expect a promise to be pending, i.e. the promise is neither resolved nor rejected. * @function @@ -4740,6 +4815,8 @@ getJasmineRequireObj().toBePending = function(j$) { }; getJasmineRequireObj().toBeRejected = function(j$) { + 'use strict'; + /** * Expect a promise to be rejected. * @function @@ -4773,6 +4850,8 @@ getJasmineRequireObj().toBeRejected = function(j$) { }; getJasmineRequireObj().toBeRejectedWith = function(j$) { + 'use strict'; + /** * Expect a promise to be rejected with a value equal to the expected, using deep equality comparison. * @function @@ -4834,6 +4913,8 @@ getJasmineRequireObj().toBeRejectedWith = function(j$) { }; getJasmineRequireObj().toBeRejectedWithError = function(j$) { + 'use strict'; + /** * Expect a promise to be rejected with a value matched to the expected * @function @@ -4957,6 +5038,8 @@ getJasmineRequireObj().toBeRejectedWithError = function(j$) { }; getJasmineRequireObj().toBeResolved = function(j$) { + 'use strict'; + /** * Expect a promise to be resolved. * @function @@ -4998,6 +5081,8 @@ getJasmineRequireObj().toBeResolved = function(j$) { }; getJasmineRequireObj().toBeResolvedTo = function(j$) { + 'use strict'; + /** * Expect a promise to be resolved to a value equal to the expected, using deep equality comparison. * @function @@ -5063,6 +5148,8 @@ getJasmineRequireObj().toBeResolvedTo = function(j$) { }; getJasmineRequireObj().DiffBuilder = function(j$) { + 'use strict'; + class DiffBuilder { constructor(config) { this.prettyPrinter_ = @@ -5177,6 +5264,8 @@ getJasmineRequireObj().DiffBuilder = function(j$) { }; getJasmineRequireObj().MatchersUtil = function(j$) { + 'use strict'; + /** * @class MatchersUtil * @classdesc Utilities for use in implementing matchers.
@@ -5862,6 +5951,8 @@ getJasmineRequireObj().MatchersUtil = function(j$) { */ getJasmineRequireObj().MismatchTree = function(j$) { + 'use strict'; + /* To be able to apply custom object formatters at all possible levels of an object graph, DiffBuilder needs to be able to know not just where the @@ -5919,6 +6010,8 @@ getJasmineRequireObj().MismatchTree = function(j$) { }; getJasmineRequireObj().nothing = function() { + 'use strict'; + /** * {@link expect} nothing explicitly. * @function @@ -5941,6 +6034,8 @@ getJasmineRequireObj().nothing = function() { }; getJasmineRequireObj().NullDiffBuilder = function(j$) { + 'use strict'; + return function() { return { withPath: function(_, block) { @@ -5953,6 +6048,8 @@ getJasmineRequireObj().NullDiffBuilder = function(j$) { }; getJasmineRequireObj().ObjectPath = function(j$) { + 'use strict'; + class ObjectPath { constructor(components) { this.components = components || []; @@ -5999,6 +6096,8 @@ getJasmineRequireObj().ObjectPath = function(j$) { }; getJasmineRequireObj().requireAsyncMatchers = function(jRequire, j$) { + 'use strict'; + const availableMatchers = [ 'toBePending', 'toBeResolved', @@ -6017,6 +6116,8 @@ getJasmineRequireObj().requireAsyncMatchers = function(jRequire, j$) { }; getJasmineRequireObj().toBe = function(j$) { + 'use strict'; + /** * {@link expect} the actual value to be `===` to the expected value. * @function @@ -6055,6 +6156,8 @@ getJasmineRequireObj().toBe = function(j$) { }; getJasmineRequireObj().toBeCloseTo = function() { + 'use strict'; + /** * {@link expect} the actual value to be within a specified precision of the expected value. * @function @@ -6106,6 +6209,8 @@ getJasmineRequireObj().toBeCloseTo = function() { }; getJasmineRequireObj().toBeDefined = function() { + 'use strict'; + /** * {@link expect} the actual value to be defined. (Not `undefined`) * @function @@ -6128,6 +6233,8 @@ getJasmineRequireObj().toBeDefined = function() { }; getJasmineRequireObj().toBeFalse = function() { + 'use strict'; + /** * {@link expect} the actual value to be `false`. * @function @@ -6150,6 +6257,8 @@ getJasmineRequireObj().toBeFalse = function() { }; getJasmineRequireObj().toBeFalsy = function() { + 'use strict'; + /** * {@link expect} the actual value to be falsy * @function @@ -6172,6 +6281,8 @@ getJasmineRequireObj().toBeFalsy = function() { }; getJasmineRequireObj().toBeGreaterThan = function() { + 'use strict'; + /** * {@link expect} the actual value to be greater than the expected value. * @function @@ -6195,6 +6306,8 @@ getJasmineRequireObj().toBeGreaterThan = function() { }; getJasmineRequireObj().toBeGreaterThanOrEqual = function() { + 'use strict'; + /** * {@link expect} the actual value to be greater than or equal to the expected value. * @function @@ -6218,6 +6331,8 @@ getJasmineRequireObj().toBeGreaterThanOrEqual = function() { }; getJasmineRequireObj().toBeInstanceOf = function(j$) { + 'use strict'; + const usageError = j$.private.formatErrorMsg( '', 'expect(value).toBeInstanceOf()' @@ -6284,6 +6399,8 @@ getJasmineRequireObj().toBeInstanceOf = function(j$) { }; getJasmineRequireObj().toBeLessThan = function() { + 'use strict'; + /** * {@link expect} the actual value to be less than the expected value. * @function @@ -6307,6 +6424,8 @@ getJasmineRequireObj().toBeLessThan = function() { }; getJasmineRequireObj().toBeLessThanOrEqual = function() { + 'use strict'; + /** * {@link expect} the actual value to be less than or equal to the expected value. * @function @@ -6330,6 +6449,8 @@ getJasmineRequireObj().toBeLessThanOrEqual = function() { }; getJasmineRequireObj().toBeNaN = function(j$) { + 'use strict'; + /** * {@link expect} the actual value to be `NaN` (Not a Number). * @function @@ -6362,6 +6483,8 @@ getJasmineRequireObj().toBeNaN = function(j$) { }; getJasmineRequireObj().toBeNegativeInfinity = function(j$) { + 'use strict'; + /** * {@link expect} the actual value to be `-Infinity` (-infinity). * @function @@ -6394,6 +6517,8 @@ getJasmineRequireObj().toBeNegativeInfinity = function(j$) { }; getJasmineRequireObj().toBeNull = function() { + 'use strict'; + /** * {@link expect} the actual value to be `null`. * @function @@ -6416,6 +6541,8 @@ getJasmineRequireObj().toBeNull = function() { }; getJasmineRequireObj().toBeNullish = function() { + 'use strict'; + /** * {@link expect} the actual value to be `null` or `undefined`. * @function @@ -6438,6 +6565,8 @@ getJasmineRequireObj().toBeNullish = function() { }; getJasmineRequireObj().toBePositiveInfinity = function(j$) { + 'use strict'; + /** * {@link expect} the actual value to be `Infinity` (infinity). * @function @@ -6470,6 +6599,8 @@ getJasmineRequireObj().toBePositiveInfinity = function(j$) { }; getJasmineRequireObj().toBeTrue = function() { + 'use strict'; + /** * {@link expect} the actual value to be `true`. * @function @@ -6492,6 +6623,8 @@ getJasmineRequireObj().toBeTrue = function() { }; getJasmineRequireObj().toBeTruthy = function() { + 'use strict'; + /** * {@link expect} the actual value to be truthy. * @function @@ -6514,6 +6647,8 @@ getJasmineRequireObj().toBeTruthy = function() { }; getJasmineRequireObj().toBeUndefined = function() { + 'use strict'; + /** * {@link expect} the actual value to be `undefined`. * @function @@ -6536,6 +6671,8 @@ getJasmineRequireObj().toBeUndefined = function() { }; getJasmineRequireObj().toContain = function() { + 'use strict'; + /** * {@link expect} the actual value to contain a specific value. * @function @@ -6560,6 +6697,8 @@ getJasmineRequireObj().toContain = function() { }; getJasmineRequireObj().toEqual = function(j$) { + 'use strict'; + /** * {@link expect} the actual value to be equal to the expected, using deep equality comparison. * @function @@ -6593,6 +6732,8 @@ getJasmineRequireObj().toEqual = function(j$) { }; getJasmineRequireObj().toHaveBeenCalled = function(j$) { + 'use strict'; + const getErrorMsg = j$.private.formatErrorMsg( '', 'expect().toHaveBeenCalled()' @@ -6643,6 +6784,8 @@ getJasmineRequireObj().toHaveBeenCalled = function(j$) { }; getJasmineRequireObj().toHaveBeenCalledBefore = function(j$) { + 'use strict'; + const getErrorMsg = j$.private.formatErrorMsg( '', 'expect().toHaveBeenCalledBefore()' @@ -6739,6 +6882,8 @@ getJasmineRequireObj().toHaveBeenCalledBefore = function(j$) { }; getJasmineRequireObj().toHaveBeenCalledOnceWith = function(j$) { + 'use strict'; + const getErrorMsg = j$.private.formatErrorMsg( '', 'expect().toHaveBeenCalledOnceWith(...arguments)' @@ -6848,6 +6993,8 @@ getJasmineRequireObj().toHaveBeenCalledOnceWith = function(j$) { }; getJasmineRequireObj().toHaveBeenCalledTimes = function(j$) { + 'use strict'; + const getErrorMsg = j$.private.formatErrorMsg( '', 'expect().toHaveBeenCalledTimes()' @@ -6924,6 +7071,8 @@ getJasmineRequireObj().toHaveBeenCalledTimes = function(j$) { }; getJasmineRequireObj().toHaveBeenCalledWith = function(j$) { + 'use strict'; + const getErrorMsg = j$.private.formatErrorMsg( '', 'expect().toHaveBeenCalledWith(...arguments)' @@ -7031,6 +7180,8 @@ getJasmineRequireObj().toHaveBeenCalledWith = function(j$) { }; getJasmineRequireObj().toHaveClass = function(j$) { + 'use strict'; + /** * {@link expect} the actual value to be a DOM element that has the expected class * @function @@ -7068,6 +7219,8 @@ getJasmineRequireObj().toHaveClass = function(j$) { }; getJasmineRequireObj().toHaveClasses = function(j$) { + 'use strict'; + /** * {@link expect} the actual value to be a DOM element that has the expected classes * @function @@ -7105,6 +7258,8 @@ getJasmineRequireObj().toHaveClasses = function(j$) { }; getJasmineRequireObj().toHaveNoOtherSpyInteractions = function(j$) { + 'use strict'; + const getErrorMsg = j$.private.formatErrorMsg( '', 'expect().toHaveNoOtherSpyInteractions()' @@ -7191,6 +7346,8 @@ getJasmineRequireObj().toHaveNoOtherSpyInteractions = function(j$) { }; getJasmineRequireObj().toHaveSize = function(j$) { + 'use strict'; + /** * {@link expect} the actual size to be equal to the expected, using array-like length or object keys size. * @function @@ -7260,6 +7417,8 @@ getJasmineRequireObj().toHaveSize = function(j$) { }; getJasmineRequireObj().toHaveSpyInteractions = function(j$) { + 'use strict'; + const getErrorMsg = j$.private.formatErrorMsg( '', 'expect().toHaveSpyInteractions()' @@ -7339,6 +7498,8 @@ getJasmineRequireObj().toHaveSpyInteractions = function(j$) { }; getJasmineRequireObj().toMatch = function(j$) { + 'use strict'; + const getErrorMsg = j$.private.formatErrorMsg( '', 'expect().toMatch( || )' @@ -7377,6 +7538,8 @@ getJasmineRequireObj().toMatch = function(j$) { }; getJasmineRequireObj().toThrow = function(j$) { + 'use strict'; + const getErrorMsg = j$.private.formatErrorMsg( '', 'expect(function() {}).toThrow()' @@ -7458,6 +7621,8 @@ getJasmineRequireObj().toThrow = function(j$) { }; getJasmineRequireObj().toThrowError = function(j$) { + 'use strict'; + const getErrorMsg = j$.private.formatErrorMsg( '', 'expect(function() {}).toThrowError(, )' @@ -7660,6 +7825,8 @@ getJasmineRequireObj().toThrowError = function(j$) { }; getJasmineRequireObj().toThrowMatching = function(j$) { + 'use strict'; + const usageError = j$.private.formatErrorMsg( '', 'expect(function() {}).toThrowMatching()' @@ -7742,6 +7909,8 @@ getJasmineRequireObj().toThrowMatching = function(j$) { }; getJasmineRequireObj().MockDate = function(j$) { + 'use strict'; + function MockDate(global) { let currentTime = 0; @@ -7850,6 +8019,8 @@ getJasmineRequireObj().MockDate = function(j$) { }; getJasmineRequireObj().NeverSkipPolicy = function(j$) { + 'use strict'; + function NeverSkipPolicy(queueableFns) {} NeverSkipPolicy.prototype.skipTo = function(lastRanFnIx) { @@ -7959,6 +8130,8 @@ getJasmineRequireObj().ParallelReportDispatcher = function(j$) { }; getJasmineRequireObj().makePrettyPrinter = function(j$) { + 'use strict'; + class SinglePrettyPrintRun { constructor(customObjectFormatters, pp) { this.customObjectFormatters_ = customObjectFormatters; @@ -8331,6 +8504,8 @@ getJasmineRequireObj().makePrettyPrinter = function(j$) { }; getJasmineRequireObj().QueueRunner = function(j$) { + 'use strict'; + let nextid = 1; function StopExecutionError() {} @@ -8715,6 +8890,8 @@ getJasmineRequireObj().ReportDispatcher = function(j$) { }; getJasmineRequireObj().reporterEvents = function(j$) { + 'use strict'; + /** * Used to tell Jasmine what optional or uncommonly implemented features * the reporter supports. If not specified, the defaults described in @@ -8812,6 +8989,8 @@ getJasmineRequireObj().reporterEvents = function(j$) { }; getJasmineRequireObj().interface = function(jasmine, env) { + 'use strict'; + const jasmineInterface = { /** * Callback passed to parts of the Jasmine base interface. @@ -9335,6 +9514,8 @@ getJasmineRequireObj().interface = function(jasmine, env) { }; getJasmineRequireObj().RunableResources = function(j$) { + 'use strict'; + class RunableResources { constructor(options) { this.byRunableId_ = {}; @@ -9493,6 +9674,8 @@ getJasmineRequireObj().RunableResources = function(j$) { }; getJasmineRequireObj().Runner = function(j$) { + 'use strict'; + class Runner { #topSuite; #getTotalSpecsDefined; @@ -9680,6 +9863,8 @@ getJasmineRequireObj().Runner = function(j$) { }; getJasmineRequireObj().SkipAfterBeforeAllErrorPolicy = function(j$) { + 'use strict'; + function SkipAfterBeforeAllErrorPolicy(queueableFns) { this.queueableFns_ = queueableFns; this.skipping_ = false; @@ -9719,6 +9904,8 @@ getJasmineRequireObj().SkipAfterBeforeAllErrorPolicy = function(j$) { }; getJasmineRequireObj().Spy = function(j$) { + 'use strict'; + const nextOrder = (function() { let order = 0; @@ -9933,6 +10120,8 @@ getJasmineRequireObj().Spy = function(j$) { }; getJasmineRequireObj().SpyFactory = function(j$) { + 'use strict'; + function SpyFactory( getCustomStrategies, getDefaultStrategyFn, @@ -10303,6 +10492,8 @@ getJasmineRequireObj().SpyRegistry = function(j$) { }; getJasmineRequireObj().SpyStrategy = function(j$) { + 'use strict'; + /** * @interface SpyStrategy */ @@ -10484,6 +10675,8 @@ getJasmineRequireObj().SpyStrategy = function(j$) { }; getJasmineRequireObj().StackTrace = function(j$) { + 'use strict'; + function StackTrace(error) { let lines = error.stack.split('\n'); @@ -10616,6 +10809,8 @@ getJasmineRequireObj().StackTrace = function(j$) { }; getJasmineRequireObj().Suite = function(j$) { + 'use strict'; + class Suite { #reportedParentSuiteId; #throwOnExpectationFailure; @@ -11002,6 +11197,8 @@ getJasmineRequireObj().Suite = function(j$) { }; getJasmineRequireObj().SuiteBuilder = function(j$) { + 'use strict'; + class SuiteBuilder { constructor(options) { this.env_ = options.env; @@ -11346,6 +11543,8 @@ getJasmineRequireObj().SuiteBuilder = function(j$) { }; getJasmineRequireObj().Timer = function() { + 'use strict'; + const defaultNow = (function(Date) { return function() { return new Date().getTime(); @@ -11390,6 +11589,8 @@ getJasmineRequireObj().Timer = function() { }; getJasmineRequireObj().TreeProcessor = function(j$) { + 'use strict'; + const defaultMin = Infinity; const defaultMax = 1 - Infinity; @@ -11597,6 +11798,8 @@ getJasmineRequireObj().TreeProcessor = function(j$) { }; getJasmineRequireObj().TreeRunner = function(j$) { + 'use strict'; + class TreeRunner { #executionTree; #setTimeout; @@ -11884,6 +12087,8 @@ getJasmineRequireObj().TreeRunner = function(j$) { }; getJasmineRequireObj().UserContext = function(j$) { + 'use strict'; + function UserContext() {} UserContext.fromExisting = function(oldContext) { diff --git a/src/boot/boot0.js b/src/boot/boot0.js index 976e623f..0bb9da86 100644 --- a/src/boot/boot0.js +++ b/src/boot/boot0.js @@ -1,3 +1,5 @@ +'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 diff --git a/src/boot/boot1.js b/src/boot/boot1.js index 45547069..7f22a55d 100644 --- a/src/boot/boot1.js +++ b/src/boot/boot1.js @@ -1,3 +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 diff --git a/src/boot/jasmine-core.js b/src/boot/jasmine-core.js index 6d8878fc..1ceab28c 100644 --- a/src/boot/jasmine-core.js +++ b/src/boot/jasmine-core.js @@ -1,3 +1,5 @@ +'use strict'; + /** * Note: Only available on Node. * @module jasmine-core diff --git a/src/core/CallTracker.js b/src/core/CallTracker.js index 403eaef4..7eeee8ca 100644 --- a/src/core/CallTracker.js +++ b/src/core/CallTracker.js @@ -1,4 +1,6 @@ getJasmineRequireObj().CallTracker = function(j$) { + 'use strict'; + /** * @namespace Spy#calls * @since 2.0.0 diff --git a/src/core/ClearStack.js b/src/core/ClearStack.js index c2948cff..6968bddc 100644 --- a/src/core/ClearStack.js +++ b/src/core/ClearStack.js @@ -1,4 +1,6 @@ getJasmineRequireObj().clearStack = function(j$) { + 'use strict'; + const maxInlineCallCount = 10; function browserQueueMicrotaskImpl(global) { diff --git a/src/core/Clock.js b/src/core/Clock.js index 4956fcac..dd018113 100644 --- a/src/core/Clock.js +++ b/src/core/Clock.js @@ -1,4 +1,6 @@ getJasmineRequireObj().Clock = function() { + 'use strict'; + /* global process */ const NODE_JS = typeof process !== 'undefined' && diff --git a/src/core/CompleteOnFirstErrorSkipPolicy.js b/src/core/CompleteOnFirstErrorSkipPolicy.js index 1dcc4019..0d1bd9d0 100644 --- a/src/core/CompleteOnFirstErrorSkipPolicy.js +++ b/src/core/CompleteOnFirstErrorSkipPolicy.js @@ -1,4 +1,6 @@ getJasmineRequireObj().CompleteOnFirstErrorSkipPolicy = function(j$) { + 'use strict'; + function CompleteOnFirstErrorSkipPolicy(queueableFns) { this.queueableFns_ = queueableFns; this.erroredFnIx_ = null; diff --git a/src/core/Configuration.js b/src/core/Configuration.js index 1d3a509c..b2aceae5 100644 --- a/src/core/Configuration.js +++ b/src/core/Configuration.js @@ -1,4 +1,6 @@ getJasmineRequireObj().Configuration = function(j$) { + 'use strict'; + /** * This represents the available options to configure Jasmine. * Options that are not provided will use their default values. diff --git a/src/core/CurrentRunableTracker.js b/src/core/CurrentRunableTracker.js index b93fda3b..a66e1f59 100644 --- a/src/core/CurrentRunableTracker.js +++ b/src/core/CurrentRunableTracker.js @@ -1,4 +1,6 @@ getJasmineRequireObj().CurrentRunableTracker = function() { + 'use strict'; + class CurrentRunableTracker { #currentSpec; #currentlyExecutingSuites; diff --git a/src/core/Deprecator.js b/src/core/Deprecator.js index e4bff4e9..7686c70e 100644 --- a/src/core/Deprecator.js +++ b/src/core/Deprecator.js @@ -1,4 +1,6 @@ getJasmineRequireObj().Deprecator = function(j$) { + 'use strict'; + function Deprecator(topSuite) { this.topSuite_ = topSuite; this.verbose_ = false; diff --git a/src/core/Env.js b/src/core/Env.js index 3b189bf2..52eefbe7 100644 --- a/src/core/Env.js +++ b/src/core/Env.js @@ -1,4 +1,6 @@ getJasmineRequireObj().Env = function(j$) { + 'use strict'; + /** * @class Env * @since 2.0.0 diff --git a/src/core/ExceptionFormatter.js b/src/core/ExceptionFormatter.js index cedc76e3..12d73645 100644 --- a/src/core/ExceptionFormatter.js +++ b/src/core/ExceptionFormatter.js @@ -1,4 +1,6 @@ getJasmineRequireObj().ExceptionFormatter = function(j$) { + 'use strict'; + const ignoredProperties = [ 'name', 'message', diff --git a/src/core/Expectation.js b/src/core/Expectation.js index 00360404..4703ec6d 100644 --- a/src/core/Expectation.js +++ b/src/core/Expectation.js @@ -1,4 +1,6 @@ getJasmineRequireObj().Expectation = function(j$) { + 'use strict'; + /** * Matchers that come with Jasmine out of the box. * @namespace matchers diff --git a/src/core/ExpectationFilterChain.js b/src/core/ExpectationFilterChain.js index 490d7d99..95f0d4fd 100644 --- a/src/core/ExpectationFilterChain.js +++ b/src/core/ExpectationFilterChain.js @@ -1,4 +1,6 @@ getJasmineRequireObj().ExpectationFilterChain = function() { + 'use strict'; + function ExpectationFilterChain(maybeFilter, prev) { this.filter_ = maybeFilter; this.prev_ = prev; diff --git a/src/core/Expector.js b/src/core/Expector.js index a5ddeabf..f833e2a1 100644 --- a/src/core/Expector.js +++ b/src/core/Expector.js @@ -1,4 +1,6 @@ getJasmineRequireObj().Expector = function(j$) { + 'use strict'; + function Expector(options) { this.matchersUtil = options.matchersUtil || { buildFailureMessage: function() {} diff --git a/src/core/GlobalErrors.js b/src/core/GlobalErrors.js index c489f72e..a10c9a2b 100644 --- a/src/core/GlobalErrors.js +++ b/src/core/GlobalErrors.js @@ -1,4 +1,6 @@ getJasmineRequireObj().GlobalErrors = function(j$) { + 'use strict'; + class GlobalErrors { #getConfig; #adapter; diff --git a/src/core/JsApiReporter.js b/src/core/JsApiReporter.js index 6ab524af..16c0d768 100644 --- a/src/core/JsApiReporter.js +++ b/src/core/JsApiReporter.js @@ -1,4 +1,6 @@ getJasmineRequireObj().JsApiReporter = function(j$) { + 'use strict'; + /** * @name jsApiReporter * @classdesc {@link Reporter} added by default in `boot.js` to record results for retrieval in javascript code. An instance is made available as `jsApiReporter` on the global object. diff --git a/src/core/MockDate.js b/src/core/MockDate.js index d73c8ba9..ba6e9ca8 100644 --- a/src/core/MockDate.js +++ b/src/core/MockDate.js @@ -1,4 +1,6 @@ getJasmineRequireObj().MockDate = function(j$) { + 'use strict'; + function MockDate(global) { let currentTime = 0; diff --git a/src/core/NeverSkipPolicy.js b/src/core/NeverSkipPolicy.js index 7d72cd50..8c76dff7 100644 --- a/src/core/NeverSkipPolicy.js +++ b/src/core/NeverSkipPolicy.js @@ -1,4 +1,6 @@ getJasmineRequireObj().NeverSkipPolicy = function(j$) { + 'use strict'; + function NeverSkipPolicy(queueableFns) {} NeverSkipPolicy.prototype.skipTo = function(lastRanFnIx) { diff --git a/src/core/Order.js b/src/core/Order.js index 3b9c27b5..dd97c7bd 100644 --- a/src/core/Order.js +++ b/src/core/Order.js @@ -1,4 +1,6 @@ getJasmineRequireObj().Order = function() { + 'use strict'; + function Order(options) { this.random = 'random' in options ? options.random : true; const seed = (this.seed = options.seed || generateSeed()); diff --git a/src/core/PrettyPrinter.js b/src/core/PrettyPrinter.js index 7ee38566..8c358680 100644 --- a/src/core/PrettyPrinter.js +++ b/src/core/PrettyPrinter.js @@ -1,4 +1,6 @@ getJasmineRequireObj().makePrettyPrinter = function(j$) { + 'use strict'; + class SinglePrettyPrintRun { constructor(customObjectFormatters, pp) { this.customObjectFormatters_ = customObjectFormatters; diff --git a/src/core/QueueRunner.js b/src/core/QueueRunner.js index 5dff3ee7..366ef5a1 100644 --- a/src/core/QueueRunner.js +++ b/src/core/QueueRunner.js @@ -1,4 +1,6 @@ getJasmineRequireObj().QueueRunner = function(j$) { + 'use strict'; + let nextid = 1; function StopExecutionError() {} diff --git a/src/core/RunableResources.js b/src/core/RunableResources.js index ae1ce6a8..eb14a86b 100644 --- a/src/core/RunableResources.js +++ b/src/core/RunableResources.js @@ -1,4 +1,6 @@ getJasmineRequireObj().RunableResources = function(j$) { + 'use strict'; + class RunableResources { constructor(options) { this.byRunableId_ = {}; diff --git a/src/core/Runner.js b/src/core/Runner.js index c2d4914d..d8bf1ba1 100644 --- a/src/core/Runner.js +++ b/src/core/Runner.js @@ -1,4 +1,6 @@ getJasmineRequireObj().Runner = function(j$) { + 'use strict'; + class Runner { #topSuite; #getTotalSpecsDefined; diff --git a/src/core/SkipAfterBeforeAllErrorPolicy.js b/src/core/SkipAfterBeforeAllErrorPolicy.js index 57d88127..c1b71a9d 100644 --- a/src/core/SkipAfterBeforeAllErrorPolicy.js +++ b/src/core/SkipAfterBeforeAllErrorPolicy.js @@ -1,4 +1,6 @@ getJasmineRequireObj().SkipAfterBeforeAllErrorPolicy = function(j$) { + 'use strict'; + function SkipAfterBeforeAllErrorPolicy(queueableFns) { this.queueableFns_ = queueableFns; this.skipping_ = false; diff --git a/src/core/Spec.js b/src/core/Spec.js index 2a284aab..e69d53a7 100644 --- a/src/core/Spec.js +++ b/src/core/Spec.js @@ -1,4 +1,6 @@ getJasmineRequireObj().Spec = function(j$) { + 'use strict'; + class Spec { #autoCleanClosures; #throwOnExpectationFailure; diff --git a/src/core/Spy.js b/src/core/Spy.js index 73d7c248..5e84d19b 100644 --- a/src/core/Spy.js +++ b/src/core/Spy.js @@ -1,4 +1,6 @@ getJasmineRequireObj().Spy = function(j$) { + 'use strict'; + const nextOrder = (function() { let order = 0; diff --git a/src/core/SpyFactory.js b/src/core/SpyFactory.js index 51f89400..26a768be 100644 --- a/src/core/SpyFactory.js +++ b/src/core/SpyFactory.js @@ -1,4 +1,6 @@ getJasmineRequireObj().SpyFactory = function(j$) { + 'use strict'; + function SpyFactory( getCustomStrategies, getDefaultStrategyFn, diff --git a/src/core/SpyStrategy.js b/src/core/SpyStrategy.js index b3f79bb5..483cfc51 100644 --- a/src/core/SpyStrategy.js +++ b/src/core/SpyStrategy.js @@ -1,4 +1,6 @@ getJasmineRequireObj().SpyStrategy = function(j$) { + 'use strict'; + /** * @interface SpyStrategy */ diff --git a/src/core/StackTrace.js b/src/core/StackTrace.js index dfefca6a..18efd720 100644 --- a/src/core/StackTrace.js +++ b/src/core/StackTrace.js @@ -1,4 +1,6 @@ getJasmineRequireObj().StackTrace = function(j$) { + 'use strict'; + function StackTrace(error) { let lines = error.stack.split('\n'); diff --git a/src/core/Suite.js b/src/core/Suite.js index 1ca477d1..6314e12c 100644 --- a/src/core/Suite.js +++ b/src/core/Suite.js @@ -1,4 +1,6 @@ getJasmineRequireObj().Suite = function(j$) { + 'use strict'; + class Suite { #reportedParentSuiteId; #throwOnExpectationFailure; diff --git a/src/core/SuiteBuilder.js b/src/core/SuiteBuilder.js index d3738969..f809d841 100644 --- a/src/core/SuiteBuilder.js +++ b/src/core/SuiteBuilder.js @@ -1,4 +1,6 @@ getJasmineRequireObj().SuiteBuilder = function(j$) { + 'use strict'; + class SuiteBuilder { constructor(options) { this.env_ = options.env; diff --git a/src/core/Timer.js b/src/core/Timer.js index 098345b3..a65064ba 100644 --- a/src/core/Timer.js +++ b/src/core/Timer.js @@ -1,4 +1,6 @@ getJasmineRequireObj().Timer = function() { + 'use strict'; + const defaultNow = (function(Date) { return function() { return new Date().getTime(); diff --git a/src/core/TreeProcessor.js b/src/core/TreeProcessor.js index 72f7bfec..aebdeafa 100644 --- a/src/core/TreeProcessor.js +++ b/src/core/TreeProcessor.js @@ -1,4 +1,6 @@ getJasmineRequireObj().TreeProcessor = function(j$) { + 'use strict'; + const defaultMin = Infinity; const defaultMax = 1 - Infinity; diff --git a/src/core/TreeRunner.js b/src/core/TreeRunner.js index 8710b9a5..d30ab517 100644 --- a/src/core/TreeRunner.js +++ b/src/core/TreeRunner.js @@ -1,4 +1,6 @@ getJasmineRequireObj().TreeRunner = function(j$) { + 'use strict'; + class TreeRunner { #executionTree; #setTimeout; diff --git a/src/core/UserContext.js b/src/core/UserContext.js index d9b60b0a..ae7978e8 100644 --- a/src/core/UserContext.js +++ b/src/core/UserContext.js @@ -1,4 +1,6 @@ getJasmineRequireObj().UserContext = function(j$) { + 'use strict'; + function UserContext() {} UserContext.fromExisting = function(oldContext) { diff --git a/src/core/asymmetric_equality/Any.js b/src/core/asymmetric_equality/Any.js index ee634e9e..62d4210f 100644 --- a/src/core/asymmetric_equality/Any.js +++ b/src/core/asymmetric_equality/Any.js @@ -1,4 +1,6 @@ getJasmineRequireObj().Any = function(j$) { + 'use strict'; + function Any(expectedObject) { if (typeof expectedObject === 'undefined') { throw new TypeError( diff --git a/src/core/asymmetric_equality/Anything.js b/src/core/asymmetric_equality/Anything.js index b22189b5..caca5af6 100644 --- a/src/core/asymmetric_equality/Anything.js +++ b/src/core/asymmetric_equality/Anything.js @@ -1,4 +1,6 @@ getJasmineRequireObj().Anything = function(j$) { + 'use strict'; + function Anything() {} Anything.prototype.asymmetricMatch = function(other) { diff --git a/src/core/asymmetric_equality/ArrayContaining.js b/src/core/asymmetric_equality/ArrayContaining.js index c22046ef..7560df19 100644 --- a/src/core/asymmetric_equality/ArrayContaining.js +++ b/src/core/asymmetric_equality/ArrayContaining.js @@ -1,4 +1,6 @@ getJasmineRequireObj().ArrayContaining = function(j$) { + 'use strict'; + function ArrayContaining(sample) { this.sample = sample; } diff --git a/src/core/asymmetric_equality/ArrayWithExactContents.js b/src/core/asymmetric_equality/ArrayWithExactContents.js index c49f92d3..2d5f5172 100644 --- a/src/core/asymmetric_equality/ArrayWithExactContents.js +++ b/src/core/asymmetric_equality/ArrayWithExactContents.js @@ -1,4 +1,6 @@ getJasmineRequireObj().ArrayWithExactContents = function(j$) { + 'use strict'; + function ArrayWithExactContents(sample) { this.sample = sample; } diff --git a/src/core/asymmetric_equality/Empty.js b/src/core/asymmetric_equality/Empty.js index 7bc3d52e..097238ad 100644 --- a/src/core/asymmetric_equality/Empty.js +++ b/src/core/asymmetric_equality/Empty.js @@ -1,4 +1,6 @@ getJasmineRequireObj().Empty = function(j$) { + 'use strict'; + function Empty() {} Empty.prototype.asymmetricMatch = function(other) { diff --git a/src/core/asymmetric_equality/Falsy.js b/src/core/asymmetric_equality/Falsy.js index d1d3c8ff..5f28722e 100644 --- a/src/core/asymmetric_equality/Falsy.js +++ b/src/core/asymmetric_equality/Falsy.js @@ -1,4 +1,6 @@ getJasmineRequireObj().Falsy = function(j$) { + 'use strict'; + function Falsy() {} Falsy.prototype.asymmetricMatch = function(other) { diff --git a/src/core/asymmetric_equality/Is.js b/src/core/asymmetric_equality/Is.js index 0152967c..67150877 100644 --- a/src/core/asymmetric_equality/Is.js +++ b/src/core/asymmetric_equality/Is.js @@ -1,4 +1,6 @@ getJasmineRequireObj().Is = function(j$) { + 'use strict'; + class Is { constructor(expected) { this.expected_ = expected; diff --git a/src/core/asymmetric_equality/MapContaining.js b/src/core/asymmetric_equality/MapContaining.js index 4afe50d6..e3a68131 100644 --- a/src/core/asymmetric_equality/MapContaining.js +++ b/src/core/asymmetric_equality/MapContaining.js @@ -1,4 +1,6 @@ getJasmineRequireObj().MapContaining = function(j$) { + 'use strict'; + function MapContaining(sample) { if (!j$.private.isMap(sample)) { throw new Error( diff --git a/src/core/asymmetric_equality/NotEmpty.js b/src/core/asymmetric_equality/NotEmpty.js index 4a13fe81..088a053f 100644 --- a/src/core/asymmetric_equality/NotEmpty.js +++ b/src/core/asymmetric_equality/NotEmpty.js @@ -1,4 +1,6 @@ getJasmineRequireObj().NotEmpty = function(j$) { + 'use strict'; + function NotEmpty() {} NotEmpty.prototype.asymmetricMatch = function(other) { diff --git a/src/core/asymmetric_equality/ObjectContaining.js b/src/core/asymmetric_equality/ObjectContaining.js index 77b48428..8b775050 100644 --- a/src/core/asymmetric_equality/ObjectContaining.js +++ b/src/core/asymmetric_equality/ObjectContaining.js @@ -1,4 +1,6 @@ getJasmineRequireObj().ObjectContaining = function(j$) { + 'use strict'; + function ObjectContaining(sample) { this.sample = sample; } diff --git a/src/core/asymmetric_equality/SetContaining.js b/src/core/asymmetric_equality/SetContaining.js index cf373fd9..a42215a1 100644 --- a/src/core/asymmetric_equality/SetContaining.js +++ b/src/core/asymmetric_equality/SetContaining.js @@ -1,4 +1,6 @@ getJasmineRequireObj().SetContaining = function(j$) { + 'use strict'; + function SetContaining(sample) { if (!j$.private.isSet(sample)) { throw new Error( diff --git a/src/core/asymmetric_equality/StringContaining.js b/src/core/asymmetric_equality/StringContaining.js index b0e899f2..98302048 100644 --- a/src/core/asymmetric_equality/StringContaining.js +++ b/src/core/asymmetric_equality/StringContaining.js @@ -1,4 +1,6 @@ getJasmineRequireObj().StringContaining = function(j$) { + 'use strict'; + function StringContaining(expected) { if (!j$.private.isString(expected)) { throw new Error('Expected is not a String'); diff --git a/src/core/asymmetric_equality/StringMatching.js b/src/core/asymmetric_equality/StringMatching.js index 89b627cd..44cebaf1 100644 --- a/src/core/asymmetric_equality/StringMatching.js +++ b/src/core/asymmetric_equality/StringMatching.js @@ -1,4 +1,6 @@ getJasmineRequireObj().StringMatching = function(j$) { + 'use strict'; + function StringMatching(expected) { if (!j$.private.isString(expected) && !j$.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 9e527164..5e17caa7 100644 --- a/src/core/asymmetric_equality/Truthy.js +++ b/src/core/asymmetric_equality/Truthy.js @@ -1,4 +1,6 @@ getJasmineRequireObj().Truthy = function(j$) { + 'use strict'; + function Truthy() {} Truthy.prototype.asymmetricMatch = function(other) { diff --git a/src/core/base.js b/src/core/base.js index c5ac348d..0fbad676 100644 --- a/src/core/base.js +++ b/src/core/base.js @@ -1,4 +1,6 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) { + 'use strict'; + /** * Maximum object depth the pretty printer will print to. * Set this to a lower value to speed up pretty printing if you have large objects. diff --git a/src/core/buildExpectationResult.js b/src/core/buildExpectationResult.js index 442a5b25..7a052878 100644 --- a/src/core/buildExpectationResult.js +++ b/src/core/buildExpectationResult.js @@ -1,5 +1,7 @@ //TODO: expectation result may make more sense as a presentation of an expectation. getJasmineRequireObj().buildExpectationResult = function(j$) { + 'use strict'; + function buildExpectationResult(options) { const exceptionFormatter = new j$.private.ExceptionFormatter(); diff --git a/src/core/errors.js b/src/core/errors.js index ba7a502d..57032108 100644 --- a/src/core/errors.js +++ b/src/core/errors.js @@ -1,4 +1,6 @@ getJasmineRequireObj().errors = function() { + 'use strict'; + function ExpectationFailed() {} ExpectationFailed.prototype = new Error(); diff --git a/src/core/formatErrorMsg.js b/src/core/formatErrorMsg.js index 8e7f1f03..5eeaa48f 100644 --- a/src/core/formatErrorMsg.js +++ b/src/core/formatErrorMsg.js @@ -1,4 +1,6 @@ getJasmineRequireObj().formatErrorMsg = function() { + 'use strict'; + function generateErrorMsg(domain, usage) { const usageDefinition = usage ? '\nUsage: ' + usage : ''; diff --git a/src/core/matchers/DiffBuilder.js b/src/core/matchers/DiffBuilder.js index 489f12c9..d06bf7e2 100644 --- a/src/core/matchers/DiffBuilder.js +++ b/src/core/matchers/DiffBuilder.js @@ -1,4 +1,6 @@ getJasmineRequireObj().DiffBuilder = function(j$) { + 'use strict'; + class DiffBuilder { constructor(config) { this.prettyPrinter_ = diff --git a/src/core/matchers/MismatchTree.js b/src/core/matchers/MismatchTree.js index 504fc600..5d4da678 100644 --- a/src/core/matchers/MismatchTree.js +++ b/src/core/matchers/MismatchTree.js @@ -1,4 +1,6 @@ getJasmineRequireObj().MismatchTree = function(j$) { + 'use strict'; + /* To be able to apply custom object formatters at all possible levels of an object graph, DiffBuilder needs to be able to know not just where the diff --git a/src/core/matchers/NullDiffBuilder.js b/src/core/matchers/NullDiffBuilder.js index cb6672e4..43d8362e 100644 --- a/src/core/matchers/NullDiffBuilder.js +++ b/src/core/matchers/NullDiffBuilder.js @@ -1,4 +1,6 @@ getJasmineRequireObj().NullDiffBuilder = function(j$) { + 'use strict'; + return function() { return { withPath: function(_, block) { diff --git a/src/core/matchers/ObjectPath.js b/src/core/matchers/ObjectPath.js index e87e17de..7493d79d 100644 --- a/src/core/matchers/ObjectPath.js +++ b/src/core/matchers/ObjectPath.js @@ -1,4 +1,6 @@ getJasmineRequireObj().ObjectPath = function(j$) { + 'use strict'; + class ObjectPath { constructor(components) { this.components = components || []; diff --git a/src/core/matchers/async/toBePending.js b/src/core/matchers/async/toBePending.js index bd5549f6..06ec4a8c 100644 --- a/src/core/matchers/async/toBePending.js +++ b/src/core/matchers/async/toBePending.js @@ -1,4 +1,6 @@ getJasmineRequireObj().toBePending = function(j$) { + 'use strict'; + /** * Expect a promise to be pending, i.e. the promise is neither resolved nor rejected. * @function diff --git a/src/core/matchers/async/toBeRejected.js b/src/core/matchers/async/toBeRejected.js index 57e6d71b..84f83b96 100644 --- a/src/core/matchers/async/toBeRejected.js +++ b/src/core/matchers/async/toBeRejected.js @@ -1,4 +1,6 @@ getJasmineRequireObj().toBeRejected = function(j$) { + 'use strict'; + /** * Expect a promise to be rejected. * @function diff --git a/src/core/matchers/async/toBeRejectedWith.js b/src/core/matchers/async/toBeRejectedWith.js index d640c901..61cce961 100644 --- a/src/core/matchers/async/toBeRejectedWith.js +++ b/src/core/matchers/async/toBeRejectedWith.js @@ -1,4 +1,6 @@ getJasmineRequireObj().toBeRejectedWith = function(j$) { + 'use strict'; + /** * Expect a promise to be rejected with a value equal to the expected, using deep equality comparison. * @function diff --git a/src/core/matchers/async/toBeRejectedWithError.js b/src/core/matchers/async/toBeRejectedWithError.js index 1ef90713..24bd5391 100644 --- a/src/core/matchers/async/toBeRejectedWithError.js +++ b/src/core/matchers/async/toBeRejectedWithError.js @@ -1,4 +1,6 @@ getJasmineRequireObj().toBeRejectedWithError = function(j$) { + 'use strict'; + /** * Expect a promise to be rejected with a value matched to the expected * @function diff --git a/src/core/matchers/async/toBeResolved.js b/src/core/matchers/async/toBeResolved.js index 1bfb7476..c9ff0c04 100644 --- a/src/core/matchers/async/toBeResolved.js +++ b/src/core/matchers/async/toBeResolved.js @@ -1,4 +1,6 @@ getJasmineRequireObj().toBeResolved = function(j$) { + 'use strict'; + /** * Expect a promise to be resolved. * @function diff --git a/src/core/matchers/async/toBeResolvedTo.js b/src/core/matchers/async/toBeResolvedTo.js index 21426b82..59e7a01f 100644 --- a/src/core/matchers/async/toBeResolvedTo.js +++ b/src/core/matchers/async/toBeResolvedTo.js @@ -1,4 +1,6 @@ getJasmineRequireObj().toBeResolvedTo = function(j$) { + 'use strict'; + /** * Expect a promise to be resolved to a value equal to the expected, using deep equality comparison. * @function diff --git a/src/core/matchers/matchersUtil.js b/src/core/matchers/matchersUtil.js index d6054aa9..a3b97768 100644 --- a/src/core/matchers/matchersUtil.js +++ b/src/core/matchers/matchersUtil.js @@ -1,4 +1,6 @@ getJasmineRequireObj().MatchersUtil = function(j$) { + 'use strict'; + /** * @class MatchersUtil * @classdesc Utilities for use in implementing matchers.
diff --git a/src/core/matchers/nothing.js b/src/core/matchers/nothing.js index 687cec28..42e5f2d5 100644 --- a/src/core/matchers/nothing.js +++ b/src/core/matchers/nothing.js @@ -1,4 +1,6 @@ getJasmineRequireObj().nothing = function() { + 'use strict'; + /** * {@link expect} nothing explicitly. * @function diff --git a/src/core/matchers/requireAsyncMatchers.js b/src/core/matchers/requireAsyncMatchers.js index cb8cf5b2..b24717db 100644 --- a/src/core/matchers/requireAsyncMatchers.js +++ b/src/core/matchers/requireAsyncMatchers.js @@ -1,4 +1,6 @@ getJasmineRequireObj().requireAsyncMatchers = function(jRequire, j$) { + 'use strict'; + const availableMatchers = [ 'toBePending', 'toBeResolved', diff --git a/src/core/matchers/requireMatchers.js b/src/core/matchers/requireMatchers.js index 5eb64617..d0567a1e 100755 --- a/src/core/matchers/requireMatchers.js +++ b/src/core/matchers/requireMatchers.js @@ -1,4 +1,6 @@ getJasmineRequireObj().requireMatchers = function(jRequire, j$) { + 'use strict'; + const availableMatchers = [ 'nothing', 'toBe', diff --git a/src/core/matchers/toBe.js b/src/core/matchers/toBe.js index 8b795380..bd997ff1 100644 --- a/src/core/matchers/toBe.js +++ b/src/core/matchers/toBe.js @@ -1,4 +1,6 @@ getJasmineRequireObj().toBe = function(j$) { + 'use strict'; + /** * {@link expect} the actual value to be `===` to the expected value. * @function diff --git a/src/core/matchers/toBeCloseTo.js b/src/core/matchers/toBeCloseTo.js index edab5522..c5a66ab0 100644 --- a/src/core/matchers/toBeCloseTo.js +++ b/src/core/matchers/toBeCloseTo.js @@ -1,4 +1,6 @@ getJasmineRequireObj().toBeCloseTo = function() { + 'use strict'; + /** * {@link expect} the actual value to be within a specified precision of the expected value. * @function diff --git a/src/core/matchers/toBeDefined.js b/src/core/matchers/toBeDefined.js index 0c43f7d2..f8274096 100644 --- a/src/core/matchers/toBeDefined.js +++ b/src/core/matchers/toBeDefined.js @@ -1,4 +1,6 @@ getJasmineRequireObj().toBeDefined = function() { + 'use strict'; + /** * {@link expect} the actual value to be defined. (Not `undefined`) * @function diff --git a/src/core/matchers/toBeFalse.js b/src/core/matchers/toBeFalse.js index e26fb834..5c14535e 100644 --- a/src/core/matchers/toBeFalse.js +++ b/src/core/matchers/toBeFalse.js @@ -1,4 +1,6 @@ getJasmineRequireObj().toBeFalse = function() { + 'use strict'; + /** * {@link expect} the actual value to be `false`. * @function diff --git a/src/core/matchers/toBeFalsy.js b/src/core/matchers/toBeFalsy.js index db61d465..a5527b5c 100644 --- a/src/core/matchers/toBeFalsy.js +++ b/src/core/matchers/toBeFalsy.js @@ -1,4 +1,6 @@ getJasmineRequireObj().toBeFalsy = function() { + 'use strict'; + /** * {@link expect} the actual value to be falsy * @function diff --git a/src/core/matchers/toBeGreaterThan.js b/src/core/matchers/toBeGreaterThan.js index 07dad333..fb06f325 100644 --- a/src/core/matchers/toBeGreaterThan.js +++ b/src/core/matchers/toBeGreaterThan.js @@ -1,4 +1,6 @@ getJasmineRequireObj().toBeGreaterThan = function() { + 'use strict'; + /** * {@link expect} the actual value to be greater than the expected value. * @function diff --git a/src/core/matchers/toBeGreaterThanOrEqual.js b/src/core/matchers/toBeGreaterThanOrEqual.js index 1f33b5e6..27de49cc 100644 --- a/src/core/matchers/toBeGreaterThanOrEqual.js +++ b/src/core/matchers/toBeGreaterThanOrEqual.js @@ -1,4 +1,6 @@ getJasmineRequireObj().toBeGreaterThanOrEqual = function() { + 'use strict'; + /** * {@link expect} the actual value to be greater than or equal to the expected value. * @function diff --git a/src/core/matchers/toBeInstanceOf.js b/src/core/matchers/toBeInstanceOf.js index a58cb32c..d759bca9 100644 --- a/src/core/matchers/toBeInstanceOf.js +++ b/src/core/matchers/toBeInstanceOf.js @@ -1,4 +1,6 @@ getJasmineRequireObj().toBeInstanceOf = function(j$) { + 'use strict'; + const usageError = j$.private.formatErrorMsg( '', 'expect(value).toBeInstanceOf()' diff --git a/src/core/matchers/toBeLessThan.js b/src/core/matchers/toBeLessThan.js index 162e52f1..a65eba82 100644 --- a/src/core/matchers/toBeLessThan.js +++ b/src/core/matchers/toBeLessThan.js @@ -1,4 +1,6 @@ getJasmineRequireObj().toBeLessThan = function() { + 'use strict'; + /** * {@link expect} the actual value to be less than the expected value. * @function diff --git a/src/core/matchers/toBeLessThanOrEqual.js b/src/core/matchers/toBeLessThanOrEqual.js index f2d47b69..67db8696 100644 --- a/src/core/matchers/toBeLessThanOrEqual.js +++ b/src/core/matchers/toBeLessThanOrEqual.js @@ -1,4 +1,6 @@ getJasmineRequireObj().toBeLessThanOrEqual = function() { + 'use strict'; + /** * {@link expect} the actual value to be less than or equal to the expected value. * @function diff --git a/src/core/matchers/toBeNaN.js b/src/core/matchers/toBeNaN.js index b17a5b5e..6140b50e 100644 --- a/src/core/matchers/toBeNaN.js +++ b/src/core/matchers/toBeNaN.js @@ -1,4 +1,6 @@ getJasmineRequireObj().toBeNaN = function(j$) { + 'use strict'; + /** * {@link expect} the actual value to be `NaN` (Not a Number). * @function diff --git a/src/core/matchers/toBeNegativeInfinity.js b/src/core/matchers/toBeNegativeInfinity.js index 36caee9a..ca306812 100644 --- a/src/core/matchers/toBeNegativeInfinity.js +++ b/src/core/matchers/toBeNegativeInfinity.js @@ -1,4 +1,6 @@ getJasmineRequireObj().toBeNegativeInfinity = function(j$) { + 'use strict'; + /** * {@link expect} the actual value to be `-Infinity` (-infinity). * @function diff --git a/src/core/matchers/toBeNull.js b/src/core/matchers/toBeNull.js index 36b06133..5fecf6d9 100644 --- a/src/core/matchers/toBeNull.js +++ b/src/core/matchers/toBeNull.js @@ -1,4 +1,6 @@ getJasmineRequireObj().toBeNull = function() { + 'use strict'; + /** * {@link expect} the actual value to be `null`. * @function diff --git a/src/core/matchers/toBeNullish.js b/src/core/matchers/toBeNullish.js index c833d43f..d249286d 100644 --- a/src/core/matchers/toBeNullish.js +++ b/src/core/matchers/toBeNullish.js @@ -1,4 +1,6 @@ getJasmineRequireObj().toBeNullish = function() { + 'use strict'; + /** * {@link expect} the actual value to be `null` or `undefined`. * @function diff --git a/src/core/matchers/toBePositiveInfinity.js b/src/core/matchers/toBePositiveInfinity.js index d4541a37..4bb1988e 100644 --- a/src/core/matchers/toBePositiveInfinity.js +++ b/src/core/matchers/toBePositiveInfinity.js @@ -1,4 +1,6 @@ getJasmineRequireObj().toBePositiveInfinity = function(j$) { + 'use strict'; + /** * {@link expect} the actual value to be `Infinity` (infinity). * @function diff --git a/src/core/matchers/toBeTrue.js b/src/core/matchers/toBeTrue.js index 63331093..06b6313d 100644 --- a/src/core/matchers/toBeTrue.js +++ b/src/core/matchers/toBeTrue.js @@ -1,4 +1,6 @@ getJasmineRequireObj().toBeTrue = function() { + 'use strict'; + /** * {@link expect} the actual value to be `true`. * @function diff --git a/src/core/matchers/toBeTruthy.js b/src/core/matchers/toBeTruthy.js index 3bece851..73e08489 100644 --- a/src/core/matchers/toBeTruthy.js +++ b/src/core/matchers/toBeTruthy.js @@ -1,4 +1,6 @@ getJasmineRequireObj().toBeTruthy = function() { + 'use strict'; + /** * {@link expect} the actual value to be truthy. * @function diff --git a/src/core/matchers/toBeUndefined.js b/src/core/matchers/toBeUndefined.js index 04469364..3eed58a4 100644 --- a/src/core/matchers/toBeUndefined.js +++ b/src/core/matchers/toBeUndefined.js @@ -1,4 +1,6 @@ getJasmineRequireObj().toBeUndefined = function() { + 'use strict'; + /** * {@link expect} the actual value to be `undefined`. * @function diff --git a/src/core/matchers/toContain.js b/src/core/matchers/toContain.js index 9ab30154..36c60e6c 100644 --- a/src/core/matchers/toContain.js +++ b/src/core/matchers/toContain.js @@ -1,4 +1,6 @@ getJasmineRequireObj().toContain = function() { + 'use strict'; + /** * {@link expect} the actual value to contain a specific value. * @function diff --git a/src/core/matchers/toEqual.js b/src/core/matchers/toEqual.js index 688c1dd1..9a8ad1c0 100644 --- a/src/core/matchers/toEqual.js +++ b/src/core/matchers/toEqual.js @@ -1,4 +1,6 @@ getJasmineRequireObj().toEqual = function(j$) { + 'use strict'; + /** * {@link expect} the actual value to be equal to the expected, using deep equality comparison. * @function diff --git a/src/core/matchers/toHaveBeenCalled.js b/src/core/matchers/toHaveBeenCalled.js index 4e836d4a..6da4c407 100644 --- a/src/core/matchers/toHaveBeenCalled.js +++ b/src/core/matchers/toHaveBeenCalled.js @@ -1,4 +1,6 @@ getJasmineRequireObj().toHaveBeenCalled = function(j$) { + 'use strict'; + const getErrorMsg = j$.private.formatErrorMsg( '', 'expect().toHaveBeenCalled()' diff --git a/src/core/matchers/toHaveBeenCalledBefore.js b/src/core/matchers/toHaveBeenCalledBefore.js index fb0b1496..8f95fc74 100644 --- a/src/core/matchers/toHaveBeenCalledBefore.js +++ b/src/core/matchers/toHaveBeenCalledBefore.js @@ -1,4 +1,6 @@ getJasmineRequireObj().toHaveBeenCalledBefore = function(j$) { + 'use strict'; + const getErrorMsg = j$.private.formatErrorMsg( '', 'expect().toHaveBeenCalledBefore()' diff --git a/src/core/matchers/toHaveBeenCalledOnceWith.js b/src/core/matchers/toHaveBeenCalledOnceWith.js index 91d8924c..1b241ab0 100644 --- a/src/core/matchers/toHaveBeenCalledOnceWith.js +++ b/src/core/matchers/toHaveBeenCalledOnceWith.js @@ -1,4 +1,6 @@ getJasmineRequireObj().toHaveBeenCalledOnceWith = function(j$) { + 'use strict'; + const getErrorMsg = j$.private.formatErrorMsg( '', 'expect().toHaveBeenCalledOnceWith(...arguments)' diff --git a/src/core/matchers/toHaveBeenCalledTimes.js b/src/core/matchers/toHaveBeenCalledTimes.js index 2bb8b02f..68023ac0 100644 --- a/src/core/matchers/toHaveBeenCalledTimes.js +++ b/src/core/matchers/toHaveBeenCalledTimes.js @@ -1,4 +1,6 @@ getJasmineRequireObj().toHaveBeenCalledTimes = function(j$) { + 'use strict'; + const getErrorMsg = j$.private.formatErrorMsg( '', 'expect().toHaveBeenCalledTimes()' diff --git a/src/core/matchers/toHaveBeenCalledWith.js b/src/core/matchers/toHaveBeenCalledWith.js index 666b504a..ebdc8492 100644 --- a/src/core/matchers/toHaveBeenCalledWith.js +++ b/src/core/matchers/toHaveBeenCalledWith.js @@ -1,4 +1,6 @@ getJasmineRequireObj().toHaveBeenCalledWith = function(j$) { + 'use strict'; + const getErrorMsg = j$.private.formatErrorMsg( '', 'expect().toHaveBeenCalledWith(...arguments)' diff --git a/src/core/matchers/toHaveClass.js b/src/core/matchers/toHaveClass.js index 7d497868..63591a6e 100644 --- a/src/core/matchers/toHaveClass.js +++ b/src/core/matchers/toHaveClass.js @@ -1,4 +1,6 @@ getJasmineRequireObj().toHaveClass = function(j$) { + 'use strict'; + /** * {@link expect} the actual value to be a DOM element that has the expected class * @function diff --git a/src/core/matchers/toHaveClasses.js b/src/core/matchers/toHaveClasses.js index 39a840d0..145ec29d 100644 --- a/src/core/matchers/toHaveClasses.js +++ b/src/core/matchers/toHaveClasses.js @@ -1,4 +1,6 @@ getJasmineRequireObj().toHaveClasses = function(j$) { + 'use strict'; + /** * {@link expect} the actual value to be a DOM element that has the expected classes * @function diff --git a/src/core/matchers/toHaveNoOtherSpyInteractions.js b/src/core/matchers/toHaveNoOtherSpyInteractions.js index 1457476c..a358828a 100644 --- a/src/core/matchers/toHaveNoOtherSpyInteractions.js +++ b/src/core/matchers/toHaveNoOtherSpyInteractions.js @@ -1,4 +1,6 @@ getJasmineRequireObj().toHaveNoOtherSpyInteractions = function(j$) { + 'use strict'; + const getErrorMsg = j$.private.formatErrorMsg( '', 'expect().toHaveNoOtherSpyInteractions()' diff --git a/src/core/matchers/toHaveSize.js b/src/core/matchers/toHaveSize.js index d215d703..d393a2e4 100644 --- a/src/core/matchers/toHaveSize.js +++ b/src/core/matchers/toHaveSize.js @@ -1,4 +1,6 @@ getJasmineRequireObj().toHaveSize = function(j$) { + 'use strict'; + /** * {@link expect} the actual size to be equal to the expected, using array-like length or object keys size. * @function diff --git a/src/core/matchers/toHaveSpyInteractions.js b/src/core/matchers/toHaveSpyInteractions.js index b71baff5..9851200d 100755 --- a/src/core/matchers/toHaveSpyInteractions.js +++ b/src/core/matchers/toHaveSpyInteractions.js @@ -1,4 +1,6 @@ getJasmineRequireObj().toHaveSpyInteractions = function(j$) { + 'use strict'; + const getErrorMsg = j$.private.formatErrorMsg( '', 'expect().toHaveSpyInteractions()' diff --git a/src/core/matchers/toMatch.js b/src/core/matchers/toMatch.js index 1475d930..dd07f713 100644 --- a/src/core/matchers/toMatch.js +++ b/src/core/matchers/toMatch.js @@ -1,4 +1,6 @@ getJasmineRequireObj().toMatch = function(j$) { + 'use strict'; + const getErrorMsg = j$.private.formatErrorMsg( '', 'expect().toMatch( || )' diff --git a/src/core/matchers/toThrow.js b/src/core/matchers/toThrow.js index db230097..00c6415c 100644 --- a/src/core/matchers/toThrow.js +++ b/src/core/matchers/toThrow.js @@ -1,4 +1,6 @@ getJasmineRequireObj().toThrow = function(j$) { + 'use strict'; + const getErrorMsg = j$.private.formatErrorMsg( '', 'expect(function() {}).toThrow()' diff --git a/src/core/matchers/toThrowError.js b/src/core/matchers/toThrowError.js index 46554220..7fb729b6 100644 --- a/src/core/matchers/toThrowError.js +++ b/src/core/matchers/toThrowError.js @@ -1,4 +1,6 @@ getJasmineRequireObj().toThrowError = function(j$) { + 'use strict'; + const getErrorMsg = j$.private.formatErrorMsg( '', 'expect(function() {}).toThrowError(, )' diff --git a/src/core/matchers/toThrowMatching.js b/src/core/matchers/toThrowMatching.js index 508fa226..d684ab36 100644 --- a/src/core/matchers/toThrowMatching.js +++ b/src/core/matchers/toThrowMatching.js @@ -1,4 +1,6 @@ getJasmineRequireObj().toThrowMatching = function(j$) { + 'use strict'; + const usageError = j$.private.formatErrorMsg( '', 'expect(function() {}).toThrowMatching()' diff --git a/src/core/reporterEvents.js b/src/core/reporterEvents.js index e215c324..633b1c4f 100644 --- a/src/core/reporterEvents.js +++ b/src/core/reporterEvents.js @@ -1,4 +1,6 @@ getJasmineRequireObj().reporterEvents = function(j$) { + 'use strict'; + /** * Used to tell Jasmine what optional or uncommonly implemented features * the reporter supports. If not specified, the defaults described in diff --git a/src/core/requireCore.js b/src/core/requireCore.js index 63925f61..3eb5f03f 100644 --- a/src/core/requireCore.js +++ b/src/core/requireCore.js @@ -1,5 +1,6 @@ // eslint-disable-next-line no-unused-vars,no-var var getJasmineRequireObj = (function(jasmineGlobal) { + 'use strict'; let jasmineRequire; if ( diff --git a/src/core/requireInterface.js b/src/core/requireInterface.js index 45f0f721..bcdb7fe0 100644 --- a/src/core/requireInterface.js +++ b/src/core/requireInterface.js @@ -1,4 +1,6 @@ getJasmineRequireObj().interface = function(jasmine, env) { + 'use strict'; + const jasmineInterface = { /** * Callback passed to parts of the Jasmine base interface. diff --git a/src/core/util.js b/src/core/util.js index 52ef4a74..a39defae 100644 --- a/src/core/util.js +++ b/src/core/util.js @@ -1,4 +1,6 @@ getJasmineRequireObj().util = function(j$) { + 'use strict'; + const util = {}; util.clone = function(obj) { diff --git a/src/html/HtmlExactSpecFilter.js b/src/html/HtmlExactSpecFilter.js index a027648c..6a18d83a 100644 --- a/src/html/HtmlExactSpecFilter.js +++ b/src/html/HtmlExactSpecFilter.js @@ -1,4 +1,6 @@ jasmineRequire.HtmlExactSpecFilter = function() { + 'use strict'; + /** * Spec filter for use with {@link HtmlReporter} * diff --git a/src/html/HtmlReporter.js b/src/html/HtmlReporter.js index 33a2f165..b063fa5d 100644 --- a/src/html/HtmlReporter.js +++ b/src/html/HtmlReporter.js @@ -1,4 +1,6 @@ jasmineRequire.HtmlReporter = function(j$) { + 'use strict'; + function ResultsStateBuilder() { this.topResults = new j$.private.ResultsNode({}, '', null); this.currentParent = this.topResults; diff --git a/src/html/HtmlSpecFilter.js b/src/html/HtmlSpecFilter.js index 187b20f2..9217eee9 100644 --- a/src/html/HtmlSpecFilter.js +++ b/src/html/HtmlSpecFilter.js @@ -1,4 +1,6 @@ jasmineRequire.HtmlSpecFilter = function() { + 'use strict'; + /** * @name HtmlSpecFilter * @classdesc Legacy HTML spec filter, for backward compatibility diff --git a/src/html/QueryString.js b/src/html/QueryString.js index f82a4dd0..9e380f54 100644 --- a/src/html/QueryString.js +++ b/src/html/QueryString.js @@ -1,4 +1,6 @@ jasmineRequire.QueryString = function() { + 'use strict'; + /** * Reads and manipulates the query string. * @since 2.0.0 diff --git a/src/html/ResultsNode.js b/src/html/ResultsNode.js index bc3e0b4c..d9331a40 100644 --- a/src/html/ResultsNode.js +++ b/src/html/ResultsNode.js @@ -1,4 +1,6 @@ jasmineRequire.ResultsNode = function() { + 'use strict'; + function ResultsNode(result, type, parent) { this.result = result; this.type = type; From c4abf3265d3368d653d29846d90831d50d79acdb Mon Sep 17 00:00:00 2001 From: Steve Gravrock Date: Sun, 5 Oct 2025 06:59:05 -0700 Subject: [PATCH 45/95] Use globalThis to determine the global object during initialization This slightly simplifies the init code and hardens Jasmine against broken bundlers that assume everything can be wrapped in a "use strict" context. This removes a workaround for incompatible `this` behavior in GJS. GJS was never a supported envronment, but in any case the change is unlikely to cause problems since GJS ha supported globalThis since 2020. --- lib/jasmine-core/jasmine.js | 16 +++------------- src/core/requireCore.js | 16 +++------------- 2 files changed, 6 insertions(+), 26 deletions(-) diff --git a/lib/jasmine-core/jasmine.js b/lib/jasmine-core/jasmine.js index 5220ab23..e6b932ef 100644 --- a/lib/jasmine-core/jasmine.js +++ b/lib/jasmine-core/jasmine.js @@ -32,20 +32,10 @@ var getJasmineRequireObj = (function(jasmineGlobal) { module.exports && typeof exports !== 'undefined' ) { - if (typeof global !== 'undefined') { - jasmineGlobal = global; - } else { - jasmineGlobal = {}; - } + // Node jasmineRequire = exports; } else { - if ( - typeof window !== 'undefined' && - typeof window.toString === 'function' && - window.toString() === '[object GjsGlobal]' - ) { - jasmineGlobal = window; - } + // Browser jasmineRequire = jasmineGlobal.jasmineRequire = {}; } @@ -56,7 +46,7 @@ var getJasmineRequireObj = (function(jasmineGlobal) { getJasmineRequire().core = function(jRequire) { const j$ = { private: {} }; - jRequire.base(j$, jasmineGlobal); + jRequire.base(j$, globalThis); j$.private.util = jRequire.util(j$); j$.private.errors = jRequire.errors(); j$.private.formatErrorMsg = jRequire.formatErrorMsg(j$); diff --git a/src/core/requireCore.js b/src/core/requireCore.js index 3eb5f03f..4fbe9abd 100644 --- a/src/core/requireCore.js +++ b/src/core/requireCore.js @@ -8,20 +8,10 @@ var getJasmineRequireObj = (function(jasmineGlobal) { module.exports && typeof exports !== 'undefined' ) { - if (typeof global !== 'undefined') { - jasmineGlobal = global; - } else { - jasmineGlobal = {}; - } + // Node jasmineRequire = exports; } else { - if ( - typeof window !== 'undefined' && - typeof window.toString === 'function' && - window.toString() === '[object GjsGlobal]' - ) { - jasmineGlobal = window; - } + // Browser jasmineRequire = jasmineGlobal.jasmineRequire = {}; } @@ -32,7 +22,7 @@ var getJasmineRequireObj = (function(jasmineGlobal) { getJasmineRequire().core = function(jRequire) { const j$ = { private: {} }; - jRequire.base(j$, jasmineGlobal); + jRequire.base(j$, globalThis); j$.private.util = jRequire.util(j$); j$.private.errors = jRequire.errors(); j$.private.formatErrorMsg = jRequire.formatErrorMsg(j$); From 67ef721c8539862b1450db68710270e61ad173c5 Mon Sep 17 00:00:00 2001 From: Steve Gravrock Date: Sun, 5 Oct 2025 08:42:31 -0700 Subject: [PATCH 46/95] Fix startup crash in Karma The previous commit left one code path un-converted to globalThis. That exposed a bug in Karma: Karma loads jasmine-core via