Compare commits
41 Commits
v6.0.0-alp
...
v6.1.0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3de4512681 | ||
|
|
4bf333ed38 | ||
|
|
4f5ef7c2d7 | ||
|
|
5de03beea1 | ||
|
|
42baa422b3 | ||
|
|
6af5d24b3b | ||
|
|
b88ce2d49f | ||
|
|
c216ae1d13 | ||
|
|
319776d241 | ||
|
|
1d0718dc2f | ||
|
|
929694310e | ||
|
|
7379a3a11b | ||
|
|
4db18aafce | ||
|
|
066669cfee | ||
|
|
87177d9d43 | ||
|
|
0c75a154a8 | ||
|
|
0a6f6d2b0e | ||
|
|
6755b03f12 | ||
|
|
e759ddced2 | ||
|
|
1ad28d8515 | ||
|
|
3d36b11c8f | ||
|
|
a15df6d455 | ||
|
|
9f0488dc32 | ||
|
|
f3dba82b04 | ||
|
|
c999ce0787 | ||
|
|
5b76bf9552 | ||
|
|
9cf9b856b0 | ||
|
|
db6c142afd | ||
|
|
79405426fa | ||
|
|
00b09a9a04 | ||
|
|
f5e9b61f73 | ||
|
|
4371081763 | ||
|
|
9530ff68ab | ||
|
|
51dc79dc22 | ||
|
|
b559faec2a | ||
|
|
d7b1456584 | ||
|
|
23894c1a0a | ||
|
|
1e691b2470 | ||
|
|
c5555dd8cc | ||
|
|
32168be6c7 | ||
|
|
78c14f81a8 |
2
LICENSE
2
LICENSE
@@ -1,5 +1,5 @@
|
||||
Copyright (c) 2008-2019 Pivotal Labs
|
||||
Copyright (c) 2008-2025 The Jasmine developers
|
||||
Copyright (c) 2008-2026 The Jasmine developers
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
|
||||
@@ -30,7 +30,7 @@ Microsoft Edge) as well as Node.
|
||||
| Environment | Supported versions |
|
||||
|-------------------|----------------------------------|
|
||||
| Node | 20, 22, 24 |
|
||||
| Safari | 16*, 17*, 26* |
|
||||
| Safari | 26* |
|
||||
| Chrome | Evergreen |
|
||||
| Firefox | Evergreen, 102*, 115*, 128*, 140 |
|
||||
| Edge | Evergreen |
|
||||
@@ -60,5 +60,5 @@ To find out what environments work with a particular Jasmine release, see the [r
|
||||
* Sheel Choksi
|
||||
|
||||
Copyright (c) 2008-2019 Pivotal Labs<br>
|
||||
Copyright (c) 2008-2025 The Jasmine developers<br>
|
||||
Copyright (c) 2008-2026 The Jasmine developers<br>
|
||||
This software is licensed under the [MIT License](https://github.com/jasmine/jasmine/blob/main/LICENSE).
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Copyright (c) 2008-2019 Pivotal Labs
|
||||
Copyright (c) 2008-2025 The Jasmine developers
|
||||
Copyright (c) 2008-2026 The Jasmine developers
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Copyright (c) 2008-2019 Pivotal Labs
|
||||
Copyright (c) 2008-2025 The Jasmine developers
|
||||
Copyright (c) 2008-2026 The Jasmine developers
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Copyright (c) 2008-2019 Pivotal Labs
|
||||
Copyright (c) 2008-2025 The Jasmine developers
|
||||
Copyright (c) 2008-2026 The Jasmine developers
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
@@ -41,23 +41,6 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
const env = jasmine.getEnv();
|
||||
const urls = new jasmine.HtmlReporterV2Urls();
|
||||
|
||||
/**
|
||||
* ## Reporters
|
||||
* The `HtmlReporter` builds all of the HTML UI for the runner page. This reporter paints the dots, stars, and x's for specs, as well as all spec names and all failures (if any).
|
||||
*/
|
||||
const htmlReporter = new jasmine.HtmlReporterV2({
|
||||
env,
|
||||
urls,
|
||||
getContainer() {
|
||||
return document.body;
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* The `jsApiReporter` also receives spec results, and is used by any environment that needs to extract the results from JavaScript.
|
||||
*/
|
||||
env.addReporter(jsApiReporter);
|
||||
env.addReporter(htmlReporter);
|
||||
/**
|
||||
* Configures Jasmine based on the current set of query parameters. This
|
||||
* supports all parameters set by the HTML reporter as well as
|
||||
@@ -66,18 +49,16 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
env.configure(urls.configFromCurrentUrl());
|
||||
|
||||
/**
|
||||
* ## Execution
|
||||
*
|
||||
* Replace the browser window's `onload`, ensure it's called, and then run all of the loaded specs. This includes initializing the `HtmlReporter` instance and then executing the loaded Jasmine environment. All of this will happen after all of the specs are loaded.
|
||||
*/
|
||||
const currentWindowOnload = window.onload;
|
||||
|
||||
window.onload = function() {
|
||||
if (currentWindowOnload) {
|
||||
currentWindowOnload();
|
||||
}
|
||||
htmlReporter.initialize();
|
||||
|
||||
// The HTML reporter needs to be set up here so it can access the DOM. Other
|
||||
// reporters can be added at any time before env.execute() is called.
|
||||
const htmlReporter = new jasmine.HtmlReporterV2({ env, urls });
|
||||
env.addReporter(htmlReporter);
|
||||
env.execute();
|
||||
};
|
||||
})();
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Copyright (c) 2008-2019 Pivotal Labs
|
||||
Copyright (c) 2008-2025 The Jasmine developers
|
||||
Copyright (c) 2008-2026 The Jasmine developers
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
@@ -309,12 +309,14 @@ jasmineRequire.HtmlSpecFilter = function(j$) {
|
||||
* @deprecated Use {@link HtmlReporterV2Urls} instead.
|
||||
*/
|
||||
function HtmlSpecFilter(options) {
|
||||
j$.getEnv().deprecated(
|
||||
const env = options?.env ?? j$.getEnv();
|
||||
env.deprecated(
|
||||
'HtmlReporter and HtmlSpecFilter are deprecated. Use HtmlReporterV2 instead.'
|
||||
);
|
||||
|
||||
const filterString =
|
||||
options &&
|
||||
options.filterString &&
|
||||
options.filterString() &&
|
||||
options.filterString().replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&');
|
||||
const filterPattern = new RegExp(filterString);
|
||||
@@ -472,45 +474,6 @@ jasmineRequire.AlertsView = function(j$) {
|
||||
);
|
||||
}
|
||||
|
||||
// TODO: remove this once HtmlReporterV2 doesn't use it
|
||||
addFailureToggle(onClickFailures, onClickSpecList) {
|
||||
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.rootEl.appendChild(
|
||||
createDom(
|
||||
'span',
|
||||
{ className: 'jasmine-menu jasmine-bar jasmine-spec-list' },
|
||||
[createDom('span', {}, 'Spec List | '), failuresLink]
|
||||
)
|
||||
);
|
||||
this.rootEl.appendChild(
|
||||
createDom(
|
||||
'span',
|
||||
{ className: 'jasmine-menu jasmine-bar jasmine-failure-list' },
|
||||
[specListLink, createDom('span', {}, ' | Failures ')]
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
addGlobalFailure(failure) {
|
||||
this.#createAndAdd(
|
||||
errorBarClassName,
|
||||
@@ -940,7 +903,7 @@ jasmineRequire.htmlReporterUtils = function(j$) {
|
||||
const el = document.createElement(type);
|
||||
let children;
|
||||
|
||||
if (j$.private.isArray(childrenArrayOrVarArgs)) {
|
||||
if (Array.isArray(childrenArrayOrVarArgs)) {
|
||||
children = childrenArrayOrVarArgs;
|
||||
} else {
|
||||
children = [];
|
||||
@@ -1007,12 +970,12 @@ jasmineRequire.HtmlReporterV2 = function(j$) {
|
||||
* const reporter = new jasmine.HtmlReporterV2({
|
||||
* env,
|
||||
* urls,
|
||||
* getContainer: () => document.body
|
||||
* // container is optional and defaults to document.body.
|
||||
* container: someElement
|
||||
* });
|
||||
*/
|
||||
class HtmlReporterV2 {
|
||||
#env;
|
||||
#getContainer;
|
||||
#container;
|
||||
#queryString;
|
||||
#urlBuilder;
|
||||
#filterSpecs;
|
||||
@@ -1029,9 +992,7 @@ jasmineRequire.HtmlReporterV2 = function(j$) {
|
||||
#failures;
|
||||
|
||||
constructor(options) {
|
||||
this.#env = options.env;
|
||||
|
||||
this.#getContainer = options.getContainer;
|
||||
this.#container = options.container || document.body;
|
||||
this.#queryString =
|
||||
options.queryString ||
|
||||
new j$.QueryString({
|
||||
@@ -1044,16 +1005,8 @@ jasmineRequire.HtmlReporterV2 = function(j$) {
|
||||
getSuiteById: id => this.#stateBuilder.suitesById[id]
|
||||
});
|
||||
this.#filterSpecs = options.urls.filteringSpecs();
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the reporter. Should be called before {@link Env#execute}.
|
||||
* @function
|
||||
* @name HtmlReporter#initialize
|
||||
*/
|
||||
initialize() {
|
||||
this.#clearPrior();
|
||||
this.#config = this.#env ? this.#env.configuration() : {};
|
||||
this.#config = options.env ? options.env.configuration() : {};
|
||||
|
||||
this.#stateBuilder = new j$.private.ResultsStateBuilder();
|
||||
|
||||
@@ -1094,13 +1047,15 @@ jasmineRequire.HtmlReporterV2 = function(j$) {
|
||||
this.#alerts.rootEl,
|
||||
this.#failures.rootEl
|
||||
);
|
||||
this.#getContainer().appendChild(this.#htmlReporterMain);
|
||||
this.#container.appendChild(this.#htmlReporterMain);
|
||||
this.#failures.show();
|
||||
}
|
||||
|
||||
jasmineStarted(options) {
|
||||
this.#stateBuilder.jasmineStarted(options);
|
||||
this.#progress.start(options.totalSpecsDefined);
|
||||
this.#progress.start(
|
||||
options.totalSpecsDefined - options.numExcludedSpecs
|
||||
);
|
||||
}
|
||||
|
||||
suiteStarted(result) {
|
||||
@@ -1185,19 +1140,11 @@ jasmineRequire.HtmlReporterV2 = function(j$) {
|
||||
}
|
||||
|
||||
#find(selector) {
|
||||
return this.#getContainer().querySelector(
|
||||
return this.#container.querySelector(
|
||||
'.jasmine_html-reporter ' + selector
|
||||
);
|
||||
}
|
||||
|
||||
#clearPrior() {
|
||||
const oldReporter = this.#find('');
|
||||
|
||||
if (oldReporter) {
|
||||
this.#getContainer().removeChild(oldReporter);
|
||||
}
|
||||
}
|
||||
|
||||
#setMenuModeTo(mode) {
|
||||
this.#htmlReporterMain.setAttribute(
|
||||
'class',
|
||||
@@ -1216,7 +1163,9 @@ jasmineRequire.HtmlReporterV2 = function(j$) {
|
||||
}
|
||||
|
||||
specDone(result) {
|
||||
this.rootEl.value = this.rootEl.value + 1;
|
||||
if (result.status !== 'excluded') {
|
||||
this.rootEl.value = this.rootEl.value + 1;
|
||||
}
|
||||
|
||||
if (result.status === 'failed') {
|
||||
this.rootEl.classList.add('failed');
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Copyright (c) 2008-2019 Pivotal Labs
|
||||
Copyright (c) 2008-2025 The Jasmine developers
|
||||
Copyright (c) 2008-2026 The Jasmine developers
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
@@ -43,10 +43,18 @@ var getJasmineRequireObj = (function() {
|
||||
return jasmineRequire;
|
||||
}
|
||||
|
||||
const loadedAsBrowserEsm =
|
||||
globalThis.document && !globalThis.document.currentScript;
|
||||
|
||||
getJasmineRequire().core = function(jRequire) {
|
||||
const j$ = { private: {} };
|
||||
const j$ = {};
|
||||
Object.defineProperty(j$, 'private', {
|
||||
enumerable: true,
|
||||
value: {}
|
||||
});
|
||||
|
||||
jRequire.base(j$, globalThis);
|
||||
j$.private.deprecateMonkeyPatching = jRequire.deprecateMonkeyPatching(j$);
|
||||
j$.private.util = jRequire.util(j$);
|
||||
j$.private.errors = jRequire.errors();
|
||||
j$.private.formatErrorMsg = jRequire.formatErrorMsg(j$);
|
||||
@@ -56,7 +64,7 @@ var getJasmineRequireObj = (function() {
|
||||
j$.private.CallTracker = jRequire.CallTracker(j$);
|
||||
j$.private.MockDate = jRequire.MockDate(j$);
|
||||
j$.private.getStackClearer = jRequire.StackClearer(j$);
|
||||
j$.private.Clock = jRequire.Clock();
|
||||
j$.private.Clock = jRequire.Clock(j$);
|
||||
j$.private.DelayedFunctionScheduler = jRequire.DelayedFunctionScheduler(j$);
|
||||
j$.private.Deprecator = jRequire.Deprecator(j$);
|
||||
j$.private.Configuration = jRequire.Configuration(j$);
|
||||
@@ -119,8 +127,21 @@ var getJasmineRequireObj = (function() {
|
||||
j$.private.matchers = jRequire.requireMatchers(jRequire, j$);
|
||||
j$.private.asyncMatchers = jRequire.requireAsyncMatchers(jRequire, j$);
|
||||
|
||||
j$.private.loadedAsBrowserEsm =
|
||||
globalThis.document && !globalThis.document.currentScript;
|
||||
j$.private.loadedAsBrowserEsm = loadedAsBrowserEsm;
|
||||
|
||||
j$.private.deprecateMonkeyPatching(j$, [
|
||||
// These are meant to be set by users.
|
||||
'DEFAULT_TIMEOUT_INTERVAL',
|
||||
'MAX_PRETTY_PRINT_ARRAY_LENGTH',
|
||||
'MAX_PRETTY_PRINT_CHARS',
|
||||
'MAX_PRETTY_PRINT_DEPTH',
|
||||
|
||||
// These are part of the deprecation warning mechanism. To avoid infinite
|
||||
// recursion, they're separately protected in a way that doesn't emit
|
||||
// deprecation warnings.
|
||||
'private',
|
||||
'getEnv'
|
||||
]);
|
||||
|
||||
return j$;
|
||||
};
|
||||
@@ -201,7 +222,7 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) {
|
||||
* Maximum number of characters to display when pretty printing objects.
|
||||
* Characters past this number will be ellipised.
|
||||
* @name jasmine.MAX_PRETTY_PRINT_CHARS
|
||||
* @default 100
|
||||
* @default 1000
|
||||
* @since 2.9.0
|
||||
*/
|
||||
j$.MAX_PRETTY_PRINT_CHARS = 1000;
|
||||
@@ -246,16 +267,15 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) {
|
||||
* @function
|
||||
* @return {Env}
|
||||
*/
|
||||
j$.getEnv = function(options) {
|
||||
const env = (j$.private.currentEnv_ =
|
||||
j$.private.currentEnv_ || new j$.private.Env(options));
|
||||
//jasmine. singletons in here (setTimeout blah blah).
|
||||
return env;
|
||||
};
|
||||
|
||||
j$.private.isArray = function(value) {
|
||||
return j$.private.isA('Array', value);
|
||||
};
|
||||
Object.defineProperty(j$, 'getEnv', {
|
||||
enumerable: true,
|
||||
value: function(options) {
|
||||
const env = (j$.private.currentEnv_ =
|
||||
j$.private.currentEnv_ || new j$.private.Env(options));
|
||||
//jasmine. singletons in here (setTimeout blah blah).
|
||||
return env;
|
||||
}
|
||||
});
|
||||
|
||||
j$.private.isObject = function(value) {
|
||||
return (
|
||||
@@ -956,7 +976,7 @@ getJasmineRequireObj().Spec = function(j$) {
|
||||
* @property {ExpectationResult[]} passedExpectations - The list of expectations that passed during execution of this spec.
|
||||
* @property {ExpectationResult[]} deprecationWarnings - The list of deprecation warnings that occurred during execution this spec.
|
||||
* @property {String} pendingReason - If the spec is {@link pending}, this will be the reason.
|
||||
* @property {String} status - Once the spec has completed, this string represents the pass/fail status of this spec.
|
||||
* @property {String} status - The result of this spec. May be 'passed', 'failed', 'pending', or 'excluded'.
|
||||
* @property {number} duration - The time in ms used by the spec execution, including any before/afterEach.
|
||||
* @property {Object} properties - User-supplied properties, if any, that were set using {@link Env#setSpecProperty}
|
||||
* @property {DebugLogEntry[]|null} debugLogs - Messages, if any, that were logged using {@link jasmine.debugLog} during a failing spec.
|
||||
@@ -1520,10 +1540,13 @@ getJasmineRequireObj().Env = function(j$) {
|
||||
* @param {String|Error} deprecation The deprecation message
|
||||
* @param {Object} [options] Optional extra options, as described above
|
||||
*/
|
||||
this.deprecated = function(deprecation, options) {
|
||||
const runable = runner.currentRunable() || topSuite;
|
||||
deprecator.addDeprecationWarning(runable, deprecation, options);
|
||||
};
|
||||
Object.defineProperty(this, 'deprecated', {
|
||||
enumerable: true,
|
||||
value: function(deprecation, options) {
|
||||
const runable = runner.currentRunable() || topSuite;
|
||||
deprecator.addDeprecationWarning(runable, deprecation, options);
|
||||
}
|
||||
});
|
||||
|
||||
function runQueue(options) {
|
||||
options.clearStack = options.clearStack || stackClearer;
|
||||
@@ -1550,7 +1573,8 @@ getJasmineRequireObj().Env = function(j$) {
|
||||
runQueue
|
||||
});
|
||||
topSuite = suiteBuilder.topSuite;
|
||||
const deprecator = new j$.private.Deprecator(topSuite);
|
||||
const deprecator =
|
||||
envOptions?.deprecator ?? new j$.private.Deprecator(topSuite);
|
||||
|
||||
/**
|
||||
* Provides the root suite, through which all suites and specs can be
|
||||
@@ -2045,9 +2069,18 @@ getJasmineRequireObj().Env = function(j$) {
|
||||
}
|
||||
};
|
||||
|
||||
this.pp = function(value) {
|
||||
const pp = runner.currentRunable()
|
||||
? runableResources.makePrettyPrinter()
|
||||
: j$.private.basicPrettyPrinter;
|
||||
return pp(value);
|
||||
};
|
||||
|
||||
this.cleanup_ = function() {
|
||||
uninstallGlobalErrors();
|
||||
};
|
||||
|
||||
j$.private.deprecateMonkeyPatching(this, ['deprecated']);
|
||||
}
|
||||
|
||||
function indirectCallerFilename(depth) {
|
||||
@@ -2064,11 +2097,13 @@ getJasmineRequireObj().Env = function(j$) {
|
||||
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();
|
||||
@@ -2295,7 +2330,7 @@ getJasmineRequireObj().ArrayContaining = function(j$) {
|
||||
}
|
||||
|
||||
ArrayContaining.prototype.asymmetricMatch = function(other, matchersUtil) {
|
||||
if (!j$.private.isArray(this.sample)) {
|
||||
if (!Array.isArray(this.sample)) {
|
||||
throw new Error(
|
||||
'You must provide an array to arrayContaining, not ' +
|
||||
j$.private.basicPrettyPrinter(this.sample) +
|
||||
@@ -2306,7 +2341,7 @@ getJasmineRequireObj().ArrayContaining = function(j$) {
|
||||
// If the actual parameter is not an array, we can fail immediately, since it couldn't
|
||||
// possibly be an "array containing" anything. However, we also want an empty sample
|
||||
// array to match anything, so we need to double-check we aren't in that case
|
||||
if (!j$.private.isArray(other) && this.sample.length > 0) {
|
||||
if (!Array.isArray(other) && this.sample.length > 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -2337,7 +2372,7 @@ getJasmineRequireObj().ArrayWithExactContents = function(j$) {
|
||||
other,
|
||||
matchersUtil
|
||||
) {
|
||||
if (!j$.private.isArray(this.sample)) {
|
||||
if (!Array.isArray(this.sample)) {
|
||||
throw new Error(
|
||||
'You must provide an array to arrayWithExactContents, not ' +
|
||||
j$.private.basicPrettyPrinter(this.sample) +
|
||||
@@ -2373,7 +2408,7 @@ getJasmineRequireObj().Empty = function(j$) {
|
||||
Empty.prototype.asymmetricMatch = function(other) {
|
||||
if (
|
||||
j$.private.isString(other) ||
|
||||
j$.private.isArray(other) ||
|
||||
Array.isArray(other) ||
|
||||
j$.private.isTypedArray(other)
|
||||
) {
|
||||
return other.length === 0;
|
||||
@@ -2488,7 +2523,7 @@ getJasmineRequireObj().NotEmpty = function(j$) {
|
||||
NotEmpty.prototype.asymmetricMatch = function(other) {
|
||||
if (
|
||||
j$.private.isString(other) ||
|
||||
j$.private.isArray(other) ||
|
||||
Array.isArray(other) ||
|
||||
j$.private.isTypedArray(other)
|
||||
) {
|
||||
return other.length !== 0;
|
||||
@@ -2920,7 +2955,7 @@ getJasmineRequireObj().CallTracker = function(j$) {
|
||||
return CallTracker;
|
||||
};
|
||||
|
||||
getJasmineRequireObj().Clock = function() {
|
||||
getJasmineRequireObj().Clock = function(j$) {
|
||||
'use strict';
|
||||
|
||||
/* global process */
|
||||
@@ -3113,6 +3148,9 @@ callbacks to execute _before_ running the next one.
|
||||
clearTimeout[IsMockClockTimingFn] = true;
|
||||
setInterval[IsMockClockTimingFn] = true;
|
||||
clearInterval[IsMockClockTimingFn] = true;
|
||||
|
||||
j$.private.deprecateMonkeyPatching(this);
|
||||
|
||||
return this;
|
||||
|
||||
// Advances the Clock's time until the mode changes.
|
||||
@@ -3821,6 +3859,29 @@ getJasmineRequireObj().DelayedFunctionScheduler = function(j$) {
|
||||
return DelayedFunctionScheduler;
|
||||
};
|
||||
|
||||
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;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
getJasmineRequireObj().Deprecator = function(j$) {
|
||||
'use strict';
|
||||
|
||||
@@ -3942,7 +4003,8 @@ getJasmineRequireObj().ExceptionFormatter = function(j$) {
|
||||
'lineNumber',
|
||||
'column',
|
||||
'description',
|
||||
'jasmineMessage'
|
||||
'jasmineMessage',
|
||||
'errors'
|
||||
];
|
||||
|
||||
function ExceptionFormatter(options) {
|
||||
@@ -4008,6 +4070,19 @@ getJasmineRequireObj().ExceptionFormatter = function(j$) {
|
||||
lines = lines.concat(substack);
|
||||
}
|
||||
|
||||
if (Array.isArray(error.errors)) {
|
||||
for (let i = 0; i < error.errors.length; i++) {
|
||||
if (error.errors[i] instanceof Error) {
|
||||
lines.push('');
|
||||
const substack = this.stack_(error.errors[i], {
|
||||
messageHandling: 'require'
|
||||
});
|
||||
substack[0] = 'Error ' + (i + 1) + ': ' + substack[0];
|
||||
lines = lines.concat(substack.map(x => ' ' + x));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return lines;
|
||||
};
|
||||
|
||||
@@ -5288,7 +5363,7 @@ getJasmineRequireObj().MatchersUtil = function(j$) {
|
||||
this.customTesters_ = options.customTesters || [];
|
||||
/**
|
||||
* Formats a value for use in matcher failure messages and similar contexts,
|
||||
* taking into account the current set of custom value formatters.
|
||||
* taking into account the current set of custom object formatters.
|
||||
* @function
|
||||
* @name MatchersUtil#pp
|
||||
* @since 3.6.0
|
||||
@@ -8200,7 +8275,7 @@ getJasmineRequireObj().makePrettyPrinter = function(j$) {
|
||||
} else if (
|
||||
value.toString &&
|
||||
typeof value === 'object' &&
|
||||
!j$.private.isArray(value) &&
|
||||
!Array.isArray(value) &&
|
||||
hasCustomToString(value)
|
||||
) {
|
||||
try {
|
||||
@@ -8212,15 +8287,12 @@ getJasmineRequireObj().makePrettyPrinter = function(j$) {
|
||||
} else if (this.seen.includes(value)) {
|
||||
this.emitScalar(
|
||||
'<circular reference: ' +
|
||||
(j$.private.isArray(value) ? 'Array' : 'Object') +
|
||||
(Array.isArray(value) ? 'Array' : 'Object') +
|
||||
'>'
|
||||
);
|
||||
} else if (
|
||||
j$.private.isArray(value) ||
|
||||
j$.private.isA('Object', value)
|
||||
) {
|
||||
} else if (Array.isArray(value) || j$.private.isA('Object', value)) {
|
||||
this.seen.push(value);
|
||||
if (j$.private.isArray(value)) {
|
||||
if (Array.isArray(value)) {
|
||||
this.emitArray(value);
|
||||
} else {
|
||||
this.emitObject(value);
|
||||
@@ -8243,10 +8315,7 @@ getJasmineRequireObj().makePrettyPrinter = function(j$) {
|
||||
}
|
||||
|
||||
iterateObject(obj, fn) {
|
||||
const objKeys = j$.private.MatchersUtil.keys(
|
||||
obj,
|
||||
j$.private.isArray(obj)
|
||||
);
|
||||
const objKeys = j$.private.MatchersUtil.keys(obj, Array.isArray(obj));
|
||||
const length = Math.min(objKeys.length, j$.MAX_PRETTY_PRINT_ARRAY_LENGTH);
|
||||
|
||||
for (let i = 0; i < length; i++) {
|
||||
@@ -8908,7 +8977,6 @@ getJasmineRequireObj().reporterEvents = function(j$) {
|
||||
* {@link ReporterCapabilities} will apply.
|
||||
* @name Reporter#reporterCapabilities
|
||||
* @type ReporterCapabilities | undefined
|
||||
* @optional
|
||||
* @since 5.0
|
||||
*/
|
||||
/**
|
||||
@@ -8975,7 +9043,6 @@ getJasmineRequireObj().reporterEvents = function(j$) {
|
||||
/**
|
||||
* `specStarted` is invoked when an `it` starts to run (including associated `beforeEach` functions)
|
||||
* @function
|
||||
* @optional
|
||||
* @name Reporter#specStarted
|
||||
* @param {SpecStartedEvent} result Information about the individual {@link it} being run
|
||||
* @param {Function} [done] Used to specify to Jasmine that this callback is asynchronous and Jasmine should wait until it has been called before moving on.
|
||||
@@ -9022,6 +9089,7 @@ getJasmineRequireObj().interface = function(jasmine, env) {
|
||||
* @since 1.3.0
|
||||
* @function
|
||||
* @global
|
||||
* @overwritable
|
||||
* @param {String} description Textual description of the group
|
||||
* @param {Function} specDefinitions Function for Jasmine to invoke that will define inner suites and specs
|
||||
*/
|
||||
@@ -9037,6 +9105,7 @@ getJasmineRequireObj().interface = function(jasmine, env) {
|
||||
* @since 1.3.0
|
||||
* @function
|
||||
* @global
|
||||
* @overwritable
|
||||
* @param {String} description Textual description of the group
|
||||
* @param {Function} specDefinitions Function for Jasmine to invoke that will define inner suites and specs
|
||||
*/
|
||||
@@ -9053,6 +9122,7 @@ getJasmineRequireObj().interface = function(jasmine, env) {
|
||||
* @since 2.1.0
|
||||
* @function
|
||||
* @global
|
||||
* @overwritable
|
||||
* @param {String} description Textual description of the group
|
||||
* @param {Function} specDefinitions Function for Jasmine to invoke that will define inner suites and specs
|
||||
*/
|
||||
@@ -9071,6 +9141,7 @@ getJasmineRequireObj().interface = function(jasmine, env) {
|
||||
* @since 1.3.0
|
||||
* @function
|
||||
* @global
|
||||
* @overwritable
|
||||
* @param {String} description Textual description of what this spec is checking
|
||||
* @param {implementationCallback} [testFunction] Function that contains the code of your test. If not provided the test will be `pending`.
|
||||
* @param {Int} [timeout={@link jasmine.DEFAULT_TIMEOUT_INTERVAL}] Custom timeout for an async spec.
|
||||
@@ -9088,6 +9159,7 @@ getJasmineRequireObj().interface = function(jasmine, env) {
|
||||
* @since 1.3.0
|
||||
* @function
|
||||
* @global
|
||||
* @overwritable
|
||||
* @param {String} description Textual description of what this spec is checking.
|
||||
* @param {implementationCallback} [testFunction] Function that contains the code of your test. Will not be executed.
|
||||
*/
|
||||
@@ -9103,6 +9175,7 @@ getJasmineRequireObj().interface = function(jasmine, env) {
|
||||
* @since 2.1.0
|
||||
* @function
|
||||
* @global
|
||||
* @overwritable
|
||||
* @param {String} description Textual description of what this spec is checking.
|
||||
* @param {implementationCallback} testFunction Function that contains the code of your test.
|
||||
* @param {Int} [timeout={@link jasmine.DEFAULT_TIMEOUT_INTERVAL}] Custom timeout for an async spec.
|
||||
@@ -9118,6 +9191,7 @@ getJasmineRequireObj().interface = function(jasmine, env) {
|
||||
* @since 1.3.0
|
||||
* @function
|
||||
* @global
|
||||
* @overwritable
|
||||
* @param {implementationCallback} [function] Function that contains the code to setup your specs.
|
||||
* @param {Int} [timeout={@link jasmine.DEFAULT_TIMEOUT_INTERVAL}] Custom timeout for an async beforeEach.
|
||||
* @see async
|
||||
@@ -9132,6 +9206,7 @@ getJasmineRequireObj().interface = function(jasmine, env) {
|
||||
* @since 1.3.0
|
||||
* @function
|
||||
* @global
|
||||
* @overwritable
|
||||
* @param {implementationCallback} [function] Function that contains the code to teardown your specs.
|
||||
* @param {Int} [timeout={@link jasmine.DEFAULT_TIMEOUT_INTERVAL}] Custom timeout for an async afterEach.
|
||||
* @see async
|
||||
@@ -9148,6 +9223,7 @@ getJasmineRequireObj().interface = function(jasmine, env) {
|
||||
* @since 2.1.0
|
||||
* @function
|
||||
* @global
|
||||
* @overwritable
|
||||
* @param {implementationCallback} [function] Function that contains the code to setup your specs.
|
||||
* @param {Int} [timeout={@link jasmine.DEFAULT_TIMEOUT_INTERVAL}] Custom timeout for an async beforeAll.
|
||||
* @see async
|
||||
@@ -9164,6 +9240,7 @@ getJasmineRequireObj().interface = function(jasmine, env) {
|
||||
* @since 2.1.0
|
||||
* @function
|
||||
* @global
|
||||
* @overwritable
|
||||
* @param {implementationCallback} [function] Function that contains the code to teardown your specs.
|
||||
* @param {Int} [timeout={@link jasmine.DEFAULT_TIMEOUT_INTERVAL}] Custom timeout for an async afterAll.
|
||||
* @see async
|
||||
@@ -9177,6 +9254,8 @@ getJasmineRequireObj().interface = function(jasmine, env) {
|
||||
* @name getSpecProperty
|
||||
* @since 5.10.0
|
||||
* @function
|
||||
* @global
|
||||
* @overwritable
|
||||
* @param {String} key The name of the property
|
||||
* @returns {*} The value of the property
|
||||
*/
|
||||
@@ -9189,6 +9268,8 @@ getJasmineRequireObj().interface = function(jasmine, env) {
|
||||
* @name setSpecProperty
|
||||
* @since 3.6.0
|
||||
* @function
|
||||
* @global
|
||||
* @overwritable
|
||||
* @param {String} key The name of the property
|
||||
* @param {*} value The value of the property
|
||||
*/
|
||||
@@ -9201,6 +9282,8 @@ getJasmineRequireObj().interface = function(jasmine, env) {
|
||||
* @name setSuiteProperty
|
||||
* @since 3.6.0
|
||||
* @function
|
||||
* @global
|
||||
* @overwritable
|
||||
* @param {String} key The name of the property
|
||||
* @param {*} value The value of the property
|
||||
*/
|
||||
@@ -9214,6 +9297,7 @@ getJasmineRequireObj().interface = function(jasmine, env) {
|
||||
* @since 1.3.0
|
||||
* @function
|
||||
* @global
|
||||
* @overwritable
|
||||
* @param {Object} actual - Actual computed value to test expectations against.
|
||||
* @return {matchers}
|
||||
*/
|
||||
@@ -9230,6 +9314,7 @@ getJasmineRequireObj().interface = function(jasmine, env) {
|
||||
* @since 3.3.0
|
||||
* @function
|
||||
* @global
|
||||
* @overwritable
|
||||
* @param {Object} actual - Actual computed value to test expectations against.
|
||||
* @return {async-matchers}
|
||||
* @example
|
||||
@@ -9256,8 +9341,8 @@ getJasmineRequireObj().interface = function(jasmine, env) {
|
||||
* @name throwUnlessAsync
|
||||
* @since 5.1.0
|
||||
* @function
|
||||
* @param actual
|
||||
* @global
|
||||
* @overwritable
|
||||
* @param {Object} actual - Actual computed value to test expectations against.
|
||||
* @return {matchers}
|
||||
*/
|
||||
@@ -9280,8 +9365,8 @@ getJasmineRequireObj().interface = function(jasmine, env) {
|
||||
* @name throwUnless
|
||||
* @since 5.1.0
|
||||
* @function
|
||||
* @param actual
|
||||
* @global
|
||||
* @overwritable
|
||||
* @param {Object} actual - Actual computed value to test expectations against.
|
||||
* @return {matchers}
|
||||
*/
|
||||
@@ -9295,6 +9380,7 @@ getJasmineRequireObj().interface = function(jasmine, env) {
|
||||
* @since 2.0.0
|
||||
* @function
|
||||
* @global
|
||||
* @overwritable
|
||||
* @param {String} [message] - Reason the spec is pending.
|
||||
*/
|
||||
pending: function() {
|
||||
@@ -9307,6 +9393,7 @@ getJasmineRequireObj().interface = function(jasmine, env) {
|
||||
* @since 2.1.0
|
||||
* @function
|
||||
* @global
|
||||
* @overwritable
|
||||
* @param {String|Error} [error] - Reason for the failure.
|
||||
*/
|
||||
fail: function() {
|
||||
@@ -9319,6 +9406,7 @@ getJasmineRequireObj().interface = function(jasmine, env) {
|
||||
* @since 1.3.0
|
||||
* @function
|
||||
* @global
|
||||
* @overwritable
|
||||
* @param {Object} obj - The object upon which to install the {@link Spy}.
|
||||
* @param {String} methodName - The name of the method to replace with a {@link Spy}.
|
||||
* @returns {Spy}
|
||||
@@ -9333,6 +9421,7 @@ getJasmineRequireObj().interface = function(jasmine, env) {
|
||||
* @since 2.6.0
|
||||
* @function
|
||||
* @global
|
||||
* @overwritable
|
||||
* @param {Object} obj - The object upon which to install the {@link Spy}
|
||||
* @param {String} propertyName - The name of the property to replace with a {@link Spy}.
|
||||
* @param {String} [accessType=get] - The access type (get|set) of the property to {@link Spy} on.
|
||||
@@ -9348,6 +9437,7 @@ getJasmineRequireObj().interface = function(jasmine, env) {
|
||||
* @since 3.2.1
|
||||
* @function
|
||||
* @global
|
||||
* @overwritable
|
||||
* @param {Object} obj - The object upon which to install the {@link Spy}s
|
||||
* @param {boolean} includeNonEnumerable - Whether or not to add spies to non-enumerable properties
|
||||
* @returns {Object} the spied object
|
||||
@@ -9371,6 +9461,7 @@ getJasmineRequireObj().interface = function(jasmine, env) {
|
||||
*/
|
||||
jasmine: jasmine
|
||||
};
|
||||
const existingKeys = Object.keys(jasmine);
|
||||
|
||||
/**
|
||||
* Add a custom equality tester for the current scope of specs.
|
||||
@@ -9500,6 +9591,21 @@ getJasmineRequireObj().interface = function(jasmine, env) {
|
||||
return env.setDefaultSpyStrategy(defaultStrategyFn);
|
||||
};
|
||||
|
||||
/**
|
||||
* Formats a value for display, taking into account the current set of
|
||||
* custom object formatters.
|
||||
*
|
||||
* @name jasmine.pp
|
||||
* @function
|
||||
* @since 6.0.0
|
||||
* @param {*} value The value to pretty-print
|
||||
* @return {string} The pretty-printed value
|
||||
* @see {MatchersUtil#pp}
|
||||
*/
|
||||
jasmine.pp = function(value) {
|
||||
return env.pp(value);
|
||||
};
|
||||
|
||||
/**
|
||||
* {@link AsymmetricEqualityTester|Asymmetric equality testers} allow for
|
||||
* non-exact matching in matchers that use Jasmine's deep value equality
|
||||
@@ -9522,6 +9628,8 @@ getJasmineRequireObj().interface = function(jasmine, env) {
|
||||
* @namespace asymmetricEqualityTesters
|
||||
*/
|
||||
|
||||
jasmine.private.deprecateMonkeyPatching(jasmine, existingKeys);
|
||||
|
||||
return jasmineInterface;
|
||||
};
|
||||
|
||||
@@ -9783,7 +9891,8 @@ getJasmineRequireObj().Runner = function(j$) {
|
||||
/**
|
||||
* Information passed to the {@link Reporter#jasmineStarted} event.
|
||||
* @typedef JasmineStartedInfo
|
||||
* @property {Int} totalSpecsDefined - The total number of specs defined in this suite. Note that this property is not present when Jasmine is run in parallel mode.
|
||||
* @property {int} totalSpecsDefined - The total number of specs defined in this suite. Note that this property is not present when Jasmine is run in parallel mode.
|
||||
* @property {int} numExcludedSpecs - The number of specs that will be excluded from execution. Note that this property is not present when Jasmine is run in parallel mode.
|
||||
* @property {Order} order - Information about the ordering (random or not) of this execution of the suite. Note that this property is not present when Jasmine is run in parallel mode.
|
||||
* @property {Boolean} parallel - Whether Jasmine is being run in parallel mode.
|
||||
* @since 2.0.0
|
||||
@@ -9792,6 +9901,7 @@ getJasmineRequireObj().Runner = function(j$) {
|
||||
// In parallel mode, the jasmineStarted event is separately dispatched
|
||||
// by jasmine-npm. This event only reaches reporters in non-parallel.
|
||||
totalSpecsDefined,
|
||||
numExcludedSpecs: this.#executionTree.numExcludedSpecs(),
|
||||
order: orderForReporting(order),
|
||||
parallel: false
|
||||
});
|
||||
@@ -10154,7 +10264,7 @@ getJasmineRequireObj().SpyFactory = function(j$) {
|
||||
|
||||
this.createSpyObj = function(baseName, methodNames, propertyNames) {
|
||||
const baseNameIsCollection =
|
||||
j$.private.isObject(baseName) || j$.private.isArray(baseName);
|
||||
j$.private.isObject(baseName) || Array.isArray(baseName);
|
||||
|
||||
if (baseNameIsCollection) {
|
||||
propertyNames = methodNames;
|
||||
@@ -10200,7 +10310,7 @@ getJasmineRequireObj().SpyFactory = function(j$) {
|
||||
|
||||
function normalizeKeyValues(object) {
|
||||
const result = [];
|
||||
if (j$.private.isArray(object)) {
|
||||
if (Array.isArray(object)) {
|
||||
for (let i = 0; i < object.length; i++) {
|
||||
result.push([object[i]]);
|
||||
}
|
||||
@@ -11898,6 +12008,23 @@ getJasmineRequireObj().TreeProcessor = function(j$) {
|
||||
const nodeStats = this.#stats[node.id];
|
||||
return node.children ? !nodeStats.willExecute : nodeStats.excluded;
|
||||
}
|
||||
|
||||
numExcludedSpecs(node) {
|
||||
if (!node) {
|
||||
return this.numExcludedSpecs(this.topSuite);
|
||||
} else if (node.children) {
|
||||
let result = 0;
|
||||
|
||||
for (const child of node.children) {
|
||||
result += this.numExcludedSpecs(child);
|
||||
}
|
||||
|
||||
return result;
|
||||
} else {
|
||||
const nodeStats = this.#stats[node.id];
|
||||
return nodeStats.willExecute ? 0 : 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function segmentChildren(node, orderedChildren, stats, executableIndex) {
|
||||
@@ -12295,5 +12422,5 @@ getJasmineRequireObj().UserContext = function(j$) {
|
||||
};
|
||||
|
||||
getJasmineRequireObj().version = function() {
|
||||
return '6.0.0-alpha.2';
|
||||
return '6.1.0';
|
||||
};
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "jasmine-core",
|
||||
"license": "MIT",
|
||||
"version": "6.0.0-alpha.2",
|
||||
"version": "6.1.0",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/jasmine/jasmine.git"
|
||||
@@ -43,10 +43,10 @@
|
||||
"ejs": "^3.1.10",
|
||||
"eslint": "^9.24.0",
|
||||
"eslint-plugin-compat": "^6.0.2",
|
||||
"glob": "^10.2.3",
|
||||
"glob": "^13.0.0",
|
||||
"globals": "^16.0.0",
|
||||
"jasmine": "github:jasmine/jasmine-npm#6.0",
|
||||
"jasmine-browser-runner": "github:jasmine/jasmine-browser-runner#4.0",
|
||||
"jasmine": "github:jasmine/jasmine-npm",
|
||||
"jasmine-browser-runner": "github:jasmine/jasmine-browser-runner",
|
||||
"jsdom": "^26.0.0",
|
||||
"prettier": "1.17.1",
|
||||
"sass": "^1.58.3"
|
||||
|
||||
44
release_notes/5.13.0.md
Normal file
44
release_notes/5.13.0.md
Normal file
@@ -0,0 +1,44 @@
|
||||
# Jasmine Core 5.13.0 Release Notes
|
||||
|
||||
## Changes to supported environments
|
||||
|
||||
Safari 26 is now supported on a best-effort basis.
|
||||
|
||||
Due to the limited availability of Safari 18 and later on free CI services,
|
||||
Safari support in future jasmine-core versions will be limited to:
|
||||
|
||||
* Best-effort support for the latest Safari version available on GitHub Actions,
|
||||
which may change at any time.
|
||||
* Best-effort support for Safari 16 and 17 for as long as it remains practical.
|
||||
|
||||
## New Features
|
||||
|
||||
* New `extraItStackFrames` and `extraDescribeStackFrames` config options to fix
|
||||
the filename properties of reporter events in configurations that wrap
|
||||
`it`/`describe`, such as zone.js. The `filename` properties of reporter events
|
||||
are no longer deprecated.
|
||||
* `jasmine.allOf` asymmetric equality tester
|
||||
* Merges [#2087](https://github.com/jasmine/jasmine/issues/2083) from @jonahd-g
|
||||
* Fixes [#2083](https://github.com/jasmine/jasmine/pull/2087)
|
||||
|
||||
## Supported environments
|
||||
|
||||
This version has been tested in the following environments.
|
||||
|
||||
| Environment | Supported versions |
|
||||
|-------------|--------------------------------|
|
||||
| Node | 18.20.5**, 20, 22, 24 |
|
||||
| Safari** | 16, 17, 26.1 |
|
||||
| Chrome | 142* |
|
||||
| Firefox | 102**, 115**, 128**, 140, 145* |
|
||||
| Edge | 142* |
|
||||
|
||||
\* Evergreen browser. Each version of Jasmine is tested against the latest
|
||||
version available at release time.<br>
|
||||
\** Supported on a best-effort basis. Support for these versions may be dropped
|
||||
if it becomes impractical, and bugs affecting only these versions may not be
|
||||
treated as release blockers.
|
||||
|
||||
------
|
||||
|
||||
_Release Notes generated with _[Anchorman](http://github.com/infews/anchorman)_
|
||||
74
release_notes/6.0.0-beta.0.md
Normal file
74
release_notes/6.0.0-beta.0.md
Normal file
@@ -0,0 +1,74 @@
|
||||
# Jasmine Core 6.0.0-beta.0 Release Notes
|
||||
|
||||
This is a pre-release, intended to offer a preview of upcoming changes and to
|
||||
solicit feedback.
|
||||
|
||||
## A Note About Pre-Release Compatibility
|
||||
|
||||
There may be additional breaking changes in future 6.0 pre-releases or in the
|
||||
final 6.0 release. That's allowed by the semver specification, but users are
|
||||
sometimes unpleasantly surprised by it.
|
||||
|
||||
NPM's implementation of carat version ranges assumes that subsequent
|
||||
pre-releases and final releases are fully compatible with earlier pre-releases.
|
||||
If your package.json contains `"jasmine-core": "^6.0.0-beta.0`,
|
||||
NPM might install any later 6.x version even though there is no guarantee of
|
||||
compatibility. If that isn't ok, you should specify an exact pre-release version:
|
||||
`"jasmine-core": "6.0.0-beta.0`.
|
||||
|
||||
|
||||
## Breaking changes
|
||||
|
||||
* boot1.js no longer adds jsApiReporter to the env.
|
||||
* HtmlReporterV2 initialization and boot1.js have been simplified. If you
|
||||
maintain your own boot file, update it to match the boot1.js included in this
|
||||
package.
|
||||
|
||||
|
||||
## New features
|
||||
|
||||
* Statically exposed pretty printer as jasmine.pp().
|
||||
|
||||
## Bug fixes
|
||||
|
||||
* Fixed HtmlReporterV2 progress bar when running a subset of specs.
|
||||
|
||||
|
||||
## Deprecations
|
||||
|
||||
* jsApiReporter is deprecated.
|
||||
* Detect monkey patching and emit a deprecation warning.
|
||||
|
||||
## Documentation improvements
|
||||
|
||||
* Documented the set of possible spec statuses.
|
||||
|
||||
|
||||
## Internal improvements
|
||||
|
||||
* Replaced isArray helper with native Array.isArray
|
||||
|
||||
|
||||
## Supported environments
|
||||
|
||||
This version has been tested in the following environments.
|
||||
|
||||
| Environment | Supported versions |
|
||||
|-------------------|--------------------------------|
|
||||
| Node | 20, 22, 24 |
|
||||
| Safari | 16**, 17**, 26.1** |
|
||||
| Chrome | 142* |
|
||||
| Firefox | 102**, 115**, 128**, 140, 145* |
|
||||
| Edge | 142* |
|
||||
|
||||
\* Evergreen browser. Each version of Jasmine is tested against the latest
|
||||
version available at release time.<br>
|
||||
\** Supported on a best-effort basis. Support for these versions may be dropped
|
||||
if it becomes impractical, and bugs affecting only these versions may not be
|
||||
treated as release blockers.
|
||||
|
||||
|
||||
|
||||
------
|
||||
|
||||
_Release Notes generated with _[Anchorman](http://github.com/infews/anchorman)_
|
||||
47
release_notes/6.0.0-beta.1.md
Normal file
47
release_notes/6.0.0-beta.1.md
Normal file
@@ -0,0 +1,47 @@
|
||||
# Jasmine Core 6.0.0-beta.1 Release Notes
|
||||
|
||||
This is a pre-release, intended to offer a preview of upcoming changes and to
|
||||
solicit feedback.
|
||||
|
||||
A corresponding release of the `jasmine` package is not planned because the
|
||||
change in this release only affects browser users.
|
||||
|
||||
## A Note About Pre-Release Compatibility
|
||||
|
||||
There may be additional breaking changes in future 6.0 pre-releases or in the
|
||||
final 6.0 release. That's allowed by the semver specification, but users are
|
||||
sometimes unpleasantly surprised by it.
|
||||
|
||||
NPM's implementation of carat version ranges assumes that subsequent
|
||||
pre-releases and final releases are fully compatible with earlier pre-releases.
|
||||
If your package.json contains `"jasmine-core": "^6.0.0-beta.1`,
|
||||
NPM might install any later 6.x version even though there is no guarantee of
|
||||
compatibility. If that isn't ok, you should specify an exact pre-release version:
|
||||
`"jasmine-core": "6.0.0-beta.1`.
|
||||
|
||||
## Bug Fixes
|
||||
|
||||
* Revert to using window.onload in boot1.js. This fixes top level await in
|
||||
jasmine-browser-runner.
|
||||
|
||||
## Supported environments
|
||||
|
||||
This version has been tested in the following environments.
|
||||
|
||||
| Environment | Supported versions |
|
||||
|-------------------|--------------------------------|
|
||||
| Node | 20, 22, 24 |
|
||||
| Safari** | 16, 17, 26.1 |
|
||||
| Chrome | 143* |
|
||||
| Firefox | 102**, 115**, 128**, 140, 145* |
|
||||
| Edge | 142* |
|
||||
|
||||
\* Evergreen browser. Each version of Jasmine is tested against the latest
|
||||
version available at release time.<br>
|
||||
\** Supported on a best-effort basis. Support for these versions may be dropped
|
||||
if it becomes impractical, and bugs affecting only these versions may not be
|
||||
treated as release blockers.
|
||||
|
||||
------
|
||||
|
||||
_Release Notes generated with _[Anchorman](http://github.com/infews/anchorman)_
|
||||
190
release_notes/6.0.0.md
Normal file
190
release_notes/6.0.0.md
Normal file
@@ -0,0 +1,190 @@
|
||||
# Jasmine Core 6.0.0 Release Notes
|
||||
|
||||
## Summary
|
||||
|
||||
This is a major release that includes breaking changes as well as significant
|
||||
new features. Many of the breaking changes and deprecations in this release are
|
||||
intended to improve the stability of the Jasmine ecosystem by making the
|
||||
distinction between public and private APIs more obvious, reducing exposure of
|
||||
jasmine-core's internal state, removing ambiguities from the reporter API, and
|
||||
warning about monkey patching.
|
||||
|
||||
6.x is intended to ba a relatively short-lived, transitional series. It is
|
||||
compatible with the current versions of karma-jasmine and other legacy Angular
|
||||
tools but emits deprecation warnings when used with them. 7.0 will drop
|
||||
compatibility with those tools. If you use Karma in a non-Angular context,
|
||||
consider migrating to a maintained alternative such as jasmine-browser-runner or
|
||||
web-test-runner. If you use Angular, please direct any questions about support
|
||||
for future versions of Jasmine to the Angular team.
|
||||
|
||||
Please see the [migration guide](https://jasmine.github.io/upgrade-guides/6.0)
|
||||
for more information. If you use Jasmine via the `jasmine` package, please see
|
||||
[its release notes](https://github.com/jasmine/jasmine-npm/blob/main/release_notes/6.0.0.md)
|
||||
as well.
|
||||
|
||||
|
||||
## Changes to supported environments
|
||||
|
||||
* Node 18 is no longer supported.
|
||||
|
||||
|
||||
## Breaking changes
|
||||
|
||||
### General
|
||||
|
||||
* Private APIs have been removed from the `jasmine` namespace.
|
||||
|
||||
The purpose of this change is to reduce the risk of users inadvertently
|
||||
depending on private APIs. Anything not covered by
|
||||
[the documentation](https://jasmine.github.io/pages/docs_home.html) remains
|
||||
private regardless of namespacing. Private APIs may be changed or removed in
|
||||
any release. This change is being made in a major release as a courtesy to
|
||||
users of libraries that depend on private APIs.
|
||||
|
||||
### Changes that affect spec writing
|
||||
|
||||
* Global error spies always receive a single argument. Previously, the browser
|
||||
error event was passed as the second argument.
|
||||
* If a spy is invoked via `.call(null, ...)` or `.apply(null, ...)`, the spy's
|
||||
`this` argument will be `null`. Previously it was `globalThis`.
|
||||
* Mock clock timing functions cannot be spied on. Previously this "worked" but
|
||||
prevented the mock clock from uninstalling itself.
|
||||
* The mock clock no longer supports the eval forms of `setTimeout` and
|
||||
`setInterval`.
|
||||
* Keys passed to `setSpecProperty`/`setSuiteProperty` must be strings. Values
|
||||
must be both structured-cloneable and JSON-serializable.
|
||||
|
||||
### Changes that affect configuration
|
||||
|
||||
* HTML reporters cache configuration throughout each run. Configuration changes
|
||||
made while specs are running will not affect reporter behavior.
|
||||
* If an execution order is passed to `Env#execute`, it must not enter any suite
|
||||
more than once.
|
||||
* The argument passed to spec filters is a
|
||||
[spec metadata](https://jasmine.github.io/api/6.0/Spec.html)
|
||||
instance, not the internal spec object.
|
||||
* The default value of the `forbidDuplicateNames` config option has been
|
||||
changed to true.
|
||||
|
||||
### Changes that affect reporters
|
||||
|
||||
This release includes changes that are intended to streamline and clarify the
|
||||
reporter interface, prevent sharing of mutable state, and prevent bugs involving
|
||||
non-serializable objects. These changes should be compatible with most existing
|
||||
reporters but could break reporters that manage their internal state in unusual
|
||||
ways.
|
||||
|
||||
* Meaningless properties such as `status` and `failedExpectations` are omitted
|
||||
from the events passed to [suiteStarted](https://jasmine.github.io/api/6.0/global.html#SuiteStartedEvent)
|
||||
and [specStarted](https://jasmine.github.io/api/6.0/global.html#SpecStartedEvent).
|
||||
* Reporter events are deep-cloned before being passed to each reporter. This
|
||||
protects reporters against later mutation by jasmine-core or other reporters.
|
||||
* The `expected` and `actual` properties of
|
||||
[passed and failed expectations](https://jasmine.github.io/api/6.0/global.html#ExpectationResult)
|
||||
have been removed.
|
||||
* The [order](https://jasmine.github.io/api/6.0/global.html#Order)
|
||||
property of the`jasmineStarted` and `jasmineDone` reporter events no longer
|
||||
includes undocumented properties.
|
||||
* boot1.js no longer adds `jsApiReporter` to the env.
|
||||
|
||||
### Changes that affect browser boot files
|
||||
|
||||
* The `createElement` and `createTextNode` options of the legacy `HtmlReporter`
|
||||
are ignored. `HtmlReporter` now unconditionally uses `document.createElement`
|
||||
and `document.createTextNode`.
|
||||
|
||||
### Changes to Node boot functions
|
||||
|
||||
* [boot](https://jasmine.github.io/api/6.0/module-jasmine-core.html#.boot)
|
||||
defaults to creating a new core instance each time it's called. This restores
|
||||
the pre-5.0 default behavior.
|
||||
* [noGlobals](https://jasmine.github.io/api/6.0/module-jasmine-core.html#.noGlobals)
|
||||
no longer takes a parameter. It always returns the same object when called
|
||||
repeatedly.
|
||||
|
||||
|
||||
## New features
|
||||
|
||||
* A new `HtmlReporterV2` with several improvements over the old `HtmlReporter`:
|
||||
* Clicking a spec/suite link does exact filtering rather than a substring
|
||||
match.
|
||||
* The old dots are replaced with a progress bar. This improves usability with
|
||||
large suites and fixes an accessibility problem.
|
||||
* Details of failed specs are displayed as soon as each spec finishes.
|
||||
* A Performance tab shows metrics and a list of the slowest specs.
|
||||
* Initialization and wire-up in boot files are much simpler.
|
||||
|
||||
If you're using jasmine-browser-runner or copying boot1.js from the standalone
|
||||
distribution, you'll automatically get the new reporter. If you maintain your
|
||||
own boot files, you'll get the old reporter unless you update your boot files
|
||||
to match the one that's in this package.
|
||||
|
||||
The new reporter produces `spec` query string parameters that are different
|
||||
from those created by the old reporter. If you use other software that
|
||||
interprets the `spec` parameter, such as karma-jasmine, you won't be able to
|
||||
adopt `HtmlReporterV2` unlesss that other software is updated.
|
||||
|
||||
* Larger body font size in HTML reporters
|
||||
* `globalThis` is used to determine the global object during initialization
|
||||
This makes jasmine-core more tolerant of buggy bundlers or loaders that
|
||||
cause `this` to be undefined in the global context.
|
||||
* Experimental [`safariYieldStrategy: "time"`](https://jasmine.github.io/api/6.0/Configuration.html#safariYieldStrategy)
|
||||
config option, which may make Jasmine run significantly faster in Safari and
|
||||
similar browsers. So far, this option has not been tested on a wide variety of
|
||||
workloads. Feedback is appreciated.
|
||||
* Statically exposed pretty printer as `jasmine.pp()`.
|
||||
|
||||
|
||||
## Deprecations
|
||||
|
||||
* Common monkey patching patterns are detected and result in a deprecation
|
||||
warning. Code that overwrites anything provided by jasmine-core (other than
|
||||
globals like `it`/`expect`/etc or configuration properties like
|
||||
`jasmine.DEFAULT_TIMEOUT_INTERVAL`) may be broken by any jasmine-core release.
|
||||
* Warn if jasmine-core is loaded as an ES module in a browser.
|
||||
This is an untested and unsupported configuration that has been known to cause
|
||||
problems.
|
||||
* `HtmlReporter` and `HtmlSpecFilter` are deprecated in favor of `HtmlReporterV2`.
|
||||
* `jsApiReporter` is deprecated.
|
||||
|
||||
|
||||
## Documentation improvements
|
||||
|
||||
* Improved API reference documentation for APIs that are used from browser boot
|
||||
files.
|
||||
* Documented the set of possible spec statuses.
|
||||
* Documented that globals are overwriteable.
|
||||
|
||||
|
||||
## Internal improvements
|
||||
|
||||
* Encapsulated suite and spec result and status management.
|
||||
* Adopted strict mode throughout the codebase.
|
||||
* Decomposed `HtmlReporter` into components and converted to ES6 classes.
|
||||
* Made global error handling more uniform between browsers and Node.
|
||||
* Removed code to support browsers that don't have `MessageChannel`. Jasmine
|
||||
hasn't run in any such browsers since 2.x.
|
||||
* Replaced `isArray` helper with native `Array.isArray`.
|
||||
|
||||
## Supported environments
|
||||
|
||||
This version has been tested in the following environments.
|
||||
|
||||
| Environment | Supported versions |
|
||||
|-------------------|--------------------------------|
|
||||
| Node | 20, 22, 24 |
|
||||
| Safari** | 16, 17, 26.2 |
|
||||
| Chrome | 143* |
|
||||
| Firefox | 102**, 115**, 128**, 140, 147* |
|
||||
| Edge | 143* |
|
||||
|
||||
\* Evergreen browser. Each version of Jasmine is tested against the latest
|
||||
version available at release time.<br>
|
||||
\** Supported on a best-effort basis. Support for these versions may be dropped
|
||||
if it becomes impractical, and bugs affecting only these versions may not be
|
||||
treated as release blockers.
|
||||
|
||||
|
||||
------
|
||||
|
||||
_Release Notes generated with _[Anchorman](http://github.com/infews/anchorman)_
|
||||
29
release_notes/6.0.1.md
Normal file
29
release_notes/6.0.1.md
Normal file
@@ -0,0 +1,29 @@
|
||||
# Jasmine Core 6.0.1 Release Notes
|
||||
|
||||
## Bug fixes
|
||||
|
||||
* Don't emit a deprecation warning when `jasmineRequire.core` is called from an
|
||||
ES module
|
||||
|
||||
## Supported environments
|
||||
|
||||
This version has been tested in the following environments.
|
||||
|
||||
| Environment | Supported versions |
|
||||
|-------------------|--------------------------------|
|
||||
| Node | 20, 22, 24 |
|
||||
| Safari** | 16, 17, 26.2 |
|
||||
| Chrome | 143* |
|
||||
| Firefox | 102**, 115**, 128**, 140, 147* |
|
||||
| Edge | 143* |
|
||||
|
||||
\* Evergreen browser. Each version of Jasmine is tested against the latest
|
||||
version available at release time.<br>
|
||||
\** Supported on a best-effort basis. Support for these versions may be dropped
|
||||
if it becomes impractical, and bugs affecting only these versions may not be
|
||||
treated as release blockers.
|
||||
|
||||
|
||||
------
|
||||
|
||||
_Release Notes generated with _[Anchorman](http://github.com/infews/anchorman)_
|
||||
40
release_notes/6.1.0.md
Normal file
40
release_notes/6.1.0.md
Normal file
@@ -0,0 +1,40 @@
|
||||
# Jasmine Core 6.1.0 Release Notes
|
||||
|
||||
## Changes to supported environments
|
||||
|
||||
* Safari 16 and 17 are no longer supported. Although jasmine-core may still work
|
||||
in those versions, we no longer have a reliable way to test them and won't try
|
||||
to maintain compatibility with them in future releases.
|
||||
|
||||
## New features
|
||||
|
||||
* Report the underlying errors that make up an `AggregateError`.
|
||||
* Merges [#2093](https://github.com/jasmine/jasmine/pull/2093) from @puglyfe
|
||||
* Fixes [#2063](https://github.com/jasmine/jasmine/issues/2063)
|
||||
|
||||
## Documentation improvements
|
||||
|
||||
* Fix default MAX_PRETTY_PRINT_CHARS in JsDoc.
|
||||
* Merges [#2091](https://github.com/jasmine/jasmine/pull/2091) from @HolgerJeromin
|
||||
|
||||
## Supported environments
|
||||
|
||||
This version has been tested in the following environments.
|
||||
|
||||
| Environment | Supported versions |
|
||||
|-------------------|--------------------------------|
|
||||
| Node | 20, 22, 24 |
|
||||
| Safari | 26.3** |
|
||||
| Chrome | 144* |
|
||||
| Firefox | 102**, 115**, 128**, 140, 147* |
|
||||
| Edge | 144* |
|
||||
|
||||
\* Evergreen browser. Each version of Jasmine is tested against the latest
|
||||
version available at release time.<br>
|
||||
\** Supported on a best-effort basis. Support for these versions may be dropped
|
||||
if it becomes impractical, and bugs affecting only these versions may not be
|
||||
treated as release blockers.
|
||||
|
||||
------
|
||||
|
||||
_Release Notes generated with _[Anchorman](http://github.com/infews/anchorman)_
|
||||
@@ -1,8 +1,8 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Run tests in supported browsers that are available on Saucelabs.
|
||||
# Note: The latest Safari version is tested via GitHub Actions because Saucelabs
|
||||
# only makes it available to paid enterprise accounts. See
|
||||
# Note: Safari is tested via GitHub Actions because Saucelabs only makes Safari
|
||||
# 18 and later available to paid enterprise accounts. See
|
||||
# .github/workflows/safari.yml.
|
||||
|
||||
run_browser() {
|
||||
@@ -44,9 +44,6 @@ else
|
||||
fi
|
||||
run_browser firefox 102
|
||||
|
||||
run_browser safari 17
|
||||
run_browser safari 16
|
||||
|
||||
run_browser MicrosoftEdge latest
|
||||
|
||||
echo
|
||||
|
||||
@@ -1247,4 +1247,25 @@ describe('Clock (acceptance)', function() {
|
||||
|
||||
clock.tick(400);
|
||||
});
|
||||
|
||||
describe('Warning about monkey patching', 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);
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@@ -26,8 +26,6 @@ describe('Env', function() {
|
||||
|
||||
describe('#topSuite', function() {
|
||||
it('returns an object that describes the tree of suites and specs', function() {
|
||||
spyOn(env, 'deprecated');
|
||||
|
||||
env.it('a top level spec');
|
||||
env.describe('a suite', function() {
|
||||
env.it('a spec');
|
||||
@@ -123,7 +121,6 @@ describe('Env', function() {
|
||||
});
|
||||
|
||||
it('ignores configuration properties that are present but undefined', function() {
|
||||
spyOn(env, 'deprecated');
|
||||
const initialConfig = {
|
||||
random: true,
|
||||
seed: '123',
|
||||
@@ -763,7 +760,6 @@ describe('Env', function() {
|
||||
|
||||
it("does not expose the suite as 'this'", function() {
|
||||
let suiteThis;
|
||||
spyOn(env, 'deprecated');
|
||||
|
||||
env.describe('a suite', function() {
|
||||
suiteThis = this;
|
||||
@@ -878,4 +874,44 @@ describe('Env', function() {
|
||||
}).toThrowError('Jasmine cannot be configured via Env in parallel mode');
|
||||
});
|
||||
});
|
||||
|
||||
describe('Warning about monkey patching', function() {
|
||||
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);
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@@ -346,5 +346,184 @@ describe('ExceptionFormatter', function() {
|
||||
}).not.toThrowError();
|
||||
});
|
||||
});
|
||||
|
||||
describe('when the error has an errors array (AggregateError)', function() {
|
||||
it('includes all aggregated errors in the stack trace', function() {
|
||||
const subject = new privateUnderTest.ExceptionFormatter();
|
||||
const error1 = (function fn1() {
|
||||
return new Error('first error');
|
||||
})();
|
||||
const error2 = (function fn2() {
|
||||
return new Error('second error');
|
||||
})();
|
||||
const aggregateError = (function fn3() {
|
||||
return new Error('Multiple errors occurred');
|
||||
})();
|
||||
aggregateError.errors = [error1, error2];
|
||||
|
||||
const lines = subject.stack(aggregateError).split('\n');
|
||||
|
||||
// TODO: be consistent across environments about whether the message is
|
||||
// included in the stack trace
|
||||
if (lines[0] === 'Error: Multiple errors occurred') {
|
||||
lines.shift();
|
||||
}
|
||||
|
||||
// Exclude lines that vary from environment to environment
|
||||
const filteredLines = lines.filter(
|
||||
x =>
|
||||
!x.includes('/jasmine.js:') &&
|
||||
// Some Node 20 and 22 minors when running in parallel
|
||||
!x.includes('process.processTicksAndRejections')
|
||||
);
|
||||
|
||||
for (let i = 0; i < filteredLines.length; i++) {
|
||||
jasmine.debugLog(`Line ${i} after filtering: ${filteredLines[i]}`);
|
||||
}
|
||||
|
||||
// Inexact matching because stack frame formatting varies from runtime
|
||||
// to runtime
|
||||
const expectedPatterns = [
|
||||
// Overall error
|
||||
/fn3.*ExceptionFormatterSpec\.js/,
|
||||
/ExceptionFormatterSpec\.js/,
|
||||
/^$/,
|
||||
|
||||
// First nested error
|
||||
/^ Error 1: Error: first error$/,
|
||||
/^ .*fn1.*ExceptionFormatterSpec\.js/,
|
||||
/^ .*ExceptionFormatterSpec\.js/,
|
||||
/^$/,
|
||||
|
||||
// Second nested error
|
||||
/^ .*Error 2: Error: second error$/,
|
||||
/^ .*fn2.*ExceptionFormatterSpec\.js/,
|
||||
/^ .*ExceptionFormatterSpec\.js/
|
||||
];
|
||||
|
||||
expect(filteredLines).toEqual(
|
||||
expectedPatterns.map(p => jasmine.stringMatching(p))
|
||||
);
|
||||
});
|
||||
|
||||
it('handles empty errors array', function() {
|
||||
const subject = new privateUnderTest.ExceptionFormatter();
|
||||
const aggregateError = new Error('No errors');
|
||||
aggregateError.errors = [];
|
||||
|
||||
expect(function() {
|
||||
subject.stack(aggregateError);
|
||||
}).not.toThrowError();
|
||||
});
|
||||
|
||||
it('handles nested AggregateError', function() {
|
||||
const subject = new privateUnderTest.ExceptionFormatter();
|
||||
const innerError1 = new Error('inner error 1');
|
||||
const innerError2 = new Error('inner error 2');
|
||||
const innerAggregate = new Error('Inner aggregate');
|
||||
innerAggregate.errors = [innerError1, innerError2];
|
||||
|
||||
const outerError = new Error('outer error');
|
||||
const outerAggregate = new Error('Outer aggregate');
|
||||
outerAggregate.errors = [innerAggregate, outerError];
|
||||
|
||||
const lines = subject.stack(outerAggregate).split('\n');
|
||||
|
||||
const innerAggMsgIx = lines.findIndex(line =>
|
||||
line.includes('Error 1: Error: Inner aggregate')
|
||||
);
|
||||
expect(innerAggMsgIx).toBeGreaterThan(-1);
|
||||
|
||||
const innerError1MsgIx = lines.findIndex(line =>
|
||||
line.includes('Error 1: Error: inner error 1')
|
||||
);
|
||||
expect(innerError1MsgIx).toBeGreaterThan(innerAggMsgIx);
|
||||
|
||||
const innerError2MsgIx = lines.findIndex(line =>
|
||||
line.includes('Error 2: Error: inner error 2')
|
||||
);
|
||||
expect(innerError2MsgIx).toBeGreaterThan(innerError1MsgIx);
|
||||
|
||||
const outerErrorMsgIx = lines.findIndex(line =>
|
||||
line.includes('Error 2: Error: outer error')
|
||||
);
|
||||
expect(outerErrorMsgIx).toBeGreaterThan(innerError2MsgIx);
|
||||
});
|
||||
|
||||
it('handles AggregateError containing error with cause', function() {
|
||||
const subject = new privateUnderTest.ExceptionFormatter();
|
||||
const rootCause = new Error('root cause');
|
||||
const errorWithCause = new Error('error with cause', {
|
||||
cause: rootCause
|
||||
});
|
||||
const aggregateError = new Error('Aggregate with cause chain');
|
||||
aggregateError.errors = [errorWithCause];
|
||||
|
||||
const lines = subject.stack(aggregateError).split('\n');
|
||||
|
||||
const error1MsgIx = lines.findIndex(line =>
|
||||
line.includes('Error 1: Error: error with cause')
|
||||
);
|
||||
expect(error1MsgIx).toBeGreaterThan(-1);
|
||||
|
||||
const causeMsgIx = lines.findIndex(line =>
|
||||
line.includes('Caused by: Error: root cause')
|
||||
);
|
||||
expect(causeMsgIx).toBeGreaterThan(error1MsgIx);
|
||||
});
|
||||
|
||||
it('skips non-Error items in errors array', function() {
|
||||
const subject = new privateUnderTest.ExceptionFormatter();
|
||||
const error1 = new Error('real error');
|
||||
const aggregateError = new Error('Mixed array');
|
||||
aggregateError.errors = [
|
||||
error1,
|
||||
'string error',
|
||||
{ message: 'object error' },
|
||||
null,
|
||||
undefined,
|
||||
42
|
||||
];
|
||||
|
||||
const lines = subject.stack(aggregateError).split('\n');
|
||||
|
||||
const error1MsgIx = lines.findIndex(line =>
|
||||
line.includes('Error 1: Error: real error')
|
||||
);
|
||||
expect(error1MsgIx).toBeGreaterThan(-1);
|
||||
|
||||
const hasStringError = lines.some(line =>
|
||||
line.includes('string error')
|
||||
);
|
||||
expect(hasStringError).toBe(false);
|
||||
|
||||
const hasObjectError = lines.some(line =>
|
||||
line.includes('object error')
|
||||
);
|
||||
expect(hasObjectError).toBe(false);
|
||||
});
|
||||
|
||||
it('works with native AggregateError constructor', function() {
|
||||
const subject = new privateUnderTest.ExceptionFormatter();
|
||||
const error1 = new Error('first error');
|
||||
const error2 = new Error('second error');
|
||||
const aggregateError = new AggregateError(
|
||||
[error1, error2],
|
||||
'Multiple errors'
|
||||
);
|
||||
|
||||
const lines = subject.stack(aggregateError).split('\n');
|
||||
|
||||
const error1MsgIx = lines.findIndex(line =>
|
||||
line.includes('Error 1: Error: first error')
|
||||
);
|
||||
expect(error1MsgIx).toBeGreaterThan(-1);
|
||||
|
||||
const error2MsgIx = lines.findIndex(line =>
|
||||
line.includes('Error 2: Error: second error')
|
||||
);
|
||||
expect(error2MsgIx).toBeGreaterThan(error1MsgIx);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -87,7 +87,7 @@ describe('Runner', function() {
|
||||
function arrayNotContaining(item) {
|
||||
return {
|
||||
asymmetricMatch(other, matchersUtil) {
|
||||
if (!jasmine.private.isArray(other)) {
|
||||
if (!Array.isArray(other)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -246,4 +246,53 @@ describe('TreeProcessor', function() {
|
||||
{ spec: leaf1 }
|
||||
]);
|
||||
});
|
||||
|
||||
describe("The returned ExecutionTree's numExcludedSpecs method", function() {
|
||||
it('counts filtered-out specs', function() {
|
||||
const included = new Leaf();
|
||||
const excluded1 = new Leaf();
|
||||
const excluded2 = new Leaf();
|
||||
const excluded3 = new Leaf();
|
||||
const topSuite = new Node({
|
||||
children: [
|
||||
excluded1,
|
||||
new Node({
|
||||
children: [included, excluded2, new Node({ children: [excluded3] })]
|
||||
})
|
||||
]
|
||||
});
|
||||
const processor = new privateUnderTest.TreeProcessor({
|
||||
tree: topSuite,
|
||||
runnableIds: [topSuite.id],
|
||||
excludeNode(node) {
|
||||
return node.id !== included.id;
|
||||
}
|
||||
});
|
||||
|
||||
const executionTree = processor.processTree();
|
||||
expect(executionTree.numExcludedSpecs()).toEqual(3);
|
||||
});
|
||||
|
||||
it("counts specs that aren't in or descendants of runnableIds", function() {
|
||||
const includedSuite = new Node({
|
||||
children: [new Node({ children: [new Leaf()] }), new Leaf()]
|
||||
});
|
||||
const directlyIncludedSpec = new Leaf();
|
||||
const topSuite = new Node({
|
||||
children: [
|
||||
includedSuite,
|
||||
new Node({
|
||||
children: [new Leaf(), directlyIncludedSpec]
|
||||
})
|
||||
]
|
||||
});
|
||||
const processor = new privateUnderTest.TreeProcessor({
|
||||
tree: topSuite,
|
||||
runnableIds: [includedSuite.id, directlyIncludedSpec.id]
|
||||
});
|
||||
|
||||
const executionTree = processor.processTree();
|
||||
expect(executionTree.numExcludedSpecs()).toEqual(1);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,20 +1,4 @@
|
||||
describe('util', function() {
|
||||
describe('isArray', function() {
|
||||
it('should return true if the argument is an array', function() {
|
||||
expect(privateUnderTest.isArray([])).toBe(true);
|
||||
expect(privateUnderTest.isArray(['a'])).toBe(true);
|
||||
});
|
||||
|
||||
it('should return false if the argument is not an array', function() {
|
||||
expect(privateUnderTest.isArray(undefined)).toBe(false);
|
||||
expect(privateUnderTest.isArray({})).toBe(false);
|
||||
expect(privateUnderTest.isArray(function() {})).toBe(false);
|
||||
expect(privateUnderTest.isArray('foo')).toBe(false);
|
||||
expect(privateUnderTest.isArray(5)).toBe(false);
|
||||
expect(privateUnderTest.isArray(null)).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe('isObject', function() {
|
||||
it('should return true if the argument is an object', function() {
|
||||
expect(privateUnderTest.isObject({})).toBe(true);
|
||||
|
||||
@@ -170,8 +170,15 @@ describe('base helpers', function() {
|
||||
});
|
||||
|
||||
describe('debugLog', function() {
|
||||
beforeEach(function() {
|
||||
privateUnderTest.currentEnv_ = jasmine.createSpyObj('env', ['debugLog']);
|
||||
});
|
||||
|
||||
afterEach(function() {
|
||||
privateUnderTest.currentEnv_ = null;
|
||||
});
|
||||
|
||||
it("forwards to the current env's debugLog function", function() {
|
||||
spyOn(jasmineUnderTest.getEnv(), 'debugLog');
|
||||
jasmineUnderTest.debugLog('a message');
|
||||
expect(jasmineUnderTest.getEnv().debugLog).toHaveBeenCalledWith(
|
||||
'a message'
|
||||
|
||||
@@ -1557,6 +1557,7 @@ describe('Env integration', function() {
|
||||
|
||||
expect(reporter.jasmineStarted).toHaveBeenCalledWith({
|
||||
totalSpecsDefined: 1,
|
||||
numExcludedSpecs: 0,
|
||||
order: { random: true, seed: jasmine.any(String) },
|
||||
parallel: false
|
||||
});
|
||||
@@ -1592,6 +1593,7 @@ describe('Env integration', function() {
|
||||
|
||||
expect(reporter.jasmineStarted).toHaveBeenCalledWith({
|
||||
totalSpecsDefined: 1,
|
||||
numExcludedSpecs: 0,
|
||||
order: { random: true, seed: jasmine.any(String) },
|
||||
parallel: false
|
||||
});
|
||||
@@ -1648,6 +1650,7 @@ describe('Env integration', function() {
|
||||
|
||||
expect(reporter.jasmineStarted).toHaveBeenCalledWith({
|
||||
totalSpecsDefined: 6,
|
||||
numExcludedSpecs: 3,
|
||||
order: { random: false },
|
||||
parallel: false
|
||||
});
|
||||
@@ -2061,6 +2064,7 @@ describe('Env integration', function() {
|
||||
|
||||
expect(reporter.jasmineStarted).toHaveBeenCalledWith({
|
||||
totalSpecsDefined: 1,
|
||||
numExcludedSpecs: 1,
|
||||
order: { random: true, seed: jasmine.any(String) },
|
||||
parallel: false
|
||||
});
|
||||
@@ -3842,6 +3846,34 @@ describe('Env integration', function() {
|
||||
});
|
||||
});
|
||||
|
||||
describe('pp', function() {
|
||||
it("pretty-prints using the current runable's custom object formatters", async function() {
|
||||
env.it('a spec', function() {
|
||||
env.addCustomObjectFormatter(function(x) {
|
||||
if (x === 1) {
|
||||
return 'hi!';
|
||||
}
|
||||
});
|
||||
env.expect(env.pp(1)).toEqual('hi!');
|
||||
});
|
||||
|
||||
const reporter = jasmine.createSpyObj('reporter', ['specDone']);
|
||||
env.addReporter(reporter);
|
||||
|
||||
await env.execute();
|
||||
|
||||
expect(reporter.specDone).toHaveBeenCalledWith(
|
||||
jasmine.objectContaining({
|
||||
failedExpectations: []
|
||||
})
|
||||
);
|
||||
});
|
||||
|
||||
it('works when there is no current runable', function() {
|
||||
expect(env.pp({ some: 'thing' })).toEqual("Object({ some: 'thing' })");
|
||||
});
|
||||
});
|
||||
|
||||
it('forbids duplicates when forbidDuplicateNames is true', function() {
|
||||
env.configure({ forbidDuplicateNames: true });
|
||||
env.it('a spec');
|
||||
|
||||
@@ -13,7 +13,72 @@ describe('The jasmine namespace', function() {
|
||||
expect(setDifference(actualKeys, expectedKeys())).toEqual(new Set());
|
||||
});
|
||||
|
||||
function expectedKeys() {
|
||||
describe('Warning about monkey patching', function() {
|
||||
beforeEach(function() {
|
||||
spyOn(console, 'error');
|
||||
});
|
||||
|
||||
for (const key of expectedKeys(false)) {
|
||||
if (!key.startsWith('MAX_') && key !== 'private' && key !== 'getEnv') {
|
||||
describe(`jasmine.${key}`, function() {
|
||||
let orig;
|
||||
|
||||
beforeEach(function() {
|
||||
orig = jasmineUnderTest[key];
|
||||
});
|
||||
|
||||
afterEach(function() {
|
||||
jasmineUnderTest[key] = orig;
|
||||
});
|
||||
|
||||
it('warns if monkey patched', function() {
|
||||
const patch = {};
|
||||
jasmineUnderTest[key] = patch;
|
||||
|
||||
verifyDeprecation();
|
||||
expect(jasmineUnderTest[key]).toBe(patch);
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// These specs rely on jasmineRequire being exposed. That only happens
|
||||
// in browsers.
|
||||
if (typeof document !== 'undefined') {
|
||||
const statics = ['addMatchers', 'clock', 'createSpyObj'];
|
||||
|
||||
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 expectedKeys(includeHtml) {
|
||||
if (includeHtml === undefined) {
|
||||
includeHtml = typeof window !== 'undefined';
|
||||
}
|
||||
// Does not include properties added by requireInterface(), since that isn't
|
||||
// called by defineJasmineUnderTest.js/nodeDefineJasmineUnderTest.js.
|
||||
const result = new Set([
|
||||
@@ -51,7 +116,7 @@ describe('The jasmine namespace', function() {
|
||||
'getGlobal'
|
||||
]);
|
||||
|
||||
if (typeof window !== 'undefined') {
|
||||
if (includeHtml) {
|
||||
// jasmine-html.js
|
||||
result.add('HtmlReporter');
|
||||
result.add('HtmlReporterV2');
|
||||
@@ -76,4 +141,15 @@ describe('The jasmine namespace', function() {
|
||||
|
||||
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')
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -768,7 +768,16 @@ describe('matchersUtil', function() {
|
||||
a2[0] = 1;
|
||||
const diffBuilder = new privateUnderTest.DiffBuilder();
|
||||
expect(matchersUtil.equals(a1, a2, diffBuilder)).toBe(false);
|
||||
jasmine.debugLog('Diff: ' + diffBuilder.getMessage());
|
||||
jasmine.debugLog(
|
||||
'a1 keys: ' + jasmine.pp(privateUnderTest.MatchersUtil.keys(a1))
|
||||
);
|
||||
jasmine.debugLog(
|
||||
'a2 keys: ' + jasmine.pp(privateUnderTest.MatchersUtil.keys(a2))
|
||||
);
|
||||
jasmine.debugLog('a1 length:' + a1.length);
|
||||
jasmine.debugLog('a2 length:' + a2.length);
|
||||
jasmine.debugLog('a1[0]: ' + a1[0]);
|
||||
jasmine.debugLog('a2[0]: ' + a2[0]);
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
describe('HtmlReporter', function() {
|
||||
let env;
|
||||
let env, deprecator;
|
||||
|
||||
beforeEach(function() {
|
||||
env = new privateUnderTest.Env();
|
||||
spyOn(env, 'deprecated');
|
||||
deprecator = jasmine.createSpyObj('deprecator', [
|
||||
'verboseDeprecations',
|
||||
'addDeprecationWarning'
|
||||
]);
|
||||
env = new privateUnderTest.Env({ deprecator });
|
||||
});
|
||||
|
||||
afterEach(function() {
|
||||
@@ -21,8 +24,10 @@ describe('HtmlReporter', function() {
|
||||
});
|
||||
reporter.initialize();
|
||||
|
||||
expect(env.deprecated).toHaveBeenCalledWith(
|
||||
'HtmlReporter and HtmlSpecFilter are deprecated. Use HtmlReporterV2 instead.'
|
||||
expect(deprecator.addDeprecationWarning).toHaveBeenCalledWith(
|
||||
jasmine.anything(),
|
||||
'HtmlReporter and HtmlSpecFilter are deprecated. Use HtmlReporterV2 instead.',
|
||||
undefined
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
@@ -14,9 +14,7 @@ describe('HtmlReporterV2', function() {
|
||||
function setup(options = {}) {
|
||||
return new jasmineUnderTest.HtmlReporterV2({
|
||||
env,
|
||||
getContainer() {
|
||||
return container;
|
||||
},
|
||||
container,
|
||||
urls: new jasmineUnderTest.HtmlReporterV2Urls(),
|
||||
queryString: new jasmineUnderTest.QueryString({
|
||||
getWindowLocation() {
|
||||
@@ -28,8 +26,7 @@ describe('HtmlReporterV2', function() {
|
||||
}
|
||||
|
||||
it('builds the initial DOM elements, including the title banner', function() {
|
||||
const reporter = setup();
|
||||
reporter.initialize();
|
||||
setup();
|
||||
|
||||
// Main top-level elements
|
||||
expect(container.querySelector('div.jasmine_html-reporter')).toBeTruthy();
|
||||
@@ -50,17 +47,6 @@ describe('HtmlReporterV2', function() {
|
||||
expect(version.textContent).toEqual(jasmineUnderTest.version);
|
||||
});
|
||||
|
||||
it('builds a single reporter even if initialized multiple times', function() {
|
||||
const reporter = setup();
|
||||
reporter.initialize();
|
||||
reporter.initialize();
|
||||
reporter.initialize();
|
||||
|
||||
expect(
|
||||
container.querySelectorAll('div.jasmine_html-reporter').length
|
||||
).toEqual(1);
|
||||
});
|
||||
|
||||
describe('when a spec is done', function() {
|
||||
describe('and no expectations ran', function() {
|
||||
let reporter;
|
||||
@@ -70,8 +56,6 @@ describe('HtmlReporterV2', function() {
|
||||
|
||||
spyOn(console, 'warn');
|
||||
spyOn(console, 'error');
|
||||
|
||||
reporter.initialize();
|
||||
});
|
||||
|
||||
it('logs a warning to the console when the spec passed', function() {
|
||||
@@ -103,7 +87,6 @@ describe('HtmlReporterV2', function() {
|
||||
|
||||
it('updates the progress bar', function() {
|
||||
const reporter = setup();
|
||||
reporter.initialize();
|
||||
const progress = container.querySelector('progress');
|
||||
|
||||
reporter.specDone({
|
||||
@@ -125,7 +108,6 @@ describe('HtmlReporterV2', function() {
|
||||
|
||||
it('changes the progress bar status if the spec failed', function() {
|
||||
const reporter = setup();
|
||||
reporter.initialize();
|
||||
|
||||
reporter.specDone({
|
||||
id: 345,
|
||||
@@ -142,9 +124,8 @@ describe('HtmlReporterV2', function() {
|
||||
describe('when there are deprecation warnings', function() {
|
||||
it('displays the messages in their own alert bars', function() {
|
||||
const reporter = setup();
|
||||
reporter.initialize();
|
||||
|
||||
reporter.jasmineStarted({ totalSpecsDefined: 0 });
|
||||
reporter.jasmineStarted({ totalSpecsDefined: 0, numExcludedSpecs: 0 });
|
||||
reporter.specDone({
|
||||
status: 'passed',
|
||||
fullName: 'a spec with a deprecation',
|
||||
@@ -183,9 +164,8 @@ describe('HtmlReporterV2', function() {
|
||||
|
||||
it('displays expandable stack traces', function() {
|
||||
const reporter = setup();
|
||||
reporter.initialize();
|
||||
|
||||
reporter.jasmineStarted({ totalSpecsDefined: 0 });
|
||||
reporter.jasmineStarted({ totalSpecsDefined: 0, numExcludedSpecs: 0 });
|
||||
reporter.jasmineDone({
|
||||
deprecationWarnings: [
|
||||
{
|
||||
@@ -219,9 +199,8 @@ describe('HtmlReporterV2', function() {
|
||||
|
||||
it('omits the expander when there is no stack trace', function() {
|
||||
const reporter = setup();
|
||||
reporter.initialize();
|
||||
|
||||
reporter.jasmineStarted({ totalSpecsDefined: 0 });
|
||||
reporter.jasmineStarted({ totalSpecsDefined: 0, numExcludedSpecs: 0 });
|
||||
reporter.jasmineDone({
|
||||
deprecationWarnings: [
|
||||
{
|
||||
@@ -238,9 +217,8 @@ describe('HtmlReporterV2', function() {
|
||||
|
||||
it('nicely formats the verboseDeprecations note', function() {
|
||||
const reporter = setup();
|
||||
reporter.initialize();
|
||||
|
||||
reporter.jasmineStarted({ totalSpecsDefined: 0 });
|
||||
reporter.jasmineStarted({ totalSpecsDefined: 0, numExcludedSpecs: 0 });
|
||||
reporter.jasmineDone({
|
||||
deprecationWarnings: [
|
||||
{
|
||||
@@ -272,8 +250,7 @@ describe('HtmlReporterV2', function() {
|
||||
describe('while Jasmine is running', function() {
|
||||
it('hides all tabs', function() {
|
||||
const reporter = setup();
|
||||
reporter.initialize();
|
||||
reporter.jasmineStarted({ totalSpecsDefined: 0 });
|
||||
reporter.jasmineStarted({ totalSpecsDefined: 0, numExcludedSpecs: 0 });
|
||||
const tabs = container.querySelectorAll('.jasmine-tab');
|
||||
expect(tabs.length).toEqual(3);
|
||||
expect(tabs[0].textContent).toEqual('Spec List');
|
||||
@@ -300,7 +277,6 @@ describe('HtmlReporterV2', function() {
|
||||
|
||||
beforeEach(function() {
|
||||
reporter = setup();
|
||||
reporter.initialize();
|
||||
reportEvents(reporter);
|
||||
});
|
||||
|
||||
@@ -354,7 +330,6 @@ describe('HtmlReporterV2', function() {
|
||||
|
||||
beforeEach(function() {
|
||||
reporter = setup();
|
||||
reporter.initialize();
|
||||
reportEvents(reporter);
|
||||
});
|
||||
|
||||
@@ -374,7 +349,10 @@ describe('HtmlReporterV2', function() {
|
||||
|
||||
describe('with spec failures', function() {
|
||||
hasSpecOrSuiteFailureBehavior(function(reporter) {
|
||||
reporter.jasmineStarted({ totalSpecsDefined: 0 });
|
||||
reporter.jasmineStarted({
|
||||
totalSpecsDefined: 0,
|
||||
numExcludedSpecs: 0
|
||||
});
|
||||
reporter.specDone({
|
||||
id: 1,
|
||||
description: 'a failing spec',
|
||||
@@ -397,7 +375,10 @@ describe('HtmlReporterV2', function() {
|
||||
|
||||
describe('with suite failures', function() {
|
||||
hasSpecOrSuiteFailureBehavior(function(reporter) {
|
||||
reporter.jasmineStarted({ totalSpecsDefined: 0 });
|
||||
reporter.jasmineStarted({
|
||||
totalSpecsDefined: 0,
|
||||
numExcludedSpecs: 0
|
||||
});
|
||||
reporter.specDone({
|
||||
id: 1,
|
||||
description: 'a failing spec',
|
||||
@@ -420,7 +401,10 @@ describe('HtmlReporterV2', function() {
|
||||
|
||||
describe('without any failures', function() {
|
||||
hasSpecAndSuiteSuccessBehavior(function(reporter) {
|
||||
reporter.jasmineStarted({ totalSpecsDefined: 0 });
|
||||
reporter.jasmineStarted({
|
||||
totalSpecsDefined: 0,
|
||||
numExcludedSpecs: 0
|
||||
});
|
||||
reporter.specDone({
|
||||
id: 1,
|
||||
description: 'a passing spec',
|
||||
@@ -438,7 +422,10 @@ describe('HtmlReporterV2', function() {
|
||||
// Top suite failures are displayed in their own alert bars, so they
|
||||
// don't cause the failures tab to be shown.
|
||||
hasSpecAndSuiteSuccessBehavior(function(reporter) {
|
||||
reporter.jasmineStarted({ totalSpecsDefined: 0 });
|
||||
reporter.jasmineStarted({
|
||||
totalSpecsDefined: 0,
|
||||
numExcludedSpecs: 0
|
||||
});
|
||||
reporter.jasmineDone({
|
||||
failedExpectations: [{}]
|
||||
});
|
||||
@@ -447,8 +434,7 @@ describe('HtmlReporterV2', function() {
|
||||
|
||||
it('shows the slow spec view when the Performance tab is clicked', function() {
|
||||
const reporter = setup();
|
||||
reporter.initialize();
|
||||
reporter.jasmineStarted({ totalSpecsDefined: 0 });
|
||||
reporter.jasmineStarted({ totalSpecsDefined: 0, numExcludedSpecs: 0 });
|
||||
reporter.specDone({
|
||||
duration: 1.2,
|
||||
failedExpectations: [],
|
||||
@@ -472,8 +458,7 @@ describe('HtmlReporterV2', function() {
|
||||
const reporter = setup();
|
||||
spyOn(console, 'error');
|
||||
|
||||
reporter.initialize();
|
||||
reporter.jasmineStarted({ totalSpecsDefined: 0 });
|
||||
reporter.jasmineStarted({ totalSpecsDefined: 0, numExcludedSpecs: 0 });
|
||||
reporter.suiteStarted({ id: 1 });
|
||||
reporter.specDone({
|
||||
id: 1,
|
||||
@@ -495,9 +480,8 @@ describe('HtmlReporterV2', function() {
|
||||
|
||||
it('reports the run time', function() {
|
||||
const reporter = setup();
|
||||
reporter.initialize();
|
||||
|
||||
reporter.jasmineStarted({ totalSpecsDefined: 0 });
|
||||
reporter.jasmineStarted({ totalSpecsDefined: 0, numExcludedSpecs: 0 });
|
||||
|
||||
reporter.jasmineDone({ totalTime: 100 });
|
||||
|
||||
@@ -513,9 +497,8 @@ describe('HtmlReporterV2', function() {
|
||||
return '?foo=bar&' + key + '=' + value;
|
||||
}
|
||||
});
|
||||
reporter.initialize();
|
||||
|
||||
reporter.jasmineStarted({ totalSpecsDefined: 0 });
|
||||
reporter.jasmineStarted({ totalSpecsDefined: 0, numExcludedSpecs: 0 });
|
||||
reporter.suiteStarted({
|
||||
id: 1,
|
||||
description: 'A Suite',
|
||||
@@ -620,7 +603,6 @@ describe('HtmlReporterV2', function() {
|
||||
|
||||
it('has an options menu', function() {
|
||||
const reporter = setup();
|
||||
reporter.initialize();
|
||||
reporter.jasmineDone({});
|
||||
|
||||
const trigger = container.querySelector(
|
||||
@@ -644,9 +626,8 @@ describe('HtmlReporterV2', function() {
|
||||
describe('when there are global errors', function() {
|
||||
it('displays the exceptions in their own alert bars', function() {
|
||||
const reporter = setup();
|
||||
reporter.initialize();
|
||||
|
||||
reporter.jasmineStarted({ totalSpecsDefined: 0 });
|
||||
reporter.jasmineStarted({ totalSpecsDefined: 0, numExcludedSpecs: 0 });
|
||||
reporter.jasmineDone({
|
||||
failedExpectations: [
|
||||
{
|
||||
@@ -673,9 +654,8 @@ describe('HtmlReporterV2', function() {
|
||||
|
||||
it('does not display the "AfterAll" prefix for other error types', function() {
|
||||
const reporter = setup();
|
||||
reporter.initialize();
|
||||
|
||||
reporter.jasmineStarted({ totalSpecsDefined: 0 });
|
||||
reporter.jasmineStarted({ totalSpecsDefined: 0, numExcludedSpecs: 0 });
|
||||
reporter.jasmineDone({
|
||||
failedExpectations: [
|
||||
{ message: 'load error', globalErrorType: 'load' },
|
||||
@@ -703,9 +683,8 @@ describe('HtmlReporterV2', function() {
|
||||
|
||||
it('displays file and line information if available', function() {
|
||||
const reporter = setup();
|
||||
reporter.initialize();
|
||||
|
||||
reporter.jasmineStarted({ totalSpecsDefined: 0 });
|
||||
reporter.jasmineStarted({ totalSpecsDefined: 0, numExcludedSpecs: 0 });
|
||||
reporter.jasmineDone({
|
||||
failedExpectations: [
|
||||
{
|
||||
@@ -731,7 +710,6 @@ describe('HtmlReporterV2', function() {
|
||||
describe('UI for stop on spec failure', function() {
|
||||
it('should be unchecked for full execution', function() {
|
||||
const reporter = setup();
|
||||
reporter.initialize();
|
||||
reporter.jasmineDone({});
|
||||
|
||||
const stopOnFailureUI = container.querySelector('.jasmine-fail-fast');
|
||||
@@ -739,10 +717,9 @@ describe('HtmlReporterV2', function() {
|
||||
});
|
||||
|
||||
it('should be checked if stopping short', function() {
|
||||
const reporter = setup();
|
||||
env.configure({ stopOnSpecFailure: true });
|
||||
const reporter = setup();
|
||||
|
||||
reporter.initialize();
|
||||
reporter.jasmineDone({});
|
||||
|
||||
const stopOnFailureUI = container.querySelector('.jasmine-fail-fast');
|
||||
@@ -752,7 +729,6 @@ describe('HtmlReporterV2', function() {
|
||||
it('should navigate and turn the setting on', function() {
|
||||
const reporter = setup();
|
||||
|
||||
reporter.initialize();
|
||||
reporter.jasmineDone({});
|
||||
|
||||
const stopOnFailureUI = container.querySelector('.jasmine-fail-fast');
|
||||
@@ -762,10 +738,9 @@ describe('HtmlReporterV2', function() {
|
||||
});
|
||||
|
||||
it('should navigate and turn the setting off', function() {
|
||||
const reporter = setup();
|
||||
env.configure({ stopOnSpecFailure: true });
|
||||
const reporter = setup();
|
||||
|
||||
reporter.initialize();
|
||||
reporter.jasmineDone({});
|
||||
|
||||
const stopOnFailureUI = container.querySelector('.jasmine-fail-fast');
|
||||
@@ -778,7 +753,6 @@ describe('HtmlReporterV2', function() {
|
||||
describe('UI for throwing errors on expectation failures', function() {
|
||||
it('should be unchecked if not throwing', function() {
|
||||
const reporter = setup();
|
||||
reporter.initialize();
|
||||
reporter.jasmineDone({});
|
||||
|
||||
const throwingExpectationsUI = container.querySelector(
|
||||
@@ -788,10 +762,9 @@ describe('HtmlReporterV2', function() {
|
||||
});
|
||||
|
||||
it('should be checked if throwing', function() {
|
||||
const reporter = setup();
|
||||
env.configure({ stopSpecOnExpectationFailure: true });
|
||||
const reporter = setup();
|
||||
|
||||
reporter.initialize();
|
||||
reporter.jasmineDone({});
|
||||
|
||||
const throwingExpectationsUI = container.querySelector(
|
||||
@@ -802,7 +775,6 @@ describe('HtmlReporterV2', function() {
|
||||
|
||||
it('should navigate and change the setting to on', function() {
|
||||
const reporter = setup();
|
||||
reporter.initialize();
|
||||
reporter.jasmineDone({});
|
||||
|
||||
const throwingExpectationsUI = container.querySelector(
|
||||
@@ -814,11 +786,9 @@ describe('HtmlReporterV2', function() {
|
||||
});
|
||||
|
||||
it('should navigate and change the setting to off', function() {
|
||||
env.configure({ stopSpecOnExpectationFailure: true });
|
||||
const reporter = setup();
|
||||
|
||||
env.configure({ stopSpecOnExpectationFailure: true });
|
||||
|
||||
reporter.initialize();
|
||||
reporter.jasmineDone({});
|
||||
|
||||
const throwingExpectationsUI = container.querySelector(
|
||||
@@ -832,9 +802,8 @@ describe('HtmlReporterV2', function() {
|
||||
|
||||
describe('UI for running tests in random order', function() {
|
||||
it('should be unchecked if not randomizing', function() {
|
||||
const reporter = setup();
|
||||
env.configure({ random: false });
|
||||
reporter.initialize();
|
||||
const reporter = setup();
|
||||
reporter.jasmineDone({});
|
||||
|
||||
const randomUI = container.querySelector('.jasmine-random');
|
||||
@@ -842,9 +811,8 @@ describe('HtmlReporterV2', function() {
|
||||
});
|
||||
|
||||
it('should be checked if randomizing', function() {
|
||||
const reporter = setup();
|
||||
env.configure({ random: true });
|
||||
reporter.initialize();
|
||||
const reporter = setup();
|
||||
reporter.jasmineDone({});
|
||||
|
||||
const randomUI = container.querySelector('.jasmine-random');
|
||||
@@ -852,10 +820,9 @@ describe('HtmlReporterV2', function() {
|
||||
});
|
||||
|
||||
it('should navigate and change the setting to on', function() {
|
||||
env.configure({ random: false });
|
||||
const reporter = setup();
|
||||
|
||||
env.configure({ random: false });
|
||||
reporter.initialize();
|
||||
reporter.jasmineDone({});
|
||||
|
||||
const randomUI = container.querySelector('.jasmine-random');
|
||||
@@ -865,10 +832,9 @@ describe('HtmlReporterV2', function() {
|
||||
});
|
||||
|
||||
it('should navigate and change the setting to off', function() {
|
||||
env.configure({ random: true });
|
||||
const reporter = setup();
|
||||
|
||||
env.configure({ random: true });
|
||||
reporter.initialize();
|
||||
reporter.jasmineDone({});
|
||||
|
||||
const randomUI = container.querySelector('.jasmine-random');
|
||||
@@ -879,7 +845,6 @@ describe('HtmlReporterV2', function() {
|
||||
|
||||
it('should show the seed bar if randomizing', function() {
|
||||
const reporter = setup();
|
||||
reporter.initialize();
|
||||
reporter.jasmineDone({
|
||||
order: {
|
||||
random: true,
|
||||
@@ -895,7 +860,6 @@ describe('HtmlReporterV2', function() {
|
||||
|
||||
it('should not show the current seed bar if not randomizing', function() {
|
||||
const reporter = setup();
|
||||
reporter.initialize();
|
||||
reporter.jasmineDone({});
|
||||
|
||||
const seedBar = container.querySelector('.jasmine-seed-bar');
|
||||
@@ -905,13 +869,12 @@ describe('HtmlReporterV2', function() {
|
||||
it('includes the number of specs in the text of the jasmine-skipped link', function() {
|
||||
const reporter = setup();
|
||||
|
||||
reporter.initialize();
|
||||
const minimalSpecDone = {
|
||||
failedExpectations: [],
|
||||
passedExpectations: []
|
||||
};
|
||||
|
||||
reporter.jasmineStarted({ totalSpecsDefined: 3 });
|
||||
reporter.jasmineStarted({ totalSpecsDefined: 3, numExcludedSpecs: 0 });
|
||||
reporter.specDone({ ...minimalSpecDone });
|
||||
reporter.specDone({ ...minimalSpecDone });
|
||||
reporter.specDone({ ...minimalSpecDone, status: 'excluded' });
|
||||
@@ -928,8 +891,7 @@ describe('HtmlReporterV2', function() {
|
||||
}
|
||||
});
|
||||
|
||||
reporter.initialize();
|
||||
reporter.jasmineStarted({ totalSpecsDefined: 1 });
|
||||
reporter.jasmineStarted({ totalSpecsDefined: 1, numExcludedSpecs: 0 });
|
||||
reporter.jasmineDone({ order: { random: true } });
|
||||
|
||||
const skippedLink = container.querySelector('.jasmine-skipped a');
|
||||
@@ -940,9 +902,8 @@ describe('HtmlReporterV2', function() {
|
||||
describe('and all specs pass', function() {
|
||||
beforeEach(function() {
|
||||
const reporter = setup();
|
||||
reporter.initialize();
|
||||
|
||||
reporter.jasmineStarted({ totalSpecsDefined: 2 });
|
||||
reporter.jasmineStarted({ totalSpecsDefined: 2, numExcludedSpecs: 0 });
|
||||
reporter.specDone({
|
||||
id: 123,
|
||||
description: 'with a spec',
|
||||
@@ -1007,8 +968,10 @@ describe('HtmlReporterV2', function() {
|
||||
}
|
||||
}
|
||||
});
|
||||
reporter.initialize();
|
||||
reporter.jasmineStarted({ totalSpecsDefined: 1 });
|
||||
reporter.jasmineStarted({
|
||||
totalSpecsDefined: 1,
|
||||
numExcludedSpecs: 0
|
||||
});
|
||||
reporter.specDone(specStatus);
|
||||
reporter.jasmineDone({});
|
||||
});
|
||||
@@ -1029,8 +992,10 @@ describe('HtmlReporterV2', function() {
|
||||
}
|
||||
}
|
||||
});
|
||||
reporter.initialize();
|
||||
reporter.jasmineStarted({ totalSpecsDefined: 1 });
|
||||
reporter.jasmineStarted({
|
||||
totalSpecsDefined: 1,
|
||||
numExcludedSpecs: 0
|
||||
});
|
||||
reporter.specDone(specStatus);
|
||||
reporter.jasmineDone({});
|
||||
});
|
||||
@@ -1064,9 +1029,8 @@ describe('HtmlReporterV2', function() {
|
||||
|
||||
beforeEach(function() {
|
||||
reporter = setup();
|
||||
reporter.initialize();
|
||||
|
||||
reporter.jasmineStarted({ totalSpecsDefined: 1 });
|
||||
reporter.jasmineStarted({ totalSpecsDefined: 1, numExcludedSpecs: 0 });
|
||||
});
|
||||
|
||||
it('reports the pending specs count', function() {
|
||||
@@ -1117,9 +1081,8 @@ describe('HtmlReporterV2', function() {
|
||||
|
||||
beforeEach(function() {
|
||||
reporter = setup();
|
||||
reporter.initialize();
|
||||
|
||||
reporter.jasmineStarted({ totalSpecsDefined: 1 });
|
||||
reporter.jasmineStarted({ totalSpecsDefined: 1, numExcludedSpecs: 0 });
|
||||
reporter.suiteStarted({
|
||||
id: 1,
|
||||
description: 'A suite'
|
||||
@@ -1285,9 +1248,8 @@ describe('HtmlReporterV2', function() {
|
||||
return '?' + key + '=' + value;
|
||||
}
|
||||
});
|
||||
reporter.initialize();
|
||||
|
||||
reporter.jasmineStarted({ totalSpecsDefined: 1 });
|
||||
reporter.jasmineStarted({ totalSpecsDefined: 1, numExcludedSpecs: 0 });
|
||||
|
||||
const failingSpecResult = {
|
||||
id: 124,
|
||||
@@ -1327,7 +1289,6 @@ describe('HtmlReporterV2', function() {
|
||||
describe('When nothing has failed', function() {
|
||||
it('shows "Running..." and the has class jasmine-in-progress', function() {
|
||||
const reporter = setup();
|
||||
reporter.initialize();
|
||||
const alertBar = container.querySelector('.jasmine-overall-result');
|
||||
|
||||
expect(alertBar.textContent).toEqual('Running...');
|
||||
@@ -1354,7 +1315,6 @@ describe('HtmlReporterV2', function() {
|
||||
describe('When a spec has failed', function() {
|
||||
it('shows "Failing..." and the has class jasmine-failed', function() {
|
||||
const reporter = setup();
|
||||
reporter.initialize();
|
||||
const alertBar = container.querySelector('.jasmine-overall-result');
|
||||
|
||||
reporter.specDone({
|
||||
@@ -1373,7 +1333,6 @@ describe('HtmlReporterV2', function() {
|
||||
describe('When a suite has failed', function() {
|
||||
it('shows "Failing..." and the has class jasmine-failed', function() {
|
||||
const reporter = setup();
|
||||
reporter.initialize();
|
||||
const alertBar = container.querySelector('.jasmine-overall-result');
|
||||
|
||||
reporter.suiteDone({
|
||||
@@ -1393,9 +1352,8 @@ describe('HtmlReporterV2', function() {
|
||||
describe("When the jasmineDone event's overallStatus is 'passed'", function() {
|
||||
it('has class jasmine-passed', function() {
|
||||
const reporter = setup();
|
||||
reporter.initialize();
|
||||
|
||||
reporter.jasmineStarted({ totalSpecsDefined: 0 });
|
||||
reporter.jasmineStarted({ totalSpecsDefined: 0, numExcludedSpecs: 0 });
|
||||
reporter.jasmineDone({
|
||||
overallStatus: 'passed',
|
||||
failedExpectations: []
|
||||
@@ -1409,9 +1367,8 @@ describe('HtmlReporterV2', function() {
|
||||
describe("When the jasmineDone event's overallStatus is 'failed'", function() {
|
||||
it('has class jasmine-failed', function() {
|
||||
const reporter = setup();
|
||||
reporter.initialize();
|
||||
|
||||
reporter.jasmineStarted({ totalSpecsDefined: 0 });
|
||||
reporter.jasmineStarted({ totalSpecsDefined: 0, numExcludedSpecs: 0 });
|
||||
reporter.jasmineDone({
|
||||
overallStatus: 'failed',
|
||||
failedExpectations: []
|
||||
@@ -1425,9 +1382,8 @@ describe('HtmlReporterV2', function() {
|
||||
describe("When the jasmineDone event's overallStatus is 'incomplete'", function() {
|
||||
it('has class jasmine-incomplete', function() {
|
||||
const reporter = setup();
|
||||
reporter.initialize();
|
||||
|
||||
reporter.jasmineStarted({ totalSpecsDefined: 0 });
|
||||
reporter.jasmineStarted({ totalSpecsDefined: 0, numExcludedSpecs: 0 });
|
||||
reporter.jasmineDone({
|
||||
overallStatus: 'incomplete',
|
||||
incompleteReason: 'because nope',
|
||||
|
||||
@@ -1,17 +1,29 @@
|
||||
describe('HtmlSpecFilter', function() {
|
||||
let env, deprecator;
|
||||
|
||||
beforeEach(function() {
|
||||
spyOn(jasmineUnderTest.getEnv(), 'deprecated');
|
||||
deprecator = jasmine.createSpyObj('deprecator', [
|
||||
'verboseDeprecations',
|
||||
'addDeprecationWarning'
|
||||
]);
|
||||
env = new privateUnderTest.Env({ deprecator });
|
||||
});
|
||||
|
||||
afterEach(function() {
|
||||
env.cleanup_();
|
||||
});
|
||||
|
||||
it('emits a deprecation warning', function() {
|
||||
new jasmineUnderTest.HtmlSpecFilter();
|
||||
expect(jasmineUnderTest.getEnv().deprecated).toHaveBeenCalledWith(
|
||||
'HtmlReporter and HtmlSpecFilter are deprecated. Use HtmlReporterV2 instead.'
|
||||
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();
|
||||
const specFilter = new jasmineUnderTest.HtmlSpecFilter({ env });
|
||||
|
||||
expect(specFilter.matches('foo')).toBe(true);
|
||||
expect(specFilter.matches('*bar')).toBe(true);
|
||||
@@ -19,6 +31,7 @@ describe('HtmlSpecFilter', function() {
|
||||
|
||||
it('should only match the provided string', function() {
|
||||
const specFilter = new jasmineUnderTest.HtmlSpecFilter({
|
||||
env,
|
||||
filterString: function() {
|
||||
return 'foo';
|
||||
}
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
/* eslint-env node, es6 */
|
||||
const path = require('path'),
|
||||
jasmineBrowser = require('jasmine-browser-runner'),
|
||||
jasmineCore = require('../../lib/jasmine-core');
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
/* eslint-env node, es6 */
|
||||
module.exports = {
|
||||
srcDir: 'src',
|
||||
srcFiles: [
|
||||
|
||||
@@ -17,23 +17,6 @@
|
||||
const env = jasmine.getEnv();
|
||||
const urls = new jasmine.HtmlReporterV2Urls();
|
||||
|
||||
/**
|
||||
* ## Reporters
|
||||
* The `HtmlReporter` builds all of the HTML UI for the runner page. This reporter paints the dots, stars, and x's for specs, as well as all spec names and all failures (if any).
|
||||
*/
|
||||
const htmlReporter = new jasmine.HtmlReporterV2({
|
||||
env,
|
||||
urls,
|
||||
getContainer() {
|
||||
return document.body;
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* The `jsApiReporter` also receives spec results, and is used by any environment that needs to extract the results from JavaScript.
|
||||
*/
|
||||
env.addReporter(jsApiReporter);
|
||||
env.addReporter(htmlReporter);
|
||||
/**
|
||||
* Configures Jasmine based on the current set of query parameters. This
|
||||
* supports all parameters set by the HTML reporter as well as
|
||||
@@ -42,18 +25,16 @@
|
||||
*/
|
||||
env.configure(urls.configFromCurrentUrl());
|
||||
|
||||
/**
|
||||
* ## Execution
|
||||
*
|
||||
* Replace the browser window's `onload`, ensure it's called, and then run all of the loaded specs. This includes initializing the `HtmlReporter` instance and then executing the loaded Jasmine environment. All of this will happen after all of the specs are loaded.
|
||||
*/
|
||||
const currentWindowOnload = window.onload;
|
||||
|
||||
window.onload = function() {
|
||||
if (currentWindowOnload) {
|
||||
currentWindowOnload();
|
||||
}
|
||||
htmlReporter.initialize();
|
||||
|
||||
// The HTML reporter needs to be set up here so it can access the DOM. Other
|
||||
// reporters can be added at any time before env.execute() is called.
|
||||
const htmlReporter = new jasmine.HtmlReporterV2({ env, urls });
|
||||
env.addReporter(htmlReporter);
|
||||
env.execute();
|
||||
};
|
||||
})();
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
getJasmineRequireObj().Clock = function() {
|
||||
getJasmineRequireObj().Clock = function(j$) {
|
||||
'use strict';
|
||||
|
||||
/* global process */
|
||||
@@ -191,6 +191,9 @@ callbacks to execute _before_ running the next one.
|
||||
clearTimeout[IsMockClockTimingFn] = true;
|
||||
setInterval[IsMockClockTimingFn] = true;
|
||||
clearInterval[IsMockClockTimingFn] = true;
|
||||
|
||||
j$.private.deprecateMonkeyPatching(this);
|
||||
|
||||
return this;
|
||||
|
||||
// Advances the Clock's time until the mode changes.
|
||||
|
||||
@@ -296,10 +296,13 @@ getJasmineRequireObj().Env = function(j$) {
|
||||
* @param {String|Error} deprecation The deprecation message
|
||||
* @param {Object} [options] Optional extra options, as described above
|
||||
*/
|
||||
this.deprecated = function(deprecation, options) {
|
||||
const runable = runner.currentRunable() || topSuite;
|
||||
deprecator.addDeprecationWarning(runable, deprecation, options);
|
||||
};
|
||||
Object.defineProperty(this, 'deprecated', {
|
||||
enumerable: true,
|
||||
value: function(deprecation, options) {
|
||||
const runable = runner.currentRunable() || topSuite;
|
||||
deprecator.addDeprecationWarning(runable, deprecation, options);
|
||||
}
|
||||
});
|
||||
|
||||
function runQueue(options) {
|
||||
options.clearStack = options.clearStack || stackClearer;
|
||||
@@ -326,7 +329,8 @@ getJasmineRequireObj().Env = function(j$) {
|
||||
runQueue
|
||||
});
|
||||
topSuite = suiteBuilder.topSuite;
|
||||
const deprecator = new j$.private.Deprecator(topSuite);
|
||||
const deprecator =
|
||||
envOptions?.deprecator ?? new j$.private.Deprecator(topSuite);
|
||||
|
||||
/**
|
||||
* Provides the root suite, through which all suites and specs can be
|
||||
@@ -821,9 +825,18 @@ getJasmineRequireObj().Env = function(j$) {
|
||||
}
|
||||
};
|
||||
|
||||
this.pp = function(value) {
|
||||
const pp = runner.currentRunable()
|
||||
? runableResources.makePrettyPrinter()
|
||||
: j$.private.basicPrettyPrinter;
|
||||
return pp(value);
|
||||
};
|
||||
|
||||
this.cleanup_ = function() {
|
||||
uninstallGlobalErrors();
|
||||
};
|
||||
|
||||
j$.private.deprecateMonkeyPatching(this, ['deprecated']);
|
||||
}
|
||||
|
||||
function indirectCallerFilename(depth) {
|
||||
|
||||
@@ -11,7 +11,8 @@ getJasmineRequireObj().ExceptionFormatter = function(j$) {
|
||||
'lineNumber',
|
||||
'column',
|
||||
'description',
|
||||
'jasmineMessage'
|
||||
'jasmineMessage',
|
||||
'errors'
|
||||
];
|
||||
|
||||
function ExceptionFormatter(options) {
|
||||
@@ -77,6 +78,19 @@ getJasmineRequireObj().ExceptionFormatter = function(j$) {
|
||||
lines = lines.concat(substack);
|
||||
}
|
||||
|
||||
if (Array.isArray(error.errors)) {
|
||||
for (let i = 0; i < error.errors.length; i++) {
|
||||
if (error.errors[i] instanceof Error) {
|
||||
lines.push('');
|
||||
const substack = this.stack_(error.errors[i], {
|
||||
messageHandling: 'require'
|
||||
});
|
||||
substack[0] = 'Error ' + (i + 1) + ': ' + substack[0];
|
||||
lines = lines.concat(substack.map(x => ' ' + x));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return lines;
|
||||
};
|
||||
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
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();
|
||||
|
||||
@@ -59,7 +59,7 @@ getJasmineRequireObj().makePrettyPrinter = function(j$) {
|
||||
} else if (
|
||||
value.toString &&
|
||||
typeof value === 'object' &&
|
||||
!j$.private.isArray(value) &&
|
||||
!Array.isArray(value) &&
|
||||
hasCustomToString(value)
|
||||
) {
|
||||
try {
|
||||
@@ -71,15 +71,12 @@ getJasmineRequireObj().makePrettyPrinter = function(j$) {
|
||||
} else if (this.seen.includes(value)) {
|
||||
this.emitScalar(
|
||||
'<circular reference: ' +
|
||||
(j$.private.isArray(value) ? 'Array' : 'Object') +
|
||||
(Array.isArray(value) ? 'Array' : 'Object') +
|
||||
'>'
|
||||
);
|
||||
} else if (
|
||||
j$.private.isArray(value) ||
|
||||
j$.private.isA('Object', value)
|
||||
) {
|
||||
} else if (Array.isArray(value) || j$.private.isA('Object', value)) {
|
||||
this.seen.push(value);
|
||||
if (j$.private.isArray(value)) {
|
||||
if (Array.isArray(value)) {
|
||||
this.emitArray(value);
|
||||
} else {
|
||||
this.emitObject(value);
|
||||
@@ -102,10 +99,7 @@ getJasmineRequireObj().makePrettyPrinter = function(j$) {
|
||||
}
|
||||
|
||||
iterateObject(obj, fn) {
|
||||
const objKeys = j$.private.MatchersUtil.keys(
|
||||
obj,
|
||||
j$.private.isArray(obj)
|
||||
);
|
||||
const objKeys = j$.private.MatchersUtil.keys(obj, Array.isArray(obj));
|
||||
const length = Math.min(objKeys.length, j$.MAX_PRETTY_PRINT_ARRAY_LENGTH);
|
||||
|
||||
for (let i = 0; i < length; i++) {
|
||||
|
||||
@@ -96,7 +96,8 @@ getJasmineRequireObj().Runner = function(j$) {
|
||||
/**
|
||||
* Information passed to the {@link Reporter#jasmineStarted} event.
|
||||
* @typedef JasmineStartedInfo
|
||||
* @property {Int} totalSpecsDefined - The total number of specs defined in this suite. Note that this property is not present when Jasmine is run in parallel mode.
|
||||
* @property {int} totalSpecsDefined - The total number of specs defined in this suite. Note that this property is not present when Jasmine is run in parallel mode.
|
||||
* @property {int} numExcludedSpecs - The number of specs that will be excluded from execution. Note that this property is not present when Jasmine is run in parallel mode.
|
||||
* @property {Order} order - Information about the ordering (random or not) of this execution of the suite. Note that this property is not present when Jasmine is run in parallel mode.
|
||||
* @property {Boolean} parallel - Whether Jasmine is being run in parallel mode.
|
||||
* @since 2.0.0
|
||||
@@ -105,6 +106,7 @@ getJasmineRequireObj().Runner = function(j$) {
|
||||
// In parallel mode, the jasmineStarted event is separately dispatched
|
||||
// by jasmine-npm. This event only reaches reporters in non-parallel.
|
||||
totalSpecsDefined,
|
||||
numExcludedSpecs: this.#executionTree.numExcludedSpecs(),
|
||||
order: orderForReporting(order),
|
||||
parallel: false
|
||||
});
|
||||
|
||||
@@ -165,7 +165,7 @@ getJasmineRequireObj().Spec = function(j$) {
|
||||
* @property {ExpectationResult[]} passedExpectations - The list of expectations that passed during execution of this spec.
|
||||
* @property {ExpectationResult[]} deprecationWarnings - The list of deprecation warnings that occurred during execution this spec.
|
||||
* @property {String} pendingReason - If the spec is {@link pending}, this will be the reason.
|
||||
* @property {String} status - Once the spec has completed, this string represents the pass/fail status of this spec.
|
||||
* @property {String} status - The result of this spec. May be 'passed', 'failed', 'pending', or 'excluded'.
|
||||
* @property {number} duration - The time in ms used by the spec execution, including any before/afterEach.
|
||||
* @property {Object} properties - User-supplied properties, if any, that were set using {@link Env#setSpecProperty}
|
||||
* @property {DebugLogEntry[]|null} debugLogs - Messages, if any, that were logged using {@link jasmine.debugLog} during a failing spec.
|
||||
|
||||
@@ -21,7 +21,7 @@ getJasmineRequireObj().SpyFactory = function(j$) {
|
||||
|
||||
this.createSpyObj = function(baseName, methodNames, propertyNames) {
|
||||
const baseNameIsCollection =
|
||||
j$.private.isObject(baseName) || j$.private.isArray(baseName);
|
||||
j$.private.isObject(baseName) || Array.isArray(baseName);
|
||||
|
||||
if (baseNameIsCollection) {
|
||||
propertyNames = methodNames;
|
||||
@@ -67,7 +67,7 @@ getJasmineRequireObj().SpyFactory = function(j$) {
|
||||
|
||||
function normalizeKeyValues(object) {
|
||||
const result = [];
|
||||
if (j$.private.isArray(object)) {
|
||||
if (Array.isArray(object)) {
|
||||
for (let i = 0; i < object.length; i++) {
|
||||
result.push([object[i]]);
|
||||
}
|
||||
|
||||
@@ -123,6 +123,23 @@ getJasmineRequireObj().TreeProcessor = function(j$) {
|
||||
const nodeStats = this.#stats[node.id];
|
||||
return node.children ? !nodeStats.willExecute : nodeStats.excluded;
|
||||
}
|
||||
|
||||
numExcludedSpecs(node) {
|
||||
if (!node) {
|
||||
return this.numExcludedSpecs(this.topSuite);
|
||||
} else if (node.children) {
|
||||
let result = 0;
|
||||
|
||||
for (const child of node.children) {
|
||||
result += this.numExcludedSpecs(child);
|
||||
}
|
||||
|
||||
return result;
|
||||
} else {
|
||||
const nodeStats = this.#stats[node.id];
|
||||
return nodeStats.willExecute ? 0 : 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function segmentChildren(node, orderedChildren, stats, executableIndex) {
|
||||
|
||||
@@ -6,7 +6,7 @@ getJasmineRequireObj().ArrayContaining = function(j$) {
|
||||
}
|
||||
|
||||
ArrayContaining.prototype.asymmetricMatch = function(other, matchersUtil) {
|
||||
if (!j$.private.isArray(this.sample)) {
|
||||
if (!Array.isArray(this.sample)) {
|
||||
throw new Error(
|
||||
'You must provide an array to arrayContaining, not ' +
|
||||
j$.private.basicPrettyPrinter(this.sample) +
|
||||
@@ -17,7 +17,7 @@ getJasmineRequireObj().ArrayContaining = function(j$) {
|
||||
// If the actual parameter is not an array, we can fail immediately, since it couldn't
|
||||
// possibly be an "array containing" anything. However, we also want an empty sample
|
||||
// array to match anything, so we need to double-check we aren't in that case
|
||||
if (!j$.private.isArray(other) && this.sample.length > 0) {
|
||||
if (!Array.isArray(other) && this.sample.length > 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ getJasmineRequireObj().ArrayWithExactContents = function(j$) {
|
||||
other,
|
||||
matchersUtil
|
||||
) {
|
||||
if (!j$.private.isArray(this.sample)) {
|
||||
if (!Array.isArray(this.sample)) {
|
||||
throw new Error(
|
||||
'You must provide an array to arrayWithExactContents, not ' +
|
||||
j$.private.basicPrettyPrinter(this.sample) +
|
||||
|
||||
@@ -6,7 +6,7 @@ getJasmineRequireObj().Empty = function(j$) {
|
||||
Empty.prototype.asymmetricMatch = function(other) {
|
||||
if (
|
||||
j$.private.isString(other) ||
|
||||
j$.private.isArray(other) ||
|
||||
Array.isArray(other) ||
|
||||
j$.private.isTypedArray(other)
|
||||
) {
|
||||
return other.length === 0;
|
||||
|
||||
@@ -6,7 +6,7 @@ getJasmineRequireObj().NotEmpty = function(j$) {
|
||||
NotEmpty.prototype.asymmetricMatch = function(other) {
|
||||
if (
|
||||
j$.private.isString(other) ||
|
||||
j$.private.isArray(other) ||
|
||||
Array.isArray(other) ||
|
||||
j$.private.isTypedArray(other)
|
||||
) {
|
||||
return other.length !== 0;
|
||||
|
||||
@@ -22,7 +22,7 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) {
|
||||
* Maximum number of characters to display when pretty printing objects.
|
||||
* Characters past this number will be ellipised.
|
||||
* @name jasmine.MAX_PRETTY_PRINT_CHARS
|
||||
* @default 100
|
||||
* @default 1000
|
||||
* @since 2.9.0
|
||||
*/
|
||||
j$.MAX_PRETTY_PRINT_CHARS = 1000;
|
||||
@@ -67,16 +67,15 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) {
|
||||
* @function
|
||||
* @return {Env}
|
||||
*/
|
||||
j$.getEnv = function(options) {
|
||||
const env = (j$.private.currentEnv_ =
|
||||
j$.private.currentEnv_ || new j$.private.Env(options));
|
||||
//jasmine. singletons in here (setTimeout blah blah).
|
||||
return env;
|
||||
};
|
||||
|
||||
j$.private.isArray = function(value) {
|
||||
return j$.private.isA('Array', value);
|
||||
};
|
||||
Object.defineProperty(j$, 'getEnv', {
|
||||
enumerable: true,
|
||||
value: function(options) {
|
||||
const env = (j$.private.currentEnv_ =
|
||||
j$.private.currentEnv_ || new j$.private.Env(options));
|
||||
//jasmine. singletons in here (setTimeout blah blah).
|
||||
return env;
|
||||
}
|
||||
});
|
||||
|
||||
j$.private.isObject = function(value) {
|
||||
return (
|
||||
|
||||
22
src/core/deprecateMonkeyPatching.js
Normal file
22
src/core/deprecateMonkeyPatching.js
Normal 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;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
@@ -13,7 +13,7 @@ getJasmineRequireObj().MatchersUtil = function(j$) {
|
||||
this.customTesters_ = options.customTesters || [];
|
||||
/**
|
||||
* Formats a value for use in matcher failure messages and similar contexts,
|
||||
* taking into account the current set of custom value formatters.
|
||||
* taking into account the current set of custom object formatters.
|
||||
* @function
|
||||
* @name MatchersUtil#pp
|
||||
* @since 3.6.0
|
||||
|
||||
@@ -7,7 +7,6 @@ getJasmineRequireObj().reporterEvents = function(j$) {
|
||||
* {@link ReporterCapabilities} will apply.
|
||||
* @name Reporter#reporterCapabilities
|
||||
* @type ReporterCapabilities | undefined
|
||||
* @optional
|
||||
* @since 5.0
|
||||
*/
|
||||
/**
|
||||
@@ -74,7 +73,6 @@ getJasmineRequireObj().reporterEvents = function(j$) {
|
||||
/**
|
||||
* `specStarted` is invoked when an `it` starts to run (including associated `beforeEach` functions)
|
||||
* @function
|
||||
* @optional
|
||||
* @name Reporter#specStarted
|
||||
* @param {SpecStartedEvent} result Information about the individual {@link it} being run
|
||||
* @param {Function} [done] Used to specify to Jasmine that this callback is asynchronous and Jasmine should wait until it has been called before moving on.
|
||||
|
||||
@@ -19,10 +19,18 @@ var getJasmineRequireObj = (function() {
|
||||
return jasmineRequire;
|
||||
}
|
||||
|
||||
const loadedAsBrowserEsm =
|
||||
globalThis.document && !globalThis.document.currentScript;
|
||||
|
||||
getJasmineRequire().core = function(jRequire) {
|
||||
const j$ = { private: {} };
|
||||
const j$ = {};
|
||||
Object.defineProperty(j$, 'private', {
|
||||
enumerable: true,
|
||||
value: {}
|
||||
});
|
||||
|
||||
jRequire.base(j$, globalThis);
|
||||
j$.private.deprecateMonkeyPatching = jRequire.deprecateMonkeyPatching(j$);
|
||||
j$.private.util = jRequire.util(j$);
|
||||
j$.private.errors = jRequire.errors();
|
||||
j$.private.formatErrorMsg = jRequire.formatErrorMsg(j$);
|
||||
@@ -32,7 +40,7 @@ var getJasmineRequireObj = (function() {
|
||||
j$.private.CallTracker = jRequire.CallTracker(j$);
|
||||
j$.private.MockDate = jRequire.MockDate(j$);
|
||||
j$.private.getStackClearer = jRequire.StackClearer(j$);
|
||||
j$.private.Clock = jRequire.Clock();
|
||||
j$.private.Clock = jRequire.Clock(j$);
|
||||
j$.private.DelayedFunctionScheduler = jRequire.DelayedFunctionScheduler(j$);
|
||||
j$.private.Deprecator = jRequire.Deprecator(j$);
|
||||
j$.private.Configuration = jRequire.Configuration(j$);
|
||||
@@ -95,8 +103,21 @@ var getJasmineRequireObj = (function() {
|
||||
j$.private.matchers = jRequire.requireMatchers(jRequire, j$);
|
||||
j$.private.asyncMatchers = jRequire.requireAsyncMatchers(jRequire, j$);
|
||||
|
||||
j$.private.loadedAsBrowserEsm =
|
||||
globalThis.document && !globalThis.document.currentScript;
|
||||
j$.private.loadedAsBrowserEsm = loadedAsBrowserEsm;
|
||||
|
||||
j$.private.deprecateMonkeyPatching(j$, [
|
||||
// These are meant to be set by users.
|
||||
'DEFAULT_TIMEOUT_INTERVAL',
|
||||
'MAX_PRETTY_PRINT_ARRAY_LENGTH',
|
||||
'MAX_PRETTY_PRINT_CHARS',
|
||||
'MAX_PRETTY_PRINT_DEPTH',
|
||||
|
||||
// These are part of the deprecation warning mechanism. To avoid infinite
|
||||
// recursion, they're separately protected in a way that doesn't emit
|
||||
// deprecation warnings.
|
||||
'private',
|
||||
'getEnv'
|
||||
]);
|
||||
|
||||
return j$;
|
||||
};
|
||||
|
||||
@@ -20,6 +20,7 @@ getJasmineRequireObj().interface = function(jasmine, env) {
|
||||
* @since 1.3.0
|
||||
* @function
|
||||
* @global
|
||||
* @overwritable
|
||||
* @param {String} description Textual description of the group
|
||||
* @param {Function} specDefinitions Function for Jasmine to invoke that will define inner suites and specs
|
||||
*/
|
||||
@@ -35,6 +36,7 @@ getJasmineRequireObj().interface = function(jasmine, env) {
|
||||
* @since 1.3.0
|
||||
* @function
|
||||
* @global
|
||||
* @overwritable
|
||||
* @param {String} description Textual description of the group
|
||||
* @param {Function} specDefinitions Function for Jasmine to invoke that will define inner suites and specs
|
||||
*/
|
||||
@@ -51,6 +53,7 @@ getJasmineRequireObj().interface = function(jasmine, env) {
|
||||
* @since 2.1.0
|
||||
* @function
|
||||
* @global
|
||||
* @overwritable
|
||||
* @param {String} description Textual description of the group
|
||||
* @param {Function} specDefinitions Function for Jasmine to invoke that will define inner suites and specs
|
||||
*/
|
||||
@@ -69,6 +72,7 @@ getJasmineRequireObj().interface = function(jasmine, env) {
|
||||
* @since 1.3.0
|
||||
* @function
|
||||
* @global
|
||||
* @overwritable
|
||||
* @param {String} description Textual description of what this spec is checking
|
||||
* @param {implementationCallback} [testFunction] Function that contains the code of your test. If not provided the test will be `pending`.
|
||||
* @param {Int} [timeout={@link jasmine.DEFAULT_TIMEOUT_INTERVAL}] Custom timeout for an async spec.
|
||||
@@ -86,6 +90,7 @@ getJasmineRequireObj().interface = function(jasmine, env) {
|
||||
* @since 1.3.0
|
||||
* @function
|
||||
* @global
|
||||
* @overwritable
|
||||
* @param {String} description Textual description of what this spec is checking.
|
||||
* @param {implementationCallback} [testFunction] Function that contains the code of your test. Will not be executed.
|
||||
*/
|
||||
@@ -101,6 +106,7 @@ getJasmineRequireObj().interface = function(jasmine, env) {
|
||||
* @since 2.1.0
|
||||
* @function
|
||||
* @global
|
||||
* @overwritable
|
||||
* @param {String} description Textual description of what this spec is checking.
|
||||
* @param {implementationCallback} testFunction Function that contains the code of your test.
|
||||
* @param {Int} [timeout={@link jasmine.DEFAULT_TIMEOUT_INTERVAL}] Custom timeout for an async spec.
|
||||
@@ -116,6 +122,7 @@ getJasmineRequireObj().interface = function(jasmine, env) {
|
||||
* @since 1.3.0
|
||||
* @function
|
||||
* @global
|
||||
* @overwritable
|
||||
* @param {implementationCallback} [function] Function that contains the code to setup your specs.
|
||||
* @param {Int} [timeout={@link jasmine.DEFAULT_TIMEOUT_INTERVAL}] Custom timeout for an async beforeEach.
|
||||
* @see async
|
||||
@@ -130,6 +137,7 @@ getJasmineRequireObj().interface = function(jasmine, env) {
|
||||
* @since 1.3.0
|
||||
* @function
|
||||
* @global
|
||||
* @overwritable
|
||||
* @param {implementationCallback} [function] Function that contains the code to teardown your specs.
|
||||
* @param {Int} [timeout={@link jasmine.DEFAULT_TIMEOUT_INTERVAL}] Custom timeout for an async afterEach.
|
||||
* @see async
|
||||
@@ -146,6 +154,7 @@ getJasmineRequireObj().interface = function(jasmine, env) {
|
||||
* @since 2.1.0
|
||||
* @function
|
||||
* @global
|
||||
* @overwritable
|
||||
* @param {implementationCallback} [function] Function that contains the code to setup your specs.
|
||||
* @param {Int} [timeout={@link jasmine.DEFAULT_TIMEOUT_INTERVAL}] Custom timeout for an async beforeAll.
|
||||
* @see async
|
||||
@@ -162,6 +171,7 @@ getJasmineRequireObj().interface = function(jasmine, env) {
|
||||
* @since 2.1.0
|
||||
* @function
|
||||
* @global
|
||||
* @overwritable
|
||||
* @param {implementationCallback} [function] Function that contains the code to teardown your specs.
|
||||
* @param {Int} [timeout={@link jasmine.DEFAULT_TIMEOUT_INTERVAL}] Custom timeout for an async afterAll.
|
||||
* @see async
|
||||
@@ -175,6 +185,8 @@ getJasmineRequireObj().interface = function(jasmine, env) {
|
||||
* @name getSpecProperty
|
||||
* @since 5.10.0
|
||||
* @function
|
||||
* @global
|
||||
* @overwritable
|
||||
* @param {String} key The name of the property
|
||||
* @returns {*} The value of the property
|
||||
*/
|
||||
@@ -187,6 +199,8 @@ getJasmineRequireObj().interface = function(jasmine, env) {
|
||||
* @name setSpecProperty
|
||||
* @since 3.6.0
|
||||
* @function
|
||||
* @global
|
||||
* @overwritable
|
||||
* @param {String} key The name of the property
|
||||
* @param {*} value The value of the property
|
||||
*/
|
||||
@@ -199,6 +213,8 @@ getJasmineRequireObj().interface = function(jasmine, env) {
|
||||
* @name setSuiteProperty
|
||||
* @since 3.6.0
|
||||
* @function
|
||||
* @global
|
||||
* @overwritable
|
||||
* @param {String} key The name of the property
|
||||
* @param {*} value The value of the property
|
||||
*/
|
||||
@@ -212,6 +228,7 @@ getJasmineRequireObj().interface = function(jasmine, env) {
|
||||
* @since 1.3.0
|
||||
* @function
|
||||
* @global
|
||||
* @overwritable
|
||||
* @param {Object} actual - Actual computed value to test expectations against.
|
||||
* @return {matchers}
|
||||
*/
|
||||
@@ -228,6 +245,7 @@ getJasmineRequireObj().interface = function(jasmine, env) {
|
||||
* @since 3.3.0
|
||||
* @function
|
||||
* @global
|
||||
* @overwritable
|
||||
* @param {Object} actual - Actual computed value to test expectations against.
|
||||
* @return {async-matchers}
|
||||
* @example
|
||||
@@ -254,8 +272,8 @@ getJasmineRequireObj().interface = function(jasmine, env) {
|
||||
* @name throwUnlessAsync
|
||||
* @since 5.1.0
|
||||
* @function
|
||||
* @param actual
|
||||
* @global
|
||||
* @overwritable
|
||||
* @param {Object} actual - Actual computed value to test expectations against.
|
||||
* @return {matchers}
|
||||
*/
|
||||
@@ -278,8 +296,8 @@ getJasmineRequireObj().interface = function(jasmine, env) {
|
||||
* @name throwUnless
|
||||
* @since 5.1.0
|
||||
* @function
|
||||
* @param actual
|
||||
* @global
|
||||
* @overwritable
|
||||
* @param {Object} actual - Actual computed value to test expectations against.
|
||||
* @return {matchers}
|
||||
*/
|
||||
@@ -293,6 +311,7 @@ getJasmineRequireObj().interface = function(jasmine, env) {
|
||||
* @since 2.0.0
|
||||
* @function
|
||||
* @global
|
||||
* @overwritable
|
||||
* @param {String} [message] - Reason the spec is pending.
|
||||
*/
|
||||
pending: function() {
|
||||
@@ -305,6 +324,7 @@ getJasmineRequireObj().interface = function(jasmine, env) {
|
||||
* @since 2.1.0
|
||||
* @function
|
||||
* @global
|
||||
* @overwritable
|
||||
* @param {String|Error} [error] - Reason for the failure.
|
||||
*/
|
||||
fail: function() {
|
||||
@@ -317,6 +337,7 @@ getJasmineRequireObj().interface = function(jasmine, env) {
|
||||
* @since 1.3.0
|
||||
* @function
|
||||
* @global
|
||||
* @overwritable
|
||||
* @param {Object} obj - The object upon which to install the {@link Spy}.
|
||||
* @param {String} methodName - The name of the method to replace with a {@link Spy}.
|
||||
* @returns {Spy}
|
||||
@@ -331,6 +352,7 @@ getJasmineRequireObj().interface = function(jasmine, env) {
|
||||
* @since 2.6.0
|
||||
* @function
|
||||
* @global
|
||||
* @overwritable
|
||||
* @param {Object} obj - The object upon which to install the {@link Spy}
|
||||
* @param {String} propertyName - The name of the property to replace with a {@link Spy}.
|
||||
* @param {String} [accessType=get] - The access type (get|set) of the property to {@link Spy} on.
|
||||
@@ -346,6 +368,7 @@ getJasmineRequireObj().interface = function(jasmine, env) {
|
||||
* @since 3.2.1
|
||||
* @function
|
||||
* @global
|
||||
* @overwritable
|
||||
* @param {Object} obj - The object upon which to install the {@link Spy}s
|
||||
* @param {boolean} includeNonEnumerable - Whether or not to add spies to non-enumerable properties
|
||||
* @returns {Object} the spied object
|
||||
@@ -369,6 +392,7 @@ getJasmineRequireObj().interface = function(jasmine, env) {
|
||||
*/
|
||||
jasmine: jasmine
|
||||
};
|
||||
const existingKeys = Object.keys(jasmine);
|
||||
|
||||
/**
|
||||
* Add a custom equality tester for the current scope of specs.
|
||||
@@ -498,6 +522,21 @@ getJasmineRequireObj().interface = function(jasmine, env) {
|
||||
return env.setDefaultSpyStrategy(defaultStrategyFn);
|
||||
};
|
||||
|
||||
/**
|
||||
* Formats a value for display, taking into account the current set of
|
||||
* custom object formatters.
|
||||
*
|
||||
* @name jasmine.pp
|
||||
* @function
|
||||
* @since 6.0.0
|
||||
* @param {*} value The value to pretty-print
|
||||
* @return {string} The pretty-printed value
|
||||
* @see {MatchersUtil#pp}
|
||||
*/
|
||||
jasmine.pp = function(value) {
|
||||
return env.pp(value);
|
||||
};
|
||||
|
||||
/**
|
||||
* {@link AsymmetricEqualityTester|Asymmetric equality testers} allow for
|
||||
* non-exact matching in matchers that use Jasmine's deep value equality
|
||||
@@ -520,5 +559,7 @@ getJasmineRequireObj().interface = function(jasmine, env) {
|
||||
* @namespace asymmetricEqualityTesters
|
||||
*/
|
||||
|
||||
jasmine.private.deprecateMonkeyPatching(jasmine, existingKeys);
|
||||
|
||||
return jasmineInterface;
|
||||
};
|
||||
|
||||
@@ -24,45 +24,6 @@ jasmineRequire.AlertsView = function(j$) {
|
||||
);
|
||||
}
|
||||
|
||||
// TODO: remove this once HtmlReporterV2 doesn't use it
|
||||
addFailureToggle(onClickFailures, onClickSpecList) {
|
||||
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.rootEl.appendChild(
|
||||
createDom(
|
||||
'span',
|
||||
{ className: 'jasmine-menu jasmine-bar jasmine-spec-list' },
|
||||
[createDom('span', {}, 'Spec List | '), failuresLink]
|
||||
)
|
||||
);
|
||||
this.rootEl.appendChild(
|
||||
createDom(
|
||||
'span',
|
||||
{ className: 'jasmine-menu jasmine-bar jasmine-failure-list' },
|
||||
[specListLink, createDom('span', {}, ' | Failures ')]
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
addGlobalFailure(failure) {
|
||||
this.#createAndAdd(
|
||||
errorBarClassName,
|
||||
|
||||
@@ -19,12 +19,12 @@ jasmineRequire.HtmlReporterV2 = function(j$) {
|
||||
* const reporter = new jasmine.HtmlReporterV2({
|
||||
* env,
|
||||
* urls,
|
||||
* getContainer: () => document.body
|
||||
* // container is optional and defaults to document.body.
|
||||
* container: someElement
|
||||
* });
|
||||
*/
|
||||
class HtmlReporterV2 {
|
||||
#env;
|
||||
#getContainer;
|
||||
#container;
|
||||
#queryString;
|
||||
#urlBuilder;
|
||||
#filterSpecs;
|
||||
@@ -41,9 +41,7 @@ jasmineRequire.HtmlReporterV2 = function(j$) {
|
||||
#failures;
|
||||
|
||||
constructor(options) {
|
||||
this.#env = options.env;
|
||||
|
||||
this.#getContainer = options.getContainer;
|
||||
this.#container = options.container || document.body;
|
||||
this.#queryString =
|
||||
options.queryString ||
|
||||
new j$.QueryString({
|
||||
@@ -56,16 +54,8 @@ jasmineRequire.HtmlReporterV2 = function(j$) {
|
||||
getSuiteById: id => this.#stateBuilder.suitesById[id]
|
||||
});
|
||||
this.#filterSpecs = options.urls.filteringSpecs();
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the reporter. Should be called before {@link Env#execute}.
|
||||
* @function
|
||||
* @name HtmlReporter#initialize
|
||||
*/
|
||||
initialize() {
|
||||
this.#clearPrior();
|
||||
this.#config = this.#env ? this.#env.configuration() : {};
|
||||
this.#config = options.env ? options.env.configuration() : {};
|
||||
|
||||
this.#stateBuilder = new j$.private.ResultsStateBuilder();
|
||||
|
||||
@@ -106,13 +96,15 @@ jasmineRequire.HtmlReporterV2 = function(j$) {
|
||||
this.#alerts.rootEl,
|
||||
this.#failures.rootEl
|
||||
);
|
||||
this.#getContainer().appendChild(this.#htmlReporterMain);
|
||||
this.#container.appendChild(this.#htmlReporterMain);
|
||||
this.#failures.show();
|
||||
}
|
||||
|
||||
jasmineStarted(options) {
|
||||
this.#stateBuilder.jasmineStarted(options);
|
||||
this.#progress.start(options.totalSpecsDefined);
|
||||
this.#progress.start(
|
||||
options.totalSpecsDefined - options.numExcludedSpecs
|
||||
);
|
||||
}
|
||||
|
||||
suiteStarted(result) {
|
||||
@@ -197,19 +189,11 @@ jasmineRequire.HtmlReporterV2 = function(j$) {
|
||||
}
|
||||
|
||||
#find(selector) {
|
||||
return this.#getContainer().querySelector(
|
||||
return this.#container.querySelector(
|
||||
'.jasmine_html-reporter ' + selector
|
||||
);
|
||||
}
|
||||
|
||||
#clearPrior() {
|
||||
const oldReporter = this.#find('');
|
||||
|
||||
if (oldReporter) {
|
||||
this.#getContainer().removeChild(oldReporter);
|
||||
}
|
||||
}
|
||||
|
||||
#setMenuModeTo(mode) {
|
||||
this.#htmlReporterMain.setAttribute(
|
||||
'class',
|
||||
@@ -228,7 +212,9 @@ jasmineRequire.HtmlReporterV2 = function(j$) {
|
||||
}
|
||||
|
||||
specDone(result) {
|
||||
this.rootEl.value = this.rootEl.value + 1;
|
||||
if (result.status !== 'excluded') {
|
||||
this.rootEl.value = this.rootEl.value + 1;
|
||||
}
|
||||
|
||||
if (result.status === 'failed') {
|
||||
this.rootEl.classList.add('failed');
|
||||
|
||||
@@ -7,12 +7,14 @@ jasmineRequire.HtmlSpecFilter = function(j$) {
|
||||
* @deprecated Use {@link HtmlReporterV2Urls} instead.
|
||||
*/
|
||||
function HtmlSpecFilter(options) {
|
||||
j$.getEnv().deprecated(
|
||||
const env = options?.env ?? j$.getEnv();
|
||||
env.deprecated(
|
||||
'HtmlReporter and HtmlSpecFilter are deprecated. Use HtmlReporterV2 instead.'
|
||||
);
|
||||
|
||||
const filterString =
|
||||
options &&
|
||||
options.filterString &&
|
||||
options.filterString() &&
|
||||
options.filterString().replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&');
|
||||
const filterPattern = new RegExp(filterString);
|
||||
|
||||
@@ -5,7 +5,7 @@ jasmineRequire.htmlReporterUtils = function(j$) {
|
||||
const el = document.createElement(type);
|
||||
let children;
|
||||
|
||||
if (j$.private.isArray(childrenArrayOrVarArgs)) {
|
||||
if (Array.isArray(childrenArrayOrVarArgs)) {
|
||||
children = childrenArrayOrVarArgs;
|
||||
} else {
|
||||
children = [];
|
||||
|
||||
Reference in New Issue
Block a user