Compare commits

...

10 Commits

Author SHA1 Message Date
Steve Gravrock
79405426fa Bump version to 6.0.0-beta.0
Some checks failed
Test in latest available Safari / build (push) Has been cancelled
2025-11-28 11:35:46 -08:00
Steve Gravrock
00b09a9a04 Simplify HtmlReporterV2 initialization and boot1.js 2025-11-28 09:47:31 -08:00
Steve Gravrock
f5e9b61f73 Replace isArray helper with native Array.isArray 2025-11-28 08:09:51 -08:00
Steve Gravrock
4371081763 Deprecate jsApiReporter and remove it from boot1.js
jsApiReporter was initially added as part of the pre-1.0 Ruby based browser
runner. It looks like it was designed to resolve a race condition betweeen
jasmine-core's startup in the browser and the Ruby runner's startup. Modern
runners handle that either by buffering messages in a custom reporter (e.g.
jasmine-browser-runner's BatchReporter) or by calling env.execute() after a
communication channel has been set up (e.g. the old Jasmine ruby gem). In
any other context, a custom reporter is easier to use than jsApiReporter
because it doesn't require polling.

Adding jsApiReporter to the env imposes small but measurable penalties in
time and space, both of which are proportional to the size of the test
suite.

Other than jasmine-py and Testdouble's jasmine-rails gem, neither of which
ever supported jasmine-core 4 or later, I can find scant evidence of
interest and no evidence of usage after about 2012.
2025-11-28 08:08:50 -08:00
Steve Gravrock
9530ff68ab Fix event listener leaks in own specs 2025-11-28 07:13:52 -08:00
Steve Gravrock
51dc79dc22 rm dead code 2025-11-27 08:45:24 -08:00
Steve Gravrock
b559faec2a HtmlReporterV2: show correct progress when running a subset of specs 2025-11-27 07:24:45 -08:00
Steve Gravrock
d7b1456584 Document the set of possible spec statuses 2025-11-27 07:24:44 -08:00
Steve Gravrock
23894c1a0a Detect monkey patching and emit a deprecation warning.
This isn't comprehensive but it should be broad enough to ensure that most
people who would be affected by blocking monkey patching see a warning.
Covers the jasmine namespace as well as classes that are monkey patched by
zone.js.

Replacing globals (describe/it/etc) doesn't trigger a warning because they
belong to the user and are expected to be replaced.
2025-11-27 07:23:57 -08:00
Steve Gravrock
32168be6c7 Statically expose pretty printer as jasmine.pp
Pretty printing is occasionally useful outside of the places where a
configured pretty printer is injected (matchers and asymmetric equality
testers). Users sometimes use the private basicPrettyPrinter for that.
jasmine.pp is part of the public interface and uses the current runable's
custom object formatters.
2025-11-22 09:46:45 -08:00
38 changed files with 691 additions and 409 deletions

View File

@@ -41,23 +41,6 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
const env = jasmine.getEnv(); const env = jasmine.getEnv();
const urls = new jasmine.HtmlReporterV2Urls(); 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 * Configures Jasmine based on the current set of query parameters. This
* supports all parameters set by the HTML reporter as well as * supports all parameters set by the HTML reporter as well as
@@ -66,18 +49,11 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/ */
env.configure(urls.configFromCurrentUrl()); env.configure(urls.configFromCurrentUrl());
/** window.addEventListener('load', function() {
* ## Execution // 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.
* 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 htmlReporter = new jasmine.HtmlReporterV2({ env, urls });
*/ env.addReporter(htmlReporter);
const currentWindowOnload = window.onload;
window.onload = function() {
if (currentWindowOnload) {
currentWindowOnload();
}
htmlReporter.initialize();
env.execute(); env.execute();
}; });
})(); })();

View File

@@ -309,12 +309,14 @@ jasmineRequire.HtmlSpecFilter = function(j$) {
* @deprecated Use {@link HtmlReporterV2Urls} instead. * @deprecated Use {@link HtmlReporterV2Urls} instead.
*/ */
function HtmlSpecFilter(options) { function HtmlSpecFilter(options) {
j$.getEnv().deprecated( const env = options?.env ?? j$.getEnv();
env.deprecated(
'HtmlReporter and HtmlSpecFilter are deprecated. Use HtmlReporterV2 instead.' 'HtmlReporter and HtmlSpecFilter are deprecated. Use HtmlReporterV2 instead.'
); );
const filterString = const filterString =
options && options &&
options.filterString &&
options.filterString() && options.filterString() &&
options.filterString().replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&'); options.filterString().replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&');
const filterPattern = new RegExp(filterString); 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) { addGlobalFailure(failure) {
this.#createAndAdd( this.#createAndAdd(
errorBarClassName, errorBarClassName,
@@ -940,7 +903,7 @@ jasmineRequire.htmlReporterUtils = function(j$) {
const el = document.createElement(type); const el = document.createElement(type);
let children; let children;
if (j$.private.isArray(childrenArrayOrVarArgs)) { if (Array.isArray(childrenArrayOrVarArgs)) {
children = childrenArrayOrVarArgs; children = childrenArrayOrVarArgs;
} else { } else {
children = []; children = [];
@@ -1007,12 +970,12 @@ jasmineRequire.HtmlReporterV2 = function(j$) {
* const reporter = new jasmine.HtmlReporterV2({ * const reporter = new jasmine.HtmlReporterV2({
* env, * env,
* urls, * urls,
* getContainer: () => document.body * // container is optional and defaults to document.body.
* container: someElement
* }); * });
*/ */
class HtmlReporterV2 { class HtmlReporterV2 {
#env; #container;
#getContainer;
#queryString; #queryString;
#urlBuilder; #urlBuilder;
#filterSpecs; #filterSpecs;
@@ -1029,9 +992,7 @@ jasmineRequire.HtmlReporterV2 = function(j$) {
#failures; #failures;
constructor(options) { constructor(options) {
this.#env = options.env; this.#container = options.container || document.body;
this.#getContainer = options.getContainer;
this.#queryString = this.#queryString =
options.queryString || options.queryString ||
new j$.QueryString({ new j$.QueryString({
@@ -1044,16 +1005,8 @@ jasmineRequire.HtmlReporterV2 = function(j$) {
getSuiteById: id => this.#stateBuilder.suitesById[id] getSuiteById: id => this.#stateBuilder.suitesById[id]
}); });
this.#filterSpecs = options.urls.filteringSpecs(); this.#filterSpecs = options.urls.filteringSpecs();
}
/** this.#config = options.env ? options.env.configuration() : {};
* 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.#stateBuilder = new j$.private.ResultsStateBuilder(); this.#stateBuilder = new j$.private.ResultsStateBuilder();
@@ -1094,13 +1047,15 @@ jasmineRequire.HtmlReporterV2 = function(j$) {
this.#alerts.rootEl, this.#alerts.rootEl,
this.#failures.rootEl this.#failures.rootEl
); );
this.#getContainer().appendChild(this.#htmlReporterMain); this.#container.appendChild(this.#htmlReporterMain);
this.#failures.show(); this.#failures.show();
} }
jasmineStarted(options) { jasmineStarted(options) {
this.#stateBuilder.jasmineStarted(options); this.#stateBuilder.jasmineStarted(options);
this.#progress.start(options.totalSpecsDefined); this.#progress.start(
options.totalSpecsDefined - options.numExcludedSpecs
);
} }
suiteStarted(result) { suiteStarted(result) {
@@ -1185,19 +1140,11 @@ jasmineRequire.HtmlReporterV2 = function(j$) {
} }
#find(selector) { #find(selector) {
return this.#getContainer().querySelector( return this.#container.querySelector(
'.jasmine_html-reporter ' + selector '.jasmine_html-reporter ' + selector
); );
} }
#clearPrior() {
const oldReporter = this.#find('');
if (oldReporter) {
this.#getContainer().removeChild(oldReporter);
}
}
#setMenuModeTo(mode) { #setMenuModeTo(mode) {
this.#htmlReporterMain.setAttribute( this.#htmlReporterMain.setAttribute(
'class', 'class',
@@ -1216,7 +1163,9 @@ jasmineRequire.HtmlReporterV2 = function(j$) {
} }
specDone(result) { specDone(result) {
this.rootEl.value = this.rootEl.value + 1; if (result.status !== 'excluded') {
this.rootEl.value = this.rootEl.value + 1;
}
if (result.status === 'failed') { if (result.status === 'failed') {
this.rootEl.classList.add('failed'); this.rootEl.classList.add('failed');

View File

@@ -44,9 +44,14 @@ var getJasmineRequireObj = (function() {
} }
getJasmineRequire().core = function(jRequire) { getJasmineRequire().core = function(jRequire) {
const j$ = { private: {} }; const j$ = {};
Object.defineProperty(j$, 'private', {
enumerable: true,
value: {}
});
jRequire.base(j$, globalThis); jRequire.base(j$, globalThis);
j$.private.deprecateMonkeyPatching = jRequire.deprecateMonkeyPatching(j$);
j$.private.util = jRequire.util(j$); j$.private.util = jRequire.util(j$);
j$.private.errors = jRequire.errors(); j$.private.errors = jRequire.errors();
j$.private.formatErrorMsg = jRequire.formatErrorMsg(j$); j$.private.formatErrorMsg = jRequire.formatErrorMsg(j$);
@@ -56,7 +61,7 @@ var getJasmineRequireObj = (function() {
j$.private.CallTracker = jRequire.CallTracker(j$); j$.private.CallTracker = jRequire.CallTracker(j$);
j$.private.MockDate = jRequire.MockDate(j$); j$.private.MockDate = jRequire.MockDate(j$);
j$.private.getStackClearer = jRequire.StackClearer(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.DelayedFunctionScheduler = jRequire.DelayedFunctionScheduler(j$);
j$.private.Deprecator = jRequire.Deprecator(j$); j$.private.Deprecator = jRequire.Deprecator(j$);
j$.private.Configuration = jRequire.Configuration(j$); j$.private.Configuration = jRequire.Configuration(j$);
@@ -122,6 +127,20 @@ var getJasmineRequireObj = (function() {
j$.private.loadedAsBrowserEsm = j$.private.loadedAsBrowserEsm =
globalThis.document && !globalThis.document.currentScript; globalThis.document && !globalThis.document.currentScript;
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$; return j$;
}; };
@@ -246,16 +265,15 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) {
* @function * @function
* @return {Env} * @return {Env}
*/ */
j$.getEnv = function(options) { Object.defineProperty(j$, 'getEnv', {
const env = (j$.private.currentEnv_ = enumerable: true,
j$.private.currentEnv_ || new j$.private.Env(options)); value: function(options) {
//jasmine. singletons in here (setTimeout blah blah). const env = (j$.private.currentEnv_ =
return env; 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); });
};
j$.private.isObject = function(value) { j$.private.isObject = function(value) {
return ( return (
@@ -956,7 +974,7 @@ getJasmineRequireObj().Spec = function(j$) {
* @property {ExpectationResult[]} passedExpectations - The list of expectations that passed during execution of this spec. * @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 {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} 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 {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 {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. * @property {DebugLogEntry[]|null} debugLogs - Messages, if any, that were logged using {@link jasmine.debugLog} during a failing spec.
@@ -1520,10 +1538,13 @@ getJasmineRequireObj().Env = function(j$) {
* @param {String|Error} deprecation The deprecation message * @param {String|Error} deprecation The deprecation message
* @param {Object} [options] Optional extra options, as described above * @param {Object} [options] Optional extra options, as described above
*/ */
this.deprecated = function(deprecation, options) { Object.defineProperty(this, 'deprecated', {
const runable = runner.currentRunable() || topSuite; enumerable: true,
deprecator.addDeprecationWarning(runable, deprecation, options); value: function(deprecation, options) {
}; const runable = runner.currentRunable() || topSuite;
deprecator.addDeprecationWarning(runable, deprecation, options);
}
});
function runQueue(options) { function runQueue(options) {
options.clearStack = options.clearStack || stackClearer; options.clearStack = options.clearStack || stackClearer;
@@ -1550,7 +1571,8 @@ getJasmineRequireObj().Env = function(j$) {
runQueue runQueue
}); });
topSuite = suiteBuilder.topSuite; 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 * Provides the root suite, through which all suites and specs can be
@@ -2045,9 +2067,18 @@ getJasmineRequireObj().Env = function(j$) {
} }
}; };
this.pp = function(value) {
const pp = runner.currentRunable()
? runableResources.makePrettyPrinter()
: j$.private.basicPrettyPrinter;
return pp(value);
};
this.cleanup_ = function() { this.cleanup_ = function() {
uninstallGlobalErrors(); uninstallGlobalErrors();
}; };
j$.private.deprecateMonkeyPatching(this, ['deprecated']);
} }
function indirectCallerFilename(depth) { function indirectCallerFilename(depth) {
@@ -2064,11 +2095,13 @@ getJasmineRequireObj().Env = function(j$) {
getJasmineRequireObj().JsApiReporter = function(j$) { getJasmineRequireObj().JsApiReporter = function(j$) {
'use strict'; 'use strict';
// TODO: remove in 7.0.
/** /**
* @name jsApiReporter * @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. * @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 * @class
* @hideconstructor * @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) { function JsApiReporter(options) {
const timer = options.timer || new j$.Timer(); const timer = options.timer || new j$.Timer();
@@ -2295,7 +2328,7 @@ getJasmineRequireObj().ArrayContaining = function(j$) {
} }
ArrayContaining.prototype.asymmetricMatch = function(other, matchersUtil) { ArrayContaining.prototype.asymmetricMatch = function(other, matchersUtil) {
if (!j$.private.isArray(this.sample)) { if (!Array.isArray(this.sample)) {
throw new Error( throw new Error(
'You must provide an array to arrayContaining, not ' + 'You must provide an array to arrayContaining, not ' +
j$.private.basicPrettyPrinter(this.sample) + j$.private.basicPrettyPrinter(this.sample) +
@@ -2306,7 +2339,7 @@ getJasmineRequireObj().ArrayContaining = function(j$) {
// If the actual parameter is not an array, we can fail immediately, since it couldn't // 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 // 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 // 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; return false;
} }
@@ -2337,7 +2370,7 @@ getJasmineRequireObj().ArrayWithExactContents = function(j$) {
other, other,
matchersUtil matchersUtil
) { ) {
if (!j$.private.isArray(this.sample)) { if (!Array.isArray(this.sample)) {
throw new Error( throw new Error(
'You must provide an array to arrayWithExactContents, not ' + 'You must provide an array to arrayWithExactContents, not ' +
j$.private.basicPrettyPrinter(this.sample) + j$.private.basicPrettyPrinter(this.sample) +
@@ -2373,7 +2406,7 @@ getJasmineRequireObj().Empty = function(j$) {
Empty.prototype.asymmetricMatch = function(other) { Empty.prototype.asymmetricMatch = function(other) {
if ( if (
j$.private.isString(other) || j$.private.isString(other) ||
j$.private.isArray(other) || Array.isArray(other) ||
j$.private.isTypedArray(other) j$.private.isTypedArray(other)
) { ) {
return other.length === 0; return other.length === 0;
@@ -2488,7 +2521,7 @@ getJasmineRequireObj().NotEmpty = function(j$) {
NotEmpty.prototype.asymmetricMatch = function(other) { NotEmpty.prototype.asymmetricMatch = function(other) {
if ( if (
j$.private.isString(other) || j$.private.isString(other) ||
j$.private.isArray(other) || Array.isArray(other) ||
j$.private.isTypedArray(other) j$.private.isTypedArray(other)
) { ) {
return other.length !== 0; return other.length !== 0;
@@ -2920,7 +2953,7 @@ getJasmineRequireObj().CallTracker = function(j$) {
return CallTracker; return CallTracker;
}; };
getJasmineRequireObj().Clock = function() { getJasmineRequireObj().Clock = function(j$) {
'use strict'; 'use strict';
/* global process */ /* global process */
@@ -3113,6 +3146,9 @@ callbacks to execute _before_ running the next one.
clearTimeout[IsMockClockTimingFn] = true; clearTimeout[IsMockClockTimingFn] = true;
setInterval[IsMockClockTimingFn] = true; setInterval[IsMockClockTimingFn] = true;
clearInterval[IsMockClockTimingFn] = true; clearInterval[IsMockClockTimingFn] = true;
j$.private.deprecateMonkeyPatching(this);
return this; return this;
// Advances the Clock's time until the mode changes. // Advances the Clock's time until the mode changes.
@@ -3821,6 +3857,29 @@ getJasmineRequireObj().DelayedFunctionScheduler = function(j$) {
return DelayedFunctionScheduler; 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. This is not supported and will break in a future jasmine-core release.'
);
value = newValue;
}
});
}
}
};
};
getJasmineRequireObj().Deprecator = function(j$) { getJasmineRequireObj().Deprecator = function(j$) {
'use strict'; 'use strict';
@@ -5288,7 +5347,7 @@ getJasmineRequireObj().MatchersUtil = function(j$) {
this.customTesters_ = options.customTesters || []; this.customTesters_ = options.customTesters || [];
/** /**
* Formats a value for use in matcher failure messages and similar contexts, * 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 * @function
* @name MatchersUtil#pp * @name MatchersUtil#pp
* @since 3.6.0 * @since 3.6.0
@@ -8200,7 +8259,7 @@ getJasmineRequireObj().makePrettyPrinter = function(j$) {
} else if ( } else if (
value.toString && value.toString &&
typeof value === 'object' && typeof value === 'object' &&
!j$.private.isArray(value) && !Array.isArray(value) &&
hasCustomToString(value) hasCustomToString(value)
) { ) {
try { try {
@@ -8212,15 +8271,12 @@ getJasmineRequireObj().makePrettyPrinter = function(j$) {
} else if (this.seen.includes(value)) { } else if (this.seen.includes(value)) {
this.emitScalar( this.emitScalar(
'<circular reference: ' + '<circular reference: ' +
(j$.private.isArray(value) ? 'Array' : 'Object') + (Array.isArray(value) ? 'Array' : 'Object') +
'>' '>'
); );
} else if ( } else if (Array.isArray(value) || j$.private.isA('Object', value)) {
j$.private.isArray(value) ||
j$.private.isA('Object', value)
) {
this.seen.push(value); this.seen.push(value);
if (j$.private.isArray(value)) { if (Array.isArray(value)) {
this.emitArray(value); this.emitArray(value);
} else { } else {
this.emitObject(value); this.emitObject(value);
@@ -8243,10 +8299,7 @@ getJasmineRequireObj().makePrettyPrinter = function(j$) {
} }
iterateObject(obj, fn) { iterateObject(obj, fn) {
const objKeys = j$.private.MatchersUtil.keys( const objKeys = j$.private.MatchersUtil.keys(obj, Array.isArray(obj));
obj,
j$.private.isArray(obj)
);
const length = Math.min(objKeys.length, j$.MAX_PRETTY_PRINT_ARRAY_LENGTH); const length = Math.min(objKeys.length, j$.MAX_PRETTY_PRINT_ARRAY_LENGTH);
for (let i = 0; i < length; i++) { for (let i = 0; i < length; i++) {
@@ -9371,6 +9424,7 @@ getJasmineRequireObj().interface = function(jasmine, env) {
*/ */
jasmine: jasmine jasmine: jasmine
}; };
const existingKeys = Object.keys(jasmine);
/** /**
* Add a custom equality tester for the current scope of specs. * Add a custom equality tester for the current scope of specs.
@@ -9500,6 +9554,21 @@ getJasmineRequireObj().interface = function(jasmine, env) {
return env.setDefaultSpyStrategy(defaultStrategyFn); 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 * {@link AsymmetricEqualityTester|Asymmetric equality testers} allow for
* non-exact matching in matchers that use Jasmine's deep value equality * non-exact matching in matchers that use Jasmine's deep value equality
@@ -9522,6 +9591,8 @@ getJasmineRequireObj().interface = function(jasmine, env) {
* @namespace asymmetricEqualityTesters * @namespace asymmetricEqualityTesters
*/ */
jasmine.private.deprecateMonkeyPatching(jasmine, existingKeys);
return jasmineInterface; return jasmineInterface;
}; };
@@ -9783,7 +9854,8 @@ getJasmineRequireObj().Runner = function(j$) {
/** /**
* Information passed to the {@link Reporter#jasmineStarted} event. * Information passed to the {@link Reporter#jasmineStarted} event.
* @typedef JasmineStartedInfo * @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 {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. * @property {Boolean} parallel - Whether Jasmine is being run in parallel mode.
* @since 2.0.0 * @since 2.0.0
@@ -9792,6 +9864,7 @@ getJasmineRequireObj().Runner = function(j$) {
// In parallel mode, the jasmineStarted event is separately dispatched // In parallel mode, the jasmineStarted event is separately dispatched
// by jasmine-npm. This event only reaches reporters in non-parallel. // by jasmine-npm. This event only reaches reporters in non-parallel.
totalSpecsDefined, totalSpecsDefined,
numExcludedSpecs: this.#executionTree.numExcludedSpecs(),
order: orderForReporting(order), order: orderForReporting(order),
parallel: false parallel: false
}); });
@@ -10154,7 +10227,7 @@ getJasmineRequireObj().SpyFactory = function(j$) {
this.createSpyObj = function(baseName, methodNames, propertyNames) { this.createSpyObj = function(baseName, methodNames, propertyNames) {
const baseNameIsCollection = const baseNameIsCollection =
j$.private.isObject(baseName) || j$.private.isArray(baseName); j$.private.isObject(baseName) || Array.isArray(baseName);
if (baseNameIsCollection) { if (baseNameIsCollection) {
propertyNames = methodNames; propertyNames = methodNames;
@@ -10200,7 +10273,7 @@ getJasmineRequireObj().SpyFactory = function(j$) {
function normalizeKeyValues(object) { function normalizeKeyValues(object) {
const result = []; const result = [];
if (j$.private.isArray(object)) { if (Array.isArray(object)) {
for (let i = 0; i < object.length; i++) { for (let i = 0; i < object.length; i++) {
result.push([object[i]]); result.push([object[i]]);
} }
@@ -11898,6 +11971,23 @@ getJasmineRequireObj().TreeProcessor = function(j$) {
const nodeStats = this.#stats[node.id]; const nodeStats = this.#stats[node.id];
return node.children ? !nodeStats.willExecute : nodeStats.excluded; 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) { function segmentChildren(node, orderedChildren, stats, executableIndex) {
@@ -12295,5 +12385,5 @@ getJasmineRequireObj().UserContext = function(j$) {
}; };
getJasmineRequireObj().version = function() { getJasmineRequireObj().version = function() {
return '6.0.0-alpha.2'; return '6.0.0-beta.0';
}; };

View File

@@ -1,7 +1,7 @@
{ {
"name": "jasmine-core", "name": "jasmine-core",
"license": "MIT", "license": "MIT",
"version": "6.0.0-alpha.2", "version": "6.0.0-beta.0",
"repository": { "repository": {
"type": "git", "type": "git",
"url": "https://github.com/jasmine/jasmine.git" "url": "https://github.com/jasmine/jasmine.git"

View 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)_

View File

@@ -1247,4 +1247,25 @@ describe('Clock (acceptance)', function() {
clock.tick(400); 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);
});
}
});
}); });

View File

@@ -26,8 +26,6 @@ describe('Env', function() {
describe('#topSuite', function() { describe('#topSuite', function() {
it('returns an object that describes the tree of suites and specs', function() { it('returns an object that describes the tree of suites and specs', function() {
spyOn(env, 'deprecated');
env.it('a top level spec'); env.it('a top level spec');
env.describe('a suite', function() { env.describe('a suite', function() {
env.it('a spec'); env.it('a spec');
@@ -123,7 +121,6 @@ describe('Env', function() {
}); });
it('ignores configuration properties that are present but undefined', function() { it('ignores configuration properties that are present but undefined', function() {
spyOn(env, 'deprecated');
const initialConfig = { const initialConfig = {
random: true, random: true,
seed: '123', seed: '123',
@@ -763,7 +760,6 @@ describe('Env', function() {
it("does not expose the suite as 'this'", function() { it("does not expose the suite as 'this'", function() {
let suiteThis; let suiteThis;
spyOn(env, 'deprecated');
env.describe('a suite', function() { env.describe('a suite', function() {
suiteThis = this; suiteThis = this;
@@ -878,4 +874,44 @@ describe('Env', function() {
}).toThrowError('Jasmine cannot be configured via Env in parallel mode'); }).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);
});
}
});
}); });

View File

@@ -87,7 +87,7 @@ describe('Runner', function() {
function arrayNotContaining(item) { function arrayNotContaining(item) {
return { return {
asymmetricMatch(other, matchersUtil) { asymmetricMatch(other, matchersUtil) {
if (!jasmine.private.isArray(other)) { if (!Array.isArray(other)) {
return false; return false;
} }

View File

@@ -246,4 +246,53 @@ describe('TreeProcessor', function() {
{ spec: leaf1 } { 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);
});
});
}); });

View File

@@ -1,20 +1,4 @@
describe('util', function() { 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() { describe('isObject', function() {
it('should return true if the argument is an object', function() { it('should return true if the argument is an object', function() {
expect(privateUnderTest.isObject({})).toBe(true); expect(privateUnderTest.isObject({})).toBe(true);

View File

@@ -170,8 +170,15 @@ describe('base helpers', function() {
}); });
describe('debugLog', 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() { it("forwards to the current env's debugLog function", function() {
spyOn(jasmineUnderTest.getEnv(), 'debugLog');
jasmineUnderTest.debugLog('a message'); jasmineUnderTest.debugLog('a message');
expect(jasmineUnderTest.getEnv().debugLog).toHaveBeenCalledWith( expect(jasmineUnderTest.getEnv().debugLog).toHaveBeenCalledWith(
'a message' 'a message'

View File

@@ -1557,6 +1557,7 @@ describe('Env integration', function() {
expect(reporter.jasmineStarted).toHaveBeenCalledWith({ expect(reporter.jasmineStarted).toHaveBeenCalledWith({
totalSpecsDefined: 1, totalSpecsDefined: 1,
numExcludedSpecs: 0,
order: { random: true, seed: jasmine.any(String) }, order: { random: true, seed: jasmine.any(String) },
parallel: false parallel: false
}); });
@@ -1592,6 +1593,7 @@ describe('Env integration', function() {
expect(reporter.jasmineStarted).toHaveBeenCalledWith({ expect(reporter.jasmineStarted).toHaveBeenCalledWith({
totalSpecsDefined: 1, totalSpecsDefined: 1,
numExcludedSpecs: 0,
order: { random: true, seed: jasmine.any(String) }, order: { random: true, seed: jasmine.any(String) },
parallel: false parallel: false
}); });
@@ -1648,6 +1650,7 @@ describe('Env integration', function() {
expect(reporter.jasmineStarted).toHaveBeenCalledWith({ expect(reporter.jasmineStarted).toHaveBeenCalledWith({
totalSpecsDefined: 6, totalSpecsDefined: 6,
numExcludedSpecs: 3,
order: { random: false }, order: { random: false },
parallel: false parallel: false
}); });
@@ -2061,6 +2064,7 @@ describe('Env integration', function() {
expect(reporter.jasmineStarted).toHaveBeenCalledWith({ expect(reporter.jasmineStarted).toHaveBeenCalledWith({
totalSpecsDefined: 1, totalSpecsDefined: 1,
numExcludedSpecs: 1,
order: { random: true, seed: jasmine.any(String) }, order: { random: true, seed: jasmine.any(String) },
parallel: false 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() { it('forbids duplicates when forbidDuplicateNames is true', function() {
env.configure({ forbidDuplicateNames: true }); env.configure({ forbidDuplicateNames: true });
env.it('a spec'); env.it('a spec');

View File

@@ -13,7 +13,72 @@ describe('The jasmine namespace', function() {
expect(setDifference(actualKeys, expectedKeys())).toEqual(new Set()); 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 // Does not include properties added by requireInterface(), since that isn't
// called by defineJasmineUnderTest.js/nodeDefineJasmineUnderTest.js. // called by defineJasmineUnderTest.js/nodeDefineJasmineUnderTest.js.
const result = new Set([ const result = new Set([
@@ -51,7 +116,7 @@ describe('The jasmine namespace', function() {
'getGlobal' 'getGlobal'
]); ]);
if (typeof window !== 'undefined') { if (includeHtml) {
// jasmine-html.js // jasmine-html.js
result.add('HtmlReporter'); result.add('HtmlReporter');
result.add('HtmlReporterV2'); result.add('HtmlReporterV2');
@@ -76,4 +141,15 @@ describe('The jasmine namespace', function() {
return result; return result;
} }
function verifyDeprecation() {
// eslint-disable-next-line no-console
expect(console.error).toHaveBeenCalledOnceWith(
jasmine.stringContaining('DEPRECATION: Monkey patching detected.')
);
// eslint-disable-next-line no-console
expect(console.error).toHaveBeenCalledOnceWith(
jasmine.stringContaining('jasmineNamespaceSpec.js')
);
}
}); });

View File

@@ -1,9 +1,12 @@
describe('HtmlReporter', function() { describe('HtmlReporter', function() {
let env; let env, deprecator;
beforeEach(function() { beforeEach(function() {
env = new privateUnderTest.Env(); deprecator = jasmine.createSpyObj('deprecator', [
spyOn(env, 'deprecated'); 'verboseDeprecations',
'addDeprecationWarning'
]);
env = new privateUnderTest.Env({ deprecator });
}); });
afterEach(function() { afterEach(function() {
@@ -21,8 +24,10 @@ describe('HtmlReporter', function() {
}); });
reporter.initialize(); reporter.initialize();
expect(env.deprecated).toHaveBeenCalledWith( expect(deprecator.addDeprecationWarning).toHaveBeenCalledWith(
'HtmlReporter and HtmlSpecFilter are deprecated. Use HtmlReporterV2 instead.' jasmine.anything(),
'HtmlReporter and HtmlSpecFilter are deprecated. Use HtmlReporterV2 instead.',
undefined
); );
}); });

View File

@@ -14,9 +14,7 @@ describe('HtmlReporterV2', function() {
function setup(options = {}) { function setup(options = {}) {
return new jasmineUnderTest.HtmlReporterV2({ return new jasmineUnderTest.HtmlReporterV2({
env, env,
getContainer() { container,
return container;
},
urls: new jasmineUnderTest.HtmlReporterV2Urls(), urls: new jasmineUnderTest.HtmlReporterV2Urls(),
queryString: new jasmineUnderTest.QueryString({ queryString: new jasmineUnderTest.QueryString({
getWindowLocation() { getWindowLocation() {
@@ -28,8 +26,7 @@ describe('HtmlReporterV2', function() {
} }
it('builds the initial DOM elements, including the title banner', function() { it('builds the initial DOM elements, including the title banner', function() {
const reporter = setup(); setup();
reporter.initialize();
// Main top-level elements // Main top-level elements
expect(container.querySelector('div.jasmine_html-reporter')).toBeTruthy(); expect(container.querySelector('div.jasmine_html-reporter')).toBeTruthy();
@@ -50,17 +47,6 @@ describe('HtmlReporterV2', function() {
expect(version.textContent).toEqual(jasmineUnderTest.version); 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('when a spec is done', function() {
describe('and no expectations ran', function() { describe('and no expectations ran', function() {
let reporter; let reporter;
@@ -70,8 +56,6 @@ describe('HtmlReporterV2', function() {
spyOn(console, 'warn'); spyOn(console, 'warn');
spyOn(console, 'error'); spyOn(console, 'error');
reporter.initialize();
}); });
it('logs a warning to the console when the spec passed', function() { 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() { it('updates the progress bar', function() {
const reporter = setup(); const reporter = setup();
reporter.initialize();
const progress = container.querySelector('progress'); const progress = container.querySelector('progress');
reporter.specDone({ reporter.specDone({
@@ -125,7 +108,6 @@ describe('HtmlReporterV2', function() {
it('changes the progress bar status if the spec failed', function() { it('changes the progress bar status if the spec failed', function() {
const reporter = setup(); const reporter = setup();
reporter.initialize();
reporter.specDone({ reporter.specDone({
id: 345, id: 345,
@@ -142,9 +124,8 @@ describe('HtmlReporterV2', function() {
describe('when there are deprecation warnings', function() { describe('when there are deprecation warnings', function() {
it('displays the messages in their own alert bars', function() { it('displays the messages in their own alert bars', function() {
const reporter = setup(); const reporter = setup();
reporter.initialize();
reporter.jasmineStarted({ totalSpecsDefined: 0 }); reporter.jasmineStarted({ totalSpecsDefined: 0, numExcludedSpecs: 0 });
reporter.specDone({ reporter.specDone({
status: 'passed', status: 'passed',
fullName: 'a spec with a deprecation', fullName: 'a spec with a deprecation',
@@ -183,9 +164,8 @@ describe('HtmlReporterV2', function() {
it('displays expandable stack traces', function() { it('displays expandable stack traces', function() {
const reporter = setup(); const reporter = setup();
reporter.initialize();
reporter.jasmineStarted({ totalSpecsDefined: 0 }); reporter.jasmineStarted({ totalSpecsDefined: 0, numExcludedSpecs: 0 });
reporter.jasmineDone({ reporter.jasmineDone({
deprecationWarnings: [ deprecationWarnings: [
{ {
@@ -219,9 +199,8 @@ describe('HtmlReporterV2', function() {
it('omits the expander when there is no stack trace', function() { it('omits the expander when there is no stack trace', function() {
const reporter = setup(); const reporter = setup();
reporter.initialize();
reporter.jasmineStarted({ totalSpecsDefined: 0 }); reporter.jasmineStarted({ totalSpecsDefined: 0, numExcludedSpecs: 0 });
reporter.jasmineDone({ reporter.jasmineDone({
deprecationWarnings: [ deprecationWarnings: [
{ {
@@ -238,9 +217,8 @@ describe('HtmlReporterV2', function() {
it('nicely formats the verboseDeprecations note', function() { it('nicely formats the verboseDeprecations note', function() {
const reporter = setup(); const reporter = setup();
reporter.initialize();
reporter.jasmineStarted({ totalSpecsDefined: 0 }); reporter.jasmineStarted({ totalSpecsDefined: 0, numExcludedSpecs: 0 });
reporter.jasmineDone({ reporter.jasmineDone({
deprecationWarnings: [ deprecationWarnings: [
{ {
@@ -272,8 +250,7 @@ describe('HtmlReporterV2', function() {
describe('while Jasmine is running', function() { describe('while Jasmine is running', function() {
it('hides all tabs', function() { it('hides all tabs', function() {
const reporter = setup(); const reporter = setup();
reporter.initialize(); reporter.jasmineStarted({ totalSpecsDefined: 0, numExcludedSpecs: 0 });
reporter.jasmineStarted({ totalSpecsDefined: 0 });
const tabs = container.querySelectorAll('.jasmine-tab'); const tabs = container.querySelectorAll('.jasmine-tab');
expect(tabs.length).toEqual(3); expect(tabs.length).toEqual(3);
expect(tabs[0].textContent).toEqual('Spec List'); expect(tabs[0].textContent).toEqual('Spec List');
@@ -300,7 +277,6 @@ describe('HtmlReporterV2', function() {
beforeEach(function() { beforeEach(function() {
reporter = setup(); reporter = setup();
reporter.initialize();
reportEvents(reporter); reportEvents(reporter);
}); });
@@ -354,7 +330,6 @@ describe('HtmlReporterV2', function() {
beforeEach(function() { beforeEach(function() {
reporter = setup(); reporter = setup();
reporter.initialize();
reportEvents(reporter); reportEvents(reporter);
}); });
@@ -374,7 +349,10 @@ describe('HtmlReporterV2', function() {
describe('with spec failures', function() { describe('with spec failures', function() {
hasSpecOrSuiteFailureBehavior(function(reporter) { hasSpecOrSuiteFailureBehavior(function(reporter) {
reporter.jasmineStarted({ totalSpecsDefined: 0 }); reporter.jasmineStarted({
totalSpecsDefined: 0,
numExcludedSpecs: 0
});
reporter.specDone({ reporter.specDone({
id: 1, id: 1,
description: 'a failing spec', description: 'a failing spec',
@@ -397,7 +375,10 @@ describe('HtmlReporterV2', function() {
describe('with suite failures', function() { describe('with suite failures', function() {
hasSpecOrSuiteFailureBehavior(function(reporter) { hasSpecOrSuiteFailureBehavior(function(reporter) {
reporter.jasmineStarted({ totalSpecsDefined: 0 }); reporter.jasmineStarted({
totalSpecsDefined: 0,
numExcludedSpecs: 0
});
reporter.specDone({ reporter.specDone({
id: 1, id: 1,
description: 'a failing spec', description: 'a failing spec',
@@ -420,7 +401,10 @@ describe('HtmlReporterV2', function() {
describe('without any failures', function() { describe('without any failures', function() {
hasSpecAndSuiteSuccessBehavior(function(reporter) { hasSpecAndSuiteSuccessBehavior(function(reporter) {
reporter.jasmineStarted({ totalSpecsDefined: 0 }); reporter.jasmineStarted({
totalSpecsDefined: 0,
numExcludedSpecs: 0
});
reporter.specDone({ reporter.specDone({
id: 1, id: 1,
description: 'a passing spec', description: 'a passing spec',
@@ -438,7 +422,10 @@ describe('HtmlReporterV2', function() {
// Top suite failures are displayed in their own alert bars, so they // Top suite failures are displayed in their own alert bars, so they
// don't cause the failures tab to be shown. // don't cause the failures tab to be shown.
hasSpecAndSuiteSuccessBehavior(function(reporter) { hasSpecAndSuiteSuccessBehavior(function(reporter) {
reporter.jasmineStarted({ totalSpecsDefined: 0 }); reporter.jasmineStarted({
totalSpecsDefined: 0,
numExcludedSpecs: 0
});
reporter.jasmineDone({ reporter.jasmineDone({
failedExpectations: [{}] failedExpectations: [{}]
}); });
@@ -447,8 +434,7 @@ describe('HtmlReporterV2', function() {
it('shows the slow spec view when the Performance tab is clicked', function() { it('shows the slow spec view when the Performance tab is clicked', function() {
const reporter = setup(); const reporter = setup();
reporter.initialize(); reporter.jasmineStarted({ totalSpecsDefined: 0, numExcludedSpecs: 0 });
reporter.jasmineStarted({ totalSpecsDefined: 0 });
reporter.specDone({ reporter.specDone({
duration: 1.2, duration: 1.2,
failedExpectations: [], failedExpectations: [],
@@ -472,8 +458,7 @@ describe('HtmlReporterV2', function() {
const reporter = setup(); const reporter = setup();
spyOn(console, 'error'); spyOn(console, 'error');
reporter.initialize(); reporter.jasmineStarted({ totalSpecsDefined: 0, numExcludedSpecs: 0 });
reporter.jasmineStarted({ totalSpecsDefined: 0 });
reporter.suiteStarted({ id: 1 }); reporter.suiteStarted({ id: 1 });
reporter.specDone({ reporter.specDone({
id: 1, id: 1,
@@ -495,9 +480,8 @@ describe('HtmlReporterV2', function() {
it('reports the run time', function() { it('reports the run time', function() {
const reporter = setup(); const reporter = setup();
reporter.initialize();
reporter.jasmineStarted({ totalSpecsDefined: 0 }); reporter.jasmineStarted({ totalSpecsDefined: 0, numExcludedSpecs: 0 });
reporter.jasmineDone({ totalTime: 100 }); reporter.jasmineDone({ totalTime: 100 });
@@ -513,9 +497,8 @@ describe('HtmlReporterV2', function() {
return '?foo=bar&' + key + '=' + value; return '?foo=bar&' + key + '=' + value;
} }
}); });
reporter.initialize();
reporter.jasmineStarted({ totalSpecsDefined: 0 }); reporter.jasmineStarted({ totalSpecsDefined: 0, numExcludedSpecs: 0 });
reporter.suiteStarted({ reporter.suiteStarted({
id: 1, id: 1,
description: 'A Suite', description: 'A Suite',
@@ -620,7 +603,6 @@ describe('HtmlReporterV2', function() {
it('has an options menu', function() { it('has an options menu', function() {
const reporter = setup(); const reporter = setup();
reporter.initialize();
reporter.jasmineDone({}); reporter.jasmineDone({});
const trigger = container.querySelector( const trigger = container.querySelector(
@@ -644,9 +626,8 @@ describe('HtmlReporterV2', function() {
describe('when there are global errors', function() { describe('when there are global errors', function() {
it('displays the exceptions in their own alert bars', function() { it('displays the exceptions in their own alert bars', function() {
const reporter = setup(); const reporter = setup();
reporter.initialize();
reporter.jasmineStarted({ totalSpecsDefined: 0 }); reporter.jasmineStarted({ totalSpecsDefined: 0, numExcludedSpecs: 0 });
reporter.jasmineDone({ reporter.jasmineDone({
failedExpectations: [ failedExpectations: [
{ {
@@ -673,9 +654,8 @@ describe('HtmlReporterV2', function() {
it('does not display the "AfterAll" prefix for other error types', function() { it('does not display the "AfterAll" prefix for other error types', function() {
const reporter = setup(); const reporter = setup();
reporter.initialize();
reporter.jasmineStarted({ totalSpecsDefined: 0 }); reporter.jasmineStarted({ totalSpecsDefined: 0, numExcludedSpecs: 0 });
reporter.jasmineDone({ reporter.jasmineDone({
failedExpectations: [ failedExpectations: [
{ message: 'load error', globalErrorType: 'load' }, { message: 'load error', globalErrorType: 'load' },
@@ -703,9 +683,8 @@ describe('HtmlReporterV2', function() {
it('displays file and line information if available', function() { it('displays file and line information if available', function() {
const reporter = setup(); const reporter = setup();
reporter.initialize();
reporter.jasmineStarted({ totalSpecsDefined: 0 }); reporter.jasmineStarted({ totalSpecsDefined: 0, numExcludedSpecs: 0 });
reporter.jasmineDone({ reporter.jasmineDone({
failedExpectations: [ failedExpectations: [
{ {
@@ -731,7 +710,6 @@ describe('HtmlReporterV2', function() {
describe('UI for stop on spec failure', function() { describe('UI for stop on spec failure', function() {
it('should be unchecked for full execution', function() { it('should be unchecked for full execution', function() {
const reporter = setup(); const reporter = setup();
reporter.initialize();
reporter.jasmineDone({}); reporter.jasmineDone({});
const stopOnFailureUI = container.querySelector('.jasmine-fail-fast'); const stopOnFailureUI = container.querySelector('.jasmine-fail-fast');
@@ -739,10 +717,9 @@ describe('HtmlReporterV2', function() {
}); });
it('should be checked if stopping short', function() { it('should be checked if stopping short', function() {
const reporter = setup();
env.configure({ stopOnSpecFailure: true }); env.configure({ stopOnSpecFailure: true });
const reporter = setup();
reporter.initialize();
reporter.jasmineDone({}); reporter.jasmineDone({});
const stopOnFailureUI = container.querySelector('.jasmine-fail-fast'); const stopOnFailureUI = container.querySelector('.jasmine-fail-fast');
@@ -752,7 +729,6 @@ describe('HtmlReporterV2', function() {
it('should navigate and turn the setting on', function() { it('should navigate and turn the setting on', function() {
const reporter = setup(); const reporter = setup();
reporter.initialize();
reporter.jasmineDone({}); reporter.jasmineDone({});
const stopOnFailureUI = container.querySelector('.jasmine-fail-fast'); const stopOnFailureUI = container.querySelector('.jasmine-fail-fast');
@@ -762,10 +738,9 @@ describe('HtmlReporterV2', function() {
}); });
it('should navigate and turn the setting off', function() { it('should navigate and turn the setting off', function() {
const reporter = setup();
env.configure({ stopOnSpecFailure: true }); env.configure({ stopOnSpecFailure: true });
const reporter = setup();
reporter.initialize();
reporter.jasmineDone({}); reporter.jasmineDone({});
const stopOnFailureUI = container.querySelector('.jasmine-fail-fast'); const stopOnFailureUI = container.querySelector('.jasmine-fail-fast');
@@ -778,7 +753,6 @@ describe('HtmlReporterV2', function() {
describe('UI for throwing errors on expectation failures', function() { describe('UI for throwing errors on expectation failures', function() {
it('should be unchecked if not throwing', function() { it('should be unchecked if not throwing', function() {
const reporter = setup(); const reporter = setup();
reporter.initialize();
reporter.jasmineDone({}); reporter.jasmineDone({});
const throwingExpectationsUI = container.querySelector( const throwingExpectationsUI = container.querySelector(
@@ -788,10 +762,9 @@ describe('HtmlReporterV2', function() {
}); });
it('should be checked if throwing', function() { it('should be checked if throwing', function() {
const reporter = setup();
env.configure({ stopSpecOnExpectationFailure: true }); env.configure({ stopSpecOnExpectationFailure: true });
const reporter = setup();
reporter.initialize();
reporter.jasmineDone({}); reporter.jasmineDone({});
const throwingExpectationsUI = container.querySelector( const throwingExpectationsUI = container.querySelector(
@@ -802,7 +775,6 @@ describe('HtmlReporterV2', function() {
it('should navigate and change the setting to on', function() { it('should navigate and change the setting to on', function() {
const reporter = setup(); const reporter = setup();
reporter.initialize();
reporter.jasmineDone({}); reporter.jasmineDone({});
const throwingExpectationsUI = container.querySelector( const throwingExpectationsUI = container.querySelector(
@@ -814,11 +786,9 @@ describe('HtmlReporterV2', function() {
}); });
it('should navigate and change the setting to off', function() { it('should navigate and change the setting to off', function() {
env.configure({ stopSpecOnExpectationFailure: true });
const reporter = setup(); const reporter = setup();
env.configure({ stopSpecOnExpectationFailure: true });
reporter.initialize();
reporter.jasmineDone({}); reporter.jasmineDone({});
const throwingExpectationsUI = container.querySelector( const throwingExpectationsUI = container.querySelector(
@@ -832,9 +802,8 @@ describe('HtmlReporterV2', function() {
describe('UI for running tests in random order', function() { describe('UI for running tests in random order', function() {
it('should be unchecked if not randomizing', function() { it('should be unchecked if not randomizing', function() {
const reporter = setup();
env.configure({ random: false }); env.configure({ random: false });
reporter.initialize(); const reporter = setup();
reporter.jasmineDone({}); reporter.jasmineDone({});
const randomUI = container.querySelector('.jasmine-random'); const randomUI = container.querySelector('.jasmine-random');
@@ -842,9 +811,8 @@ describe('HtmlReporterV2', function() {
}); });
it('should be checked if randomizing', function() { it('should be checked if randomizing', function() {
const reporter = setup();
env.configure({ random: true }); env.configure({ random: true });
reporter.initialize(); const reporter = setup();
reporter.jasmineDone({}); reporter.jasmineDone({});
const randomUI = container.querySelector('.jasmine-random'); const randomUI = container.querySelector('.jasmine-random');
@@ -852,10 +820,9 @@ describe('HtmlReporterV2', function() {
}); });
it('should navigate and change the setting to on', function() { it('should navigate and change the setting to on', function() {
env.configure({ random: false });
const reporter = setup(); const reporter = setup();
env.configure({ random: false });
reporter.initialize();
reporter.jasmineDone({}); reporter.jasmineDone({});
const randomUI = container.querySelector('.jasmine-random'); const randomUI = container.querySelector('.jasmine-random');
@@ -865,10 +832,9 @@ describe('HtmlReporterV2', function() {
}); });
it('should navigate and change the setting to off', function() { it('should navigate and change the setting to off', function() {
env.configure({ random: true });
const reporter = setup(); const reporter = setup();
env.configure({ random: true });
reporter.initialize();
reporter.jasmineDone({}); reporter.jasmineDone({});
const randomUI = container.querySelector('.jasmine-random'); const randomUI = container.querySelector('.jasmine-random');
@@ -879,7 +845,6 @@ describe('HtmlReporterV2', function() {
it('should show the seed bar if randomizing', function() { it('should show the seed bar if randomizing', function() {
const reporter = setup(); const reporter = setup();
reporter.initialize();
reporter.jasmineDone({ reporter.jasmineDone({
order: { order: {
random: true, random: true,
@@ -895,7 +860,6 @@ describe('HtmlReporterV2', function() {
it('should not show the current seed bar if not randomizing', function() { it('should not show the current seed bar if not randomizing', function() {
const reporter = setup(); const reporter = setup();
reporter.initialize();
reporter.jasmineDone({}); reporter.jasmineDone({});
const seedBar = container.querySelector('.jasmine-seed-bar'); 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() { it('includes the number of specs in the text of the jasmine-skipped link', function() {
const reporter = setup(); const reporter = setup();
reporter.initialize();
const minimalSpecDone = { const minimalSpecDone = {
failedExpectations: [], failedExpectations: [],
passedExpectations: [] passedExpectations: []
}; };
reporter.jasmineStarted({ totalSpecsDefined: 3 }); reporter.jasmineStarted({ totalSpecsDefined: 3, numExcludedSpecs: 0 });
reporter.specDone({ ...minimalSpecDone }); reporter.specDone({ ...minimalSpecDone });
reporter.specDone({ ...minimalSpecDone }); reporter.specDone({ ...minimalSpecDone });
reporter.specDone({ ...minimalSpecDone, status: 'excluded' }); reporter.specDone({ ...minimalSpecDone, status: 'excluded' });
@@ -928,8 +891,7 @@ describe('HtmlReporterV2', function() {
} }
}); });
reporter.initialize(); reporter.jasmineStarted({ totalSpecsDefined: 1, numExcludedSpecs: 0 });
reporter.jasmineStarted({ totalSpecsDefined: 1 });
reporter.jasmineDone({ order: { random: true } }); reporter.jasmineDone({ order: { random: true } });
const skippedLink = container.querySelector('.jasmine-skipped a'); const skippedLink = container.querySelector('.jasmine-skipped a');
@@ -940,9 +902,8 @@ describe('HtmlReporterV2', function() {
describe('and all specs pass', function() { describe('and all specs pass', function() {
beforeEach(function() { beforeEach(function() {
const reporter = setup(); const reporter = setup();
reporter.initialize();
reporter.jasmineStarted({ totalSpecsDefined: 2 }); reporter.jasmineStarted({ totalSpecsDefined: 2, numExcludedSpecs: 0 });
reporter.specDone({ reporter.specDone({
id: 123, id: 123,
description: 'with a spec', description: 'with a spec',
@@ -1007,8 +968,10 @@ describe('HtmlReporterV2', function() {
} }
} }
}); });
reporter.initialize(); reporter.jasmineStarted({
reporter.jasmineStarted({ totalSpecsDefined: 1 }); totalSpecsDefined: 1,
numExcludedSpecs: 0
});
reporter.specDone(specStatus); reporter.specDone(specStatus);
reporter.jasmineDone({}); reporter.jasmineDone({});
}); });
@@ -1029,8 +992,10 @@ describe('HtmlReporterV2', function() {
} }
} }
}); });
reporter.initialize(); reporter.jasmineStarted({
reporter.jasmineStarted({ totalSpecsDefined: 1 }); totalSpecsDefined: 1,
numExcludedSpecs: 0
});
reporter.specDone(specStatus); reporter.specDone(specStatus);
reporter.jasmineDone({}); reporter.jasmineDone({});
}); });
@@ -1064,9 +1029,8 @@ describe('HtmlReporterV2', function() {
beforeEach(function() { beforeEach(function() {
reporter = setup(); reporter = setup();
reporter.initialize();
reporter.jasmineStarted({ totalSpecsDefined: 1 }); reporter.jasmineStarted({ totalSpecsDefined: 1, numExcludedSpecs: 0 });
}); });
it('reports the pending specs count', function() { it('reports the pending specs count', function() {
@@ -1117,9 +1081,8 @@ describe('HtmlReporterV2', function() {
beforeEach(function() { beforeEach(function() {
reporter = setup(); reporter = setup();
reporter.initialize();
reporter.jasmineStarted({ totalSpecsDefined: 1 }); reporter.jasmineStarted({ totalSpecsDefined: 1, numExcludedSpecs: 0 });
reporter.suiteStarted({ reporter.suiteStarted({
id: 1, id: 1,
description: 'A suite' description: 'A suite'
@@ -1285,9 +1248,8 @@ describe('HtmlReporterV2', function() {
return '?' + key + '=' + value; return '?' + key + '=' + value;
} }
}); });
reporter.initialize();
reporter.jasmineStarted({ totalSpecsDefined: 1 }); reporter.jasmineStarted({ totalSpecsDefined: 1, numExcludedSpecs: 0 });
const failingSpecResult = { const failingSpecResult = {
id: 124, id: 124,
@@ -1327,7 +1289,6 @@ describe('HtmlReporterV2', function() {
describe('When nothing has failed', function() { describe('When nothing has failed', function() {
it('shows "Running..." and the has class jasmine-in-progress', function() { it('shows "Running..." and the has class jasmine-in-progress', function() {
const reporter = setup(); const reporter = setup();
reporter.initialize();
const alertBar = container.querySelector('.jasmine-overall-result'); const alertBar = container.querySelector('.jasmine-overall-result');
expect(alertBar.textContent).toEqual('Running...'); expect(alertBar.textContent).toEqual('Running...');
@@ -1354,7 +1315,6 @@ describe('HtmlReporterV2', function() {
describe('When a spec has failed', function() { describe('When a spec has failed', function() {
it('shows "Failing..." and the has class jasmine-failed', function() { it('shows "Failing..." and the has class jasmine-failed', function() {
const reporter = setup(); const reporter = setup();
reporter.initialize();
const alertBar = container.querySelector('.jasmine-overall-result'); const alertBar = container.querySelector('.jasmine-overall-result');
reporter.specDone({ reporter.specDone({
@@ -1373,7 +1333,6 @@ describe('HtmlReporterV2', function() {
describe('When a suite has failed', function() { describe('When a suite has failed', function() {
it('shows "Failing..." and the has class jasmine-failed', function() { it('shows "Failing..." and the has class jasmine-failed', function() {
const reporter = setup(); const reporter = setup();
reporter.initialize();
const alertBar = container.querySelector('.jasmine-overall-result'); const alertBar = container.querySelector('.jasmine-overall-result');
reporter.suiteDone({ reporter.suiteDone({
@@ -1393,9 +1352,8 @@ describe('HtmlReporterV2', function() {
describe("When the jasmineDone event's overallStatus is 'passed'", function() { describe("When the jasmineDone event's overallStatus is 'passed'", function() {
it('has class jasmine-passed', function() { it('has class jasmine-passed', function() {
const reporter = setup(); const reporter = setup();
reporter.initialize();
reporter.jasmineStarted({ totalSpecsDefined: 0 }); reporter.jasmineStarted({ totalSpecsDefined: 0, numExcludedSpecs: 0 });
reporter.jasmineDone({ reporter.jasmineDone({
overallStatus: 'passed', overallStatus: 'passed',
failedExpectations: [] failedExpectations: []
@@ -1409,9 +1367,8 @@ describe('HtmlReporterV2', function() {
describe("When the jasmineDone event's overallStatus is 'failed'", function() { describe("When the jasmineDone event's overallStatus is 'failed'", function() {
it('has class jasmine-failed', function() { it('has class jasmine-failed', function() {
const reporter = setup(); const reporter = setup();
reporter.initialize();
reporter.jasmineStarted({ totalSpecsDefined: 0 }); reporter.jasmineStarted({ totalSpecsDefined: 0, numExcludedSpecs: 0 });
reporter.jasmineDone({ reporter.jasmineDone({
overallStatus: 'failed', overallStatus: 'failed',
failedExpectations: [] failedExpectations: []
@@ -1425,9 +1382,8 @@ describe('HtmlReporterV2', function() {
describe("When the jasmineDone event's overallStatus is 'incomplete'", function() { describe("When the jasmineDone event's overallStatus is 'incomplete'", function() {
it('has class jasmine-incomplete', function() { it('has class jasmine-incomplete', function() {
const reporter = setup(); const reporter = setup();
reporter.initialize();
reporter.jasmineStarted({ totalSpecsDefined: 0 }); reporter.jasmineStarted({ totalSpecsDefined: 0, numExcludedSpecs: 0 });
reporter.jasmineDone({ reporter.jasmineDone({
overallStatus: 'incomplete', overallStatus: 'incomplete',
incompleteReason: 'because nope', incompleteReason: 'because nope',

View File

@@ -1,17 +1,29 @@
describe('HtmlSpecFilter', function() { describe('HtmlSpecFilter', function() {
let env, deprecator;
beforeEach(function() { 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() { it('emits a deprecation warning', function() {
new jasmineUnderTest.HtmlSpecFilter(); new jasmineUnderTest.HtmlSpecFilter({ env });
expect(jasmineUnderTest.getEnv().deprecated).toHaveBeenCalledWith( expect(deprecator.addDeprecationWarning).toHaveBeenCalledWith(
'HtmlReporter and HtmlSpecFilter are deprecated. Use HtmlReporterV2 instead.' jasmine.anything(),
'HtmlReporter and HtmlSpecFilter are deprecated. Use HtmlReporterV2 instead.',
undefined
); );
}); });
it('should match when no string is provided', function() { 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('foo')).toBe(true);
expect(specFilter.matches('*bar')).toBe(true); expect(specFilter.matches('*bar')).toBe(true);
@@ -19,6 +31,7 @@ describe('HtmlSpecFilter', function() {
it('should only match the provided string', function() { it('should only match the provided string', function() {
const specFilter = new jasmineUnderTest.HtmlSpecFilter({ const specFilter = new jasmineUnderTest.HtmlSpecFilter({
env,
filterString: function() { filterString: function() {
return 'foo'; return 'foo';
} }

View File

@@ -17,23 +17,6 @@
const env = jasmine.getEnv(); const env = jasmine.getEnv();
const urls = new jasmine.HtmlReporterV2Urls(); 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 * Configures Jasmine based on the current set of query parameters. This
* supports all parameters set by the HTML reporter as well as * supports all parameters set by the HTML reporter as well as
@@ -42,18 +25,11 @@
*/ */
env.configure(urls.configFromCurrentUrl()); env.configure(urls.configFromCurrentUrl());
/** window.addEventListener('load', function() {
* ## Execution // 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.
* 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 htmlReporter = new jasmine.HtmlReporterV2({ env, urls });
*/ env.addReporter(htmlReporter);
const currentWindowOnload = window.onload;
window.onload = function() {
if (currentWindowOnload) {
currentWindowOnload();
}
htmlReporter.initialize();
env.execute(); env.execute();
}; });
})(); })();

View File

@@ -1,4 +1,4 @@
getJasmineRequireObj().Clock = function() { getJasmineRequireObj().Clock = function(j$) {
'use strict'; 'use strict';
/* global process */ /* global process */
@@ -191,6 +191,9 @@ callbacks to execute _before_ running the next one.
clearTimeout[IsMockClockTimingFn] = true; clearTimeout[IsMockClockTimingFn] = true;
setInterval[IsMockClockTimingFn] = true; setInterval[IsMockClockTimingFn] = true;
clearInterval[IsMockClockTimingFn] = true; clearInterval[IsMockClockTimingFn] = true;
j$.private.deprecateMonkeyPatching(this);
return this; return this;
// Advances the Clock's time until the mode changes. // Advances the Clock's time until the mode changes.

View File

@@ -296,10 +296,13 @@ getJasmineRequireObj().Env = function(j$) {
* @param {String|Error} deprecation The deprecation message * @param {String|Error} deprecation The deprecation message
* @param {Object} [options] Optional extra options, as described above * @param {Object} [options] Optional extra options, as described above
*/ */
this.deprecated = function(deprecation, options) { Object.defineProperty(this, 'deprecated', {
const runable = runner.currentRunable() || topSuite; enumerable: true,
deprecator.addDeprecationWarning(runable, deprecation, options); value: function(deprecation, options) {
}; const runable = runner.currentRunable() || topSuite;
deprecator.addDeprecationWarning(runable, deprecation, options);
}
});
function runQueue(options) { function runQueue(options) {
options.clearStack = options.clearStack || stackClearer; options.clearStack = options.clearStack || stackClearer;
@@ -326,7 +329,8 @@ getJasmineRequireObj().Env = function(j$) {
runQueue runQueue
}); });
topSuite = suiteBuilder.topSuite; 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 * 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() { this.cleanup_ = function() {
uninstallGlobalErrors(); uninstallGlobalErrors();
}; };
j$.private.deprecateMonkeyPatching(this, ['deprecated']);
} }
function indirectCallerFilename(depth) { function indirectCallerFilename(depth) {

View File

@@ -1,11 +1,13 @@
getJasmineRequireObj().JsApiReporter = function(j$) { getJasmineRequireObj().JsApiReporter = function(j$) {
'use strict'; 'use strict';
// TODO: remove in 7.0.
/** /**
* @name jsApiReporter * @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. * @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 * @class
* @hideconstructor * @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) { function JsApiReporter(options) {
const timer = options.timer || new j$.Timer(); const timer = options.timer || new j$.Timer();

View File

@@ -59,7 +59,7 @@ getJasmineRequireObj().makePrettyPrinter = function(j$) {
} else if ( } else if (
value.toString && value.toString &&
typeof value === 'object' && typeof value === 'object' &&
!j$.private.isArray(value) && !Array.isArray(value) &&
hasCustomToString(value) hasCustomToString(value)
) { ) {
try { try {
@@ -71,15 +71,12 @@ getJasmineRequireObj().makePrettyPrinter = function(j$) {
} else if (this.seen.includes(value)) { } else if (this.seen.includes(value)) {
this.emitScalar( this.emitScalar(
'<circular reference: ' + '<circular reference: ' +
(j$.private.isArray(value) ? 'Array' : 'Object') + (Array.isArray(value) ? 'Array' : 'Object') +
'>' '>'
); );
} else if ( } else if (Array.isArray(value) || j$.private.isA('Object', value)) {
j$.private.isArray(value) ||
j$.private.isA('Object', value)
) {
this.seen.push(value); this.seen.push(value);
if (j$.private.isArray(value)) { if (Array.isArray(value)) {
this.emitArray(value); this.emitArray(value);
} else { } else {
this.emitObject(value); this.emitObject(value);
@@ -102,10 +99,7 @@ getJasmineRequireObj().makePrettyPrinter = function(j$) {
} }
iterateObject(obj, fn) { iterateObject(obj, fn) {
const objKeys = j$.private.MatchersUtil.keys( const objKeys = j$.private.MatchersUtil.keys(obj, Array.isArray(obj));
obj,
j$.private.isArray(obj)
);
const length = Math.min(objKeys.length, j$.MAX_PRETTY_PRINT_ARRAY_LENGTH); const length = Math.min(objKeys.length, j$.MAX_PRETTY_PRINT_ARRAY_LENGTH);
for (let i = 0; i < length; i++) { for (let i = 0; i < length; i++) {

View File

@@ -96,7 +96,8 @@ getJasmineRequireObj().Runner = function(j$) {
/** /**
* Information passed to the {@link Reporter#jasmineStarted} event. * Information passed to the {@link Reporter#jasmineStarted} event.
* @typedef JasmineStartedInfo * @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 {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. * @property {Boolean} parallel - Whether Jasmine is being run in parallel mode.
* @since 2.0.0 * @since 2.0.0
@@ -105,6 +106,7 @@ getJasmineRequireObj().Runner = function(j$) {
// In parallel mode, the jasmineStarted event is separately dispatched // In parallel mode, the jasmineStarted event is separately dispatched
// by jasmine-npm. This event only reaches reporters in non-parallel. // by jasmine-npm. This event only reaches reporters in non-parallel.
totalSpecsDefined, totalSpecsDefined,
numExcludedSpecs: this.#executionTree.numExcludedSpecs(),
order: orderForReporting(order), order: orderForReporting(order),
parallel: false parallel: false
}); });

View File

@@ -165,7 +165,7 @@ getJasmineRequireObj().Spec = function(j$) {
* @property {ExpectationResult[]} passedExpectations - The list of expectations that passed during execution of this spec. * @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 {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} 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 {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 {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. * @property {DebugLogEntry[]|null} debugLogs - Messages, if any, that were logged using {@link jasmine.debugLog} during a failing spec.

View File

@@ -21,7 +21,7 @@ getJasmineRequireObj().SpyFactory = function(j$) {
this.createSpyObj = function(baseName, methodNames, propertyNames) { this.createSpyObj = function(baseName, methodNames, propertyNames) {
const baseNameIsCollection = const baseNameIsCollection =
j$.private.isObject(baseName) || j$.private.isArray(baseName); j$.private.isObject(baseName) || Array.isArray(baseName);
if (baseNameIsCollection) { if (baseNameIsCollection) {
propertyNames = methodNames; propertyNames = methodNames;
@@ -67,7 +67,7 @@ getJasmineRequireObj().SpyFactory = function(j$) {
function normalizeKeyValues(object) { function normalizeKeyValues(object) {
const result = []; const result = [];
if (j$.private.isArray(object)) { if (Array.isArray(object)) {
for (let i = 0; i < object.length; i++) { for (let i = 0; i < object.length; i++) {
result.push([object[i]]); result.push([object[i]]);
} }

View File

@@ -123,6 +123,23 @@ getJasmineRequireObj().TreeProcessor = function(j$) {
const nodeStats = this.#stats[node.id]; const nodeStats = this.#stats[node.id];
return node.children ? !nodeStats.willExecute : nodeStats.excluded; 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) { function segmentChildren(node, orderedChildren, stats, executableIndex) {

View File

@@ -6,7 +6,7 @@ getJasmineRequireObj().ArrayContaining = function(j$) {
} }
ArrayContaining.prototype.asymmetricMatch = function(other, matchersUtil) { ArrayContaining.prototype.asymmetricMatch = function(other, matchersUtil) {
if (!j$.private.isArray(this.sample)) { if (!Array.isArray(this.sample)) {
throw new Error( throw new Error(
'You must provide an array to arrayContaining, not ' + 'You must provide an array to arrayContaining, not ' +
j$.private.basicPrettyPrinter(this.sample) + 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 // 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 // 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 // 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; return false;
} }

View File

@@ -9,7 +9,7 @@ getJasmineRequireObj().ArrayWithExactContents = function(j$) {
other, other,
matchersUtil matchersUtil
) { ) {
if (!j$.private.isArray(this.sample)) { if (!Array.isArray(this.sample)) {
throw new Error( throw new Error(
'You must provide an array to arrayWithExactContents, not ' + 'You must provide an array to arrayWithExactContents, not ' +
j$.private.basicPrettyPrinter(this.sample) + j$.private.basicPrettyPrinter(this.sample) +

View File

@@ -6,7 +6,7 @@ getJasmineRequireObj().Empty = function(j$) {
Empty.prototype.asymmetricMatch = function(other) { Empty.prototype.asymmetricMatch = function(other) {
if ( if (
j$.private.isString(other) || j$.private.isString(other) ||
j$.private.isArray(other) || Array.isArray(other) ||
j$.private.isTypedArray(other) j$.private.isTypedArray(other)
) { ) {
return other.length === 0; return other.length === 0;

View File

@@ -6,7 +6,7 @@ getJasmineRequireObj().NotEmpty = function(j$) {
NotEmpty.prototype.asymmetricMatch = function(other) { NotEmpty.prototype.asymmetricMatch = function(other) {
if ( if (
j$.private.isString(other) || j$.private.isString(other) ||
j$.private.isArray(other) || Array.isArray(other) ||
j$.private.isTypedArray(other) j$.private.isTypedArray(other)
) { ) {
return other.length !== 0; return other.length !== 0;

View File

@@ -67,16 +67,15 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) {
* @function * @function
* @return {Env} * @return {Env}
*/ */
j$.getEnv = function(options) { Object.defineProperty(j$, 'getEnv', {
const env = (j$.private.currentEnv_ = enumerable: true,
j$.private.currentEnv_ || new j$.private.Env(options)); value: function(options) {
//jasmine. singletons in here (setTimeout blah blah). const env = (j$.private.currentEnv_ =
return env; 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); });
};
j$.private.isObject = function(value) { j$.private.isObject = function(value) {
return ( return (

View File

@@ -0,0 +1,22 @@
getJasmineRequireObj().deprecateMonkeyPatching = function(j$) {
return function deprecateMonkeyPatching(obj, keysToSkip) {
for (const key of Object.keys(obj)) {
if (!keysToSkip?.includes(key)) {
let value = obj[key];
Object.defineProperty(obj, key, {
enumerable: key in obj,
get() {
return value;
},
set(newValue) {
j$.getEnv().deprecated(
'Monkey patching detected. This is not supported and will break in a future jasmine-core release.'
);
value = newValue;
}
});
}
}
};
};

View File

@@ -13,7 +13,7 @@ getJasmineRequireObj().MatchersUtil = function(j$) {
this.customTesters_ = options.customTesters || []; this.customTesters_ = options.customTesters || [];
/** /**
* Formats a value for use in matcher failure messages and similar contexts, * 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 * @function
* @name MatchersUtil#pp * @name MatchersUtil#pp
* @since 3.6.0 * @since 3.6.0

View File

@@ -20,9 +20,14 @@ var getJasmineRequireObj = (function() {
} }
getJasmineRequire().core = function(jRequire) { getJasmineRequire().core = function(jRequire) {
const j$ = { private: {} }; const j$ = {};
Object.defineProperty(j$, 'private', {
enumerable: true,
value: {}
});
jRequire.base(j$, globalThis); jRequire.base(j$, globalThis);
j$.private.deprecateMonkeyPatching = jRequire.deprecateMonkeyPatching(j$);
j$.private.util = jRequire.util(j$); j$.private.util = jRequire.util(j$);
j$.private.errors = jRequire.errors(); j$.private.errors = jRequire.errors();
j$.private.formatErrorMsg = jRequire.formatErrorMsg(j$); j$.private.formatErrorMsg = jRequire.formatErrorMsg(j$);
@@ -32,7 +37,7 @@ var getJasmineRequireObj = (function() {
j$.private.CallTracker = jRequire.CallTracker(j$); j$.private.CallTracker = jRequire.CallTracker(j$);
j$.private.MockDate = jRequire.MockDate(j$); j$.private.MockDate = jRequire.MockDate(j$);
j$.private.getStackClearer = jRequire.StackClearer(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.DelayedFunctionScheduler = jRequire.DelayedFunctionScheduler(j$);
j$.private.Deprecator = jRequire.Deprecator(j$); j$.private.Deprecator = jRequire.Deprecator(j$);
j$.private.Configuration = jRequire.Configuration(j$); j$.private.Configuration = jRequire.Configuration(j$);
@@ -98,6 +103,20 @@ var getJasmineRequireObj = (function() {
j$.private.loadedAsBrowserEsm = j$.private.loadedAsBrowserEsm =
globalThis.document && !globalThis.document.currentScript; globalThis.document && !globalThis.document.currentScript;
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$; return j$;
}; };

View File

@@ -369,6 +369,7 @@ getJasmineRequireObj().interface = function(jasmine, env) {
*/ */
jasmine: jasmine jasmine: jasmine
}; };
const existingKeys = Object.keys(jasmine);
/** /**
* Add a custom equality tester for the current scope of specs. * Add a custom equality tester for the current scope of specs.
@@ -498,6 +499,21 @@ getJasmineRequireObj().interface = function(jasmine, env) {
return env.setDefaultSpyStrategy(defaultStrategyFn); 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 * {@link AsymmetricEqualityTester|Asymmetric equality testers} allow for
* non-exact matching in matchers that use Jasmine's deep value equality * non-exact matching in matchers that use Jasmine's deep value equality
@@ -520,5 +536,7 @@ getJasmineRequireObj().interface = function(jasmine, env) {
* @namespace asymmetricEqualityTesters * @namespace asymmetricEqualityTesters
*/ */
jasmine.private.deprecateMonkeyPatching(jasmine, existingKeys);
return jasmineInterface; return jasmineInterface;
}; };

View File

@@ -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) { addGlobalFailure(failure) {
this.#createAndAdd( this.#createAndAdd(
errorBarClassName, errorBarClassName,

View File

@@ -19,12 +19,12 @@ jasmineRequire.HtmlReporterV2 = function(j$) {
* const reporter = new jasmine.HtmlReporterV2({ * const reporter = new jasmine.HtmlReporterV2({
* env, * env,
* urls, * urls,
* getContainer: () => document.body * // container is optional and defaults to document.body.
* container: someElement
* }); * });
*/ */
class HtmlReporterV2 { class HtmlReporterV2 {
#env; #container;
#getContainer;
#queryString; #queryString;
#urlBuilder; #urlBuilder;
#filterSpecs; #filterSpecs;
@@ -41,9 +41,7 @@ jasmineRequire.HtmlReporterV2 = function(j$) {
#failures; #failures;
constructor(options) { constructor(options) {
this.#env = options.env; this.#container = options.container || document.body;
this.#getContainer = options.getContainer;
this.#queryString = this.#queryString =
options.queryString || options.queryString ||
new j$.QueryString({ new j$.QueryString({
@@ -56,16 +54,8 @@ jasmineRequire.HtmlReporterV2 = function(j$) {
getSuiteById: id => this.#stateBuilder.suitesById[id] getSuiteById: id => this.#stateBuilder.suitesById[id]
}); });
this.#filterSpecs = options.urls.filteringSpecs(); this.#filterSpecs = options.urls.filteringSpecs();
}
/** this.#config = options.env ? options.env.configuration() : {};
* 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.#stateBuilder = new j$.private.ResultsStateBuilder(); this.#stateBuilder = new j$.private.ResultsStateBuilder();
@@ -106,13 +96,15 @@ jasmineRequire.HtmlReporterV2 = function(j$) {
this.#alerts.rootEl, this.#alerts.rootEl,
this.#failures.rootEl this.#failures.rootEl
); );
this.#getContainer().appendChild(this.#htmlReporterMain); this.#container.appendChild(this.#htmlReporterMain);
this.#failures.show(); this.#failures.show();
} }
jasmineStarted(options) { jasmineStarted(options) {
this.#stateBuilder.jasmineStarted(options); this.#stateBuilder.jasmineStarted(options);
this.#progress.start(options.totalSpecsDefined); this.#progress.start(
options.totalSpecsDefined - options.numExcludedSpecs
);
} }
suiteStarted(result) { suiteStarted(result) {
@@ -197,19 +189,11 @@ jasmineRequire.HtmlReporterV2 = function(j$) {
} }
#find(selector) { #find(selector) {
return this.#getContainer().querySelector( return this.#container.querySelector(
'.jasmine_html-reporter ' + selector '.jasmine_html-reporter ' + selector
); );
} }
#clearPrior() {
const oldReporter = this.#find('');
if (oldReporter) {
this.#getContainer().removeChild(oldReporter);
}
}
#setMenuModeTo(mode) { #setMenuModeTo(mode) {
this.#htmlReporterMain.setAttribute( this.#htmlReporterMain.setAttribute(
'class', 'class',
@@ -228,7 +212,9 @@ jasmineRequire.HtmlReporterV2 = function(j$) {
} }
specDone(result) { specDone(result) {
this.rootEl.value = this.rootEl.value + 1; if (result.status !== 'excluded') {
this.rootEl.value = this.rootEl.value + 1;
}
if (result.status === 'failed') { if (result.status === 'failed') {
this.rootEl.classList.add('failed'); this.rootEl.classList.add('failed');

View File

@@ -7,12 +7,14 @@ jasmineRequire.HtmlSpecFilter = function(j$) {
* @deprecated Use {@link HtmlReporterV2Urls} instead. * @deprecated Use {@link HtmlReporterV2Urls} instead.
*/ */
function HtmlSpecFilter(options) { function HtmlSpecFilter(options) {
j$.getEnv().deprecated( const env = options?.env ?? j$.getEnv();
env.deprecated(
'HtmlReporter and HtmlSpecFilter are deprecated. Use HtmlReporterV2 instead.' 'HtmlReporter and HtmlSpecFilter are deprecated. Use HtmlReporterV2 instead.'
); );
const filterString = const filterString =
options && options &&
options.filterString &&
options.filterString() && options.filterString() &&
options.filterString().replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&'); options.filterString().replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&');
const filterPattern = new RegExp(filterString); const filterPattern = new RegExp(filterString);

View File

@@ -5,7 +5,7 @@ jasmineRequire.htmlReporterUtils = function(j$) {
const el = document.createElement(type); const el = document.createElement(type);
let children; let children;
if (j$.private.isArray(childrenArrayOrVarArgs)) { if (Array.isArray(childrenArrayOrVarArgs)) {
children = childrenArrayOrVarArgs; children = childrenArrayOrVarArgs;
} else { } else {
children = []; children = [];