Compare commits

..

3 Commits

Author SHA1 Message Date
Steve Gravrock 6e52b971cd Merge branch 'fix-issue-1781' of github.com:Tyoneb/jasmine
* Adds toBeRejectedWithMatching async matcher
* Merges #2097 from @Tyoneb
* Fixes #1781
2026-02-28 10:33:33 -08:00
Benoit CHOMEL 0a5acd99cb feat: Add new toBeRejectedWithMatching async matcher
Addresses #1781
2026-02-26 00:01:45 +01:00
Steve Gravrock f7132d98cd Copy 7.0.0-pre.0 release notes from branch 2026-02-22 14:24:50 -08:00
150 changed files with 4786 additions and 1637 deletions
+6 -4
View File
@@ -41,11 +41,13 @@ Jasmine tests itself. The files in `lib` are loaded first, defining the referenc
The tests should always use `jasmineUnderTest` to refer to the objects and functions that are being tested. But the tests can use functions on `jasmine` as needed. _Be careful how you structure any new test code_. Copy the patterns you see in the existing code - this ensures that the code you're testing is not leaking into the `jasmine` reference and vice-versa. The tests should always use `jasmineUnderTest` to refer to the objects and functions that are being tested. But the tests can use functions on `jasmine` as needed. _Be careful how you structure any new test code_. Copy the patterns you see in the existing code - this ensures that the code you're testing is not leaking into the `jasmine` reference and vice-versa.
### `boot.js` ### `boot0.js` and `boot1.js`
This file does all the setup necessary for Jasmine to work in a browser. While These files file does all of the setup necessary for Jasmine to work in a
the default in `lib`is appropriate for most uses, users may wish to customize browser. They load all of the code, create an `Env`, attach the global
this file. functions, and build the reporter. It also sets up the execution of the
`Env` - for browsers this is in `window.onload`. While the default in `lib`
is appropriate for browsers, projects may wish to customize this file.
### Compatibility ### Compatibility
+67 -51
View File
@@ -24,26 +24,70 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
'use strict'; 'use strict';
const path = require('path'); /**
const fs = require('fs'); * Note: Only available on Node.
const { * @module jasmine-core
globals, */
installGlobals,
version,
private$
} = require('./jasmine-core/jasmine.js');
function reset() { const jasmineRequire = require('./jasmine-core/jasmine.js');
private$.currentEnv_ = null; module.exports = jasmineRequire;
const env = jasmine.getEnv({ suppressLoadErrors: true });
rebindInterface(env); 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'), const rootPath = path.join(__dirname, 'jasmine-core'),
bootFiles = ['boot.js'], bootFiles = ['boot0.js', 'boot1.js'],
legacyBootFiles = ['boot.js'],
cssFiles = [], cssFiles = [],
jsFiles = [], jsFiles = [],
jsFilesToSkip = ['jasmine.js'].concat(bootFiles); jsFilesToSkip = ['jasmine.js'].concat(bootFiles, legacyBootFiles);
fs.readdirSync(rootPath).forEach(function(file) { fs.readdirSync(rootPath).forEach(function(file) {
if (fs.statSync(path.join(rootPath, file)).isFile()) { if (fs.statSync(path.join(rootPath, file)).isFile()) {
@@ -60,40 +104,12 @@ fs.readdirSync(rootPath).forEach(function(file) {
} }
}); });
/** module.exports.files = {
* Note: Only available on Node. self: __filename,
* path: rootPath,
* In addition to the members documented here, this module's exports include all bootDir: rootPath,
* {@link globals}. bootFiles: bootFiles,
* @module jasmine-core cssFiles: cssFiles,
*/ jsFiles: ['jasmine.js'].concat(jsFiles),
module.exports = { imagesDir: path.join(__dirname, '../images')
...globals,
/**
* Copies Jasmine globals (jasmine, describe, it, etc) to the specified
* object or to globalThis.
* @function
* @param {object} [dest] - The object to copy globals to.
*/
installGlobals,
/**
* Returns the jasmine-core version.
* @function
*/
version,
/**
* Resets all of jasmine-core's state, including removing specs, suites, and
* reporters, and resetting configuration to the default.
* @function
*/
reset,
files: {
self: __filename,
path: rootPath,
bootDir: rootPath,
bootFiles: bootFiles,
cssFiles: cssFiles,
jsFiles: ['jasmine.js'].concat(jsFiles),
imagesDir: path.join(__dirname, '../images')
}
}; };
+68
View File
@@ -0,0 +1,68 @@
/*
Copyright (c) 2008-2019 Pivotal Labs
Copyright (c) 2008-2026 The Jasmine developers
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
'use strict';
/**
This file starts the process of "booting" Jasmine. It initializes Jasmine,
makes its globals available, and creates the env. This file should be loaded
after `jasmine.js` and `jasmine_html.js`, but before `boot1.js` or any project
source files or spec files are loaded.
*/
(function() {
const jasmineRequire = window.jasmineRequire || require('./jasmine.js');
/**
* ## Require & Instantiate
*
* Require Jasmine's core files. Specifically, this requires and attaches all of Jasmine's code to the `jasmine` reference.
*/
const jasmine = jasmineRequire.core(jasmineRequire),
global = jasmine.getGlobal();
global.jasmine = jasmine;
/**
* Since this is being run in a browser and the results should populate to an HTML page, require the HTML-specific Jasmine code, injecting the same reference.
*/
jasmineRequire.html(jasmine);
/**
* Create the Jasmine environment. This is used to run all specs in a project.
*/
const env = jasmine.getEnv();
/**
* ## The Global Interface
*
* Build up the functions that will be exposed as the Jasmine public interface. A project can customize, rename or alias any of these functions as desired, provided the implementation remains unchanged.
*/
const jasmineInterface = jasmineRequire.interface(jasmine, env);
/**
* Add all of the Jasmine global/public interface to the global scope, so a project can use the public interface directly. For example, calling `describe` in specs instead of `jasmine.getEnv().describe`.
*/
for (const property in jasmineInterface) {
global[property] = jasmineInterface[property];
}
})();
@@ -24,6 +24,19 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
'use strict'; 'use strict';
/**
This file finishes 'booting' Jasmine, performing all of the necessary
initialization before executing the loaded environment and all of a project's
specs. This file should be loaded after `boot0.js` but before any project
source files or spec files are loaded. Thus this file can also be used to
customize Jasmine for a project.
If a project is using Jasmine via the standalone distribution, this file can
be customized directly. If you only wish to configure the Jasmine env, you
can load another file that calls `jasmine.getEnv().configure({...})`
after `boot0.js` is loaded and before this file is loaded.
*/
(function() { (function() {
const env = jasmine.getEnv(); const env = jasmine.getEnv();
const urls = new jasmine.HtmlReporterV2Urls(); const urls = new jasmine.HtmlReporterV2Urls();
+377 -81
View File
@@ -22,50 +22,321 @@ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/ */
(function() { // eslint-disable-next-line no-var
// eslint-disable-next-line no-unused-vars var jasmineRequire = window.jasmineRequire || require('./jasmine.js');
const getJasmineHtmlRequireObj = (function() {
'use strict';
const htmlRequire = {};
function getJasmineHtmlRequire() { jasmineRequire.html = function(j$) {
return htmlRequire; j$.private.ResultsNode = jasmineRequire.ResultsNode();
j$.private.ResultsStateBuilder = jasmineRequire.ResultsStateBuilder(j$);
j$.private.htmlReporterUtils = jasmineRequire.htmlReporterUtils(j$);
j$.private.AlertsView = jasmineRequire.AlertsView(j$);
j$.private.OverallStatusBar = jasmineRequire.OverallStatusBar(j$);
j$.private.Banner = jasmineRequire.Banner(j$);
j$.private.SymbolsView = jasmineRequire.SymbolsView(j$);
j$.private.SummaryTreeView = jasmineRequire.SummaryTreeView(j$);
j$.private.FailuresView = jasmineRequire.FailuresView(j$);
j$.private.PerformanceView = jasmineRequire.PerformanceView(j$);
j$.private.TabBar = jasmineRequire.TabBar(j$);
j$.HtmlReporter = jasmineRequire.HtmlReporter(j$);
j$.HtmlReporterV2Urls = jasmineRequire.HtmlReporterV2Urls(j$);
j$.HtmlReporterV2 = jasmineRequire.HtmlReporterV2(j$);
j$.QueryString = jasmineRequire.QueryString();
j$.HtmlSpecFilter = jasmineRequire.HtmlSpecFilter(j$);
j$.private.HtmlSpecFilterV2 = jasmineRequire.HtmlSpecFilterV2();
};
jasmineRequire.HtmlReporter = function(j$) {
'use strict';
const { createDom, noExpectations } = j$.private.htmlReporterUtils;
/**
* @class HtmlReporter
* @classdesc Displays results and allows re-running individual specs and suites.
* @implements {Reporter}
* @param options Options object. See lib/jasmine-core/boot1.js for details.
* @since 1.2.0
* @deprecated Use {@link HtmlReporterV2} instead.
*/
class HtmlReporter {
#env;
#getContainer;
#navigateWithNewParam;
#urlBuilder;
#filterSpecs;
#stateBuilder;
#config;
#htmlReporterMain;
// Sub-views
#alerts;
#symbols;
#banner;
#failures;
constructor(options) {
this.#env = options.env;
this.#getContainer = options.getContainer;
this.#navigateWithNewParam =
options.navigateWithNewParam || function() {};
this.#urlBuilder = new UrlBuilder(
options.addToExistingQueryString || defaultQueryString
);
this.#filterSpecs = options.filterSpecs;
}
/**
* Initializes the reporter. Should be called before {@link Env#execute}.
* @function
* @name HtmlReporter#initialize
*/
initialize() {
this.#env.deprecated(
'HtmlReporter and HtmlSpecFilter are deprecated. Use HtmlReporterV2 instead.'
);
this.#clearPrior();
this.#config = this.#env ? this.#env.configuration() : {};
this.#stateBuilder = new j$.private.ResultsStateBuilder();
this.#alerts = new j$.private.AlertsView(this.#urlBuilder);
this.#symbols = new j$.private.SymbolsView();
this.#banner = new j$.private.Banner(this.#navigateWithNewParam);
this.#failures = new j$.private.FailuresView(this.#urlBuilder);
this.#htmlReporterMain = createDom(
'div',
{ className: 'jasmine_html-reporter' },
this.#banner.rootEl,
this.#symbols.rootEl,
this.#alerts.rootEl,
this.#failures.rootEl
);
this.#getContainer().appendChild(this.#htmlReporterMain);
}
jasmineStarted(options) {
this.#stateBuilder.jasmineStarted(options);
}
suiteStarted(result) {
this.#stateBuilder.suiteStarted(result);
}
suiteDone(result) {
this.#stateBuilder.suiteDone(result);
if (result.status === 'failed') {
this.#failures.append(result, this.#stateBuilder.currentParent);
}
}
specStarted() {}
specDone(result) {
this.#stateBuilder.specDone(result);
this.#symbols.append(result, this.#config);
if (noExpectations(result)) {
const noSpecMsg = "Spec '" + result.fullName + "' has no expectations.";
if (result.status === 'failed') {
// eslint-disable-next-line no-console
console.error(noSpecMsg);
} else {
// eslint-disable-next-line no-console
console.warn(noSpecMsg);
}
}
if (result.status === 'failed') {
this.#failures.append(result, this.#stateBuilder.currentParent);
}
}
jasmineDone(doneResult) {
this.#stateBuilder.jasmineDone(doneResult);
this.#banner.showOptionsMenu(this.#config);
if (
this.#stateBuilder.specsExecuted < this.#stateBuilder.totalSpecsDefined
) {
this.#alerts.addSkipped(
this.#stateBuilder.specsExecuted,
this.#stateBuilder.totalSpecsDefined
);
}
const statusBar = new j$.private.OverallStatusBar(this.#urlBuilder);
statusBar.showDone(doneResult, this.#stateBuilder);
this.#alerts.addBar(statusBar.rootEl);
if (doneResult.failedExpectations) {
for (const f of doneResult.failedExpectations) {
this.#alerts.addGlobalFailure(f);
}
}
for (const dw of this.#stateBuilder.deprecationWarnings) {
this.#alerts.addDeprecationWarning(dw);
}
const results = this.#find('.jasmine-results');
const summary = new j$.private.SummaryTreeView(
this.#urlBuilder,
this.#filterSpecs
);
summary.addResults(this.#stateBuilder.topResults);
results.appendChild(summary.rootEl);
if (this.#stateBuilder.anyNonTopSuiteFailures) {
this.#addFailureToggle();
this.#setMenuModeTo('jasmine-failure-list');
this.#failures.show();
}
}
#addFailureToggle() {
const onClickFailures = () => this.#setMenuModeTo('jasmine-failure-list');
const onClickSpecList = () => this.#setMenuModeTo('jasmine-spec-list');
const failuresLink = createDom(
'a',
{ className: 'jasmine-failures-menu', href: '#' },
'Failures'
);
let specListLink = createDom(
'a',
{ className: 'jasmine-spec-list-menu', href: '#' },
'Spec List'
);
failuresLink.onclick = function() {
onClickFailures();
return false;
};
specListLink.onclick = function() {
onClickSpecList();
return false;
};
this.#alerts.addBar(
createDom(
'span',
{ className: 'jasmine-menu jasmine-bar jasmine-spec-list' },
[createDom('span', {}, 'Spec List | '), failuresLink]
)
);
this.#alerts.addBar(
createDom(
'span',
{ className: 'jasmine-menu jasmine-bar jasmine-failure-list' },
[specListLink, createDom('span', {}, ' | Failures ')]
)
);
}
#find(selector) {
return this.#getContainer().querySelector(
'.jasmine_html-reporter ' + selector
);
}
#clearPrior() {
const oldReporter = this.#find('');
if (oldReporter) {
this.#getContainer().removeChild(oldReporter);
}
}
#setMenuModeTo(mode) {
this.#htmlReporterMain.setAttribute(
'class',
'jasmine_html-reporter ' + mode
);
}
} }
htmlRequire.html = function(j$, private$) { class UrlBuilder {
if (!private$) { #addToExistingQueryString;
private$ = {};
constructor(addToExistingQueryString) {
this.#addToExistingQueryString = function(k, v) {
// include window.location.pathname to fix issue with karma-jasmine-html-reporter in angular: see https://github.com/jasmine/jasmine/issues/1906
return (
(window.location.pathname || '') + addToExistingQueryString(k, v)
);
};
} }
private$.ResultsNode = htmlRequire.ResultsNode(); suiteHref(suite) {
private$.ResultsStateBuilder = htmlRequire.ResultsStateBuilder( const els = [];
j$,
private$ while (suite && suite.parent) {
els.unshift(suite.result.description);
suite = suite.parent;
}
return this.#addToExistingQueryString('spec', els.join(' '));
}
specHref(result) {
return this.#addToExistingQueryString('spec', result.fullName);
}
runAllHref() {
return this.#addToExistingQueryString('spec', '');
}
seedHref(seed) {
return this.#addToExistingQueryString('seed', seed);
}
}
function defaultQueryString(key, value) {
return '?' + key + '=' + value;
}
return HtmlReporter;
};
jasmineRequire.HtmlSpecFilter = function(j$) {
'use strict';
/**
* @class HtmlSpecFilter
* @param options Options object. See lib/jasmine-core/boot1.js for details.
* @deprecated Use {@link HtmlReporterV2Urls} instead.
*/
function HtmlSpecFilter(options) {
const env = options?.env ?? j$.getEnv();
env.deprecated(
'HtmlReporter and HtmlSpecFilter are deprecated. Use HtmlReporterV2 instead.'
); );
private$.htmlReporterUtils = htmlRequire.htmlReporterUtils(j$, private$);
private$.AlertsView = htmlRequire.AlertsView(j$, private$);
private$.OverallStatusBar = htmlRequire.OverallStatusBar(j$, private$);
private$.Banner = htmlRequire.Banner(j$, private$);
private$.SummaryTreeView = htmlRequire.SummaryTreeView(j$, private$);
private$.FailuresView = htmlRequire.FailuresView(j$, private$);
private$.PerformanceView = htmlRequire.PerformanceView(j$, private$);
private$.TabBar = htmlRequire.TabBar(j$, private$);
private$.HtmlSpecFilterV2 = htmlRequire.HtmlSpecFilterV2();
for (const k of ['HtmlReporterV2Urls', 'HtmlReporterV2', 'QueryString']) { const filterString =
Object.defineProperty(j$, k, { options &&
enumerable: true, options.filterString &&
configurable: false, options.filterString() &&
writable: false, options.filterString().replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&');
value: htmlRequire[k](j$, private$) const filterPattern = new RegExp(filterString);
});
}
};
return getJasmineHtmlRequire; /**
})(); * Determines whether the spec with the specified name should be executed.
* @name HtmlSpecFilter#matches
* @function
* @param {string} specName The full name of the spec
* @returns {boolean}
*/
this.matches = function(specName) {
return filterPattern.test(specName);
};
}
getJasmineHtmlRequireObj().ResultsNode = function() { return HtmlSpecFilter;
};
jasmineRequire.ResultsNode = function() {
'use strict'; 'use strict';
function ResultsNode(result, type, parent) { function ResultsNode(result, type, parent) {
@@ -91,7 +362,7 @@ getJasmineHtmlRequireObj().ResultsNode = function() {
return ResultsNode; return ResultsNode;
}; };
getJasmineHtmlRequireObj().QueryString = function() { jasmineRequire.QueryString = function() {
'use strict'; 'use strict';
/** /**
@@ -107,7 +378,6 @@ getJasmineHtmlRequireObj().QueryString = function() {
*/ */
constructor(options) { constructor(options) {
this.#getWindowLocation = options.getWindowLocation; this.#getWindowLocation = options.getWindowLocation;
Object.freeze(this);
} }
/** /**
@@ -175,14 +445,13 @@ getJasmineHtmlRequireObj().QueryString = function() {
return '?' + qStrPairs.join('&'); return '?' + qStrPairs.join('&');
} }
Object.freeze(QueryString.prototype);
return QueryString; return QueryString;
}; };
getJasmineHtmlRequireObj().AlertsView = function(j$, private$) { jasmineRequire.AlertsView = function(j$) {
'use strict'; 'use strict';
const { createDom } = private$.htmlReporterUtils; const { createDom } = j$.private.htmlReporterUtils;
const errorBarClassName = 'jasmine-bar jasmine-errored'; const errorBarClassName = 'jasmine-bar jasmine-errored';
const afterAllMessagePrefix = 'AfterAll '; const afterAllMessagePrefix = 'AfterAll ';
@@ -298,10 +567,10 @@ getJasmineHtmlRequireObj().AlertsView = function(j$, private$) {
return AlertsView; return AlertsView;
}; };
getJasmineHtmlRequireObj().Banner = function(j$, private$) { jasmineRequire.Banner = function(j$) {
'use strict'; 'use strict';
const { createDom } = private$.htmlReporterUtils; const { createDom } = j$.private.htmlReporterUtils;
class Banner { class Banner {
#navigateWithNewParam; #navigateWithNewParam;
@@ -460,10 +729,10 @@ getJasmineHtmlRequireObj().Banner = function(j$, private$) {
return Banner; return Banner;
}; };
getJasmineHtmlRequireObj().FailuresView = function(j$, private$) { jasmineRequire.FailuresView = function(j$) {
'use strict'; 'use strict';
const { createDom } = private$.htmlReporterUtils; const { createDom } = j$.private.htmlReporterUtils;
class FailuresView { class FailuresView {
#urlBuilder; #urlBuilder;
@@ -627,7 +896,7 @@ getJasmineHtmlRequireObj().FailuresView = function(j$, private$) {
return FailuresView; return FailuresView;
}; };
getJasmineHtmlRequireObj().htmlReporterUtils = function(j$, private$) { jasmineRequire.htmlReporterUtils = function(j$) {
'use strict'; 'use strict';
function createDom(type, attrs, childrenArrayOrVarArgs) { function createDom(type, attrs, childrenArrayOrVarArgs) {
@@ -680,10 +949,10 @@ getJasmineHtmlRequireObj().htmlReporterUtils = function(j$, private$) {
return { createDom, noExpectations }; return { createDom, noExpectations };
}; };
getJasmineHtmlRequireObj().HtmlReporterV2 = function(j$, private$) { jasmineRequire.HtmlReporterV2 = function(j$) {
'use strict'; 'use strict';
const { createDom, noExpectations } = private$.htmlReporterUtils; const { createDom, noExpectations } = j$.private.htmlReporterUtils;
const specListTabId = 'jasmine-specListTab'; const specListTabId = 'jasmine-specListTab';
const failuresTabId = 'jasmine-failuresTab'; const failuresTabId = 'jasmine-failuresTab';
@@ -739,14 +1008,14 @@ getJasmineHtmlRequireObj().HtmlReporterV2 = function(j$, private$) {
this.#config = options.env ? options.env.configuration() : {}; this.#config = options.env ? options.env.configuration() : {};
this.#stateBuilder = new private$.ResultsStateBuilder(); this.#stateBuilder = new j$.private.ResultsStateBuilder();
this.#alerts = new private$.AlertsView(this.#urlBuilder); this.#alerts = new j$.private.AlertsView(this.#urlBuilder);
this.#statusBar = new private$.OverallStatusBar(this.#urlBuilder); this.#statusBar = new j$.private.OverallStatusBar(this.#urlBuilder);
this.#statusBar.showRunning(); this.#statusBar.showRunning();
this.#alerts.addBar(this.#statusBar.rootEl); this.#alerts.addBar(this.#statusBar.rootEl);
this.#tabBar = new private$.TabBar( this.#tabBar = new j$.private.TabBar(
[ [
{ id: specListTabId, label: 'Spec List' }, { id: specListTabId, label: 'Spec List' },
{ id: failuresTabId, label: 'Failures' }, { id: failuresTabId, label: 'Failures' },
@@ -765,11 +1034,11 @@ getJasmineHtmlRequireObj().HtmlReporterV2 = function(j$, private$) {
this.#alerts.addBar(this.#tabBar.rootEl); this.#alerts.addBar(this.#tabBar.rootEl);
this.#progress = new ProgressView(); this.#progress = new ProgressView();
this.#banner = new private$.Banner( this.#banner = new j$.private.Banner(
this.#queryString.navigateWithNewParam.bind(this.#queryString), this.#queryString.navigateWithNewParam.bind(this.#queryString),
true true
); );
this.#failures = new private$.FailuresView(this.#urlBuilder); this.#failures = new j$.private.FailuresView(this.#urlBuilder);
this.#htmlReporterMain = createDom( this.#htmlReporterMain = createDom(
'div', 'div',
{ className: 'jasmine_html-reporter' }, { className: 'jasmine_html-reporter' },
@@ -780,8 +1049,6 @@ getJasmineHtmlRequireObj().HtmlReporterV2 = function(j$, private$) {
); );
this.#container.appendChild(this.#htmlReporterMain); this.#container.appendChild(this.#htmlReporterMain);
this.#failures.show(); this.#failures.show();
Object.freeze(this);
} }
jasmineStarted(options) { jasmineStarted(options) {
@@ -852,13 +1119,13 @@ getJasmineHtmlRequireObj().HtmlReporterV2 = function(j$, private$) {
} }
const results = this.#find('.jasmine-results'); const results = this.#find('.jasmine-results');
const summary = new private$.SummaryTreeView( const summary = new j$.private.SummaryTreeView(
this.#urlBuilder, this.#urlBuilder,
this.#filterSpecs this.#filterSpecs
); );
summary.addResults(this.#stateBuilder.topResults); summary.addResults(this.#stateBuilder.topResults);
results.appendChild(summary.rootEl); results.appendChild(summary.rootEl);
const perf = new private$.PerformanceView(); const perf = new j$.private.PerformanceView();
perf.addResults(this.#stateBuilder.topResults); perf.addResults(this.#stateBuilder.topResults);
results.appendChild(perf.rootEl); results.appendChild(perf.rootEl);
this.#tabBar.showTab(specListTabId); this.#tabBar.showTab(specListTabId);
@@ -959,11 +1226,10 @@ getJasmineHtmlRequireObj().HtmlReporterV2 = function(j$, private$) {
} }
} }
Object.freeze(HtmlReporterV2.prototype);
return HtmlReporterV2; return HtmlReporterV2;
}; };
getJasmineHtmlRequireObj().HtmlReporterV2Urls = function(j$, private$) { jasmineRequire.HtmlReporterV2Urls = function(j$) {
'use strict'; 'use strict';
// TODO unify with V2 UrlBuilder? // TODO unify with V2 UrlBuilder?
@@ -983,8 +1249,6 @@ getJasmineHtmlRequireObj().HtmlReporterV2Urls = function(j$, private$) {
return window.location; return window.location;
} }
}); });
Object.freeze(this);
} }
/** /**
@@ -1016,7 +1280,7 @@ getJasmineHtmlRequireObj().HtmlReporterV2Urls = function(j$, private$) {
config.seed = seed; config.seed = seed;
} }
const specFilter = new private$.HtmlSpecFilterV2({ const specFilter = new j$.private.HtmlSpecFilterV2({
filterParams: () => ({ filterParams: () => ({
path: this.queryString.getParam('path'), path: this.queryString.getParam('path'),
spec: this.queryString.getParam('spec') spec: this.queryString.getParam('spec')
@@ -1035,11 +1299,10 @@ getJasmineHtmlRequireObj().HtmlReporterV2Urls = function(j$, private$) {
} }
} }
Object.freeze(HtmlReporterV2Urls.prototype);
return HtmlReporterV2Urls; return HtmlReporterV2Urls;
}; };
getJasmineHtmlRequireObj().HtmlSpecFilterV2 = function() { jasmineRequire.HtmlSpecFilterV2 = function() {
class HtmlSpecFilterV2 { class HtmlSpecFilterV2 {
#getFilterParams; #getFilterParams;
@@ -1081,10 +1344,10 @@ getJasmineHtmlRequireObj().HtmlSpecFilterV2 = function() {
return HtmlSpecFilterV2; return HtmlSpecFilterV2;
}; };
getJasmineHtmlRequireObj().OverallStatusBar = function(j$, private$) { jasmineRequire.OverallStatusBar = function(j$) {
'use strict'; 'use strict';
const { createDom } = private$.htmlReporterUtils; const { createDom } = j$.private.htmlReporterUtils;
const staticClassNames = 'jasmine-overall-result jasmine-bar'; const staticClassNames = 'jasmine-overall-result jasmine-bar';
class OverallStatusBar { class OverallStatusBar {
@@ -1190,8 +1453,8 @@ getJasmineHtmlRequireObj().OverallStatusBar = function(j$, private$) {
return OverallStatusBar; return OverallStatusBar;
}; };
getJasmineHtmlRequireObj().PerformanceView = function(j$, private$) { jasmineRequire.PerformanceView = function(j$) {
const createDom = private$.htmlReporterUtils.createDom; const createDom = j$.private.htmlReporterUtils.createDom;
const MAX_SLOW_SPECS = 20; const MAX_SLOW_SPECS = 20;
class PerformanceView { class PerformanceView {
@@ -1289,12 +1552,12 @@ getJasmineHtmlRequireObj().PerformanceView = function(j$, private$) {
return PerformanceView; return PerformanceView;
}; };
getJasmineHtmlRequireObj().ResultsStateBuilder = function(j$, private$) { jasmineRequire.ResultsStateBuilder = function(j$) {
'use strict'; 'use strict';
class ResultsStateBuilder { class ResultsStateBuilder {
constructor() { constructor() {
this.topResults = new private$.ResultsNode({}, '', null); this.topResults = new j$.private.ResultsNode({}, '', null);
this.currentParent = this.topResults; this.currentParent = this.topResults;
this.suitesById = {}; this.suitesById = {};
this.totalSpecsDefined = 0; this.totalSpecsDefined = 0;
@@ -1372,10 +1635,10 @@ getJasmineHtmlRequireObj().ResultsStateBuilder = function(j$, private$) {
return ResultsStateBuilder; return ResultsStateBuilder;
}; };
getJasmineHtmlRequireObj().SummaryTreeView = function(j$, private$) { jasmineRequire.SummaryTreeView = function(j$) {
'use strict'; 'use strict';
const { createDom, noExpectations } = private$.htmlReporterUtils; const { createDom, noExpectations } = j$.private.htmlReporterUtils;
class SummaryTreeView { class SummaryTreeView {
#urlBuilder; #urlBuilder;
@@ -1481,8 +1744,48 @@ getJasmineHtmlRequireObj().SummaryTreeView = function(j$, private$) {
return SummaryTreeView; return SummaryTreeView;
}; };
getJasmineHtmlRequireObj().TabBar = function(j$, private$) { jasmineRequire.SymbolsView = function(j$) {
const createDom = private$.htmlReporterUtils.createDom; 'use strict';
const { createDom, noExpectations } = j$.private.htmlReporterUtils;
class SymbolsView {
constructor() {
this.rootEl = createDom('ul', {
className: 'jasmine-symbol-summary'
});
}
append(result, config) {
this.rootEl.appendChild(
createDom('li', {
className: this.#className(result, config),
id: 'spec_' + result.id,
title: result.fullName
})
);
}
#className(result, config) {
if (noExpectations(result) && result.status === 'passed') {
return 'jasmine-empty';
} else if (result.status === 'excluded') {
if (config.hideDisabled) {
return 'jasmine-excluded-no-display';
} else {
return 'jasmine-excluded';
}
} else {
return 'jasmine-' + result.status;
}
}
}
return SymbolsView;
};
jasmineRequire.TabBar = function(j$) {
const createDom = j$.private.htmlReporterUtils.createDom;
class TabBar { class TabBar {
#tabs; #tabs;
@@ -1558,10 +1861,3 @@ getJasmineHtmlRequireObj().TabBar = function(j$, private$) {
return TabBar; return TabBar;
}; };
(function() {
'use strict';
getJasmineHtmlRequireObj().html(jasmine);
})();
})()
+54
View File
@@ -24,6 +24,7 @@ body {
line-height: 14px; line-height: 14px;
} }
.jasmine_html-reporter .jasmine-banner, .jasmine_html-reporter .jasmine-banner,
.jasmine_html-reporter .jasmine-symbol-summary,
.jasmine_html-reporter .jasmine-summary, .jasmine_html-reporter .jasmine-summary,
.jasmine_html-reporter .jasmine-result-message, .jasmine_html-reporter .jasmine-result-message,
.jasmine_html-reporter .jasmine-spec .jasmine-description, .jasmine_html-reporter .jasmine-spec .jasmine-description,
@@ -64,6 +65,57 @@ body {
padding-right: 9px; padding-right: 9px;
font-size: 12px; font-size: 12px;
} }
.jasmine_html-reporter .jasmine-symbol-summary {
overflow: hidden;
margin: 14px 0;
}
.jasmine_html-reporter .jasmine-symbol-summary li {
display: inline-block;
height: 10px;
width: 14px;
font-size: 16px;
}
.jasmine_html-reporter .jasmine-symbol-summary li.jasmine-passed {
font-size: 14px;
}
.jasmine_html-reporter .jasmine-symbol-summary li.jasmine-passed:before {
color: #007069;
content: "•";
}
.jasmine_html-reporter .jasmine-symbol-summary li.jasmine-failed {
line-height: 9px;
}
.jasmine_html-reporter .jasmine-symbol-summary li.jasmine-failed:before {
color: #ca3a11;
content: "×";
font-weight: bold;
margin-left: -1px;
}
.jasmine_html-reporter .jasmine-symbol-summary li.jasmine-excluded {
font-size: 14px;
}
.jasmine_html-reporter .jasmine-symbol-summary li.jasmine-excluded:before {
color: #bababa;
content: "•";
}
.jasmine_html-reporter .jasmine-symbol-summary li.jasmine-excluded-no-display {
font-size: 14px;
display: none;
}
.jasmine_html-reporter .jasmine-symbol-summary li.jasmine-pending {
line-height: 17px;
}
.jasmine_html-reporter .jasmine-symbol-summary li.jasmine-pending:before {
color: #ba9d37;
content: "*";
}
.jasmine_html-reporter .jasmine-symbol-summary li.jasmine-empty {
font-size: 14px;
}
.jasmine_html-reporter .jasmine-symbol-summary li.jasmine-empty:before {
color: #ba9d37;
content: "•";
}
.jasmine_html-reporter progress { .jasmine_html-reporter progress {
width: 100%; width: 100%;
} }
@@ -145,10 +197,12 @@ body {
.jasmine_html-reporter .jasmine-bar a { .jasmine_html-reporter .jasmine-bar a {
color: white; color: white;
} }
.jasmine_html-reporter.jasmine-spec-list .jasmine-bar.jasmine-menu.jasmine-failure-list,
.jasmine_html-reporter.jasmine-spec-list .jasmine-results .jasmine-failures, .jasmine_html-reporter.jasmine-spec-list .jasmine-results .jasmine-failures,
.jasmine_html-reporter.jasmine-spec-list .jasmine-performance-view { .jasmine_html-reporter.jasmine-spec-list .jasmine-performance-view {
display: none; display: none;
} }
.jasmine_html-reporter.jasmine-failure-list .jasmine-bar.jasmine-menu.jasmine-spec-list,
.jasmine_html-reporter.jasmine-failure-list .jasmine-summary, .jasmine_html-reporter.jasmine-failure-list .jasmine-summary,
.jasmine_html-reporter.jasmine-failure-list .jasmine-performance-view { .jasmine_html-reporter.jasmine-failure-list .jasmine-performance-view {
display: none; display: none;
File diff suppressed because it is too large Load Diff
+3 -6
View File
@@ -1,7 +1,7 @@
{ {
"name": "jasmine-core", "name": "jasmine-core",
"license": "MIT", "license": "MIT",
"version": "7.0.0-pre.0", "version": "6.1.0",
"repository": { "repository": {
"type": "git", "type": "git",
"url": "https://github.com/jasmine/jasmine.git" "url": "https://github.com/jasmine/jasmine.git"
@@ -28,9 +28,6 @@
"description": "Simple JavaScript testing framework for browsers and node.js", "description": "Simple JavaScript testing framework for browsers and node.js",
"homepage": "https://jasmine.github.io", "homepage": "https://jasmine.github.io",
"main": "./lib/jasmine-core.js", "main": "./lib/jasmine-core.js",
"exports": {
".": "./lib/jasmine-core.js"
},
"files": [ "files": [
"LICENSE", "LICENSE",
"README.md", "README.md",
@@ -48,8 +45,8 @@
"eslint-plugin-compat": "^6.0.2", "eslint-plugin-compat": "^6.0.2",
"glob": "^13.0.0", "glob": "^13.0.0",
"globals": "^16.0.0", "globals": "^16.0.0",
"jasmine": "github:jasmine/jasmine-npm#7.0", "jasmine": "github:jasmine/jasmine-npm",
"jasmine-browser-runner": "github:jasmine/jasmine-browser-runner#5.0", "jasmine-browser-runner": "github:jasmine/jasmine-browser-runner",
"jsdom": "^26.0.0", "jsdom": "^26.0.0",
"prettier": "1.17.1", "prettier": "1.17.1",
"sass": "^1.58.3" "sass": "^1.58.3"
+2 -1
View File
@@ -42,7 +42,8 @@ async function zipStandaloneDist(jasmineVersion) {
'lib/jasmine-core/jasmine.js', 'lib/jasmine-core/jasmine.js',
'lib/jasmine-core/jasmine-html.js', 'lib/jasmine-core/jasmine-html.js',
'lib/jasmine-core/jasmine.css', 'lib/jasmine-core/jasmine.css',
'lib/jasmine-core/boot.js', 'lib/jasmine-core/boot0.js',
'lib/jasmine-core/boot1.js',
], ],
destDir: 'lib/jasmine-' + jasmineVersion destDir: 'lib/jasmine-' + jasmineVersion
}, },
+26 -30
View File
@@ -34,20 +34,18 @@ function concatFiles() {
const configs = [ const configs = [
{ {
src: [ src: [
{ literal: '(function() {' },
'src/html/requireHtml.js', 'src/html/requireHtml.js',
'src/html/HtmlReporter.js',
'src/html/HtmlSpecFilter.js',
'src/html/ResultsNode.js', 'src/html/ResultsNode.js',
'src/html/QueryString.js', 'src/html/QueryString.js',
{ glob: 'src/html/**/*.js', exclude: 'src/html/requireSuffix.js' }, 'src/html/**/*.js'
'src/html/requireSuffix.js',
{ literal: '})()' },
], ],
dest: 'lib/jasmine-core/jasmine-html.js', dest: 'lib/jasmine-core/jasmine-html.js',
}, },
{ {
dest: 'lib/jasmine-core/jasmine.js', dest: 'lib/jasmine-core/jasmine.js',
src: [ src: [
{ literal: '(function() {' },
'src/core/requireCore.js', 'src/core/requireCore.js',
'src/core/matchers/requireMatchers.js', 'src/core/matchers/requireMatchers.js',
'src/core/base.js', 'src/core/base.js',
@@ -55,20 +53,23 @@ function concatFiles() {
'src/core/Spec.js', 'src/core/Spec.js',
'src/core/Order.js', 'src/core/Order.js',
'src/core/Env.js', 'src/core/Env.js',
'src/core/JsApiReporter.js',
'src/core/PrettyPrinter', 'src/core/PrettyPrinter',
'src/core/Suite', 'src/core/Suite',
{ glob: 'src/core/**/*.js', exclude: 'src/core/requireSuffix.js'}, 'src/core/**/*.js',
{ {
template: 'src/version.js', template: 'src/version.js',
data: {version: pkg.version} data: {version: pkg.version}
}, },
'src/core/requireSuffix.js',
{ literal: '})()' },
], ],
}, },
{ {
dest: 'lib/jasmine-core/boot.js', dest: 'lib/jasmine-core/boot0.js',
src: ['src/boot/boot.js'], src: ['src/boot/boot0.js'],
},
{
dest: 'lib/jasmine-core/boot1.js',
src: ['src/boot/boot1.js'],
}, },
{ {
dest: 'lib/jasmine-core.js', dest: 'lib/jasmine-core.js',
@@ -84,28 +85,25 @@ function concatFiles() {
src.unshift(licenseBanner); src.unshift(licenseBanner);
function expand(srcListEntry) { function expand(srcListEntry) {
if (typeof srcListEntry === 'object' && !srcListEntry.glob) { if (typeof srcListEntry === 'object') {
return srcListEntry; return srcListEntry;
} }
const matches = glob.sync( return glob.sync(srcListEntry)
srcListEntry.glob ?? srcListEntry, .sort(function (a, b) {
{ignore: srcListEntry.exclude} // Match the sort order of previous build tools, so that the
); // output is the same.
return matches.sort(function (a, b) { a = a.toLowerCase();
// Match the sort order of previous build tools, so that the b = b.toLowerCase();
// output is the same.
a = a.toLowerCase();
b = b.toLowerCase();
if (a < b) { if (a < b) {
return -1; return -1;
} else if (a === b) { } else if (a === b) {
return 0; return 0;
} else { } else {
return 1; return 1;
} }
}); });
} }
const srcs = src.flatMap(expand); const srcs = src.flatMap(expand);
@@ -119,8 +117,6 @@ function concatFiles() {
if (s.template) { if (s.template) {
const template = fs.readFileSync(s.template, {encoding: 'utf8'}); const template = fs.readFileSync(s.template, {encoding: 'utf8'});
content = ejs.render(template, s.data); content = ejs.render(template, s.data);
} else if (s.literal) {
content = s.literal;
} else { } else {
content = fs.readFileSync(s, {encoding: 'utf8'}); content = fs.readFileSync(s, {encoding: 'utf8'});
} }
+3 -4
View File
@@ -1,9 +1,8 @@
let jasmineCore; verifyNoGlobals(() => require('../lib/jasmine-core.js').noGlobals());
verifyNoGlobals(() => { jasmineCore = require('../lib/jasmine-core.js'); });
jasmineCore.installGlobals();
const Jasmine = require('jasmine'); const Jasmine = require('jasmine');
const runner = new Jasmine({jasmineCore}); const jasmineCore = require('../lib/jasmine-core.js');
const runner = new Jasmine({jasmineCore: jasmineCore});
runner.loadConfigFile('./spec/support/jasmine.json'); runner.loadConfigFile('./spec/support/jasmine.json');
runner.exitOnCompletion = false; runner.exitOnCompletion = false;
+19 -2
View File
@@ -1248,7 +1248,24 @@ describe('Clock (acceptance)', function() {
clock.tick(400); clock.tick(400);
}); });
isNonMonkeyPatchableClass(privateUnderTest.Clock, function() { describe('Warning about monkey patching', function() {
return new privateUnderTest.Clock({}, function() {}, {}); for (const name of ['tick', 'mockDate', 'install', 'uninstall']) {
it(`warns if Clock#${name} is monkey patched`, function() {
spyOn(console, 'error');
const clock = new privateUnderTest.Clock({}, function() {}, {});
const patch = {};
clock[name] = patch;
// eslint-disable-next-line no-console
expect(console.error).toHaveBeenCalledOnceWith(
jasmine.stringContaining('DEPRECATION: Monkey patching detected.')
);
// eslint-disable-next-line no-console
expect(console.error).toHaveBeenCalledOnceWith(
jasmine.stringContaining('ClockSpec.js')
);
expect(clock[name]).toBe(patch);
});
}
}); });
}); });
+38 -2
View File
@@ -875,7 +875,43 @@ describe('Env', function() {
}); });
}); });
isNonMonkeyPatchableClass(privateUnderTest.Env, function() { describe('Warning about monkey patching', function() {
return new privateUnderTest.Env(); afterEach(function() {
// deprecateMonkeyPatching() uses jasmine.getEnv(), not the env from
// this suite. Clean it up so we don't leak event listeners.
jasmineUnderTest.getEnv().cleanup_();
privateUnderTest.currentEnv_ = null;
});
const names = [
'describe',
'xdescribe',
'fdescribe',
'it',
'xit',
'fit',
'beforeEach',
'afterEach',
'beforeAll',
'afterAll'
];
for (const name of names) {
it(`warns if Env#${name} is monkey patched`, function() {
spyOn(console, 'error');
const patch = {};
env[name] = patch;
// eslint-disable-next-line no-console
expect(console.error).toHaveBeenCalledOnceWith(
jasmine.stringContaining('DEPRECATION: Monkey patching detected.')
);
// eslint-disable-next-line no-console
expect(console.error).toHaveBeenCalledOnceWith(
jasmine.stringContaining('EnvSpec.js')
);
expect(env[name]).toBe(patch);
});
}
}); });
}); });
+7 -13
View File
@@ -173,13 +173,10 @@ describe('ExceptionFormatter', function() {
}); });
it('filters Jasmine stack frames in this environment', function() { it('filters Jasmine stack frames in this environment', function() {
const jasmineFile = (function() {
const trace = new privateUnderTest.StackTrace(new Error());
return trace.frames[2].file;
})();
expect(jasmineFile).toMatch(/\/jasmine.js$/);
const error = new Error('an error'); const error = new Error('an error');
const subject = new privateUnderTest.ExceptionFormatter({ jasmineFile }); const subject = new privateUnderTest.ExceptionFormatter({
jasmineFile: jasmine.private.util.jasmineFile()
});
const result = subject.stack(error); const result = subject.stack(error);
jasmine.debugLog('Original stack trace: ' + error.stack); jasmine.debugLog('Original stack trace: ' + error.stack);
jasmine.debugLog('Filtered stack trace: ' + result); jasmine.debugLog('Filtered stack trace: ' + result);
@@ -199,18 +196,15 @@ describe('ExceptionFormatter', function() {
}); });
it('handles multiline error messages in this environment', function() { it('handles multiline error messages in this environment', function() {
const jasmineFile = (function() {
const trace = new privateUnderTest.StackTrace(new Error());
return trace.frames[2].file;
})();
expect(jasmineFile).toMatch(/\/jasmine.js$/);
const msg = 'an error\nwith two lines'; const msg = 'an error\nwith two lines';
const error = new Error(msg); const error = new Error(msg);
if (error.stack.indexOf(msg) === -1) { if (error.stack.indexOf(msg) === -1) {
pending("Stack traces don't have messages in this environment"); pending("Stack traces don't have messages in this environment");
} }
const subject = new privateUnderTest.ExceptionFormatter({ jasmineFile }); const subject = new privateUnderTest.ExceptionFormatter({
jasmineFile: jasmine.private.util.jasmineFile()
});
const result = subject.stack(error); const result = subject.stack(error);
const lines = result.split('\n'); const lines = result.split('\n');
@@ -290,7 +284,7 @@ describe('ExceptionFormatter', function() {
it('ensures that stack traces do not include the message in this environment', function() { it('ensures that stack traces do not include the message in this environment', function() {
const error = new Error('an error'); const error = new Error('an error');
const subject = new privateUnderTest.ExceptionFormatter({ const subject = new privateUnderTest.ExceptionFormatter({
jasmineFile: "doesn't matter" jasmineFile: jasmine.private.util.jasmineFile()
}); });
const result = subject.stack(error, { omitMessage: true }); const result = subject.stack(error, { omitMessage: true });
expect(result).not.toContain('an error'); expect(result).not.toContain('an error');
+179
View File
@@ -0,0 +1,179 @@
describe('JsApiReporter', function() {
it('knows when a full environment is started', function() {
const reporter = new privateUnderTest.JsApiReporter({});
expect(reporter.started).toBe(false);
expect(reporter.finished).toBe(false);
reporter.jasmineStarted();
expect(reporter.started).toBe(true);
expect(reporter.finished).toBe(false);
});
it('knows when a full environment is done', function() {
const reporter = new privateUnderTest.JsApiReporter({});
expect(reporter.started).toBe(false);
expect(reporter.finished).toBe(false);
reporter.jasmineStarted();
reporter.jasmineDone({});
expect(reporter.finished).toBe(true);
});
it("defaults to 'loaded' status", function() {
const reporter = new privateUnderTest.JsApiReporter({});
expect(reporter.status()).toEqual('loaded');
});
it("reports 'started' when Jasmine has started", function() {
const reporter = new privateUnderTest.JsApiReporter({});
reporter.jasmineStarted();
expect(reporter.status()).toEqual('started');
});
it("reports 'done' when Jasmine is done", function() {
const reporter = new privateUnderTest.JsApiReporter({});
reporter.jasmineDone({});
expect(reporter.status()).toEqual('done');
});
it('tracks a suite', function() {
const reporter = new privateUnderTest.JsApiReporter({});
reporter.suiteStarted({
id: 123,
description: 'A suite'
});
const suites = reporter.suites();
expect(suites).toEqual({ 123: { id: 123, description: 'A suite' } });
reporter.suiteDone({
id: 123,
description: 'A suite',
status: 'passed'
});
expect(suites).toEqual({
123: { id: 123, description: 'A suite', status: 'passed' }
});
});
describe('#specResults', function() {
let reporter, specResult1, specResult2;
beforeEach(function() {
reporter = new privateUnderTest.JsApiReporter({});
specResult1 = {
id: 1,
description: 'A spec'
};
specResult2 = {
id: 2,
description: 'Another spec'
};
reporter.specDone(specResult1);
reporter.specDone(specResult2);
});
it('should return a slice of results', function() {
expect(reporter.specResults(0, 1)).toEqual([specResult1]);
expect(reporter.specResults(1, 1)).toEqual([specResult2]);
});
describe('when the results do not exist', function() {
it('should return a slice of shorter length', function() {
expect(reporter.specResults(0, 3)).toEqual([specResult1, specResult2]);
expect(reporter.specResults(2, 3)).toEqual([]);
});
});
});
describe('#suiteResults', function() {
let reporter, suiteStarted1, suiteResult1, suiteResult2;
beforeEach(function() {
reporter = new privateUnderTest.JsApiReporter({});
suiteStarted1 = {
id: 1
};
suiteResult1 = {
id: 1,
status: 'failed',
failedExpectations: [{ message: 'My After All Exception' }]
};
suiteResult2 = {
id: 2,
status: 'passed'
};
reporter.suiteStarted(suiteStarted1);
reporter.suiteDone(suiteResult1);
reporter.suiteDone(suiteResult2);
});
it('should not include suite starts', function() {
expect(reporter.suiteResults(0, 3).length).toEqual(2);
});
it('should return a slice of results', function() {
expect(reporter.suiteResults(0, 1)).toEqual([suiteResult1]);
expect(reporter.suiteResults(1, 1)).toEqual([suiteResult2]);
});
it('returns nothing for out of bounds indices', function() {
expect(reporter.suiteResults(0, 3)).toEqual([suiteResult1, suiteResult2]);
expect(reporter.suiteResults(2, 3)).toEqual([]);
});
});
describe('#executionTime', function() {
it('should start the timer when jasmine starts', function() {
const timerSpy = jasmine.createSpyObj('timer', ['start', 'elapsed']),
reporter = new privateUnderTest.JsApiReporter({
timer: timerSpy
});
reporter.jasmineStarted();
expect(timerSpy.start).toHaveBeenCalled();
});
it('should return the time it took the specs to run, in ms', function() {
const timerSpy = jasmine.createSpyObj('timer', ['start', 'elapsed']),
reporter = new privateUnderTest.JsApiReporter({
timer: timerSpy
});
timerSpy.elapsed.and.returnValue(1000);
reporter.jasmineDone();
expect(reporter.executionTime()).toEqual(1000);
});
describe("when the specs haven't finished being run", function() {
it('should return undefined', function() {
const timerSpy = jasmine.createSpyObj('timer', ['start', 'elapsed']),
reporter = new privateUnderTest.JsApiReporter({
timer: timerSpy
});
expect(reporter.executionTime()).toBeUndefined();
});
});
});
describe('#runDetails', function() {
it('should have details about the run', function() {
const reporter = new privateUnderTest.JsApiReporter({});
reporter.jasmineDone({ some: { run: 'details' } });
expect(reporter.runDetails).toEqual({ some: { run: 'details' } });
});
});
});
@@ -160,13 +160,6 @@ describe('ParallelReportDispatcher', function() {
); );
}); });
isNonMonkeyPatchableClass(
jasmineUnderTest.ParallelReportDispatcher,
function() {
return new jasmineUnderTest.ParallelReportDispatcher();
}
);
function mockGlobalErrors() { function mockGlobalErrors() {
const globalErrors = jasmine.createSpyObj('globalErrors', [ const globalErrors = jasmine.createSpyObj('globalErrors', [
'install', 'install',
+4 -2
View File
@@ -278,7 +278,7 @@ describe('Spec', function() {
spec.addExpectationResult(true, { message: 'passed' }); spec.addExpectationResult(true, { message: 'passed' });
expect(function() { expect(function() {
spec.addExpectationResult(false, { message: 'failed' }); spec.addExpectationResult(false, { message: 'failed' });
}).toThrowError(privateUnderTest.errors.ExpectationFailed); }).toThrowError(jasmineUnderTest.private.errors.ExpectationFailed);
expect(spec.doneEvent().failedExpectations).toEqual([ expect(spec.doneEvent().failedExpectations).toEqual([
jasmine.objectContaining({ message: 'failed' }) jasmine.objectContaining({ message: 'failed' })
@@ -453,7 +453,9 @@ describe('Spec', function() {
queueableFn: {} queueableFn: {}
}); });
spec.handleException(new privateUnderTest.errors.ExpectationFailed()); spec.handleException(
new jasmineUnderTest.private.errors.ExpectationFailed()
);
expect(spec.doneEvent().failedExpectations).toEqual([]); expect(spec.doneEvent().failedExpectations).toEqual([]);
}); });
+4 -2
View File
@@ -138,7 +138,7 @@ describe('Suite', function() {
expect(function() { expect(function() {
suite.addExpectationResult(false, { message: 'failed' }); suite.addExpectationResult(false, { message: 'failed' });
}).toThrowError(privateUnderTest.errors.ExpectationFailed); }).toThrowError(jasmineUnderTest.private.errors.ExpectationFailed);
expect(suite.doneEvent().status).toBe('failed'); expect(suite.doneEvent().status).toBe('failed');
expect(suite.doneEvent().failedExpectations).toEqual([ expect(suite.doneEvent().failedExpectations).toEqual([
@@ -149,7 +149,9 @@ describe('Suite', function() {
it('does not add an additional failure when an expectation fails', function() { it('does not add an additional failure when an expectation fails', function() {
const suite = new privateUnderTest.Suite({}); const suite = new privateUnderTest.Suite({});
suite.handleException(new privateUnderTest.errors.ExpectationFailed()); suite.handleException(
new jasmineUnderTest.private.errors.ExpectationFailed()
);
expect(suite.doneEvent().failedExpectations).toEqual([]); expect(suite.doneEvent().failedExpectations).toEqual([]);
}); });
-4
View File
@@ -30,8 +30,4 @@ describe('Timer', function() {
expect(timer.elapsed()).toEqual(jasmine.any(Number)); expect(timer.elapsed()).toEqual(jasmine.any(Number));
}); });
}); });
isNonMonkeyPatchableClass(jasmineUnderTest.Timer, function() {
return new jasmineUnderTest.Timer();
});
}); });
+1
View File
@@ -163,6 +163,7 @@ describe('util', function() {
// Chrome sometimes reports foo.js as foo.js/, so tolerate // Chrome sometimes reports foo.js as foo.js/, so tolerate
// a trailing slash if present. // a trailing slash if present.
expect(privateUnderTest.util.jasmineFile()).toMatch(/util.js\/?$/); expect(privateUnderTest.util.jasmineFile()).toMatch(/util.js\/?$/);
expect(jasmine.private.util.jasmineFile()).toMatch(/jasmine.js\/?$/);
}); });
}); });
}); });
+3 -1
View File
@@ -1289,7 +1289,9 @@ describe('Env integration', function() {
await env.execute(); await env.execute();
expect(reporter.specDone).toHaveBeenCalledTimes(1); expect(reporter.specDone).toHaveBeenCalledTimes(1);
const event = reporter.specDone.calls.argsFor(0)[0]; const event = reporter.specDone.calls.argsFor(0)[0];
jasmine.debugLog('Spec result: ' + jasmine.pp(event)); jasmine.debugLog(
'Spec result: ' + jasmine.private.basicPrettyPrinter(event)
);
expect(event).toEqual(jasmine.objectContaining({ status: 'passed' })); expect(event).toEqual(jasmine.objectContaining({ status: 'passed' }));
jasmine.clock().tick(1); jasmine.clock().tick(1);
+74 -43
View File
@@ -13,65 +13,83 @@ describe('The jasmine namespace', function() {
expect(setDifference(actualKeys, expectedKeys())).toEqual(new Set()); expect(setDifference(actualKeys, expectedKeys())).toEqual(new Set());
}); });
describe('Preventing monkey patching', function() { describe('Warning about monkey patching', function() {
const mutable = mutableKeys(); beforeEach(function() {
spyOn(console, 'error');
});
for (const key of expectedKeys()) { for (const key of expectedKeys(false)) {
if (mutable.includes(key)) { if (!key.startsWith('MAX_') && key !== 'private' && key !== 'getEnv') {
it(`allows overwriting of jasmine.${key}`, function() { describe(`jasmine.${key}`, function() {
const existingVal = jasmineUnderTest[key]; let orig;
try { beforeEach(function() {
jasmineUnderTest[key] = 'new value'; orig = jasmineUnderTest[key];
expect(jasmineUnderTest[key]).toEqual('new value'); });
} finally {
jasmineUnderTest[key] = existingVal;
}
});
} else {
it(`prevents overwriting of jasmine.${key}`, function() {
const existingVal = jasmineUnderTest[key];
try { afterEach(function() {
jasmineUnderTest[key] = 'monkey patch'; jasmineUnderTest[key] = orig;
expect(jasmineUnderTest[key]).toBe(existingVal); });
} finally {
// This will be a no-op if the test passed, but will prevent state it('warns if monkey patched', function() {
// leakage if it failed. const patch = {};
jasmineUnderTest[key] = existingVal; jasmineUnderTest[key] = patch;
}
verifyDeprecation();
expect(jasmineUnderTest[key]).toBe(patch);
});
}); });
} }
} }
it('allows additions', function() { // These specs rely on jasmineRequire being exposed. That only happens
try { // in browsers.
jasmineUnderTest.Ajax = 'it worked'; if (typeof document !== 'undefined') {
expect(jasmineUnderTest.Ajax).toEqual('it worked'); const statics = ['addMatchers', 'clock', 'createSpyObj'];
} finally {
delete jasmineUnderTest.Ajax; for (const name of statics) {
describe(`jasmine.${name}`, function() {
let bootedCore, env, orig;
beforeEach(function() {
bootedCore = jasmineRequire.core(jasmineRequire);
env = bootedCore.getEnv();
jasmineRequire.interface(bootedCore, env);
orig = bootedCore[name];
});
afterEach(function() {
bootedCore[name] = orig;
env.cleanup_();
});
it(`warns if jasmine.${name} is monkey patched`, function() {
const patch = {};
bootedCore[name] = patch;
verifyDeprecation();
expect(bootedCore[name]).toBe(patch);
});
});
} }
}); }
}); });
function mutableKeys() { function expectedKeys(includeHtml) {
return [ if (includeHtml === undefined) {
'MAX_PRETTY_PRINT_ARRAY_LENGTH', includeHtml = typeof window !== 'undefined';
'MAX_PRETTY_PRINT_CHARS', }
'MAX_PRETTY_PRINT_DEPTH',
'DEFAULT_TIMEOUT_INTERVAL'
];
}
function expectedKeys() {
// Does not include properties added by requireInterface(), since that isn't // Does not include properties added by requireInterface(), since that isn't
// called by defineJasmineUnderTest.js/nodeDefineJasmineUnderTest.js. // called by defineJasmineUnderTest.js/nodeDefineJasmineUnderTest.js.
const result = new Set([ const result = new Set([
...mutableKeys(), 'MAX_PRETTY_PRINT_ARRAY_LENGTH',
'MAX_PRETTY_PRINT_CHARS',
'MAX_PRETTY_PRINT_DEPTH',
'debugLog', 'debugLog',
'getEnv', 'getEnv',
'isSpy', 'isSpy',
'ParallelReportDispatcher', 'ParallelReportDispatcher',
'private',
'spyOnGlobalErrorsAsync', 'spyOnGlobalErrorsAsync',
'Timer', 'Timer',
'version', 'version',
@@ -98,10 +116,12 @@ describe('The jasmine namespace', function() {
'getGlobal' 'getGlobal'
]); ]);
if (typeof window !== 'undefined') { if (includeHtml) {
// jasmine-html.js // jasmine-html.js
result.add('HtmlReporter');
result.add('HtmlReporterV2'); result.add('HtmlReporterV2');
result.add('HtmlReporterV2Urls'); result.add('HtmlReporterV2Urls');
result.add('HtmlSpecFilter');
result.add('QueryString'); result.add('QueryString');
} }
@@ -121,4 +141,15 @@ describe('The jasmine namespace', function() {
return result; return result;
} }
function verifyDeprecation() {
// eslint-disable-next-line no-console
expect(console.error).toHaveBeenCalledOnceWith(
jasmine.stringContaining('DEPRECATION: Monkey patching detected.')
);
// eslint-disable-next-line no-console
expect(console.error).toHaveBeenCalledOnceWith(
jasmine.stringContaining('jasmineNamespaceSpec.js')
);
}
}); });
@@ -0,0 +1,78 @@
describe('#toBeRejectedWithMatching', function() {
it('passes if the promise is rejected with something matching the predicate', function() {
const matcher = privateUnderTest.asyncMatchers.toBeRejectedWithMatching(),
actual = Promise.reject(new Error('nope')),
predicate = value => value.message === 'nope';
return matcher.compare(actual, predicate).then(function(result) {
expect(result).toEqual(jasmine.objectContaining({ pass: true }));
});
});
it('fails if the promise resolves', function() {
const matcher = privateUnderTest.asyncMatchers.toBeRejectedWithMatching(),
actual = Promise.resolve(),
predicate = () => true;
return matcher.compare(actual, predicate).then(function(result) {
expect(result).toEqual(jasmine.objectContaining({ pass: false }));
});
});
it('fails if the promise is rejected with something not matching the predicate', function() {
const matcher = privateUnderTest.asyncMatchers.toBeRejectedWithMatching(),
actual = Promise.reject('A Bad Apple'),
predicate = value => value === 'A Good Orange';
return matcher.compare(actual, predicate).then(function(result) {
expect(result).toEqual(
jasmine.objectContaining({
pass: false,
message:
'Expected a promise to be rejected matching a predicate, but the predicate returned "false".'
})
);
});
});
it('should build its error correctly when negated', function() {
const matcher = privateUnderTest.asyncMatchers.toBeRejectedWithMatching(),
actual = Promise.reject(true),
predicate = () => true;
return matcher.compare(actual, predicate).then(function(result) {
expect(result).toEqual(
jasmine.objectContaining({
pass: true,
message:
'Expected a promise not to be rejected matching a predicate, but the predicate returned "true".'
})
);
});
});
it('fails if actual is not a promise', function() {
const matcher = privateUnderTest.asyncMatchers.toBeRejectedWithMatching(),
actual = 'not a promise';
function f() {
return matcher.compare(actual);
}
expect(f).toThrowError(
'Expected toBeRejectedWithMatching to be called on a promise but was on a string.'
);
});
it('fails if predicate is not a function', function() {
const matcher = privateUnderTest.asyncMatchers.toBeRejectedWithMatching(),
actual = Promise.resolve(),
predicate = 'not a function';
function f() {
return matcher.compare(actual, predicate);
}
expect(f).toThrowError(/Predicate is not a Function/);
});
});
+6 -8
View File
@@ -1,11 +1,9 @@
(function() { (function() {
// By the time onload is called, getJasmineRequireObj() and // By the time onload is called, jasmineRequire will be redefined to point
// getJasmineHtmlRequireObj() will be redefined to point // to the Jasmine source files (and not jasmine.js). So re-require
// to the Jasmine source files (and not jasmine.js). So re-require. window.jasmineUnderTest = jasmineRequire.core(jasmineRequire);
const jasmineRequire = getJasmineRequireObj(); jasmineRequire.html(jasmineUnderTest);
const coreUnderTest = jasmineRequire.core(jasmineRequire);
window.jasmineUnderTest = coreUnderTest.jasmine;
window.privateUnderTest = coreUnderTest.private;
getJasmineHtmlRequireObj().html(jasmineUnderTest, privateUnderTest); // Alias the private namespace so tests can be less verbose
window.privateUnderTest = window.jasmineUnderTest.private;
})(); })();
+2 -2
View File
@@ -42,9 +42,9 @@
: 'Expected runnable "' + : 'Expected runnable "' +
fullName + fullName +
'" to have failures ' + '" to have failures ' +
jasmine.pp(expectedFailures) + jasmine.private.basicPrettyPrinter(expectedFailures) +
' but it had ' + ' but it had ' +
jasmine.pp(foundFailures) jasmine.private.basicPrettyPrinter(foundFailures)
}; };
} }
}; };
-67
View File
@@ -1,67 +0,0 @@
globalThis.isNonMonkeyPatchableClass = function(ctor, makeInstance) {
describe('Monkey patching prevention', function() {
it(`prevents overwriting ${ctor.name}.prototype`, function() {
const existing = ctor.prototype;
try {
ctor.prototype = {};
expect(ctor.prototype).toBe(existing);
} finally {
// This will be a no-op if the test passed, but will prevent state
// leakage if it failed.
ctor.prototype = existing;
}
});
it("prevents overwriting an instance's prototype", function() {
const instance = makeInstance();
let thrown;
// The message varies from browser to browser, so we can't rely on it
try {
instance.__proto__ = {};
} catch (e) {
thrown = e;
}
expect(thrown).toBeInstanceOf(TypeError);
});
it('prevents overwriting prototype properties', function() {
let any = false;
for (const k of Object.getOwnPropertyNames(ctor.prototype)) {
any = true;
const existingValue = ctor.prototype[k];
try {
ctor.prototype[k] = {};
expect(ctor.prototype[k])
.withContext(k)
.toBe(existingValue);
} finally {
// This will be a no-op if the test passed, but will prevent state
// leakage if it failed.
ctor.prototype[k] = existingValue;
}
}
expect(any).toBe(true);
});
it('prevents overriding prototype properties', function() {
const instance = makeInstance();
let any = false;
for (const k of Object.getOwnPropertyNames(ctor.prototype)) {
any = true;
instance[k] = {};
expect(instance[k])
.withContext(k)
.toBe(ctor.prototype[k]);
}
expect(any).toBe(true);
});
});
};
+12 -17
View File
@@ -7,29 +7,24 @@
'../../src/core/requireCore.js' '../../src/core/requireCore.js'
)); ));
// Individual source files call getJasmineRequireObj. It's normally defined
// by requireCore.js which is concatenated into jasmine.js before other source
// files. Since we're bypassing that mechanism, we need to provide our own.
global.getJasmineRequireObj = function() { global.getJasmineRequireObj = function() {
return jasmineUnderTestRequire; return jasmineUnderTestRequire;
}; };
const srcFiles = [ function getSourceFiles() {
...glob.sync('../../src/core/**/*.js', { const globs = ['../../src/core/**/*.js', '../../src/version.js'];
ignore: '../../src/core/requireSuffix.js', const srcFiles = globs.flatMap(g => glob.sync(g, { cwd: __dirname }));
cwd: __dirname
}),
'../../src/version.js',
'../../src/core/requireCore.js'
];
for (const file of srcFiles) { for (const file of srcFiles) {
require(file); require(file);
}
} }
delete global.getJasmineRequireObj; getSourceFiles();
global.jasmineUnderTest = jasmineUnderTestRequire.core(
jasmineUnderTestRequire
);
const built = jasmineUnderTestRequire.core(jasmineUnderTestRequire); // Alias the private namespace so tests can be less verbose
global.jasmineUnderTest = built.jasmine; global.privateUnderTest = global.jasmineUnderTest.private;
global.privateUnderTest = built.private;
})(); })();
File diff suppressed because it is too large Load Diff
-2
View File
@@ -1396,6 +1396,4 @@ describe('HtmlReporterV2', function() {
}); });
}); });
}); });
isNonMonkeyPatchableClass(jasmineUnderTest.HtmlReporterV2, setup);
}); });
-4
View File
@@ -63,8 +63,4 @@ describe('HtmlReporterV2Urls', function() {
return qs; return qs;
} }
}); });
isNonMonkeyPatchableClass(jasmineUnderTest.HtmlReporterV2Urls, function() {
return new jasmineUnderTest.HtmlReporterV2Urls({});
});
}); });
+43
View File
@@ -0,0 +1,43 @@
describe('HtmlSpecFilter', function() {
let env, deprecator;
beforeEach(function() {
deprecator = jasmine.createSpyObj('deprecator', [
'verboseDeprecations',
'addDeprecationWarning'
]);
env = new privateUnderTest.Env({ deprecator });
});
afterEach(function() {
env.cleanup_();
});
it('emits a deprecation warning', function() {
new jasmineUnderTest.HtmlSpecFilter({ env });
expect(deprecator.addDeprecationWarning).toHaveBeenCalledWith(
jasmine.anything(),
'HtmlReporter and HtmlSpecFilter are deprecated. Use HtmlReporterV2 instead.',
undefined
);
});
it('should match when no string is provided', function() {
const specFilter = new jasmineUnderTest.HtmlSpecFilter({ env });
expect(specFilter.matches('foo')).toBe(true);
expect(specFilter.matches('*bar')).toBe(true);
});
it('should only match the provided string', function() {
const specFilter = new jasmineUnderTest.HtmlSpecFilter({
env,
filterString: function() {
return 'foo';
}
});
expect(specFilter.matches('foo')).toBe(true);
expect(specFilter.matches('bar')).toBe(false);
});
});
-8
View File
@@ -77,12 +77,4 @@ describe('QueryString', function() {
expect(queryString.getParam('baz')).toBeFalsy(); expect(queryString.getParam('baz')).toBeFalsy();
}); });
}); });
isNonMonkeyPatchableClass(jasmineUnderTest.QueryString, function() {
return new jasmineUnderTest.QueryString({
getWindowLocation: function() {
return { search: '' };
}
});
});
}); });
+1 -1
View File
@@ -77,7 +77,7 @@ describe('npm package', function() {
}); });
it('has bootFiles', function() { it('has bootFiles', function() {
expect(this.packagedCore.files.bootFiles).toEqual(['boot.js']); expect(this.packagedCore.files.bootFiles).toEqual(['boot0.js', 'boot1.js']);
for (const fileName of this.packagedCore.files.bootFiles) { for (const fileName of this.packagedCore.files.bootFiles) {
expect(fileName).toExistInPath(this.packagedCore.files.bootDir); expect(fileName).toExistInPath(this.packagedCore.files.bootDir);
+2 -4
View File
@@ -6,14 +6,13 @@ module.exports = {
'core/util.js', 'core/util.js',
'core/Spec.js', 'core/Spec.js',
'core/Env.js', 'core/Env.js',
'core/JsApiReporter.js',
'core/PrettyPrinter.js', 'core/PrettyPrinter.js',
'core/Suite.js', 'core/Suite.js',
'core/**/*.js', 'core/**/*.js',
'html/**/*.js', 'html/**/*.js',
'**/*.js', '**/*.js',
'!boot/**.js', '!boot/**.js'
'!core/requireSuffix.js',
'!html/requireSuffix.js'
], ],
specDir: 'spec', specDir: 'spec',
specFiles: ['**/*[Ss]pec.js', '!npmPackage/**/*'], specFiles: ['**/*[Ss]pec.js', '!npmPackage/**/*'],
@@ -24,7 +23,6 @@ module.exports = {
'helpers/domHelpers.js', 'helpers/domHelpers.js',
'helpers/integrationMatchers.js', 'helpers/integrationMatchers.js',
'helpers/callerFilenameShim.js', 'helpers/callerFilenameShim.js',
'helpers/monkeyPatchingSpecs.js',
'helpers/defineJasmineUnderTest.js', 'helpers/defineJasmineUnderTest.js',
'helpers/resetEnv.js' 'helpers/resetEnv.js'
], ],
-1
View File
@@ -10,7 +10,6 @@
"helpers/integrationMatchers.js", "helpers/integrationMatchers.js",
"helpers/callerFilenameShim.js", "helpers/callerFilenameShim.js",
"helpers/overrideConsoleLogForCircleCi.js", "helpers/overrideConsoleLogForCircleCi.js",
"helpers/monkeyPatchingSpecs.js",
"helpers/nodeDefineJasmineUnderTest.js", "helpers/nodeDefineJasmineUnderTest.js",
"helpers/resetEnv.js" "helpers/resetEnv.js"
], ],
+2 -2
View File
@@ -8,10 +8,10 @@
<link rel="stylesheet" href="lib/jasmine-<%= jasmineVersion %>/jasmine.css"> <link rel="stylesheet" href="lib/jasmine-<%= jasmineVersion %>/jasmine.css">
<script src="lib/jasmine-<%= jasmineVersion %>/jasmine.js"></script> <script src="lib/jasmine-<%= jasmineVersion %>/jasmine.js"></script>
<script src="lib/jasmine-<%= jasmineVersion %>/boot0.js"></script>
<script src="lib/jasmine-<%= jasmineVersion %>/jasmine-html.js"></script> <script src="lib/jasmine-<%= jasmineVersion %>/jasmine-html.js"></script>
<script src="lib/jasmine-<%= jasmineVersion %>/boot0.js"></script>
<!-- optional: include a file here that configures the Jasmine env --> <!-- optional: include a file here that configures the Jasmine env -->
<script src="lib/jasmine-<%= jasmineVersion %>/boot.js"></script> <script src="lib/jasmine-<%= jasmineVersion %>/boot1.js"></script>
<!-- include source files here... --> <!-- include source files here... -->
<script src="src/Player.js"></script> <script src="src/Player.js"></script>
+44
View File
@@ -0,0 +1,44 @@
'use strict';
/**
This file starts the process of "booting" Jasmine. It initializes Jasmine,
makes its globals available, and creates the env. This file should be loaded
after `jasmine.js` and `jasmine_html.js`, but before `boot1.js` or any project
source files or spec files are loaded.
*/
(function() {
const jasmineRequire = window.jasmineRequire || require('./jasmine.js');
/**
* ## Require &amp; Instantiate
*
* Require Jasmine's core files. Specifically, this requires and attaches all of Jasmine's code to the `jasmine` reference.
*/
const jasmine = jasmineRequire.core(jasmineRequire),
global = jasmine.getGlobal();
global.jasmine = jasmine;
/**
* Since this is being run in a browser and the results should populate to an HTML page, require the HTML-specific Jasmine code, injecting the same reference.
*/
jasmineRequire.html(jasmine);
/**
* Create the Jasmine environment. This is used to run all specs in a project.
*/
const env = jasmine.getEnv();
/**
* ## The Global Interface
*
* Build up the functions that will be exposed as the Jasmine public interface. A project can customize, rename or alias any of these functions as desired, provided the implementation remains unchanged.
*/
const jasmineInterface = jasmineRequire.interface(jasmine, env);
/**
* Add all of the Jasmine global/public interface to the global scope, so a project can use the public interface directly. For example, calling `describe` in specs instead of `jasmine.getEnv().describe`.
*/
for (const property in jasmineInterface) {
global[property] = jasmineInterface[property];
}
})();
+13
View File
@@ -1,5 +1,18 @@
'use strict'; 'use strict';
/**
This file finishes 'booting' Jasmine, performing all of the necessary
initialization before executing the loaded environment and all of a project's
specs. This file should be loaded after `boot0.js` but before any project
source files or spec files are loaded. Thus this file can also be used to
customize Jasmine for a project.
If a project is using Jasmine via the standalone distribution, this file can
be customized directly. If you only wish to configure the Jasmine env, you
can load another file that calls `jasmine.getEnv().configure({...})`
after `boot0.js` is loaded and before this file is loaded.
*/
(function() { (function() {
const env = jasmine.getEnv(); const env = jasmine.getEnv();
const urls = new jasmine.HtmlReporterV2Urls(); const urls = new jasmine.HtmlReporterV2Urls();
+67 -51
View File
@@ -1,25 +1,69 @@
'use strict'; 'use strict';
const path = require('path'); /**
const fs = require('fs'); * Note: Only available on Node.
const { * @module jasmine-core
globals, */
installGlobals,
version,
private$
} = require('./jasmine-core/jasmine.js');
function reset() { const jasmineRequire = require('./jasmine-core/jasmine.js');
private$.currentEnv_ = null; module.exports = jasmineRequire;
const env = jasmine.getEnv({ suppressLoadErrors: true });
rebindInterface(env); 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'), const rootPath = path.join(__dirname, 'jasmine-core'),
bootFiles = ['boot.js'], bootFiles = ['boot0.js', 'boot1.js'],
legacyBootFiles = ['boot.js'],
cssFiles = [], cssFiles = [],
jsFiles = [], jsFiles = [],
jsFilesToSkip = ['jasmine.js'].concat(bootFiles); jsFilesToSkip = ['jasmine.js'].concat(bootFiles, legacyBootFiles);
fs.readdirSync(rootPath).forEach(function(file) { fs.readdirSync(rootPath).forEach(function(file) {
if (fs.statSync(path.join(rootPath, file)).isFile()) { if (fs.statSync(path.join(rootPath, file)).isFile()) {
@@ -36,40 +80,12 @@ fs.readdirSync(rootPath).forEach(function(file) {
} }
}); });
/** module.exports.files = {
* Note: Only available on Node. self: __filename,
* path: rootPath,
* In addition to the members documented here, this module's exports include all bootDir: rootPath,
* {@link globals}. bootFiles: bootFiles,
* @module jasmine-core cssFiles: cssFiles,
*/ jsFiles: ['jasmine.js'].concat(jsFiles),
module.exports = { imagesDir: path.join(__dirname, '../images')
...globals,
/**
* Copies Jasmine globals (jasmine, describe, it, etc) to the specified
* object or to globalThis.
* @function
* @param {object} [dest] - The object to copy globals to.
*/
installGlobals,
/**
* Returns the jasmine-core version.
* @function
*/
version,
/**
* Resets all of jasmine-core's state, including removing specs, suites, and
* reporters, and resetting configuration to the default.
* @function
*/
reset,
files: {
self: __filename,
path: rootPath,
bootDir: rootPath,
bootFiles: bootFiles,
cssFiles: cssFiles,
jsFiles: ['jasmine.js'].concat(jsFiles),
imagesDir: path.join(__dirname, '../images')
}
}; };
+4 -2
View File
@@ -1,4 +1,4 @@
getJasmineRequireObj().CallTracker = function(j$, private$) { getJasmineRequireObj().CallTracker = function(j$) {
'use strict'; 'use strict';
/** /**
@@ -125,7 +125,9 @@ getJasmineRequireObj().CallTracker = function(j$, private$) {
* @param {Function} [argsCloner] A function to use to clone the arguments. Defaults to a shallow cloning function. * @param {Function} [argsCloner] A function to use to clone the arguments. Defaults to a shallow cloning function.
* @function * @function
*/ */
this.saveArgumentsByValue = function(argsCloner = private$.util.cloneArgs) { this.saveArgumentsByValue = function(
argsCloner = j$.private.util.cloneArgs
) {
opts.cloneArgs = true; opts.cloneArgs = true;
opts.argsCloner = argsCloner; opts.argsCloner = argsCloner;
}; };
+2 -4
View File
@@ -1,4 +1,4 @@
getJasmineRequireObj().Clock = function(j$, private$) { getJasmineRequireObj().Clock = function(j$) {
'use strict'; 'use strict';
/* global process */ /* global process */
@@ -192,7 +192,7 @@ callbacks to execute _before_ running the next one.
setInterval[IsMockClockTimingFn] = true; setInterval[IsMockClockTimingFn] = true;
clearInterval[IsMockClockTimingFn] = true; clearInterval[IsMockClockTimingFn] = true;
Object.freeze(this); j$.private.deprecateMonkeyPatching(this);
return this; return this;
@@ -347,7 +347,5 @@ callbacks to execute _before_ running the next one.
}; };
Clock.IsMockClockTimingFn = IsMockClockTimingFn; Clock.IsMockClockTimingFn = IsMockClockTimingFn;
Object.freeze(Clock);
Object.freeze(Clock.prototype);
return Clock; return Clock;
}; };
+1 -1
View File
@@ -1,4 +1,4 @@
getJasmineRequireObj().CompleteOnFirstErrorSkipPolicy = function(j$, private$) { getJasmineRequireObj().CompleteOnFirstErrorSkipPolicy = function(j$) {
'use strict'; 'use strict';
function CompleteOnFirstErrorSkipPolicy(queueableFns) { function CompleteOnFirstErrorSkipPolicy(queueableFns) {
+1 -1
View File
@@ -1,4 +1,4 @@
getJasmineRequireObj().Configuration = function(j$, private$) { getJasmineRequireObj().Configuration = function(j$) {
'use strict'; 'use strict';
/** /**
+1 -1
View File
@@ -1,4 +1,4 @@
getJasmineRequireObj().DelayedFunctionScheduler = function(j$, private$) { getJasmineRequireObj().DelayedFunctionScheduler = function(j$) {
'use strict'; 'use strict';
function DelayedFunctionScheduler() { function DelayedFunctionScheduler() {
+5 -5
View File
@@ -1,4 +1,4 @@
getJasmineRequireObj().Deprecator = function(j$, private$) { getJasmineRequireObj().Deprecator = function(j$) {
'use strict'; 'use strict';
function Deprecator(topSuite) { function Deprecator(topSuite) {
@@ -25,7 +25,7 @@ getJasmineRequireObj().Deprecator = function(j$, private$) {
) { ) {
options = options || {}; options = options || {};
if (!this.verbose_ && !private$.isError(deprecation)) { if (!this.verbose_ && !j$.private.isError(deprecation)) {
if (this.toSuppress_.indexOf(deprecation) !== -1) { if (this.toSuppress_.indexOf(deprecation) !== -1) {
return; return;
} }
@@ -37,7 +37,7 @@ getJasmineRequireObj().Deprecator = function(j$, private$) {
}; };
Deprecator.prototype.log_ = function(runnable, deprecation, options) { Deprecator.prototype.log_ = function(runnable, deprecation, options) {
if (private$.isError(deprecation)) { if (j$.private.isError(deprecation)) {
// eslint-disable-next-line no-console // eslint-disable-next-line no-console
console.error(deprecation); console.error(deprecation);
return; return;
@@ -66,7 +66,7 @@ getJasmineRequireObj().Deprecator = function(j$, private$) {
}; };
Deprecator.prototype.stackTrace_ = function() { Deprecator.prototype.stackTrace_ = function() {
const formatter = new private$.ExceptionFormatter(); const formatter = new j$.private.ExceptionFormatter();
return formatter.stack(new Error()).replace(/^Error\n/m, ''); return formatter.stack(new Error()).replace(/^Error\n/m, '');
}; };
@@ -75,7 +75,7 @@ getJasmineRequireObj().Deprecator = function(j$, private$) {
runnable = this.topSuite_; runnable = this.topSuite_;
} }
if (private$.isError(deprecation)) { if (j$.private.isError(deprecation)) {
runnable.addDeprecationWarning(deprecation); runnable.addDeprecationWarning(deprecation);
return; return;
} }
+30 -32
View File
@@ -1,4 +1,4 @@
getJasmineRequireObj().Env = function(j$, private$) { getJasmineRequireObj().Env = function(j$) {
'use strict'; 'use strict';
const DEFAULT_IT_DESCRIBE_STACK_DEPTH = 3; const DEFAULT_IT_DESCRIBE_STACK_DEPTH = 3;
@@ -15,18 +15,18 @@ getJasmineRequireObj().Env = function(j$, private$) {
envOptions = envOptions || {}; envOptions = envOptions || {};
const self = this; const self = this;
const GlobalErrors = envOptions.GlobalErrors || private$.GlobalErrors; const GlobalErrors = envOptions.GlobalErrors || j$.private.GlobalErrors;
const global = envOptions.global || j$.getGlobal(); const global = envOptions.global || j$.getGlobal();
const realSetTimeout = global.setTimeout; const realSetTimeout = global.setTimeout;
const realClearTimeout = global.clearTimeout; const realClearTimeout = global.clearTimeout;
const stackClearer = private$.getStackClearer(global); const stackClearer = j$.private.getStackClearer(global);
this.clock = new private$.Clock( this.clock = new j$.private.Clock(
global, global,
function() { function() {
return new private$.DelayedFunctionScheduler(); return new j$.private.DelayedFunctionScheduler();
}, },
new private$.MockDate(global) new j$.private.MockDate(global)
); );
const globalErrors = new GlobalErrors( const globalErrors = new GlobalErrors(
@@ -54,7 +54,7 @@ getJasmineRequireObj().Env = function(j$, private$) {
}; };
})(); })();
const runableResources = new private$.RunableResources({ const runableResources = new j$.private.RunableResources({
getCurrentRunableId: function() { getCurrentRunableId: function() {
const r = runner.currentRunable(); const r = runner.currentRunable();
return r ? r.id : null; return r ? r.id : null;
@@ -67,7 +67,7 @@ getJasmineRequireObj().Env = function(j$, private$) {
let runner; let runner;
let parallelLoadingState = null; // 'specs', 'helpers', or null for non-parallel let parallelLoadingState = null; // 'specs', 'helpers', or null for non-parallel
const config = new private$.Configuration(); const config = new j$.private.Configuration();
if (!envOptions.suppressLoadErrors) { if (!envOptions.suppressLoadErrors) {
installGlobalErrors(); installGlobalErrors();
@@ -137,11 +137,11 @@ getJasmineRequireObj().Env = function(j$, private$) {
runableResources.customObjectFormatters().push(formatter); runableResources.customObjectFormatters().push(formatter);
}; };
private$.Expectation.addCoreMatchers(private$.matchers); j$.private.Expectation.addCoreMatchers(j$.private.matchers);
private$.Expectation.addAsyncCoreMatchers(private$.asyncMatchers); j$.private.Expectation.addAsyncCoreMatchers(j$.private.asyncMatchers);
const expectationFactory = function(actual, spec) { const expectationFactory = function(actual, spec) {
return private$.Expectation.factory({ return j$.private.Expectation.factory({
matchersUtil: runableResources.makeMatchersUtil(), matchersUtil: runableResources.makeMatchersUtil(),
customMatchers: runableResources.customMatchers(), customMatchers: runableResources.customMatchers(),
actual: actual, actual: actual,
@@ -174,7 +174,7 @@ getJasmineRequireObj().Env = function(j$, private$) {
}; };
const throwUnlessFactory = function(actual, spec) { const throwUnlessFactory = function(actual, spec) {
return private$.Expectation.factory({ return j$.private.Expectation.factory({
matchersUtil: runableResources.makeMatchersUtil(), matchersUtil: runableResources.makeMatchersUtil(),
customMatchers: runableResources.customMatchers(), customMatchers: runableResources.customMatchers(),
actual: actual, actual: actual,
@@ -183,7 +183,7 @@ getJasmineRequireObj().Env = function(j$, private$) {
}; };
const throwUnlessAsyncFactory = function(actual, spec) { const throwUnlessAsyncFactory = function(actual, spec) {
return private$.Expectation.asyncFactory({ return j$.private.Expectation.asyncFactory({
matchersUtil: runableResources.makeMatchersUtil(), matchersUtil: runableResources.makeMatchersUtil(),
customAsyncMatchers: runableResources.customAsyncMatchers(), customAsyncMatchers: runableResources.customAsyncMatchers(),
actual: actual, actual: actual,
@@ -198,7 +198,7 @@ getJasmineRequireObj().Env = function(j$, private$) {
error.matcherName !== undefined && error.passed !== undefined; error.matcherName !== undefined && error.passed !== undefined;
const result = isExpectationResult const result = isExpectationResult
? error ? error
: private$.buildExpectationResult({ : j$.private.buildExpectationResult({
error, error,
passed: false, passed: false,
matcherName: '', matcherName: '',
@@ -259,7 +259,7 @@ getJasmineRequireObj().Env = function(j$, private$) {
} }
const asyncExpectationFactory = function(actual, spec, runableType) { const asyncExpectationFactory = function(actual, spec, runableType) {
return private$.Expectation.asyncFactory({ return j$.private.Expectation.asyncFactory({
matchersUtil: runableResources.makeMatchersUtil(), matchersUtil: runableResources.makeMatchersUtil(),
customAsyncMatchers: runableResources.customAsyncMatchers(), customAsyncMatchers: runableResources.customAsyncMatchers(),
actual: actual, actual: actual,
@@ -318,10 +318,10 @@ getJasmineRequireObj().Env = function(j$, private$) {
(runner.currentRunable() || topSuite).handleException(e); (runner.currentRunable() || topSuite).handleException(e);
}; };
new private$.QueueRunner(options).execute(); new j$.private.QueueRunner(options).execute();
} }
const suiteBuilder = new private$.SuiteBuilder({ const suiteBuilder = new j$.private.SuiteBuilder({
env: this, env: this,
expectationFactory, expectationFactory,
asyncExpectationFactory, asyncExpectationFactory,
@@ -330,7 +330,7 @@ getJasmineRequireObj().Env = function(j$, private$) {
}); });
topSuite = suiteBuilder.topSuite; topSuite = suiteBuilder.topSuite;
const deprecator = const deprecator =
envOptions?.deprecator ?? new private$.Deprecator(topSuite); envOptions?.deprecator ?? new j$.private.Deprecator(topSuite);
/** /**
* Provides the root suite, through which all suites and specs can be * Provides the root suite, through which all suites and specs can be
@@ -350,23 +350,23 @@ getJasmineRequireObj().Env = function(j$, private$) {
* @interface Reporter * @interface Reporter
* @see custom_reporter * @see custom_reporter
*/ */
reportDispatcher = new private$.ReportDispatcher( reportDispatcher = new j$.private.ReportDispatcher(
private$.reporterEvents, j$.private.reporterEvents,
function(options) { function(options) {
options.SkipPolicy = private$.NeverSkipPolicy; options.SkipPolicy = j$.private.NeverSkipPolicy;
return runQueue(options); return runQueue(options);
}, },
recordLateError recordLateError
); );
runner = new private$.Runner({ runner = new j$.private.Runner({
topSuite, topSuite,
totalSpecsDefined: () => suiteBuilder.totalSpecsDefined, totalSpecsDefined: () => suiteBuilder.totalSpecsDefined,
focusedRunables: () => suiteBuilder.focusedRunables, focusedRunables: () => suiteBuilder.focusedRunables,
runableResources, runableResources,
reportDispatcher, reportDispatcher,
runQueue, runQueue,
TreeProcessor: private$.TreeProcessor, TreeProcessor: j$.private.TreeProcessor,
globalErrors, globalErrors,
getConfig: () => config getConfig: () => config
}); });
@@ -411,7 +411,7 @@ getJasmineRequireObj().Env = function(j$, private$) {
// Karma incorrectly loads jasmine-core as an ES module. It isn't one, // Karma incorrectly loads jasmine-core as an ES module. It isn't one,
// and we don't test that configuration. Warn about it. // and we don't test that configuration. Warn about it.
if (private$.loadedAsBrowserEsm) { if (j$.private.loadedAsBrowserEsm) {
this.deprecated( this.deprecated(
"jasmine-core isn't an ES module but it was loaded as one. This is not a supported configuration." "jasmine-core isn't an ES module but it was loaded as one. This is not a supported configuration."
); );
@@ -540,7 +540,7 @@ getJasmineRequireObj().Env = function(j$, private$) {
try { try {
const maybePromise = fn(spy); const maybePromise = fn(spy);
if (!private$.isPromiseLike(maybePromise)) { if (!j$.private.isPromiseLike(maybePromise)) {
throw new Error( throw new Error(
'The callback to spyOnGlobalErrorsAsync must be an async or promise-returning function' 'The callback to spyOnGlobalErrorsAsync must be an async or promise-returning function'
); );
@@ -783,7 +783,7 @@ getJasmineRequireObj().Env = function(j$, private$) {
}; };
this.pending = function(message) { this.pending = function(message) {
let fullMessage = private$.Spec.pendingSpecExceptionMessage; let fullMessage = j$.private.Spec.pendingSpecExceptionMessage;
if (message) { if (message) {
fullMessage += message; fullMessage += message;
} }
@@ -802,7 +802,7 @@ getJasmineRequireObj().Env = function(j$, private$) {
message += ': '; message += ': ';
if (error.message) { if (error.message) {
message += error.message; message += error.message;
} else if (private$.isString(error)) { } else if (j$.private.isString(error)) {
message += error; message += error;
} else { } else {
// pretty print all kind of objects. This includes arrays. // pretty print all kind of objects. This includes arrays.
@@ -828,7 +828,7 @@ getJasmineRequireObj().Env = function(j$, private$) {
this.pp = function(value) { this.pp = function(value) {
const pp = runner.currentRunable() const pp = runner.currentRunable()
? runableResources.makePrettyPrinter() ? runableResources.makePrettyPrinter()
: private$.basicPrettyPrinter; : j$.private.basicPrettyPrinter;
return pp(value); return pp(value);
}; };
@@ -836,18 +836,16 @@ getJasmineRequireObj().Env = function(j$, private$) {
uninstallGlobalErrors(); uninstallGlobalErrors();
}; };
Object.freeze(this); j$.private.deprecateMonkeyPatching(this, ['deprecated']);
} }
function indirectCallerFilename(depth) { function indirectCallerFilename(depth) {
const frames = new private$.StackTrace(new Error()).frames; const frames = new j$.private.StackTrace(new Error()).frames;
// The specified frame should always exist except in Jasmine's own tests, // The specified frame should always exist except in Jasmine's own tests,
// which bypass the global it/describe layer, but could be absent in case // which bypass the global it/describe layer, but could be absent in case
// of misconfiguration. Don't crash if it's absent. // of misconfiguration. Don't crash if it's absent.
return frames[depth] && frames[depth].file; return frames[depth] && frames[depth].file;
} }
Object.freeze(Env);
Object.freeze(Env.prototype);
return Env; return Env;
}; };
+4 -4
View File
@@ -1,4 +1,4 @@
getJasmineRequireObj().ExceptionFormatter = function(j$, private$) { getJasmineRequireObj().ExceptionFormatter = function(j$) {
'use strict'; 'use strict';
const ignoredProperties = [ const ignoredProperties = [
@@ -17,7 +17,7 @@ getJasmineRequireObj().ExceptionFormatter = function(j$, private$) {
function ExceptionFormatter(options) { function ExceptionFormatter(options) {
const jasmineFile = const jasmineFile =
(options && options.jasmineFile) || private$.util.jasmineFile(); (options && options.jasmineFile) || j$.private.util.jasmineFile();
this.message = function(error) { this.message = function(error) {
let message = ''; let message = '';
@@ -61,7 +61,7 @@ getJasmineRequireObj().ExceptionFormatter = function(j$, private$) {
lines.pop(); lines.pop();
} }
const stackTrace = new private$.StackTrace(error); const stackTrace = new j$.private.StackTrace(error);
lines = lines.concat(filterJasmine(stackTrace)); lines = lines.concat(filterJasmine(stackTrace));
if (messageHandling === 'require') { if (messageHandling === 'require') {
@@ -128,7 +128,7 @@ getJasmineRequireObj().ExceptionFormatter = function(j$, private$) {
if (!empty) { if (!empty) {
return ( return (
'error properties: ' + private$.basicPrettyPrinter(result) + '\n' 'error properties: ' + j$.private.basicPrettyPrinter(result) + '\n'
); );
} }
+5 -5
View File
@@ -1,4 +1,4 @@
getJasmineRequireObj().Expectation = function(j$, private$) { getJasmineRequireObj().Expectation = function(j$) {
'use strict'; 'use strict';
/** /**
@@ -6,7 +6,7 @@ getJasmineRequireObj().Expectation = function(j$, private$) {
* @namespace matchers * @namespace matchers
*/ */
function Expectation(options) { function Expectation(options) {
this.expector = new private$.Expector(options); this.expector = new j$.private.Expector(options);
const customMatchers = options.customMatchers || {}; const customMatchers = options.customMatchers || {};
for (const matcherName in customMatchers) { for (const matcherName in customMatchers) {
@@ -82,7 +82,7 @@ getJasmineRequireObj().Expectation = function(j$, private$) {
* @namespace async-matchers * @namespace async-matchers
*/ */
function AsyncExpectation(options) { function AsyncExpectation(options) {
this.expector = new private$.Expector(options); this.expector = new j$.private.Expector(options);
const customAsyncMatchers = options.customAsyncMatchers || {}; const customAsyncMatchers = options.customAsyncMatchers || {};
for (const matcherName in customAsyncMatchers) { for (const matcherName in customAsyncMatchers) {
@@ -175,7 +175,7 @@ getJasmineRequireObj().Expectation = function(j$, private$) {
function negatedFailureMessage(result, matcherName, args, matchersUtil) { function negatedFailureMessage(result, matcherName, args, matchersUtil) {
if (result.message) { if (result.message) {
if (private$.isFunction(result.message)) { if (j$.private.isFunction(result.message)) {
return result.message(); return result.message();
} else { } else {
return result.message; return result.message;
@@ -220,7 +220,7 @@ getJasmineRequireObj().Expectation = function(j$, private$) {
return function(actual) { return function(actual) {
const matcherArgs = arguments; const matcherArgs = arguments;
return private$.isPending(actual).then(function(isPending) { return j$.private.isPending(actual).then(function(isPending) {
if (isPending) { if (isPending) {
return { return {
pass: false, pass: false,
+3 -3
View File
@@ -1,4 +1,4 @@
getJasmineRequireObj().Expector = function(j$, private$) { getJasmineRequireObj().Expector = function(j$) {
'use strict'; 'use strict';
function Expector(options) { function Expector(options) {
@@ -7,7 +7,7 @@ getJasmineRequireObj().Expector = function(j$, private$) {
}; };
this.actual = options.actual; this.actual = options.actual;
this.addExpectationResult = options.addExpectationResult || function() {}; this.addExpectationResult = options.addExpectationResult || function() {};
this.filters = new private$.ExpectationFilterChain(); this.filters = new j$.private.ExpectationFilterChain();
} }
Expector.prototype.instantiateMatcher = function( Expector.prototype.instantiateMatcher = function(
@@ -41,7 +41,7 @@ getJasmineRequireObj().Expector = function(j$, private$) {
this.matchersUtil, this.matchersUtil,
args args
); );
} else if (private$.isFunction(result.message)) { } else if (j$.private.isFunction(result.message)) {
return result.message(); return result.message();
} else { } else {
return result.message; return result.message;
+4 -4
View File
@@ -1,4 +1,4 @@
getJasmineRequireObj().GlobalErrors = function(j$, private$) { getJasmineRequireObj().GlobalErrors = function(j$) {
'use strict'; 'use strict';
class GlobalErrors { class GlobalErrors {
@@ -26,7 +26,7 @@ getJasmineRequireObj().GlobalErrors = function(j$, private$) {
if ( if (
global.process && global.process &&
global.process.listeners && global.process.listeners &&
private$.isFunction(global.process.on) j$.private.isFunction(global.process.on)
) { ) {
this.#adapter = new NodeAdapter(global, dispatch); this.#adapter = new NodeAdapter(global, dispatch);
} else { } else {
@@ -183,7 +183,7 @@ getJasmineRequireObj().GlobalErrors = function(j$, private$) {
const jasmineMessage = 'Unhandled promise rejection: ' + event.reason; const jasmineMessage = 'Unhandled promise rejection: ' + event.reason;
let reason; let reason;
if (private$.isError(event.reason)) { if (j$.private.isError(event.reason)) {
reason = event.reason; reason = event.reason;
reason.jasmineMessage = jasmineMessage; reason.jasmineMessage = jasmineMessage;
} else { } else {
@@ -262,7 +262,7 @@ getJasmineRequireObj().GlobalErrors = function(j$, private$) {
jasmineMessagePrefix = 'Uncaught exception'; jasmineMessagePrefix = 'Uncaught exception';
} }
if (private$.isError(error)) { if (j$.private.isError(error)) {
error.jasmineMessage = jasmineMessagePrefix + ': ' + error; error.jasmineMessage = jasmineMessagePrefix + ': ' + error;
return error; return error;
} else { } else {
+133
View File
@@ -0,0 +1,133 @@
getJasmineRequireObj().JsApiReporter = function(j$) {
'use strict';
// TODO: remove in 7.0.
/**
* @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.
* @class
* @hideconstructor
* @deprecated In most cases jsApiReporter can simply be removed. If necessary, it can be replaced with a {@link Reporter|custom reporter}.
*/
function JsApiReporter(options) {
const timer = options.timer || new j$.Timer();
let status = 'loaded';
this.started = false;
this.finished = false;
this.runDetails = {};
this.jasmineStarted = function() {
this.started = true;
status = 'started';
timer.start();
};
let executionTime;
this.jasmineDone = function(runDetails) {
this.finished = true;
this.runDetails = runDetails;
executionTime = timer.elapsed();
status = 'done';
};
/**
* Get the current status for the Jasmine environment.
* @name jsApiReporter#status
* @since 2.0.0
* @function
* @return {String} - One of `loaded`, `started`, or `done`
*/
this.status = function() {
return status;
};
const suites = [],
suites_hash = {};
this.suiteStarted = function(result) {
suites_hash[result.id] = result;
};
this.suiteDone = function(result) {
storeSuite(result);
};
/**
* Get the results for a set of suites.
*
* Retrievable in slices for easier serialization.
* @name jsApiReporter#suiteResults
* @since 2.1.0
* @function
* @param {Number} index - The position in the suites list to start from.
* @param {Number} length - Maximum number of suite results to return.
* @return {SuiteResult[]}
*/
this.suiteResults = function(index, length) {
return suites.slice(index, index + length);
};
function storeSuite(result) {
suites.push(result);
suites_hash[result.id] = result;
}
/**
* Get all of the suites in a single object, with their `id` as the key.
* @name jsApiReporter#suites
* @since 2.0.0
* @function
* @return {Object} - Map of suite id to {@link SuiteResult}
*/
this.suites = function() {
return suites_hash;
};
const specs = [];
this.specDone = function(result) {
specs.push(result);
};
/**
* Get the results for a set of specs.
*
* Retrievable in slices for easier serialization.
* @name jsApiReporter#specResults
* @since 2.0.0
* @function
* @param {Number} index - The position in the specs list to start from.
* @param {Number} length - Maximum number of specs results to return.
* @return {SpecDoneEvent[]}
*/
this.specResults = function(index, length) {
return specs.slice(index, index + length);
};
/**
* Get all spec results.
* @name jsApiReporter#specs
* @since 2.0.0
* @function
* @return {SpecDoneEvent[]}
*/
this.specs = function() {
return specs;
};
/**
* Get the number of milliseconds it took for the full Jasmine suite to run.
* @name jsApiReporter#executionTime
* @since 2.0.0
* @function
* @return {Number}
*/
this.executionTime = function() {
return executionTime;
};
}
return JsApiReporter;
};
+1 -1
View File
@@ -1,4 +1,4 @@
getJasmineRequireObj().MockDate = function(j$, private$) { getJasmineRequireObj().MockDate = function(j$) {
'use strict'; 'use strict';
function MockDate(global) { function MockDate(global) {
+1 -1
View File
@@ -1,4 +1,4 @@
getJasmineRequireObj().NeverSkipPolicy = function(j$, private$) { getJasmineRequireObj().NeverSkipPolicy = function(j$) {
'use strict'; 'use strict';
function NeverSkipPolicy(queueableFns) {} function NeverSkipPolicy(queueableFns) {}
+45 -46
View File
@@ -1,4 +1,4 @@
getJasmineRequireObj().ParallelReportDispatcher = function(j$, private$) { getJasmineRequireObj().ParallelReportDispatcher = function(j$) {
'use strict'; 'use strict';
/** /**
@@ -15,43 +15,43 @@ getJasmineRequireObj().ParallelReportDispatcher = function(j$, private$) {
* Jasmine specs run in. Doing so will break Jasmine's error handling. * Jasmine specs run in. Doing so will break Jasmine's error handling.
* @param onError {function} Function called when an unhandled exception, unhandled promise rejection, or explicit reporter failure occurs * @param onError {function} Function called when an unhandled exception, unhandled promise rejection, or explicit reporter failure occurs
*/ */
class ParallelReportDispatcher { function ParallelReportDispatcher(onError, deps = {}) {
constructor(onError, deps = {}) { const ReportDispatcher =
const ReportDispatcher = deps.ReportDispatcher || j$.private.ReportDispatcher;
deps.ReportDispatcher || private$.ReportDispatcher; const QueueRunner = deps.QueueRunner || j$.private.QueueRunner;
const QueueRunner = deps.QueueRunner || private$.QueueRunner; const globalErrors = deps.globalErrors || new j$.private.GlobalErrors();
const globalErrors = deps.globalErrors || new private$.GlobalErrors(); const dispatcher = new ReportDispatcher(
const dispatcher = new ReportDispatcher( j$.private.reporterEvents,
private$.reporterEvents, function(queueRunnerOptions) {
function(queueRunnerOptions) { queueRunnerOptions = {
queueRunnerOptions = { ...queueRunnerOptions,
...queueRunnerOptions, globalErrors,
globalErrors, timeout: { setTimeout, clearTimeout },
timeout: { setTimeout, clearTimeout }, fail: function(error) {
fail: function(error) { // A callback-style async reporter called either done.fail()
// A callback-style async reporter called either done.fail() // or done(anError).
// or done(anError). if (!error) {
if (!error) { error = new Error('A reporter called done.fail()');
error = new Error('A reporter called done.fail()');
}
onError(error);
},
onException: function(error) {
// A reporter method threw an exception or returned a rejected
// promise, or there was an unhandled exception or unhandled promise
// rejection while an asynchronous reporter method was running.
onError(error);
} }
};
new QueueRunner(queueRunnerOptions).execute();
},
function(error) {
// A reporter called done() more than once.
onError(error);
}
);
onError(error);
},
onException: function(error) {
// A reporter method threw an exception or returned a rejected
// promise, or there was an unhandled exception or unhandled promise
// rejection while an asynchronous reporter method was running.
onError(error);
}
};
new QueueRunner(queueRunnerOptions).execute();
},
function(error) {
// A reporter called done() more than once.
onError(error);
}
);
const self = {
/** /**
* Adds a reporter to the list of reporters that events will be dispatched to. * Adds a reporter to the list of reporters that events will be dispatched to.
* @function * @function
@@ -59,13 +59,13 @@ getJasmineRequireObj().ParallelReportDispatcher = function(j$, private$) {
* @param {Reporter} reporterToAdd The reporter to be added. * @param {Reporter} reporterToAdd The reporter to be added.
* @see custom_reporter * @see custom_reporter
*/ */
this.addReporter = dispatcher.addReporter.bind(dispatcher); addReporter: dispatcher.addReporter.bind(dispatcher),
/** /**
* Clears all registered reporters. * Clears all registered reporters.
* @function * @function
* @name ParallelReportDispatcher#clearReporters * @name ParallelReportDispatcher#clearReporters
*/ */
this.clearReporters = dispatcher.clearReporters.bind(dispatcher); clearReporters: dispatcher.clearReporters.bind(dispatcher),
/** /**
* Installs a global error handler. After this method is called, any * Installs a global error handler. After this method is called, any
* unhandled exceptions or unhandled promise rejections will be passed to * unhandled exceptions or unhandled promise rejections will be passed to
@@ -73,25 +73,24 @@ getJasmineRequireObj().ParallelReportDispatcher = function(j$, private$) {
* @function * @function
* @name ParallelReportDispatcher#installGlobalErrors * @name ParallelReportDispatcher#installGlobalErrors
*/ */
this.installGlobalErrors = globalErrors.install.bind(globalErrors); installGlobalErrors: globalErrors.install.bind(globalErrors),
/** /**
* Uninstalls the global error handler. * Uninstalls the global error handler.
* @function * @function
* @name ParallelReportDispatcher#uninstallGlobalErrors * @name ParallelReportDispatcher#uninstallGlobalErrors
*/ */
this.uninstallGlobalErrors = function() { uninstallGlobalErrors: function() {
// late-bind uninstall because it doesn't exist until install is called // late-bind uninstall because it doesn't exist until install is called
globalErrors.uninstall(globalErrors); globalErrors.uninstall(globalErrors);
};
for (const eventName of private$.reporterEvents) {
this[eventName] = dispatcher[eventName].bind(dispatcher);
} }
};
Object.freeze(this); for (const eventName of j$.private.reporterEvents) {
self[eventName] = dispatcher[eventName].bind(dispatcher);
} }
return self;
} }
Object.freeze(ParallelReportDispatcher.prototype);
return ParallelReportDispatcher; return ParallelReportDispatcher;
}; };
+11 -11
View File
@@ -1,4 +1,4 @@
getJasmineRequireObj().makePrettyPrinter = function(j$, private$) { getJasmineRequireObj().makePrettyPrinter = function(j$) {
'use strict'; 'use strict';
class SinglePrettyPrintRun { class SinglePrettyPrintRun {
@@ -28,7 +28,7 @@ getJasmineRequireObj().makePrettyPrinter = function(j$, private$) {
this.emitScalar('<global>'); this.emitScalar('<global>');
} else if (value.jasmineToString) { } else if (value.jasmineToString) {
this.emitScalar(value.jasmineToString(this.pp_)); this.emitScalar(value.jasmineToString(this.pp_));
} else if (private$.isString(value)) { } else if (j$.private.isString(value)) {
this.emitString(value); this.emitString(value);
} else if (j$.isSpy(value)) { } else if (j$.isSpy(value)) {
this.emitScalar('spy on ' + value.and.identity); this.emitScalar('spy on ' + value.and.identity);
@@ -42,7 +42,7 @@ getJasmineRequireObj().makePrettyPrinter = function(j$, private$) {
} else { } else {
this.emitScalar('Function'); this.emitScalar('Function');
} }
} else if (private$.isDomNode(value)) { } else if (j$.private.isDomNode(value)) {
if (value.tagName) { if (value.tagName) {
this.emitDomElement(value); this.emitDomElement(value);
} else { } else {
@@ -50,11 +50,11 @@ getJasmineRequireObj().makePrettyPrinter = function(j$, private$) {
} }
} else if (value instanceof Date) { } else if (value instanceof Date) {
this.emitScalar('Date(' + value + ')'); this.emitScalar('Date(' + value + ')');
} else if (private$.isSet(value)) { } else if (j$.private.isSet(value)) {
this.emitSet(value); this.emitSet(value);
} else if (private$.isMap(value)) { } else if (j$.private.isMap(value)) {
this.emitMap(value); this.emitMap(value);
} else if (private$.isTypedArray(value)) { } else if (j$.private.isTypedArray(value)) {
this.emitTypedArray(value); this.emitTypedArray(value);
} else if ( } else if (
value.toString && value.toString &&
@@ -74,7 +74,7 @@ getJasmineRequireObj().makePrettyPrinter = function(j$, private$) {
(Array.isArray(value) ? 'Array' : 'Object') + (Array.isArray(value) ? 'Array' : 'Object') +
'>' '>'
); );
} else if (Array.isArray(value) || private$.isA('Object', value)) { } else if (Array.isArray(value) || j$.private.isA('Object', value)) {
this.seen.push(value); this.seen.push(value);
if (Array.isArray(value)) { if (Array.isArray(value)) {
this.emitArray(value); this.emitArray(value);
@@ -99,7 +99,7 @@ getJasmineRequireObj().makePrettyPrinter = function(j$, private$) {
} }
iterateObject(obj, fn) { iterateObject(obj, fn) {
const objKeys = private$.MatchersUtil.keys(obj, Array.isArray(obj)); const objKeys = j$.private.MatchersUtil.keys(obj, Array.isArray(obj));
const length = Math.min(objKeys.length, j$.MAX_PRETTY_PRINT_ARRAY_LENGTH); const length = Math.min(objKeys.length, j$.MAX_PRETTY_PRINT_ARRAY_LENGTH);
for (let i = 0; i < length; i++) { for (let i = 0; i < length; i++) {
@@ -208,7 +208,7 @@ getJasmineRequireObj().makePrettyPrinter = function(j$, private$) {
const ctor = obj.constructor; const ctor = obj.constructor;
const constructorName = const constructorName =
typeof ctor === 'function' && obj instanceof ctor typeof ctor === 'function' && obj instanceof ctor
? private$.fnNameFor(obj.constructor) ? j$.private.fnNameFor(obj.constructor)
: 'null'; : 'null';
this.append(constructorName); this.append(constructorName);
@@ -238,7 +238,7 @@ getJasmineRequireObj().makePrettyPrinter = function(j$, private$) {
} }
emitTypedArray(arr) { emitTypedArray(arr) {
const constructorName = private$.fnNameFor(arr.constructor); const constructorName = j$.private.fnNameFor(arr.constructor);
const limitedArray = Array.prototype.slice.call( const limitedArray = Array.prototype.slice.call(
arr, arr,
0, 0,
@@ -307,7 +307,7 @@ getJasmineRequireObj().makePrettyPrinter = function(j$, private$) {
// iframe, web worker) // iframe, web worker)
try { try {
return ( return (
private$.isFunction(value.toString) && j$.private.isFunction(value.toString) &&
value.toString !== Object.prototype.toString && value.toString !== Object.prototype.toString &&
value.toString() !== Object.prototype.toString.call(value) value.toString() !== Object.prototype.toString.call(value)
); );
+8 -8
View File
@@ -1,11 +1,11 @@
getJasmineRequireObj().QueueRunner = function(j$, private$) { getJasmineRequireObj().QueueRunner = function(j$) {
'use strict'; 'use strict';
let nextid = 1; let nextid = 1;
function StopExecutionError() {} function StopExecutionError() {}
StopExecutionError.prototype = new Error(); StopExecutionError.prototype = new Error();
private$.StopExecutionError = StopExecutionError; j$.private.StopExecutionError = StopExecutionError;
function once(fn, onTwice) { function once(fn, onTwice) {
let called = false; let called = false;
@@ -58,7 +58,7 @@ getJasmineRequireObj().QueueRunner = function(j$, private$) {
}; };
this.onException = attrs.onException || emptyFn; this.onException = attrs.onException || emptyFn;
this.onMultipleDone = attrs.onMultipleDone || fallbackOnMultipleDone; this.onMultipleDone = attrs.onMultipleDone || fallbackOnMultipleDone;
this.userContext = attrs.userContext || new private$.UserContext(); this.userContext = attrs.userContext || new j$.private.UserContext();
this.timeout = attrs.timeout || { this.timeout = attrs.timeout || {
setTimeout: setTimeout, setTimeout: setTimeout,
clearTimeout: clearTimeout clearTimeout: clearTimeout
@@ -69,7 +69,7 @@ getJasmineRequireObj().QueueRunner = function(j$, private$) {
popListener: emptyFn popListener: emptyFn
}; };
const SkipPolicy = attrs.SkipPolicy || private$.NeverSkipPolicy; const SkipPolicy = attrs.SkipPolicy || j$.private.NeverSkipPolicy;
this.skipPolicy_ = new SkipPolicy(this.queueableFns); this.skipPolicy_ = new SkipPolicy(this.queueableFns);
this.errored_ = false; this.errored_ = false;
@@ -192,7 +192,7 @@ getJasmineRequireObj().QueueRunner = function(j$, private$) {
if (queueableFn.fn.length === 0) { if (queueableFn.fn.length === 0) {
maybeThenable = queueableFn.fn.call(this.userContext); maybeThenable = queueableFn.fn.call(this.userContext);
if (maybeThenable && private$.isFunction(maybeThenable.then)) { if (maybeThenable && j$.private.isFunction(maybeThenable.then)) {
maybeThenable.then( maybeThenable.then(
wrapInPromiseResolutionHandler(next), wrapInPromiseResolutionHandler(next),
onPromiseRejection onPromiseRejection
@@ -262,11 +262,11 @@ getJasmineRequireObj().QueueRunner = function(j$, private$) {
}; };
QueueRunner.prototype.diagnoseConflictingAsync_ = function(fn, retval) { QueueRunner.prototype.diagnoseConflictingAsync_ = function(fn, retval) {
if (retval && private$.isFunction(retval.then)) { if (retval && j$.private.isFunction(retval.then)) {
// Issue a warning that matches the user's code. // Issue a warning that matches the user's code.
// Omit the stack trace because there's almost certainly no user code // Omit the stack trace because there's almost certainly no user code
// on the stack at this point. // on the stack at this point.
if (private$.isAsyncFunction(fn)) { if (j$.private.isAsyncFunction(fn)) {
this.onException( this.onException(
new Error( new Error(
'An asynchronous before/it/after ' + 'An asynchronous before/it/after ' +
@@ -290,7 +290,7 @@ getJasmineRequireObj().QueueRunner = function(j$, private$) {
function wrapInPromiseResolutionHandler(fn) { function wrapInPromiseResolutionHandler(fn) {
return function(maybeArg) { return function(maybeArg) {
if (private$.isError(maybeArg)) { if (j$.private.isError(maybeArg)) {
fn(maybeArg); fn(maybeArg);
} else { } else {
fn(); fn();
+1 -1
View File
@@ -1,4 +1,4 @@
getJasmineRequireObj().ReportDispatcher = function(j$, private$) { getJasmineRequireObj().ReportDispatcher = function(j$) {
'use strict'; 'use strict';
function ReportDispatcher(methods, runQueue, onLateError) { function ReportDispatcher(methods, runQueue, onLateError) {
+8 -8
View File
@@ -1,4 +1,4 @@
getJasmineRequireObj().RunableResources = function(j$, private$) { getJasmineRequireObj().RunableResources = function(j$) {
'use strict'; 'use strict';
class RunableResources { class RunableResources {
@@ -7,7 +7,7 @@ getJasmineRequireObj().RunableResources = function(j$, private$) {
this.getCurrentRunableId_ = options.getCurrentRunableId; this.getCurrentRunableId_ = options.getCurrentRunableId;
this.globalErrors_ = options.globalErrors; this.globalErrors_ = options.globalErrors;
this.spyFactory = new private$.SpyFactory( this.spyFactory = new j$.private.SpyFactory(
() => { () => {
if (this.getCurrentRunableId_()) { if (this.getCurrentRunableId_()) {
return this.customSpyStrategies(); return this.customSpyStrategies();
@@ -19,7 +19,7 @@ getJasmineRequireObj().RunableResources = function(j$, private$) {
() => this.makeMatchersUtil() () => this.makeMatchersUtil()
); );
this.spyRegistry = new private$.SpyRegistry({ this.spyRegistry = new j$.private.SpyRegistry({
currentSpies: () => this.spies(), currentSpies: () => this.spies(),
createSpy: (name, originalFn) => createSpy: (name, originalFn) =>
this.spyFactory.createSpy(name, originalFn) this.spyFactory.createSpy(name, originalFn)
@@ -50,7 +50,7 @@ getJasmineRequireObj().RunableResources = function(j$, private$) {
]; ];
for (const k of toClone) { for (const k of toClone) {
newRes[k] = private$.util.clone(parentRes[k]); newRes[k] = j$.private.util.clone(parentRes[k]);
} }
} }
} }
@@ -128,18 +128,18 @@ getJasmineRequireObj().RunableResources = function(j$, private$) {
} }
makePrettyPrinter() { makePrettyPrinter() {
return private$.makePrettyPrinter(this.customObjectFormatters()); return j$.private.makePrettyPrinter(this.customObjectFormatters());
} }
makeMatchersUtil() { makeMatchersUtil() {
if (this.getCurrentRunableId_()) { if (this.getCurrentRunableId_()) {
return new private$.MatchersUtil({ return new j$.private.MatchersUtil({
customTesters: this.customEqualityTesters(), customTesters: this.customEqualityTesters(),
pp: this.makePrettyPrinter() pp: this.makePrettyPrinter()
}); });
} else { } else {
return new private$.MatchersUtil({ return new j$.private.MatchersUtil({
pp: private$.basicPrettyPrinter pp: j$.private.basicPrettyPrinter
}); });
} }
} }
+5 -5
View File
@@ -1,4 +1,4 @@
getJasmineRequireObj().Runner = function(j$, private$) { getJasmineRequireObj().Runner = function(j$) {
'use strict'; 'use strict';
class Runner { class Runner {
@@ -26,7 +26,7 @@ getJasmineRequireObj().Runner = function(j$, private$) {
this.#reportDispatcher = options.reportDispatcher; this.#reportDispatcher = options.reportDispatcher;
this.#getConfig = options.getConfig; this.#getConfig = options.getConfig;
this.#executedBefore = false; this.#executedBefore = false;
this.#currentRunableTracker = new private$.CurrentRunableTracker(); this.#currentRunableTracker = new j$.private.CurrentRunableTracker();
} }
currentSpec() { currentSpec() {
@@ -66,9 +66,9 @@ getJasmineRequireObj().Runner = function(j$, private$) {
} }
} }
const order = new private$.Order({ const order = new j$.private.Order({
random: config.random, random: config.random,
seed: private$.isNumber(config.seed) ? config.seed + '' : config.seed seed: j$.private.isNumber(config.seed) ? config.seed + '' : config.seed
}); });
const treeProcessor = new this.#TreeProcessor({ const treeProcessor = new this.#TreeProcessor({
@@ -112,7 +112,7 @@ getJasmineRequireObj().Runner = function(j$, private$) {
}); });
this.#currentRunableTracker.pushSuite(this.#topSuite); this.#currentRunableTracker.pushSuite(this.#topSuite);
const treeRunner = new private$.TreeRunner({ const treeRunner = new j$.private.TreeRunner({
executionTree: this.#executionTree, executionTree: this.#executionTree,
globalErrors: this.#globalErrors, globalErrors: this.#globalErrors,
runableResources: this.#runableResources, runableResources: this.#runableResources,
+1 -1
View File
@@ -1,4 +1,4 @@
getJasmineRequireObj().SkipAfterBeforeAllErrorPolicy = function(j$, private$) { getJasmineRequireObj().SkipAfterBeforeAllErrorPolicy = function(j$) {
'use strict'; 'use strict';
function SkipAfterBeforeAllErrorPolicy(queueableFns) { function SkipAfterBeforeAllErrorPolicy(queueableFns) {
+7 -7
View File
@@ -1,4 +1,4 @@
getJasmineRequireObj().Spec = function(j$, private$) { getJasmineRequireObj().Spec = function(j$) {
'use strict'; 'use strict';
class Spec { class Spec {
@@ -46,7 +46,7 @@ getJasmineRequireObj().Spec = function(j$, private$) {
} }
addExpectationResult(passed, data, isError) { addExpectationResult(passed, data, isError) {
const expectationResult = private$.buildExpectationResult(data); const expectationResult = j$.private.buildExpectationResult(data);
if (passed) { if (passed) {
this.#executionState.passedExpectations.push(expectationResult); this.#executionState.passedExpectations.push(expectationResult);
@@ -58,7 +58,7 @@ getJasmineRequireObj().Spec = function(j$, private$) {
} }
if (this.#throwOnExpectationFailure && !isError) { if (this.#throwOnExpectationFailure && !isError) {
throw new private$.errors.ExpectationFailed(); throw new j$.private.errors.ExpectationFailed();
} }
} }
} }
@@ -72,10 +72,10 @@ getJasmineRequireObj().Spec = function(j$, private$) {
// Key and value will eventually be cloned during reporting. The error // Key and value will eventually be cloned during reporting. The error
// thrown at that point if they aren't cloneable isn't very helpful. // thrown at that point if they aren't cloneable isn't very helpful.
// Throw a better one now. // Throw a better one now.
if (!private$.isString(key)) { if (!j$.private.isString(key)) {
throw new Error('Key must be a string'); throw new Error('Key must be a string');
} }
private$.util.assertReporterCloneable(value, 'Value'); j$.private.util.assertReporterCloneable(value, 'Value');
this.#executionState.properties = this.#executionState.properties || {}; this.#executionState.properties = this.#executionState.properties || {};
this.#executionState.properties[key] = value; this.#executionState.properties[key] = value;
@@ -208,7 +208,7 @@ getJasmineRequireObj().Spec = function(j$, private$) {
return; return;
} }
if (e instanceof private$.errors.ExpectationFailed) { if (e instanceof j$.private.errors.ExpectationFailed) {
return; return;
} }
@@ -275,7 +275,7 @@ getJasmineRequireObj().Spec = function(j$, private$) {
deprecation = { message: deprecation }; deprecation = { message: deprecation };
} }
this.#executionState.deprecationWarnings.push( this.#executionState.deprecationWarnings.push(
private$.buildExpectationResult(deprecation) j$.private.buildExpectationResult(deprecation)
); );
} }
+4 -4
View File
@@ -1,4 +1,4 @@
getJasmineRequireObj().Spy = function(j$, private$) { getJasmineRequireObj().Spy = function(j$) {
'use strict'; 'use strict';
const nextOrder = (function() { const nextOrder = (function() {
@@ -55,7 +55,7 @@ getJasmineRequireObj().Spy = function(j$, private$) {
}, },
matchersUtil matchersUtil
), ),
callTracker = new private$.CallTracker(); callTracker = new j$.private.CallTracker();
function makeFunc(length, fn) { function makeFunc(length, fn) {
switch (length) { switch (length) {
@@ -147,9 +147,9 @@ getJasmineRequireObj().Spy = function(j$, private$) {
} }
function SpyStrategyDispatcher(strategyArgs, matchersUtil) { function SpyStrategyDispatcher(strategyArgs, matchersUtil) {
const baseStrategy = new private$.SpyStrategy(strategyArgs); const baseStrategy = new j$.private.SpyStrategy(strategyArgs);
const argsStrategies = new StrategyDict(function() { const argsStrategies = new StrategyDict(function() {
return new private$.SpyStrategy(strategyArgs); return new j$.private.SpyStrategy(strategyArgs);
}, matchersUtil); }, matchersUtil);
this.and = baseStrategy; this.and = baseStrategy;
+5 -5
View File
@@ -1,4 +1,4 @@
getJasmineRequireObj().SpyFactory = function(j$, private$) { getJasmineRequireObj().SpyFactory = function(j$) {
'use strict'; 'use strict';
function SpyFactory( function SpyFactory(
@@ -7,12 +7,12 @@ getJasmineRequireObj().SpyFactory = function(j$, private$) {
getMatchersUtil getMatchersUtil
) { ) {
this.createSpy = function(name, originalFn) { this.createSpy = function(name, originalFn) {
if (private$.isFunction(name) && originalFn === undefined) { if (j$.private.isFunction(name) && originalFn === undefined) {
originalFn = name; originalFn = name;
name = originalFn.name; name = originalFn.name;
} }
return private$.Spy(name, getMatchersUtil(), { return j$.private.Spy(name, getMatchersUtil(), {
originalFn, originalFn,
customStrategies: getCustomStrategies(), customStrategies: getCustomStrategies(),
defaultStrategyFn: getDefaultStrategyFn() defaultStrategyFn: getDefaultStrategyFn()
@@ -21,7 +21,7 @@ getJasmineRequireObj().SpyFactory = function(j$, private$) {
this.createSpyObj = function(baseName, methodNames, propertyNames) { this.createSpyObj = function(baseName, methodNames, propertyNames) {
const baseNameIsCollection = const baseNameIsCollection =
private$.isObject(baseName) || Array.isArray(baseName); j$.private.isObject(baseName) || Array.isArray(baseName);
if (baseNameIsCollection) { if (baseNameIsCollection) {
propertyNames = methodNames; propertyNames = methodNames;
@@ -71,7 +71,7 @@ getJasmineRequireObj().SpyFactory = function(j$, private$) {
for (let i = 0; i < object.length; i++) { for (let i = 0; i < object.length; i++) {
result.push([object[i]]); result.push([object[i]]);
} }
} else if (private$.isObject(object)) { } else if (j$.private.isObject(object)) {
for (const key in object) { for (const key in object) {
if (object.hasOwnProperty(key)) { if (object.hasOwnProperty(key)) {
result.push([key, object[key]]); result.push([key, object[key]]);
+10 -7
View File
@@ -1,11 +1,11 @@
getJasmineRequireObj().SpyRegistry = function(j$, private$) { getJasmineRequireObj().SpyRegistry = function(j$) {
'use strict'; 'use strict';
const spyOnMsg = private$.formatErrorMsg( const spyOnMsg = j$.private.formatErrorMsg(
'<spyOn>', '<spyOn>',
'spyOn(<object>, <methodName>)' 'spyOn(<object>, <methodName>)'
); );
const spyOnPropertyMsg = private$.formatErrorMsg( const spyOnPropertyMsg = j$.private.formatErrorMsg(
'<spyOnProperty>', '<spyOnProperty>',
'spyOnProperty(<object>, <propName>, [accessType])' 'spyOnProperty(<object>, <propName>, [accessType])'
); );
@@ -47,7 +47,7 @@ getJasmineRequireObj().SpyRegistry = function(j$, private$) {
// restored. // restored.
if ( if (
obj[methodName] && obj[methodName] &&
obj[methodName][private$.Clock.IsMockClockTimingFn] obj[methodName][j$.private.Clock.IsMockClockTimingFn]
) { ) {
throw new Error("Mock clock timing functions can't be spied on"); throw new Error("Mock clock timing functions can't be spied on");
} }
@@ -102,7 +102,7 @@ getJasmineRequireObj().SpyRegistry = function(j$, private$) {
// localStorage in Firefox and later Safari versions, have no-op setters. // localStorage in Firefox and later Safari versions, have no-op setters.
if (obj[methodName] !== spiedMethod) { if (obj[methodName] !== spiedMethod) {
throw new Error( throw new Error(
private$.formatErrorMsg('<spyOn>')( j$.private.formatErrorMsg('<spyOn>')(
`Can't spy on ${methodName} because assigning to it had no effect` `Can't spy on ${methodName} because assigning to it had no effect`
) )
); );
@@ -130,7 +130,10 @@ getJasmineRequireObj().SpyRegistry = function(j$, private$) {
throw new Error(getErrorMsg('No property name supplied')); throw new Error(getErrorMsg('No property name supplied'));
} }
const descriptor = private$.util.getPropertyDescriptor(obj, propertyName); const descriptor = j$.private.util.getPropertyDescriptor(
obj,
propertyName
);
if (!descriptor) { if (!descriptor) {
throw new Error(getErrorMsg(propertyName + ' property does not exist')); throw new Error(getErrorMsg(propertyName + ' property does not exist'));
@@ -165,7 +168,7 @@ getJasmineRequireObj().SpyRegistry = function(j$, private$) {
} }
} }
const originalDescriptor = private$.util.clone(descriptor); const originalDescriptor = j$.private.util.clone(descriptor);
const spy = createSpy(propertyName, descriptor[accessType]); const spy = createSpy(propertyName, descriptor[accessType]);
let restoreStrategy; let restoreStrategy;
+7 -7
View File
@@ -1,4 +1,4 @@
getJasmineRequireObj().SpyStrategy = function(j$, private$) { getJasmineRequireObj().SpyStrategy = function(j$) {
'use strict'; 'use strict';
/** /**
@@ -21,7 +21,7 @@ getJasmineRequireObj().SpyStrategy = function(j$, private$) {
const cs = options.customStrategies || {}; const cs = options.customStrategies || {};
for (const k in cs) { for (const k in cs) {
if (private$.util.has(cs, k) && !this[k]) { if (j$.private.util.has(cs, k) && !this[k]) {
this[k] = createCustomPlan(cs[k]); this[k] = createCustomPlan(cs[k]);
} }
} }
@@ -59,7 +59,7 @@ getJasmineRequireObj().SpyStrategy = function(j$, private$) {
return function() { return function() {
const plan = factory.apply(null, arguments); const plan = factory.apply(null, arguments);
if (!private$.isFunction(plan)) { if (!j$.private.isFunction(plan)) {
throw new Error('Spy strategy must return a function'); throw new Error('Spy strategy must return a function');
} }
@@ -131,7 +131,7 @@ getJasmineRequireObj().SpyStrategy = function(j$, private$) {
* @param {Error|Object|String} something Thing to throw * @param {Error|Object|String} something Thing to throw
*/ */
SpyStrategy.prototype.throwError = function(something) { SpyStrategy.prototype.throwError = function(something) {
const error = private$.isString(something) const error = j$.private.isString(something)
? new Error(something) ? new Error(something)
: something; : something;
this.plan = function() { this.plan = function() {
@@ -150,9 +150,9 @@ getJasmineRequireObj().SpyStrategy = function(j$, private$) {
SpyStrategy.prototype.callFake = function(fn) { SpyStrategy.prototype.callFake = function(fn) {
if ( if (
!( !(
private$.isFunction(fn) || j$.private.isFunction(fn) ||
private$.isAsyncFunction(fn) || j$.private.isAsyncFunction(fn) ||
private$.isGeneratorFunction(fn) j$.private.isGeneratorFunction(fn)
) )
) { ) {
throw new Error( throw new Error(
+1 -1
View File
@@ -1,4 +1,4 @@
getJasmineRequireObj().StackClearer = function(j$, private$) { getJasmineRequireObj().StackClearer = function(j$) {
'use strict'; 'use strict';
const maxInlineCallCount = 10; const maxInlineCallCount = 10;
+1 -1
View File
@@ -1,4 +1,4 @@
getJasmineRequireObj().StackTrace = function(j$, private$) { getJasmineRequireObj().StackTrace = function(j$) {
'use strict'; 'use strict';
function StackTrace(error) { function StackTrace(error) {
+10 -10
View File
@@ -1,4 +1,4 @@
getJasmineRequireObj().Suite = function(j$, private$) { getJasmineRequireObj().Suite = function(j$) {
'use strict'; 'use strict';
class Suite { class Suite {
@@ -37,10 +37,10 @@ getJasmineRequireObj().Suite = function(j$, private$) {
// Key and value will eventually be cloned during reporting. The error // Key and value will eventually be cloned during reporting. The error
// thrown at that point if they aren't cloneable isn't very helpful. // thrown at that point if they aren't cloneable isn't very helpful.
// Throw a better one now. // Throw a better one now.
if (!private$.isString(key)) { if (!j$.private.isString(key)) {
throw new Error('Key must be a string'); throw new Error('Key must be a string');
} }
private$.util.assertReporterCloneable(value, 'Value'); j$.private.util.assertReporterCloneable(value, 'Value');
this.#result.properties = this.#result.properties || {}; this.#result.properties = this.#result.properties || {};
this.#result.properties[key] = value; this.#result.properties[key] = value;
@@ -217,18 +217,18 @@ getJasmineRequireObj().Suite = function(j$, private$) {
if (!this.sharedContext) { if (!this.sharedContext) {
this.sharedContext = this.parentSuite this.sharedContext = this.parentSuite
? this.parentSuite.clonedSharedUserContext() ? this.parentSuite.clonedSharedUserContext()
: new private$.UserContext(); : new j$.private.UserContext();
} }
return this.sharedContext; return this.sharedContext;
} }
clonedSharedUserContext() { clonedSharedUserContext() {
return private$.UserContext.fromExisting(this.sharedUserContext()); return j$.private.UserContext.fromExisting(this.sharedUserContext());
} }
handleException() { handleException() {
if (arguments[0] instanceof private$.errors.ExpectationFailed) { if (arguments[0] instanceof j$.private.errors.ExpectationFailed) {
return; return;
} }
@@ -237,7 +237,7 @@ getJasmineRequireObj().Suite = function(j$, private$) {
passed: false, passed: false,
error: arguments[0] error: arguments[0]
}; };
const failedExpectation = private$.buildExpectationResult(data); const failedExpectation = j$.private.buildExpectationResult(data);
if (!this.parentSuite) { if (!this.parentSuite) {
failedExpectation.globalErrorType = 'afterAll'; failedExpectation.globalErrorType = 'afterAll';
@@ -279,7 +279,7 @@ getJasmineRequireObj().Suite = function(j$, private$) {
return; return;
} }
const expectationResult = private$.buildExpectationResult(data); const expectationResult = j$.private.buildExpectationResult(data);
if (this.reportedDone) { if (this.reportedDone) {
this.onLateError(expectationResult); this.onLateError(expectationResult);
@@ -288,7 +288,7 @@ getJasmineRequireObj().Suite = function(j$, private$) {
} }
if (this.#throwOnExpectationFailure) { if (this.#throwOnExpectationFailure) {
throw new private$.errors.ExpectationFailed(); throw new j$.private.errors.ExpectationFailed();
} }
} }
@@ -297,7 +297,7 @@ getJasmineRequireObj().Suite = function(j$, private$) {
deprecation = { message: deprecation }; deprecation = { message: deprecation };
} }
this.#result.deprecationWarnings.push( this.#result.deprecationWarnings.push(
private$.buildExpectationResult(deprecation) j$.private.buildExpectationResult(deprecation)
); );
} }
+13 -13
View File
@@ -1,4 +1,4 @@
getJasmineRequireObj().SuiteBuilder = function(j$, private$) { getJasmineRequireObj().SuiteBuilder = function(j$) {
'use strict'; 'use strict';
class SuiteBuilder { class SuiteBuilder {
@@ -94,7 +94,7 @@ getJasmineRequireObj().SuiteBuilder = function(j$, private$) {
ensureIsFunctionOrAsync(fn, 'fit'); ensureIsFunctionOrAsync(fn, 'fit');
if (timeout) { if (timeout) {
private$.util.validateTimeout(timeout); j$.private.util.validateTimeout(timeout);
} }
const spec = this.specFactory_(description, fn, timeout, filename); const spec = this.specFactory_(description, fn, timeout, filename);
this.currentDeclarationSuite_.addChild(spec); this.currentDeclarationSuite_.addChild(spec);
@@ -107,7 +107,7 @@ getJasmineRequireObj().SuiteBuilder = function(j$, private$) {
ensureIsFunctionOrAsync(beforeEachFunction, 'beforeEach'); ensureIsFunctionOrAsync(beforeEachFunction, 'beforeEach');
if (timeout) { if (timeout) {
private$.util.validateTimeout(timeout); j$.private.util.validateTimeout(timeout);
} }
this.currentDeclarationSuite_.beforeEach({ this.currentDeclarationSuite_.beforeEach({
@@ -120,7 +120,7 @@ getJasmineRequireObj().SuiteBuilder = function(j$, private$) {
ensureIsFunctionOrAsync(beforeAllFunction, 'beforeAll'); ensureIsFunctionOrAsync(beforeAllFunction, 'beforeAll');
if (timeout) { if (timeout) {
private$.util.validateTimeout(timeout); j$.private.util.validateTimeout(timeout);
} }
this.currentDeclarationSuite_.beforeAll({ this.currentDeclarationSuite_.beforeAll({
@@ -133,7 +133,7 @@ getJasmineRequireObj().SuiteBuilder = function(j$, private$) {
ensureIsFunctionOrAsync(afterEachFunction, 'afterEach'); ensureIsFunctionOrAsync(afterEachFunction, 'afterEach');
if (timeout) { if (timeout) {
private$.util.validateTimeout(timeout); j$.private.util.validateTimeout(timeout);
} }
afterEachFunction.isCleanup = true; afterEachFunction.isCleanup = true;
@@ -147,7 +147,7 @@ getJasmineRequireObj().SuiteBuilder = function(j$, private$) {
ensureIsFunctionOrAsync(afterAllFunction, 'afterAll'); ensureIsFunctionOrAsync(afterAllFunction, 'afterAll');
if (timeout) { if (timeout) {
private$.util.validateTimeout(timeout); j$.private.util.validateTimeout(timeout);
} }
this.currentDeclarationSuite_.afterAll({ this.currentDeclarationSuite_.afterAll({
@@ -158,7 +158,7 @@ getJasmineRequireObj().SuiteBuilder = function(j$, private$) {
it_(description, fn, timeout, filename) { it_(description, fn, timeout, filename) {
if (timeout) { if (timeout) {
private$.util.validateTimeout(timeout); j$.private.util.validateTimeout(timeout);
} }
this.checkDuplicate_(description, 'spec'); this.checkDuplicate_(description, 'spec');
@@ -197,7 +197,7 @@ getJasmineRequireObj().SuiteBuilder = function(j$, private$) {
const parentSuite = this.currentDeclarationSuite_; const parentSuite = this.currentDeclarationSuite_;
const reportedParentSuiteId = const reportedParentSuiteId =
parentSuite === this.topSuite ? null : parentSuite.id; parentSuite === this.topSuite ? null : parentSuite.id;
return new private$.Suite({ return new j$.private.Suite({
id: 'suite' + this.nextSuiteId_++, id: 'suite' + this.nextSuiteId_++,
description, description,
filename, filename,
@@ -239,7 +239,7 @@ getJasmineRequireObj().SuiteBuilder = function(j$, private$) {
const config = this.env_.configuration(); const config = this.env_.configuration();
const suite = this.currentDeclarationSuite_; const suite = this.currentDeclarationSuite_;
const parentSuiteId = suite === this.topSuite ? null : suite.id; const parentSuiteId = suite === this.topSuite ? null : suite.id;
const spec = new private$.Spec({ const spec = new j$.private.Spec({
id: 'spec' + this.nextSpecId_++, id: 'spec' + this.nextSpecId_++,
filename, filename,
parentSuiteId, parentSuiteId,
@@ -302,21 +302,21 @@ getJasmineRequireObj().SuiteBuilder = function(j$, private$) {
} }
function ensureIsFunction(fn, caller) { function ensureIsFunction(fn, caller) {
if (!private$.isFunction(fn)) { if (!j$.private.isFunction(fn)) {
throw new Error( throw new Error(
caller + caller +
' expects a function argument; received ' + ' expects a function argument; received ' +
private$.getType(fn) j$.private.getType(fn)
); );
} }
} }
function ensureIsFunctionOrAsync(fn, caller) { function ensureIsFunctionOrAsync(fn, caller) {
if (!private$.isFunction(fn) && !private$.isAsyncFunction(fn)) { if (!j$.private.isFunction(fn) && !j$.private.isAsyncFunction(fn)) {
throw new Error( throw new Error(
caller + caller +
' expects a function argument; received ' + ' expects a function argument; received ' +
private$.getType(fn) j$.private.getType(fn)
); );
} }
} }
-4
View File
@@ -39,11 +39,7 @@ getJasmineRequireObj().Timer = function() {
this.elapsed = function() { this.elapsed = function() {
return now() - startTime; return now() - startTime;
}; };
Object.freeze(this);
} }
Object.freeze(Timer);
Object.freeze(Timer.prototype);
return Timer; return Timer;
}; };
+1 -1
View File
@@ -1,4 +1,4 @@
getJasmineRequireObj().TreeProcessor = function(j$, private$) { getJasmineRequireObj().TreeProcessor = function(j$) {
'use strict'; 'use strict';
const defaultMin = Infinity; const defaultMin = Infinity;
+6 -6
View File
@@ -1,4 +1,4 @@
getJasmineRequireObj().TreeRunner = function(j$, private$) { getJasmineRequireObj().TreeRunner = function(j$) {
'use strict'; 'use strict';
class TreeRunner { class TreeRunner {
@@ -83,14 +83,14 @@ getJasmineRequireObj().TreeRunner = function(j$, private$) {
}, },
onComplete: () => { onComplete: () => {
if (spec.status() === 'failed') { if (spec.status() === 'failed') {
specOverallDone(new private$.StopExecutionError('spec failed')); specOverallDone(new j$.private.StopExecutionError('spec failed'));
} else { } else {
specOverallDone(); specOverallDone();
} }
}, },
userContext: spec.userContext(), userContext: spec.userContext(),
runnableName: spec.getFullName.bind(spec), runnableName: spec.getFullName.bind(spec),
SkipPolicy: private$.CompleteOnFirstErrorSkipPolicy SkipPolicy: j$.private.CompleteOnFirstErrorSkipPolicy
}); });
} }
@@ -265,7 +265,7 @@ getJasmineRequireObj().TreeRunner = function(j$, private$) {
async #reportChildrenOfBeforeAllFailure(suite) { async #reportChildrenOfBeforeAllFailure(suite) {
for (const child of suite.children) { for (const child of suite.children) {
if (child instanceof private$.Suite) { if (child instanceof j$.private.Suite) {
await this.#reportDispatcher.suiteStarted(child.startedEvent()); await this.#reportDispatcher.suiteStarted(child.startedEvent());
await this.#reportChildrenOfBeforeAllFailure(child); await this.#reportChildrenOfBeforeAllFailure(child);
await this.#reportDispatcher.suiteDone(child.doneEvent()); await this.#reportDispatcher.suiteDone(child.doneEvent());
@@ -280,9 +280,9 @@ getJasmineRequireObj().TreeRunner = function(j$, private$) {
#suiteSkipPolicy() { #suiteSkipPolicy() {
if (this.#getConfig().stopOnSpecFailure) { if (this.#getConfig().stopOnSpecFailure) {
return private$.CompleteOnFirstErrorSkipPolicy; return j$.private.CompleteOnFirstErrorSkipPolicy;
} else { } else {
return private$.SkipAfterBeforeAllErrorPolicy; return j$.private.SkipAfterBeforeAllErrorPolicy;
} }
} }
} }
+1 -1
View File
@@ -1,4 +1,4 @@
getJasmineRequireObj().UserContext = function(j$, private$) { getJasmineRequireObj().UserContext = function(j$) {
'use strict'; 'use strict';
function UserContext() {} function UserContext() {}
+1 -1
View File
@@ -1,4 +1,4 @@
getJasmineRequireObj().AllOf = function(j$, private$) { getJasmineRequireObj().AllOf = function(j$) {
'use strict'; 'use strict';
function AllOf() { function AllOf() {
+2 -2
View File
@@ -1,4 +1,4 @@
getJasmineRequireObj().Any = function(j$, private$) { getJasmineRequireObj().Any = function(j$) {
'use strict'; 'use strict';
function Any(expectedObject) { function Any(expectedObject) {
@@ -40,7 +40,7 @@ getJasmineRequireObj().Any = function(j$, private$) {
}; };
Any.prototype.jasmineToString = function() { Any.prototype.jasmineToString = function() {
return '<jasmine.any(' + private$.fnNameFor(this.expectedObject) + ')>'; return '<jasmine.any(' + j$.private.fnNameFor(this.expectedObject) + ')>';
}; };
return Any; return Any;
+1 -1
View File
@@ -1,4 +1,4 @@
getJasmineRequireObj().Anything = function(j$, private$) { getJasmineRequireObj().Anything = function(j$) {
'use strict'; 'use strict';
function Anything() {} function Anything() {}
@@ -1,4 +1,4 @@
getJasmineRequireObj().ArrayContaining = function(j$, private$) { getJasmineRequireObj().ArrayContaining = function(j$) {
'use strict'; 'use strict';
function ArrayContaining(sample) { function ArrayContaining(sample) {
@@ -9,7 +9,7 @@ getJasmineRequireObj().ArrayContaining = function(j$, private$) {
if (!Array.isArray(this.sample)) { if (!Array.isArray(this.sample)) {
throw new Error( throw new Error(
'You must provide an array to arrayContaining, not ' + 'You must provide an array to arrayContaining, not ' +
private$.basicPrettyPrinter(this.sample) + j$.private.basicPrettyPrinter(this.sample) +
'.' '.'
); );
} }
@@ -1,4 +1,4 @@
getJasmineRequireObj().ArrayWithExactContents = function(j$, private$) { getJasmineRequireObj().ArrayWithExactContents = function(j$) {
'use strict'; 'use strict';
function ArrayWithExactContents(sample) { function ArrayWithExactContents(sample) {
@@ -12,7 +12,7 @@ getJasmineRequireObj().ArrayWithExactContents = function(j$, private$) {
if (!Array.isArray(this.sample)) { if (!Array.isArray(this.sample)) {
throw new Error( throw new Error(
'You must provide an array to arrayWithExactContents, not ' + 'You must provide an array to arrayWithExactContents, not ' +
private$.basicPrettyPrinter(this.sample) + j$.private.basicPrettyPrinter(this.sample) +
'.' '.'
); );
} }
+5 -5
View File
@@ -1,22 +1,22 @@
getJasmineRequireObj().Empty = function(j$, private$) { getJasmineRequireObj().Empty = function(j$) {
'use strict'; 'use strict';
function Empty() {} function Empty() {}
Empty.prototype.asymmetricMatch = function(other) { Empty.prototype.asymmetricMatch = function(other) {
if ( if (
private$.isString(other) || j$.private.isString(other) ||
Array.isArray(other) || Array.isArray(other) ||
private$.isTypedArray(other) j$.private.isTypedArray(other)
) { ) {
return other.length === 0; return other.length === 0;
} }
if (private$.isMap(other) || private$.isSet(other)) { if (j$.private.isMap(other) || j$.private.isSet(other)) {
return other.size === 0; return other.size === 0;
} }
if (private$.isObject(other)) { if (j$.private.isObject(other)) {
return Object.keys(other).length === 0; return Object.keys(other).length === 0;
} }
return false; return false;
+1 -1
View File
@@ -1,4 +1,4 @@
getJasmineRequireObj().Falsy = function(j$, private$) { getJasmineRequireObj().Falsy = function(j$) {
'use strict'; 'use strict';
function Falsy() {} function Falsy() {}
+1 -1
View File
@@ -1,4 +1,4 @@
getJasmineRequireObj().Is = function(j$, private$) { getJasmineRequireObj().Is = function(j$) {
'use strict'; 'use strict';
class Is { class Is {
@@ -1,11 +1,11 @@
getJasmineRequireObj().MapContaining = function(j$, private$) { getJasmineRequireObj().MapContaining = function(j$) {
'use strict'; 'use strict';
function MapContaining(sample) { function MapContaining(sample) {
if (!private$.isMap(sample)) { if (!j$.private.isMap(sample)) {
throw new Error( throw new Error(
'You must provide a map to `mapContaining`, not ' + 'You must provide a map to `mapContaining`, not ' +
private$.basicPrettyPrinter(sample) j$.private.basicPrettyPrinter(sample)
); );
} }
@@ -13,7 +13,7 @@ getJasmineRequireObj().MapContaining = function(j$, private$) {
} }
MapContaining.prototype.asymmetricMatch = function(other, matchersUtil) { MapContaining.prototype.asymmetricMatch = function(other, matchersUtil) {
if (!private$.isMap(other)) { if (!j$.private.isMap(other)) {
return false; return false;
} }
+5 -5
View File
@@ -1,22 +1,22 @@
getJasmineRequireObj().NotEmpty = function(j$, private$) { getJasmineRequireObj().NotEmpty = function(j$) {
'use strict'; 'use strict';
function NotEmpty() {} function NotEmpty() {}
NotEmpty.prototype.asymmetricMatch = function(other) { NotEmpty.prototype.asymmetricMatch = function(other) {
if ( if (
private$.isString(other) || j$.private.isString(other) ||
Array.isArray(other) || Array.isArray(other) ||
private$.isTypedArray(other) j$.private.isTypedArray(other)
) { ) {
return other.length !== 0; return other.length !== 0;
} }
if (private$.isMap(other) || private$.isSet(other)) { if (j$.private.isMap(other) || j$.private.isSet(other)) {
return other.size !== 0; return other.size !== 0;
} }
if (private$.isObject(other)) { if (j$.private.isObject(other)) {
return Object.keys(other).length !== 0; return Object.keys(other).length !== 0;
} }
@@ -1,4 +1,4 @@
getJasmineRequireObj().ObjectContaining = function(j$, private$) { getJasmineRequireObj().ObjectContaining = function(j$) {
'use strict'; 'use strict';
function ObjectContaining(sample) { function ObjectContaining(sample) {
@@ -42,7 +42,7 @@ getJasmineRequireObj().ObjectContaining = function(j$, private$) {
}; };
ObjectContaining.prototype.valuesForDiff_ = function(other, pp) { ObjectContaining.prototype.valuesForDiff_ = function(other, pp) {
if (!private$.isObject(other)) { if (!j$.private.isObject(other)) {
return { return {
self: this.jasmineToString(pp), self: this.jasmineToString(pp),
other: other other: other
@@ -1,11 +1,11 @@
getJasmineRequireObj().SetContaining = function(j$, private$) { getJasmineRequireObj().SetContaining = function(j$) {
'use strict'; 'use strict';
function SetContaining(sample) { function SetContaining(sample) {
if (!private$.isSet(sample)) { if (!j$.private.isSet(sample)) {
throw new Error( throw new Error(
'You must provide a set to `setContaining`, not ' + 'You must provide a set to `setContaining`, not ' +
private$.basicPrettyPrinter(sample) j$.private.basicPrettyPrinter(sample)
); );
} }
@@ -13,7 +13,7 @@ getJasmineRequireObj().SetContaining = function(j$, private$) {
} }
SetContaining.prototype.asymmetricMatch = function(other, matchersUtil) { SetContaining.prototype.asymmetricMatch = function(other, matchersUtil) {
if (!private$.isSet(other)) { if (!j$.private.isSet(other)) {
return false; return false;
} }
@@ -1,8 +1,8 @@
getJasmineRequireObj().StringContaining = function(j$, private$) { getJasmineRequireObj().StringContaining = function(j$) {
'use strict'; 'use strict';
function StringContaining(expected) { function StringContaining(expected) {
if (!private$.isString(expected)) { if (!j$.private.isString(expected)) {
throw new Error('Expected is not a String'); throw new Error('Expected is not a String');
} }
@@ -10,7 +10,7 @@ getJasmineRequireObj().StringContaining = function(j$, private$) {
} }
StringContaining.prototype.asymmetricMatch = function(other) { StringContaining.prototype.asymmetricMatch = function(other) {
if (!private$.isString(other)) { if (!j$.private.isString(other)) {
// Arrays, etc. don't match no matter what their indexOf returns. // Arrays, etc. don't match no matter what their indexOf returns.
return false; return false;
} }
@@ -1,8 +1,8 @@
getJasmineRequireObj().StringMatching = function(j$, private$) { getJasmineRequireObj().StringMatching = function(j$) {
'use strict'; 'use strict';
function StringMatching(expected) { function StringMatching(expected) {
if (!private$.isString(expected) && !private$.isA('RegExp', expected)) { if (!j$.private.isString(expected) && !j$.private.isA('RegExp', expected)) {
throw new Error('Expected is not a String or a RegExp'); throw new Error('Expected is not a String or a RegExp');
} }
+1 -1
View File
@@ -1,4 +1,4 @@
getJasmineRequireObj().Truthy = function(j$, private$) { getJasmineRequireObj().Truthy = function(j$) {
'use strict'; 'use strict';
function Truthy() {} function Truthy() {}
+60 -61
View File
@@ -1,4 +1,4 @@
getJasmineRequireObj().base = function(j$, private$, jasmineGlobal) { getJasmineRequireObj().base = function(j$, jasmineGlobal) {
'use strict'; 'use strict';
/** /**
@@ -43,12 +43,11 @@ getJasmineRequireObj().base = function(j$, private$, jasmineGlobal) {
*/ */
let DEFAULT_TIMEOUT_INTERVAL = 5000; let DEFAULT_TIMEOUT_INTERVAL = 5000;
Object.defineProperty(j$, 'DEFAULT_TIMEOUT_INTERVAL', { Object.defineProperty(j$, 'DEFAULT_TIMEOUT_INTERVAL', {
enumerable: true,
get: function() { get: function() {
return DEFAULT_TIMEOUT_INTERVAL; return DEFAULT_TIMEOUT_INTERVAL;
}, },
set: function(newValue) { set: function(newValue) {
private$.util.validateTimeout( j$.private.util.validateTimeout(
newValue, newValue,
'jasmine.DEFAULT_TIMEOUT_INTERVAL' 'jasmine.DEFAULT_TIMEOUT_INTERVAL'
); );
@@ -71,58 +70,58 @@ getJasmineRequireObj().base = function(j$, private$, jasmineGlobal) {
Object.defineProperty(j$, 'getEnv', { Object.defineProperty(j$, 'getEnv', {
enumerable: true, enumerable: true,
value: function(options) { value: function(options) {
const env = (private$.currentEnv_ = const env = (j$.private.currentEnv_ =
private$.currentEnv_ || new private$.Env(options)); j$.private.currentEnv_ || new j$.private.Env(options));
//jasmine. singletons in here (setTimeout blah blah). //jasmine. singletons in here (setTimeout blah blah).
return env; return env;
} }
}); });
private$.isObject = function(value) { j$.private.isObject = function(value) {
return ( return (
value !== undefined && value !== null && private$.isA('Object', value) value !== undefined && value !== null && j$.private.isA('Object', value)
); );
}; };
private$.isString = function(value) { j$.private.isString = function(value) {
return private$.isA('String', value); return j$.private.isA('String', value);
}; };
private$.isNumber = function(value) { j$.private.isNumber = function(value) {
return private$.isA('Number', value); return j$.private.isA('Number', value);
}; };
private$.isFunction = function(value) { j$.private.isFunction = function(value) {
return private$.isA('Function', value); return j$.private.isA('Function', value);
}; };
private$.isAsyncFunction = function(value) { j$.private.isAsyncFunction = function(value) {
return private$.isA('AsyncFunction', value); return j$.private.isA('AsyncFunction', value);
}; };
private$.isGeneratorFunction = function(value) { j$.private.isGeneratorFunction = function(value) {
return private$.isA('GeneratorFunction', value); return j$.private.isA('GeneratorFunction', value);
}; };
private$.isTypedArray = function(value) { j$.private.isTypedArray = function(value) {
return ( return (
private$.isA('Float32Array', value) || j$.private.isA('Float32Array', value) ||
private$.isA('Float64Array', value) || j$.private.isA('Float64Array', value) ||
private$.isA('Int16Array', value) || j$.private.isA('Int16Array', value) ||
private$.isA('Int32Array', value) || j$.private.isA('Int32Array', value) ||
private$.isA('Int8Array', value) || j$.private.isA('Int8Array', value) ||
private$.isA('Uint16Array', value) || j$.private.isA('Uint16Array', value) ||
private$.isA('Uint32Array', value) || j$.private.isA('Uint32Array', value) ||
private$.isA('Uint8Array', value) || j$.private.isA('Uint8Array', value) ||
private$.isA('Uint8ClampedArray', value) j$.private.isA('Uint8ClampedArray', value)
); );
}; };
private$.isA = function(typeName, value) { j$.private.isA = function(typeName, value) {
return private$.getType(value) === '[object ' + typeName + ']'; return j$.private.getType(value) === '[object ' + typeName + ']';
}; };
private$.isError = function(value) { j$.private.isError = function(value) {
if (!value) { if (!value) {
return false; return false;
} }
@@ -134,15 +133,15 @@ getJasmineRequireObj().base = function(j$, private$, jasmineGlobal) {
return typeof value.stack === 'string' && typeof value.message === 'string'; return typeof value.stack === 'string' && typeof value.message === 'string';
}; };
private$.isAsymmetricEqualityTester = function(obj) { j$.private.isAsymmetricEqualityTester = function(obj) {
return obj ? private$.isA('Function', obj.asymmetricMatch) : false; return obj ? j$.private.isA('Function', obj.asymmetricMatch) : false;
}; };
private$.getType = function(value) { j$.private.getType = function(value) {
return Object.prototype.toString.apply(value); return Object.prototype.toString.apply(value);
}; };
private$.isDomNode = function(obj) { j$.private.isDomNode = function(obj) {
// Node is a function, because constructors // Node is a function, because constructors
return typeof jasmineGlobal.Node !== 'undefined' return typeof jasmineGlobal.Node !== 'undefined'
? obj instanceof jasmineGlobal.Node ? obj instanceof jasmineGlobal.Node
@@ -153,7 +152,7 @@ getJasmineRequireObj().base = function(j$, private$, jasmineGlobal) {
// return obj.nodeType > 0; // return obj.nodeType > 0;
}; };
private$.isMap = function(obj) { j$.private.isMap = function(obj) {
return ( return (
obj !== null && obj !== null &&
typeof obj !== 'undefined' && typeof obj !== 'undefined' &&
@@ -161,7 +160,7 @@ getJasmineRequireObj().base = function(j$, private$, jasmineGlobal) {
); );
}; };
private$.isSet = function(obj) { j$.private.isSet = function(obj) {
return ( return (
obj !== null && obj !== null &&
typeof obj !== 'undefined' && typeof obj !== 'undefined' &&
@@ -169,7 +168,7 @@ getJasmineRequireObj().base = function(j$, private$, jasmineGlobal) {
); );
}; };
private$.isWeakMap = function(obj) { j$.private.isWeakMap = function(obj) {
return ( return (
obj !== null && obj !== null &&
typeof obj !== 'undefined' && typeof obj !== 'undefined' &&
@@ -177,7 +176,7 @@ getJasmineRequireObj().base = function(j$, private$, jasmineGlobal) {
); );
}; };
private$.isURL = function(obj) { j$.private.isURL = function(obj) {
return ( return (
obj !== null && obj !== null &&
typeof obj !== 'undefined' && typeof obj !== 'undefined' &&
@@ -185,11 +184,11 @@ getJasmineRequireObj().base = function(j$, private$, jasmineGlobal) {
); );
}; };
private$.isIterable = function(value) { j$.private.isIterable = function(value) {
return value && !!value[Symbol.iterator]; return value && !!value[Symbol.iterator];
}; };
private$.isDataView = function(obj) { j$.private.isDataView = function(obj) {
return ( return (
obj !== null && obj !== null &&
typeof obj !== 'undefined' && typeof obj !== 'undefined' &&
@@ -197,15 +196,15 @@ getJasmineRequireObj().base = function(j$, private$, jasmineGlobal) {
); );
}; };
private$.isPromise = function(obj) { j$.private.isPromise = function(obj) {
return !!obj && obj.constructor === jasmineGlobal.Promise; return !!obj && obj.constructor === jasmineGlobal.Promise;
}; };
private$.isPromiseLike = function(obj) { j$.private.isPromiseLike = function(obj) {
return !!obj && private$.isFunction(obj.then); return !!obj && j$.private.isFunction(obj.then);
}; };
private$.fnNameFor = function(func) { j$.private.fnNameFor = function(func) {
if (func.name) { if (func.name) {
return func.name; return func.name;
} }
@@ -217,7 +216,7 @@ getJasmineRequireObj().base = function(j$, private$, jasmineGlobal) {
return matches ? matches[1] : '<anonymous>'; return matches ? matches[1] : '<anonymous>';
}; };
private$.isPending = function(promise) { j$.private.isPending = function(promise) {
const sentinel = {}; const sentinel = {};
return Promise.race([promise, Promise.resolve(sentinel)]).then( return Promise.race([promise, Promise.resolve(sentinel)]).then(
function(result) { function(result) {
@@ -252,7 +251,7 @@ getJasmineRequireObj().base = function(j$, private$, jasmineGlobal) {
* @param {Constructor} clazz - The constructor to check against. * @param {Constructor} clazz - The constructor to check against.
*/ */
j$.any = function(clazz) { j$.any = function(clazz) {
return new private$.Any(clazz); return new j$.private.Any(clazz);
}; };
/** /**
@@ -264,7 +263,7 @@ getJasmineRequireObj().base = function(j$, private$, jasmineGlobal) {
* @function * @function
*/ */
j$.anything = function() { j$.anything = function() {
return new private$.Anything(); return new j$.private.Anything();
}; };
/** /**
@@ -276,7 +275,7 @@ getJasmineRequireObj().base = function(j$, private$, jasmineGlobal) {
* @function * @function
*/ */
j$.truthy = function() { j$.truthy = function() {
return new private$.Truthy(); return new j$.private.Truthy();
}; };
/** /**
@@ -289,7 +288,7 @@ getJasmineRequireObj().base = function(j$, private$, jasmineGlobal) {
* @function * @function
*/ */
j$.falsy = function() { j$.falsy = function() {
return new private$.Falsy(); return new j$.private.Falsy();
}; };
/** /**
@@ -301,7 +300,7 @@ getJasmineRequireObj().base = function(j$, private$, jasmineGlobal) {
* @function * @function
*/ */
j$.empty = function() { j$.empty = function() {
return new private$.Empty(); return new j$.private.Empty();
}; };
/** /**
@@ -313,7 +312,7 @@ getJasmineRequireObj().base = function(j$, private$, jasmineGlobal) {
* @param {Object} sample - The value to compare the actual to. * @param {Object} sample - The value to compare the actual to.
*/ */
j$.is = function(sample) { j$.is = function(sample) {
return new private$.Is(sample); return new j$.private.Is(sample);
}; };
/** /**
@@ -325,7 +324,7 @@ getJasmineRequireObj().base = function(j$, private$, jasmineGlobal) {
* @function * @function
*/ */
j$.notEmpty = function() { j$.notEmpty = function() {
return new private$.NotEmpty(); return new j$.private.NotEmpty();
}; };
/** /**
@@ -338,7 +337,7 @@ getJasmineRequireObj().base = function(j$, private$, jasmineGlobal) {
* @param {Object} sample - The subset of properties that _must_ be in the actual. * @param {Object} sample - The subset of properties that _must_ be in the actual.
*/ */
j$.objectContaining = function(sample) { j$.objectContaining = function(sample) {
return new private$.ObjectContaining(sample); return new j$.private.ObjectContaining(sample);
}; };
/** /**
@@ -351,7 +350,7 @@ getJasmineRequireObj().base = function(j$, private$, jasmineGlobal) {
* @param {RegExp|String} expected * @param {RegExp|String} expected
*/ */
j$.stringMatching = function(expected) { j$.stringMatching = function(expected) {
return new private$.StringMatching(expected); return new j$.private.StringMatching(expected);
}; };
/** /**
@@ -364,7 +363,7 @@ getJasmineRequireObj().base = function(j$, private$, jasmineGlobal) {
* @param {String} expected * @param {String} expected
*/ */
j$.stringContaining = function(expected) { j$.stringContaining = function(expected) {
return new private$.StringContaining(expected); return new j$.private.StringContaining(expected);
}; };
/** /**
@@ -377,7 +376,7 @@ getJasmineRequireObj().base = function(j$, private$, jasmineGlobal) {
* @param {Array} sample * @param {Array} sample
*/ */
j$.arrayContaining = function(sample) { j$.arrayContaining = function(sample) {
return new private$.ArrayContaining(sample); return new j$.private.ArrayContaining(sample);
}; };
/** /**
@@ -391,7 +390,7 @@ getJasmineRequireObj().base = function(j$, private$, jasmineGlobal) {
* @param {Array} sample * @param {Array} sample
*/ */
j$.arrayWithExactContents = function(sample) { j$.arrayWithExactContents = function(sample) {
return new private$.ArrayWithExactContents(sample); return new j$.private.ArrayWithExactContents(sample);
}; };
/** /**
@@ -405,7 +404,7 @@ getJasmineRequireObj().base = function(j$, private$, jasmineGlobal) {
* @param {Map} sample - The subset of items that _must_ be in the actual. * @param {Map} sample - The subset of items that _must_ be in the actual.
*/ */
j$.mapContaining = function(sample) { j$.mapContaining = function(sample) {
return new private$.MapContaining(sample); return new j$.private.MapContaining(sample);
}; };
/** /**
@@ -419,7 +418,7 @@ getJasmineRequireObj().base = function(j$, private$, jasmineGlobal) {
* @param {Set} sample - The subset of items that _must_ be in the actual. * @param {Set} sample - The subset of items that _must_ be in the actual.
*/ */
j$.setContaining = function(sample) { j$.setContaining = function(sample) {
return new private$.SetContaining(sample); return new j$.private.SetContaining(sample);
}; };
/** /**
@@ -435,8 +434,8 @@ getJasmineRequireObj().base = function(j$, private$, jasmineGlobal) {
return false; return false;
} }
return ( return (
putativeSpy.and instanceof private$.SpyStrategy && putativeSpy.and instanceof j$.private.SpyStrategy &&
putativeSpy.calls instanceof private$.CallTracker putativeSpy.calls instanceof j$.private.CallTracker
); );
}; };
+3 -3
View File
@@ -1,9 +1,9 @@
//TODO: expectation result may make more sense as a presentation of an expectation. //TODO: expectation result may make more sense as a presentation of an expectation.
getJasmineRequireObj().buildExpectationResult = function(j$, private$) { getJasmineRequireObj().buildExpectationResult = function(j$) {
'use strict'; 'use strict';
function buildExpectationResult(options) { function buildExpectationResult(options) {
const exceptionFormatter = new private$.ExceptionFormatter(); const exceptionFormatter = new j$.private.ExceptionFormatter();
/** /**
* Describes the result of evaluating an expectation * Describes the result of evaluating an expectation
@@ -33,7 +33,7 @@ getJasmineRequireObj().buildExpectationResult = function(j$, private$) {
} }
if (!result.passed) { if (!result.passed) {
if (options.error && !private$.isString(options.error)) { if (options.error && !j$.private.isString(options.error)) {
if ('code' in options.error) { if ('code' in options.error) {
result.code = options.error.code; result.code = options.error.code;
} }
+22
View File
@@ -0,0 +1,22 @@
getJasmineRequireObj().deprecateMonkeyPatching = function(j$) {
return function deprecateMonkeyPatching(obj, keysToSkip) {
for (const key of Object.keys(obj)) {
if (!keysToSkip?.includes(key)) {
let value = obj[key];
Object.defineProperty(obj, key, {
enumerable: key in obj,
get() {
return value;
},
set(newValue) {
j$.getEnv().deprecated(
'Monkey patching detected. Code that overwrites parts of Jasmine, except globala and other properties that are documented as writeable, is not supported and will break in a future release.'
);
value = newValue;
}
});
}
}
};
};
+6 -6
View File
@@ -1,12 +1,12 @@
getJasmineRequireObj().DiffBuilder = function(j$, private$) { getJasmineRequireObj().DiffBuilder = function(j$) {
'use strict'; 'use strict';
class DiffBuilder { class DiffBuilder {
constructor(config) { constructor(config) {
this.prettyPrinter_ = this.prettyPrinter_ =
(config || {}).prettyPrinter || private$.makePrettyPrinter(); (config || {}).prettyPrinter || j$.private.makePrettyPrinter();
this.mismatches_ = new private$.MismatchTree(); this.mismatches_ = new j$.private.MismatchTree();
this.path_ = new private$.ObjectPath(); this.path_ = new j$.private.ObjectPath();
this.actualRoot_ = undefined; this.actualRoot_ = undefined;
this.expectedRoot_ = undefined; this.expectedRoot_ = undefined;
} }
@@ -67,8 +67,8 @@ getJasmineRequireObj().DiffBuilder = function(j$, private$) {
const handleAsymmetricExpected = () => { const handleAsymmetricExpected = () => {
if ( if (
private$.isAsymmetricEqualityTester(expected) && j$.private.isAsymmetricEqualityTester(expected) &&
private$.isFunction(expected.valuesForDiff_) j$.private.isFunction(expected.valuesForDiff_)
) { ) {
const asymmetricResult = expected.valuesForDiff_( const asymmetricResult = expected.valuesForDiff_(
actual, actual,
+2 -2
View File
@@ -1,4 +1,4 @@
getJasmineRequireObj().MismatchTree = function(j$, private$) { getJasmineRequireObj().MismatchTree = function(j$) {
'use strict'; 'use strict';
/* /*
@@ -10,7 +10,7 @@ getJasmineRequireObj().MismatchTree = function(j$, private$) {
*/ */
class MismatchTree { class MismatchTree {
constructor(path) { constructor(path) {
this.path = path || new private$.ObjectPath([]); this.path = path || new j$.private.ObjectPath([]);
this.formatter = undefined; this.formatter = undefined;
this.children = []; this.children = [];
this.isMismatch = false; this.isMismatch = false;
+1 -1
View File
@@ -1,4 +1,4 @@
getJasmineRequireObj().NullDiffBuilder = function(j$, private$) { getJasmineRequireObj().NullDiffBuilder = function(j$) {
'use strict'; 'use strict';
return function() { return function() {
+1 -1
View File
@@ -1,4 +1,4 @@
getJasmineRequireObj().ObjectPath = function(j$, private$) { getJasmineRequireObj().ObjectPath = function(j$) {
'use strict'; 'use strict';
class ObjectPath { class ObjectPath {
+2 -2
View File
@@ -1,4 +1,4 @@
getJasmineRequireObj().toBePending = function(j$, private$) { getJasmineRequireObj().toBePending = function(j$) {
'use strict'; 'use strict';
/** /**
@@ -13,7 +13,7 @@ getJasmineRequireObj().toBePending = function(j$, private$) {
return function toBePending() { return function toBePending() {
return { return {
compare: function(actual) { compare: function(actual) {
if (!private$.isPromiseLike(actual)) { if (!j$.private.isPromiseLike(actual)) {
throw new Error( throw new Error(
`Expected toBePending to be called on a promise but was on a ${typeof actual}.` `Expected toBePending to be called on a promise but was on a ${typeof actual}.`
); );
+2 -2
View File
@@ -1,4 +1,4 @@
getJasmineRequireObj().toBeRejected = function(j$, private$) { getJasmineRequireObj().toBeRejected = function(j$) {
'use strict'; 'use strict';
/** /**
@@ -15,7 +15,7 @@ getJasmineRequireObj().toBeRejected = function(j$, private$) {
return function toBeRejected() { return function toBeRejected() {
return { return {
compare: function(actual) { compare: function(actual) {
if (!private$.isPromiseLike(actual)) { if (!j$.private.isPromiseLike(actual)) {
throw new Error( throw new Error(
`Expected toBeRejected to be called on a promise but was on a ${typeof actual}.` `Expected toBeRejected to be called on a promise but was on a ${typeof actual}.`
); );
+2 -2
View File
@@ -1,4 +1,4 @@
getJasmineRequireObj().toBeRejectedWith = function(j$, private$) { getJasmineRequireObj().toBeRejectedWith = function(j$) {
'use strict'; 'use strict';
/** /**
@@ -16,7 +16,7 @@ getJasmineRequireObj().toBeRejectedWith = function(j$, private$) {
return function toBeRejectedWith(matchersUtil) { return function toBeRejectedWith(matchersUtil) {
return { return {
compare: function(actualPromise, expectedValue) { compare: function(actualPromise, expectedValue) {
if (!private$.isPromiseLike(actualPromise)) { if (!j$.private.isPromiseLike(actualPromise)) {
throw new Error( throw new Error(
`Expected toBeRejectedWith to be called on a promise but was on a ${typeof actualPromise}.` `Expected toBeRejectedWith to be called on a promise but was on a ${typeof actualPromise}.`
); );
@@ -1,4 +1,4 @@
getJasmineRequireObj().toBeRejectedWithError = function(j$, private$) { getJasmineRequireObj().toBeRejectedWithError = function(j$) {
'use strict'; 'use strict';
/** /**
@@ -19,7 +19,7 @@ getJasmineRequireObj().toBeRejectedWithError = function(j$, private$) {
return function toBeRejectedWithError(matchersUtil) { return function toBeRejectedWithError(matchersUtil) {
return { return {
compare: function(actualPromise, arg1, arg2) { compare: function(actualPromise, arg1, arg2) {
if (!private$.isPromiseLike(actualPromise)) { if (!j$.private.isPromiseLike(actualPromise)) {
throw new Error( throw new Error(
`Expected toBeRejectedWithError to be called on a promise but was on a ${typeof actualPromise}.` `Expected toBeRejectedWithError to be called on a promise but was on a ${typeof actualPromise}.`
); );
@@ -43,14 +43,14 @@ getJasmineRequireObj().toBeRejectedWithError = function(j$, private$) {
}; };
function matchError(actual, expected, matchersUtil) { function matchError(actual, expected, matchersUtil) {
if (!private$.isError(actual)) { if (!j$.private.isError(actual)) {
return fail(expected, 'rejected with ' + matchersUtil.pp(actual)); return fail(expected, 'rejected with ' + matchersUtil.pp(actual));
} }
if (!(actual instanceof expected.error)) { if (!(actual instanceof expected.error)) {
return fail( return fail(
expected, expected,
'rejected with type ' + private$.fnNameFor(actual.constructor) 'rejected with type ' + j$.private.fnNameFor(actual.constructor)
); );
} }
@@ -110,7 +110,7 @@ getJasmineRequireObj().toBeRejectedWithError = function(j$, private$) {
error: error, error: error,
message: message, message: message,
printValue: printValue:
private$.fnNameFor(error) + j$.private.fnNameFor(error) +
(typeof message === 'undefined' ? '' : ': ' + matchersUtil.pp(message)) (typeof message === 'undefined' ? '' : ': ' + matchersUtil.pp(message))
}; };
} }
@@ -118,7 +118,7 @@ getJasmineRequireObj().toBeRejectedWithError = function(j$, private$) {
function isErrorConstructor(value) { function isErrorConstructor(value) {
return ( return (
typeof value === 'function' && typeof value === 'function' &&
(value === Error || private$.isError(value.prototype)) (value === Error || j$.private.isError(value.prototype))
); );
} }
}; };
@@ -0,0 +1,64 @@
getJasmineRequireObj().toBeRejectedWithMatching = function(j$) {
'use strict';
const usageError = j$.private.formatErrorMsg(
'<toBeRejectedWithMatching>',
'expect(function() {<expectation>}).toBeRejectedWithMatching(<Predicate>)'
);
/**
* Expect a promise to be rejected with a value matching a predicate.
* @function
* @async
* @name async-matchers#toBeRejectedWithMatching
* @since 6.2.0
* @param {Function} predicate - A function that takes the rejected promise value as its parameter and returns true if it matches.
* @example
* await expectAsync(aPromise).toBeRejectedWithMatching((error) => error.message === 'Some error');
* @example
* return expectAsync(aPromise).toBeRejectedWithMatching((error) => error.message === 'Some error');
*/
return function toBeRejectedWithMatching() {
return {
compare: function(actualPromise, predicate) {
if (!j$.private.isPromiseLike(actualPromise)) {
throw new Error(
`Expected toBeRejectedWithMatching to be called on a promise but was on a ${typeof actualPromise}.`
);
}
if (typeof predicate !== 'function') {
throw new Error(usageError('Predicate is not a Function'));
}
function prefix(passed) {
return (
'Expected a promise ' +
(passed ? 'not ' : '') +
'to be rejected matching a predicate'
);
}
return actualPromise.then(
function() {
return {
pass: false,
message: prefix(false) + ', but it was resolved.'
};
},
function(actualValue) {
const result = predicate(actualValue);
return {
pass: Boolean(result),
message:
prefix(result) +
', but the predicate returned "' +
result +
'".'
};
}
);
}
};
};
};

Some files were not shown because too many files have changed in this diff Show More