Compare commits

...

54 Commits

Author SHA1 Message Date
Steve Gravrock
d9023b1fde Bump version to 7.0.0-pre.0
Some checks failed
Test in latest available Safari / build (push) Has been cancelled
2026-02-22 14:08:32 -08:00
Steve Gravrock
27319fd6ae Merge branch 'main' into 7.0 2026-02-22 10:13:11 -08:00
Steve Gravrock
3de4512681 Bump version to 6.1.0
Some checks failed
Test in latest available Safari / build (push) Has been cancelled
2026-02-22 10:10:40 -08:00
Steve Gravrock
d230b0500d Test against 5.0 branch of jasmine-browser-runner 2026-02-21 12:57:26 -08:00
Steve Gravrock
c6520763d8 Re-add version() to Node module exports 2026-02-21 12:12:54 -08:00
Steve Gravrock
e087ebc419 Merge branch 'main' into 7.0 2026-02-21 11:19:51 -08:00
Steve Gravrock
4bf333ed38 rm unnecessary and deprecated eslint-env comments 2026-02-21 11:15:57 -08:00
Steve Gravrock
4f5ef7c2d7 Drop support for Safari 16 and 17
Safari 16 and 17 runners are no longer reliably available in CI. Saucelabs
still provides them, but session creation failures have been frequent for
weeks now. When this has happened in the past, it's been a prelude to
Saucelabs dropping the affected Safari versions altogether.

We could live with retrying ~30-50% of test runs in the hope that things
might improve, but it's probably better to just rip the band-aid off.
2026-02-21 11:14:32 -08:00
Steve Gravrock
63ac7da082 Prevent monkey patching
This doesn't affect globals (describe, it, expect, etc). Those belong to
the user and Jasmine doesn't depend on them.
2026-02-16 20:30:29 -08:00
Steve Gravrock
281c0d1ee8 Convert ParallelReportDispatcher to an ES6 class
ParallelReportDispatcher itself doesn't gain anything from this, but
it'll allow monkey patching prevention to be implemented and tested
more uniformly.
2026-02-16 16:36:06 -08:00
Steve Gravrock
8bb325628f Depend on 7.0 branch of -npm 2026-02-16 16:35:23 -08:00
Steve Gravrock
ff0699035f Merge branch 'main' into 7.0 2026-02-16 07:28:22 -08:00
Steve Gravrock
f12f4395f0 Redesigned moudule system
* Top level private APIs (e.g. jasmine.private.whatever) are no longer
  exposed
* jasmineRequire is no longer exposed
* core is self-booting
* Globals are automatically created in browsers. (They can subsequently
  be removed by user code if desired.)
* Globals are *not* automatically created in Node. An installGlobals
  function is exported instead. The jasmine package calls installGlobals
  unless configured not to do so.
* In Node, the same instance is returned each time jasmine-core is
  imported. A reset function is exported. It effectively resets all state
  by discarding the env and creating a new one. This allows mulitple
  sequential runs within the same process to be independent of each
  other, but does not allow multiple concurrent runs. (That probably never
  worked anyway.)

Fixes #2094
2026-02-15 20:16:45 -08:00
Steve Gravrock
5de03beea1 Fix test failure in Node 20 and 22 parallel tests 2026-02-07 20:03:59 -08:00
Steve Gravrock
42baa422b3 Formatting 2026-02-07 18:36:36 -08:00
Steve Gravrock
6af5d24b3b Improve formatting of AggregateErrors 2026-02-07 18:22:12 -08:00
Steve Gravrock
b88ce2d49f Improve AggregateError specs
* Assert that the right inner stack traces are in the right places
* Drop the integration tests. All of the AggregateError-specific code
  is in ExceptionFormatter, so the integration tests just duplicate
  existing integration tests and the ExceptionFormatter specs.
2026-02-07 17:41:39 -08:00
Steve Gravrock
c216ae1d13 Merge branch 'puglyfe-aggregate-errors'
* Adds support for AggregateError
* Merges #2093 from @puglyfe
* Fixes #2063
2026-02-07 16:01:06 -08:00
Charley
319776d241 Report the constituent errors of an AggregateError
Fixes #2063
2026-02-07 11:16:57 -08:00
Steve Gravrock
1d0718dc2f Fix MAX_PRETTY_PRINT_CHARS default jsdoc in source code too 2026-01-19 14:58:15 -08:00
Steve Gravrock
929694310e Merge branch 'fixDefaultsJsDoc' of github.com:HolgerJeromin/jasmine
* Merges #2091 from @HolgerJeromin
2026-01-19 08:15:42 -08:00
Steve Gravrock
7379a3a11b Bump version to 6.0.1
Some checks failed
Test in latest available Safari / build (push) Has been cancelled
2026-01-19 07:59:36 -08:00
Holger Jeromin
4db18aafce Fix default MAX_PRETTY_PRINT_CHARS in JsDoc 2026-01-19 13:41:08 +01:00
Steve Gravrock
066669cfee Revert "Temporarily (I hope) disable testing against Safari 16 and 17"
This reverts commit 6755b03f12.
2026-01-18 20:51:20 -08:00
Steve Gravrock
87177d9d43 Fix browser ESM deprecation wraning
Previously, the warning was issued if jasmineRequire.core was called from
an ES module rather than being defined in an ES module.
2026-01-17 17:12:32 -08:00
Steve Gravrock
0c75a154a8 Fix typo 2026-01-17 12:00:58 -08:00
Steve Gravrock
0a6f6d2b0e Bump version to 6.0.0
Some checks failed
Test in latest available Safari / build (push) Has been cancelled
2026-01-17 11:35:56 -08:00
Steve Gravrock
6755b03f12 Temporarily (I hope) disable testing against Safari 16 and 17
Saucelabs VMs for these browsers currently fail to start. There was a
successful run last night against commit e759ddced2.
2026-01-17 11:25:22 -08:00
Steve Gravrock
e759ddced2 Clarify monkey patching deprecation warning 2026-01-11 19:23:51 -08:00
Steve Gravrock
1ad28d8515 Update copyright date 2026-01-11 19:23:25 -08:00
Steve Gravrock
3d36b11c8f rm bogus @optional jsdoc tags 2025-12-30 12:18:22 -08:00
Steve Gravrock
a15df6d455 Document that globals may be overwritten 2025-12-30 12:15:33 -08:00
Steve Gravrock
9f0488dc32 Bump version to 6.0.0-beta.1
Some checks failed
Test in latest available Safari / build (push) Has been cancelled
2025-12-06 10:56:56 -08:00
Steve Gravrock
f3dba82b04 Revert to using window.onload
To support top level await, jasmine-browser-runner needs to be able
to delay env execution until after spec files have initialized. The
old-fashioned event listener style makes that straightforward.
2025-12-01 18:33:08 -08:00
Steve Gravrock
c999ce0787 Update some dev dependencies 2025-12-01 17:57:37 -08:00
Steve Gravrock
5b76bf9552 Merge branch '6.0' 2025-12-01 17:48:49 -08:00
Steve Gravrock
9cf9b856b0 Bump version to 5.13.0
Some checks failed
Test in latest available Safari / build (push) Has been cancelled
2025-12-01 17:25:03 -08:00
Steve Gravrock
db6c142afd Copy 6.0.0-beta.0 release notes from branch 2025-11-28 11:49:05 -08:00
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
03006080d4 rm deprecated jsApiReporter 2025-11-28 09:53:15 -08:00
Steve Gravrock
876de65803 rm monkey patch warnings 2025-11-28 09:53:15 -08:00
Steve Gravrock
8b3c4ce3b4 Remove HtmlReporter, HtmlSpecFilter, and supporting internal code 2025-11-28 09:53:15 -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
1e691b2470 Prettier 2025-11-27 06:53:27 -08:00
Steve Gravrock
c5555dd8cc Better debug logging for spec that occasionally fails in FF 2025-11-27 06:30:09 -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
Steve Gravrock
78c14f81a8 Copy 6.0.0-alpha.2 release notes from branch 2025-11-15 14:40:39 -08:00
163 changed files with 2772 additions and 4755 deletions

View File

@@ -41,13 +41,11 @@ Jasmine tests itself. The files in `lib` are loaded first, defining the referenc
The tests should always use `jasmineUnderTest` to refer to the objects and functions that are being tested. But the tests can use functions on `jasmine` as needed. _Be careful how you structure any new test code_. Copy the patterns you see in the existing code - this ensures that the code you're testing is not leaking into the `jasmine` reference and vice-versa. The tests should always use `jasmineUnderTest` to refer to the objects and functions that are being tested. But the tests can use functions on `jasmine` as needed. _Be careful how you structure any new test code_. Copy the patterns you see in the existing code - this ensures that the code you're testing is not leaking into the `jasmine` reference and vice-versa.
### `boot0.js` and `boot1.js` ### `boot.js`
These files file does all of the setup necessary for Jasmine to work in a This file does all the setup necessary for Jasmine to work in a browser. While
browser. They load all of the code, create an `Env`, attach the global the default in `lib`is appropriate for most uses, users may wish to customize
functions, and build the reporter. It also sets up the execution of the this file.
`Env` - for browsers this is in `window.onload`. While the default in `lib`
is appropriate for browsers, projects may wish to customize this file.
### Compatibility ### Compatibility

View File

@@ -1,5 +1,5 @@
Copyright (c) 2008-2019 Pivotal Labs Copyright (c) 2008-2019 Pivotal Labs
Copyright (c) 2008-2025 The Jasmine developers Copyright (c) 2008-2026 The Jasmine developers
Permission is hereby granted, free of charge, to any person obtaining Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the a copy of this software and associated documentation files (the

View File

@@ -30,7 +30,7 @@ Microsoft Edge) as well as Node.
| Environment | Supported versions | | Environment | Supported versions |
|-------------------|----------------------------------| |-------------------|----------------------------------|
| Node | 20, 22, 24 | | Node | 20, 22, 24 |
| Safari | 16*, 17*, 26* | | Safari | 26* |
| Chrome | Evergreen | | Chrome | Evergreen |
| Firefox | Evergreen, 102*, 115*, 128*, 140 | | Firefox | Evergreen, 102*, 115*, 128*, 140 |
| Edge | Evergreen | | Edge | Evergreen |
@@ -60,5 +60,5 @@ To find out what environments work with a particular Jasmine release, see the [r
* Sheel Choksi * Sheel Choksi
Copyright (c) 2008-2019 Pivotal Labs<br> Copyright (c) 2008-2019 Pivotal Labs<br>
Copyright (c) 2008-2025 The Jasmine developers<br> Copyright (c) 2008-2026 The Jasmine developers<br>
This software is licensed under the [MIT License](https://github.com/jasmine/jasmine/blob/main/LICENSE). This software is licensed under the [MIT License](https://github.com/jasmine/jasmine/blob/main/LICENSE).

View File

@@ -1,6 +1,6 @@
/* /*
Copyright (c) 2008-2019 Pivotal Labs Copyright (c) 2008-2019 Pivotal Labs
Copyright (c) 2008-2025 The Jasmine developers Copyright (c) 2008-2026 The Jasmine developers
Permission is hereby granted, free of charge, to any person obtaining Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the a copy of this software and associated documentation files (the
@@ -24,70 +24,26 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
'use strict'; 'use strict';
/** const path = require('path');
* Note: Only available on Node. const fs = require('fs');
* @module jasmine-core const {
*/ globals,
installGlobals,
version,
private$
} = require('./jasmine-core/jasmine.js');
const jasmineRequire = require('./jasmine-core/jasmine.js'); function reset() {
module.exports = jasmineRequire; private$.currentEnv_ = null;
const env = jasmine.getEnv({ suppressLoadErrors: true });
const bootWithoutGlobals = (function() { rebindInterface(env);
let jasmine, jasmineInterface; }
return function bootWithoutGlobals(reinitialize) {
if (!jasmineInterface || reinitialize === true) {
jasmine = jasmineRequire.core(jasmineRequire);
const env = jasmine.getEnv({ suppressLoadErrors: true });
jasmineInterface = jasmineRequire.interface(jasmine, env);
}
return { jasmine, jasmineInterface };
};
})();
/**
* Boots a copy of Jasmine and returns an object as described in {@link jasmine}.
* @param {boolean} [reinitialize=true] Whether to create a new copy of Jasmine if one already exists
* @type {function}
* @return {jasmine}
*/
module.exports.boot = function(reinitialize) {
if (reinitialize === undefined) {
reinitialize = true;
}
const { jasmine, jasmineInterface } = bootWithoutGlobals(reinitialize);
for (const k in jasmineInterface) {
global[k] = jasmineInterface[k];
}
return jasmine;
};
/**
* Boots a copy of Jasmine and returns an object containing the properties
* that would normally be added to the global object. If noGlobals is called
* multiple times, the same object is returned every time.
*
* @example
* const {describe, beforeEach, it, expect, jasmine} = require('jasmine-core').noGlobals();
*/
module.exports.noGlobals = function() {
const { jasmineInterface } = bootWithoutGlobals(false);
return jasmineInterface;
};
const path = require('path'),
fs = require('fs');
const rootPath = path.join(__dirname, 'jasmine-core'), const rootPath = path.join(__dirname, 'jasmine-core'),
bootFiles = ['boot0.js', 'boot1.js'], bootFiles = ['boot.js'],
legacyBootFiles = ['boot.js'],
cssFiles = [], cssFiles = [],
jsFiles = [], jsFiles = [],
jsFilesToSkip = ['jasmine.js'].concat(bootFiles, legacyBootFiles); jsFilesToSkip = ['jasmine.js'].concat(bootFiles);
fs.readdirSync(rootPath).forEach(function(file) { fs.readdirSync(rootPath).forEach(function(file) {
if (fs.statSync(path.join(rootPath, file)).isFile()) { if (fs.statSync(path.join(rootPath, file)).isFile()) {
@@ -104,12 +60,40 @@ fs.readdirSync(rootPath).forEach(function(file) {
} }
}); });
module.exports.files = { /**
self: __filename, * Note: Only available on Node.
path: rootPath, *
bootDir: rootPath, * In addition to the members documented here, this module's exports include all
bootFiles: bootFiles, * {@link globals}.
cssFiles: cssFiles, * @module jasmine-core
jsFiles: ['jasmine.js'].concat(jsFiles), */
imagesDir: path.join(__dirname, '../images') module.exports = {
...globals,
/**
* Copies Jasmine globals (jasmine, describe, it, etc) to the specified
* object or to globalThis.
* @function
* @param {object} [dest] - The object to copy globals to.
*/
installGlobals,
/**
* Returns the jasmine-core version.
* @function
*/
version,
/**
* Resets all of jasmine-core's state, including removing specs, suites, and
* reporters, and resetting configuration to the default.
* @function
*/
reset,
files: {
self: __filename,
path: rootPath,
bootDir: rootPath,
bootFiles: bootFiles,
cssFiles: cssFiles,
jsFiles: ['jasmine.js'].concat(jsFiles),
imagesDir: path.join(__dirname, '../images')
}
}; };

View File

@@ -1,6 +1,6 @@
/* /*
Copyright (c) 2008-2019 Pivotal Labs Copyright (c) 2008-2019 Pivotal Labs
Copyright (c) 2008-2025 The Jasmine developers Copyright (c) 2008-2026 The Jasmine developers
Permission is hereby granted, free of charge, to any person obtaining Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the a copy of this software and associated documentation files (the
@@ -24,40 +24,10 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
'use strict'; 'use strict';
/**
This file finishes 'booting' Jasmine, performing all of the necessary
initialization before executing the loaded environment and all of a project's
specs. This file should be loaded after `boot0.js` but before any project
source files or spec files are loaded. Thus this file can also be used to
customize Jasmine for a project.
If a project is using Jasmine via the standalone distribution, this file can
be customized directly. If you only wish to configure the Jasmine env, you
can load another file that calls `jasmine.getEnv().configure({...})`
after `boot0.js` is loaded and before this file is loaded.
*/
(function() { (function() {
const env = jasmine.getEnv(); const env = jasmine.getEnv();
const urls = new jasmine.HtmlReporterV2Urls(); const urls = new jasmine.HtmlReporterV2Urls();
/**
* ## 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 +36,16 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/ */
env.configure(urls.configFromCurrentUrl()); env.configure(urls.configFromCurrentUrl());
/**
* ## Execution
*
* Replace the browser window's `onload`, ensure it's called, and then run all of the loaded specs. This includes initializing the `HtmlReporter` instance and then executing the loaded Jasmine environment. All of this will happen after all of the specs are loaded.
*/
const currentWindowOnload = window.onload; const currentWindowOnload = window.onload;
window.onload = function() { window.onload = function() {
if (currentWindowOnload) { if (currentWindowOnload) {
currentWindowOnload(); currentWindowOnload();
} }
htmlReporter.initialize();
// The HTML reporter needs to be set up here so it can access the DOM. Other
// reporters can be added at any time before env.execute() is called.
const htmlReporter = new jasmine.HtmlReporterV2({ env, urls });
env.addReporter(htmlReporter);
env.execute(); env.execute();
}; };
})(); })();

View File

@@ -1,68 +0,0 @@
/*
Copyright (c) 2008-2019 Pivotal Labs
Copyright (c) 2008-2025 The Jasmine developers
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
'use strict';
/**
This file starts the process of "booting" Jasmine. It initializes Jasmine,
makes its globals available, and creates the env. This file should be loaded
after `jasmine.js` and `jasmine_html.js`, but before `boot1.js` or any project
source files or spec files are loaded.
*/
(function() {
const jasmineRequire = window.jasmineRequire || require('./jasmine.js');
/**
* ## Require &amp; Instantiate
*
* Require Jasmine's core files. Specifically, this requires and attaches all of Jasmine's code to the `jasmine` reference.
*/
const jasmine = jasmineRequire.core(jasmineRequire),
global = jasmine.getGlobal();
global.jasmine = jasmine;
/**
* Since this is being run in a browser and the results should populate to an HTML page, require the HTML-specific Jasmine code, injecting the same reference.
*/
jasmineRequire.html(jasmine);
/**
* Create the Jasmine environment. This is used to run all specs in a project.
*/
const env = jasmine.getEnv();
/**
* ## The Global Interface
*
* Build up the functions that will be exposed as the Jasmine public interface. A project can customize, rename or alias any of these functions as desired, provided the implementation remains unchanged.
*/
const jasmineInterface = jasmineRequire.interface(jasmine, env);
/**
* Add all of the Jasmine global/public interface to the global scope, so a project can use the public interface directly. For example, calling `describe` in specs instead of `jasmine.getEnv().describe`.
*/
for (const property in jasmineInterface) {
global[property] = jasmineInterface[property];
}
})();

View File

@@ -1,6 +1,6 @@
/* /*
Copyright (c) 2008-2019 Pivotal Labs Copyright (c) 2008-2019 Pivotal Labs
Copyright (c) 2008-2025 The Jasmine developers Copyright (c) 2008-2026 The Jasmine developers
Permission is hereby granted, free of charge, to any person obtaining Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the a copy of this software and associated documentation files (the
@@ -22,319 +22,50 @@ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/ */
// eslint-disable-next-line no-var (function() {
var jasmineRequire = window.jasmineRequire || require('./jasmine.js'); // eslint-disable-next-line no-unused-vars
const getJasmineHtmlRequireObj = (function() {
jasmineRequire.html = function(j$) {
j$.private.ResultsNode = jasmineRequire.ResultsNode();
j$.private.ResultsStateBuilder = jasmineRequire.ResultsStateBuilder(j$);
j$.private.htmlReporterUtils = jasmineRequire.htmlReporterUtils(j$);
j$.private.AlertsView = jasmineRequire.AlertsView(j$);
j$.private.OverallStatusBar = jasmineRequire.OverallStatusBar(j$);
j$.private.Banner = jasmineRequire.Banner(j$);
j$.private.SymbolsView = jasmineRequire.SymbolsView(j$);
j$.private.SummaryTreeView = jasmineRequire.SummaryTreeView(j$);
j$.private.FailuresView = jasmineRequire.FailuresView(j$);
j$.private.PerformanceView = jasmineRequire.PerformanceView(j$);
j$.private.TabBar = jasmineRequire.TabBar(j$);
j$.HtmlReporter = jasmineRequire.HtmlReporter(j$);
j$.HtmlReporterV2Urls = jasmineRequire.HtmlReporterV2Urls(j$);
j$.HtmlReporterV2 = jasmineRequire.HtmlReporterV2(j$);
j$.QueryString = jasmineRequire.QueryString();
j$.HtmlSpecFilter = jasmineRequire.HtmlSpecFilter(j$);
j$.private.HtmlSpecFilterV2 = jasmineRequire.HtmlSpecFilterV2();
};
jasmineRequire.HtmlReporter = function(j$) {
'use strict'; 'use strict';
const htmlRequire = {};
const { createDom, noExpectations } = j$.private.htmlReporterUtils; function getJasmineHtmlRequire() {
return htmlRequire;
/**
* @class HtmlReporter
* @classdesc Displays results and allows re-running individual specs and suites.
* @implements {Reporter}
* @param options Options object. See lib/jasmine-core/boot1.js for details.
* @since 1.2.0
* @deprecated Use {@link HtmlReporterV2} instead.
*/
class HtmlReporter {
#env;
#getContainer;
#navigateWithNewParam;
#urlBuilder;
#filterSpecs;
#stateBuilder;
#config;
#htmlReporterMain;
// Sub-views
#alerts;
#symbols;
#banner;
#failures;
constructor(options) {
this.#env = options.env;
this.#getContainer = options.getContainer;
this.#navigateWithNewParam =
options.navigateWithNewParam || function() {};
this.#urlBuilder = new UrlBuilder(
options.addToExistingQueryString || defaultQueryString
);
this.#filterSpecs = options.filterSpecs;
}
/**
* Initializes the reporter. Should be called before {@link Env#execute}.
* @function
* @name HtmlReporter#initialize
*/
initialize() {
this.#env.deprecated(
'HtmlReporter and HtmlSpecFilter are deprecated. Use HtmlReporterV2 instead.'
);
this.#clearPrior();
this.#config = this.#env ? this.#env.configuration() : {};
this.#stateBuilder = new j$.private.ResultsStateBuilder();
this.#alerts = new j$.private.AlertsView(this.#urlBuilder);
this.#symbols = new j$.private.SymbolsView();
this.#banner = new j$.private.Banner(this.#navigateWithNewParam);
this.#failures = new j$.private.FailuresView(this.#urlBuilder);
this.#htmlReporterMain = createDom(
'div',
{ className: 'jasmine_html-reporter' },
this.#banner.rootEl,
this.#symbols.rootEl,
this.#alerts.rootEl,
this.#failures.rootEl
);
this.#getContainer().appendChild(this.#htmlReporterMain);
}
jasmineStarted(options) {
this.#stateBuilder.jasmineStarted(options);
}
suiteStarted(result) {
this.#stateBuilder.suiteStarted(result);
}
suiteDone(result) {
this.#stateBuilder.suiteDone(result);
if (result.status === 'failed') {
this.#failures.append(result, this.#stateBuilder.currentParent);
}
}
specStarted() {}
specDone(result) {
this.#stateBuilder.specDone(result);
this.#symbols.append(result, this.#config);
if (noExpectations(result)) {
const noSpecMsg = "Spec '" + result.fullName + "' has no expectations.";
if (result.status === 'failed') {
// eslint-disable-next-line no-console
console.error(noSpecMsg);
} else {
// eslint-disable-next-line no-console
console.warn(noSpecMsg);
}
}
if (result.status === 'failed') {
this.#failures.append(result, this.#stateBuilder.currentParent);
}
}
jasmineDone(doneResult) {
this.#stateBuilder.jasmineDone(doneResult);
this.#banner.showOptionsMenu(this.#config);
if (
this.#stateBuilder.specsExecuted < this.#stateBuilder.totalSpecsDefined
) {
this.#alerts.addSkipped(
this.#stateBuilder.specsExecuted,
this.#stateBuilder.totalSpecsDefined
);
}
const statusBar = new j$.private.OverallStatusBar(this.#urlBuilder);
statusBar.showDone(doneResult, this.#stateBuilder);
this.#alerts.addBar(statusBar.rootEl);
if (doneResult.failedExpectations) {
for (const f of doneResult.failedExpectations) {
this.#alerts.addGlobalFailure(f);
}
}
for (const dw of this.#stateBuilder.deprecationWarnings) {
this.#alerts.addDeprecationWarning(dw);
}
const results = this.#find('.jasmine-results');
const summary = new j$.private.SummaryTreeView(
this.#urlBuilder,
this.#filterSpecs
);
summary.addResults(this.#stateBuilder.topResults);
results.appendChild(summary.rootEl);
if (this.#stateBuilder.anyNonTopSuiteFailures) {
this.#addFailureToggle();
this.#setMenuModeTo('jasmine-failure-list');
this.#failures.show();
}
}
#addFailureToggle() {
const onClickFailures = () => this.#setMenuModeTo('jasmine-failure-list');
const onClickSpecList = () => this.#setMenuModeTo('jasmine-spec-list');
const failuresLink = createDom(
'a',
{ className: 'jasmine-failures-menu', href: '#' },
'Failures'
);
let specListLink = createDom(
'a',
{ className: 'jasmine-spec-list-menu', href: '#' },
'Spec List'
);
failuresLink.onclick = function() {
onClickFailures();
return false;
};
specListLink.onclick = function() {
onClickSpecList();
return false;
};
this.#alerts.addBar(
createDom(
'span',
{ className: 'jasmine-menu jasmine-bar jasmine-spec-list' },
[createDom('span', {}, 'Spec List | '), failuresLink]
)
);
this.#alerts.addBar(
createDom(
'span',
{ className: 'jasmine-menu jasmine-bar jasmine-failure-list' },
[specListLink, createDom('span', {}, ' | Failures ')]
)
);
}
#find(selector) {
return this.#getContainer().querySelector(
'.jasmine_html-reporter ' + selector
);
}
#clearPrior() {
const oldReporter = this.#find('');
if (oldReporter) {
this.#getContainer().removeChild(oldReporter);
}
}
#setMenuModeTo(mode) {
this.#htmlReporterMain.setAttribute(
'class',
'jasmine_html-reporter ' + mode
);
}
} }
class UrlBuilder { htmlRequire.html = function(j$, private$) {
#addToExistingQueryString; if (!private$) {
private$ = {};
constructor(addToExistingQueryString) {
this.#addToExistingQueryString = function(k, v) {
// include window.location.pathname to fix issue with karma-jasmine-html-reporter in angular: see https://github.com/jasmine/jasmine/issues/1906
return (
(window.location.pathname || '') + addToExistingQueryString(k, v)
);
};
} }
suiteHref(suite) { private$.ResultsNode = htmlRequire.ResultsNode();
const els = []; private$.ResultsStateBuilder = htmlRequire.ResultsStateBuilder(
j$,
while (suite && suite.parent) { private$
els.unshift(suite.result.description);
suite = suite.parent;
}
return this.#addToExistingQueryString('spec', els.join(' '));
}
specHref(result) {
return this.#addToExistingQueryString('spec', result.fullName);
}
runAllHref() {
return this.#addToExistingQueryString('spec', '');
}
seedHref(seed) {
return this.#addToExistingQueryString('seed', seed);
}
}
function defaultQueryString(key, value) {
return '?' + key + '=' + value;
}
return HtmlReporter;
};
jasmineRequire.HtmlSpecFilter = function(j$) {
'use strict';
/**
* @class HtmlSpecFilter
* @param options Options object. See lib/jasmine-core/boot1.js for details.
* @deprecated Use {@link HtmlReporterV2Urls} instead.
*/
function HtmlSpecFilter(options) {
j$.getEnv().deprecated(
'HtmlReporter and HtmlSpecFilter are deprecated. Use HtmlReporterV2 instead.'
); );
private$.htmlReporterUtils = htmlRequire.htmlReporterUtils(j$, private$);
private$.AlertsView = htmlRequire.AlertsView(j$, private$);
private$.OverallStatusBar = htmlRequire.OverallStatusBar(j$, private$);
private$.Banner = htmlRequire.Banner(j$, private$);
private$.SummaryTreeView = htmlRequire.SummaryTreeView(j$, private$);
private$.FailuresView = htmlRequire.FailuresView(j$, private$);
private$.PerformanceView = htmlRequire.PerformanceView(j$, private$);
private$.TabBar = htmlRequire.TabBar(j$, private$);
private$.HtmlSpecFilterV2 = htmlRequire.HtmlSpecFilterV2();
const filterString = for (const k of ['HtmlReporterV2Urls', 'HtmlReporterV2', 'QueryString']) {
options && Object.defineProperty(j$, k, {
options.filterString() && enumerable: true,
options.filterString().replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&'); configurable: false,
const filterPattern = new RegExp(filterString); writable: false,
value: htmlRequire[k](j$, private$)
});
}
};
/** return getJasmineHtmlRequire;
* Determines whether the spec with the specified name should be executed. })();
* @name HtmlSpecFilter#matches
* @function
* @param {string} specName The full name of the spec
* @returns {boolean}
*/
this.matches = function(specName) {
return filterPattern.test(specName);
};
}
return HtmlSpecFilter; getJasmineHtmlRequireObj().ResultsNode = function() {
};
jasmineRequire.ResultsNode = function() {
'use strict'; 'use strict';
function ResultsNode(result, type, parent) { function ResultsNode(result, type, parent) {
@@ -360,7 +91,7 @@ jasmineRequire.ResultsNode = function() {
return ResultsNode; return ResultsNode;
}; };
jasmineRequire.QueryString = function() { getJasmineHtmlRequireObj().QueryString = function() {
'use strict'; 'use strict';
/** /**
@@ -376,6 +107,7 @@ jasmineRequire.QueryString = function() {
*/ */
constructor(options) { constructor(options) {
this.#getWindowLocation = options.getWindowLocation; this.#getWindowLocation = options.getWindowLocation;
Object.freeze(this);
} }
/** /**
@@ -443,13 +175,14 @@ jasmineRequire.QueryString = function() {
return '?' + qStrPairs.join('&'); return '?' + qStrPairs.join('&');
} }
Object.freeze(QueryString.prototype);
return QueryString; return QueryString;
}; };
jasmineRequire.AlertsView = function(j$) { getJasmineHtmlRequireObj().AlertsView = function(j$, private$) {
'use strict'; 'use strict';
const { createDom } = j$.private.htmlReporterUtils; const { createDom } = private$.htmlReporterUtils;
const errorBarClassName = 'jasmine-bar jasmine-errored'; const errorBarClassName = 'jasmine-bar jasmine-errored';
const afterAllMessagePrefix = 'AfterAll '; const afterAllMessagePrefix = 'AfterAll ';
@@ -472,45 +205,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,
@@ -604,10 +298,10 @@ jasmineRequire.AlertsView = function(j$) {
return AlertsView; return AlertsView;
}; };
jasmineRequire.Banner = function(j$) { getJasmineHtmlRequireObj().Banner = function(j$, private$) {
'use strict'; 'use strict';
const { createDom } = j$.private.htmlReporterUtils; const { createDom } = private$.htmlReporterUtils;
class Banner { class Banner {
#navigateWithNewParam; #navigateWithNewParam;
@@ -766,10 +460,10 @@ jasmineRequire.Banner = function(j$) {
return Banner; return Banner;
}; };
jasmineRequire.FailuresView = function(j$) { getJasmineHtmlRequireObj().FailuresView = function(j$, private$) {
'use strict'; 'use strict';
const { createDom } = j$.private.htmlReporterUtils; const { createDom } = private$.htmlReporterUtils;
class FailuresView { class FailuresView {
#urlBuilder; #urlBuilder;
@@ -933,14 +627,14 @@ jasmineRequire.FailuresView = function(j$) {
return FailuresView; return FailuresView;
}; };
jasmineRequire.htmlReporterUtils = function(j$) { getJasmineHtmlRequireObj().htmlReporterUtils = function(j$, private$) {
'use strict'; 'use strict';
function createDom(type, attrs, childrenArrayOrVarArgs) { function createDom(type, attrs, childrenArrayOrVarArgs) {
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 = [];
@@ -986,10 +680,10 @@ jasmineRequire.htmlReporterUtils = function(j$) {
return { createDom, noExpectations }; return { createDom, noExpectations };
}; };
jasmineRequire.HtmlReporterV2 = function(j$) { getJasmineHtmlRequireObj().HtmlReporterV2 = function(j$, private$) {
'use strict'; 'use strict';
const { createDom, noExpectations } = j$.private.htmlReporterUtils; const { createDom, noExpectations } = private$.htmlReporterUtils;
const specListTabId = 'jasmine-specListTab'; const specListTabId = 'jasmine-specListTab';
const failuresTabId = 'jasmine-failuresTab'; const failuresTabId = 'jasmine-failuresTab';
@@ -1007,12 +701,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 +723,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,25 +736,17 @@ 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 private$.ResultsStateBuilder();
this.#alerts = new j$.private.AlertsView(this.#urlBuilder); this.#alerts = new private$.AlertsView(this.#urlBuilder);
this.#statusBar = new j$.private.OverallStatusBar(this.#urlBuilder); this.#statusBar = new private$.OverallStatusBar(this.#urlBuilder);
this.#statusBar.showRunning(); this.#statusBar.showRunning();
this.#alerts.addBar(this.#statusBar.rootEl); this.#alerts.addBar(this.#statusBar.rootEl);
this.#tabBar = new j$.private.TabBar( this.#tabBar = new private$.TabBar(
[ [
{ id: specListTabId, label: 'Spec List' }, { id: specListTabId, label: 'Spec List' },
{ id: failuresTabId, label: 'Failures' }, { id: failuresTabId, label: 'Failures' },
@@ -1081,11 +765,11 @@ jasmineRequire.HtmlReporterV2 = function(j$) {
this.#alerts.addBar(this.#tabBar.rootEl); this.#alerts.addBar(this.#tabBar.rootEl);
this.#progress = new ProgressView(); this.#progress = new ProgressView();
this.#banner = new j$.private.Banner( this.#banner = new private$.Banner(
this.#queryString.navigateWithNewParam.bind(this.#queryString), this.#queryString.navigateWithNewParam.bind(this.#queryString),
true true
); );
this.#failures = new j$.private.FailuresView(this.#urlBuilder); this.#failures = new private$.FailuresView(this.#urlBuilder);
this.#htmlReporterMain = createDom( this.#htmlReporterMain = createDom(
'div', 'div',
{ className: 'jasmine_html-reporter' }, { className: 'jasmine_html-reporter' },
@@ -1094,13 +778,17 @@ 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();
Object.freeze(this);
} }
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) {
@@ -1164,13 +852,13 @@ jasmineRequire.HtmlReporterV2 = function(j$) {
} }
const results = this.#find('.jasmine-results'); const results = this.#find('.jasmine-results');
const summary = new j$.private.SummaryTreeView( const summary = new private$.SummaryTreeView(
this.#urlBuilder, this.#urlBuilder,
this.#filterSpecs this.#filterSpecs
); );
summary.addResults(this.#stateBuilder.topResults); summary.addResults(this.#stateBuilder.topResults);
results.appendChild(summary.rootEl); results.appendChild(summary.rootEl);
const perf = new j$.private.PerformanceView(); const perf = new private$.PerformanceView();
perf.addResults(this.#stateBuilder.topResults); perf.addResults(this.#stateBuilder.topResults);
results.appendChild(perf.rootEl); results.appendChild(perf.rootEl);
this.#tabBar.showTab(specListTabId); this.#tabBar.showTab(specListTabId);
@@ -1185,19 +873,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 +896,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');
@@ -1277,10 +959,11 @@ jasmineRequire.HtmlReporterV2 = function(j$) {
} }
} }
Object.freeze(HtmlReporterV2.prototype);
return HtmlReporterV2; return HtmlReporterV2;
}; };
jasmineRequire.HtmlReporterV2Urls = function(j$) { getJasmineHtmlRequireObj().HtmlReporterV2Urls = function(j$, private$) {
'use strict'; 'use strict';
// TODO unify with V2 UrlBuilder? // TODO unify with V2 UrlBuilder?
@@ -1300,6 +983,8 @@ jasmineRequire.HtmlReporterV2Urls = function(j$) {
return window.location; return window.location;
} }
}); });
Object.freeze(this);
} }
/** /**
@@ -1331,7 +1016,7 @@ jasmineRequire.HtmlReporterV2Urls = function(j$) {
config.seed = seed; config.seed = seed;
} }
const specFilter = new j$.private.HtmlSpecFilterV2({ const specFilter = new private$.HtmlSpecFilterV2({
filterParams: () => ({ filterParams: () => ({
path: this.queryString.getParam('path'), path: this.queryString.getParam('path'),
spec: this.queryString.getParam('spec') spec: this.queryString.getParam('spec')
@@ -1350,10 +1035,11 @@ jasmineRequire.HtmlReporterV2Urls = function(j$) {
} }
} }
Object.freeze(HtmlReporterV2Urls.prototype);
return HtmlReporterV2Urls; return HtmlReporterV2Urls;
}; };
jasmineRequire.HtmlSpecFilterV2 = function() { getJasmineHtmlRequireObj().HtmlSpecFilterV2 = function() {
class HtmlSpecFilterV2 { class HtmlSpecFilterV2 {
#getFilterParams; #getFilterParams;
@@ -1395,10 +1081,10 @@ jasmineRequire.HtmlSpecFilterV2 = function() {
return HtmlSpecFilterV2; return HtmlSpecFilterV2;
}; };
jasmineRequire.OverallStatusBar = function(j$) { getJasmineHtmlRequireObj().OverallStatusBar = function(j$, private$) {
'use strict'; 'use strict';
const { createDom } = j$.private.htmlReporterUtils; const { createDom } = private$.htmlReporterUtils;
const staticClassNames = 'jasmine-overall-result jasmine-bar'; const staticClassNames = 'jasmine-overall-result jasmine-bar';
class OverallStatusBar { class OverallStatusBar {
@@ -1504,8 +1190,8 @@ jasmineRequire.OverallStatusBar = function(j$) {
return OverallStatusBar; return OverallStatusBar;
}; };
jasmineRequire.PerformanceView = function(j$) { getJasmineHtmlRequireObj().PerformanceView = function(j$, private$) {
const createDom = j$.private.htmlReporterUtils.createDom; const createDom = private$.htmlReporterUtils.createDom;
const MAX_SLOW_SPECS = 20; const MAX_SLOW_SPECS = 20;
class PerformanceView { class PerformanceView {
@@ -1603,12 +1289,12 @@ jasmineRequire.PerformanceView = function(j$) {
return PerformanceView; return PerformanceView;
}; };
jasmineRequire.ResultsStateBuilder = function(j$) { getJasmineHtmlRequireObj().ResultsStateBuilder = function(j$, private$) {
'use strict'; 'use strict';
class ResultsStateBuilder { class ResultsStateBuilder {
constructor() { constructor() {
this.topResults = new j$.private.ResultsNode({}, '', null); this.topResults = new private$.ResultsNode({}, '', null);
this.currentParent = this.topResults; this.currentParent = this.topResults;
this.suitesById = {}; this.suitesById = {};
this.totalSpecsDefined = 0; this.totalSpecsDefined = 0;
@@ -1686,10 +1372,10 @@ jasmineRequire.ResultsStateBuilder = function(j$) {
return ResultsStateBuilder; return ResultsStateBuilder;
}; };
jasmineRequire.SummaryTreeView = function(j$) { getJasmineHtmlRequireObj().SummaryTreeView = function(j$, private$) {
'use strict'; 'use strict';
const { createDom, noExpectations } = j$.private.htmlReporterUtils; const { createDom, noExpectations } = private$.htmlReporterUtils;
class SummaryTreeView { class SummaryTreeView {
#urlBuilder; #urlBuilder;
@@ -1795,48 +1481,8 @@ jasmineRequire.SummaryTreeView = function(j$) {
return SummaryTreeView; return SummaryTreeView;
}; };
jasmineRequire.SymbolsView = function(j$) { getJasmineHtmlRequireObj().TabBar = function(j$, private$) {
'use strict'; const createDom = private$.htmlReporterUtils.createDom;
const { createDom, noExpectations } = j$.private.htmlReporterUtils;
class SymbolsView {
constructor() {
this.rootEl = createDom('ul', {
className: 'jasmine-symbol-summary'
});
}
append(result, config) {
this.rootEl.appendChild(
createDom('li', {
className: this.#className(result, config),
id: 'spec_' + result.id,
title: result.fullName
})
);
}
#className(result, config) {
if (noExpectations(result) && result.status === 'passed') {
return 'jasmine-empty';
} else if (result.status === 'excluded') {
if (config.hideDisabled) {
return 'jasmine-excluded-no-display';
} else {
return 'jasmine-excluded';
}
} else {
return 'jasmine-' + result.status;
}
}
}
return SymbolsView;
};
jasmineRequire.TabBar = function(j$) {
const createDom = j$.private.htmlReporterUtils.createDom;
class TabBar { class TabBar {
#tabs; #tabs;
@@ -1912,3 +1558,10 @@ jasmineRequire.TabBar = function(j$) {
return TabBar; return TabBar;
}; };
(function() {
'use strict';
getJasmineHtmlRequireObj().html(jasmine);
})();
})()

View File

@@ -24,7 +24,6 @@ body {
line-height: 14px; line-height: 14px;
} }
.jasmine_html-reporter .jasmine-banner, .jasmine_html-reporter .jasmine-banner,
.jasmine_html-reporter .jasmine-symbol-summary,
.jasmine_html-reporter .jasmine-summary, .jasmine_html-reporter .jasmine-summary,
.jasmine_html-reporter .jasmine-result-message, .jasmine_html-reporter .jasmine-result-message,
.jasmine_html-reporter .jasmine-spec .jasmine-description, .jasmine_html-reporter .jasmine-spec .jasmine-description,
@@ -65,57 +64,6 @@ body {
padding-right: 9px; padding-right: 9px;
font-size: 12px; font-size: 12px;
} }
.jasmine_html-reporter .jasmine-symbol-summary {
overflow: hidden;
margin: 14px 0;
}
.jasmine_html-reporter .jasmine-symbol-summary li {
display: inline-block;
height: 10px;
width: 14px;
font-size: 16px;
}
.jasmine_html-reporter .jasmine-symbol-summary li.jasmine-passed {
font-size: 14px;
}
.jasmine_html-reporter .jasmine-symbol-summary li.jasmine-passed:before {
color: #007069;
content: "•";
}
.jasmine_html-reporter .jasmine-symbol-summary li.jasmine-failed {
line-height: 9px;
}
.jasmine_html-reporter .jasmine-symbol-summary li.jasmine-failed:before {
color: #ca3a11;
content: "×";
font-weight: bold;
margin-left: -1px;
}
.jasmine_html-reporter .jasmine-symbol-summary li.jasmine-excluded {
font-size: 14px;
}
.jasmine_html-reporter .jasmine-symbol-summary li.jasmine-excluded:before {
color: #bababa;
content: "•";
}
.jasmine_html-reporter .jasmine-symbol-summary li.jasmine-excluded-no-display {
font-size: 14px;
display: none;
}
.jasmine_html-reporter .jasmine-symbol-summary li.jasmine-pending {
line-height: 17px;
}
.jasmine_html-reporter .jasmine-symbol-summary li.jasmine-pending:before {
color: #ba9d37;
content: "*";
}
.jasmine_html-reporter .jasmine-symbol-summary li.jasmine-empty {
font-size: 14px;
}
.jasmine_html-reporter .jasmine-symbol-summary li.jasmine-empty:before {
color: #ba9d37;
content: "•";
}
.jasmine_html-reporter progress { .jasmine_html-reporter progress {
width: 100%; width: 100%;
} }
@@ -197,12 +145,10 @@ body {
.jasmine_html-reporter .jasmine-bar a { .jasmine_html-reporter .jasmine-bar a {
color: white; color: white;
} }
.jasmine_html-reporter.jasmine-spec-list .jasmine-bar.jasmine-menu.jasmine-failure-list,
.jasmine_html-reporter.jasmine-spec-list .jasmine-results .jasmine-failures, .jasmine_html-reporter.jasmine-spec-list .jasmine-results .jasmine-failures,
.jasmine_html-reporter.jasmine-spec-list .jasmine-performance-view { .jasmine_html-reporter.jasmine-spec-list .jasmine-performance-view {
display: none; display: none;
} }
.jasmine_html-reporter.jasmine-failure-list .jasmine-bar.jasmine-menu.jasmine-spec-list,
.jasmine_html-reporter.jasmine-failure-list .jasmine-summary, .jasmine_html-reporter.jasmine-failure-list .jasmine-summary,
.jasmine_html-reporter.jasmine-failure-list .jasmine-performance-view { .jasmine_html-reporter.jasmine-failure-list .jasmine-performance-view {
display: none; display: none;

File diff suppressed because it is too large Load Diff

View File

@@ -1,7 +1,7 @@
{ {
"name": "jasmine-core", "name": "jasmine-core",
"license": "MIT", "license": "MIT",
"version": "6.0.0-alpha.2", "version": "7.0.0-pre.0",
"repository": { "repository": {
"type": "git", "type": "git",
"url": "https://github.com/jasmine/jasmine.git" "url": "https://github.com/jasmine/jasmine.git"
@@ -28,6 +28,9 @@
"description": "Simple JavaScript testing framework for browsers and node.js", "description": "Simple JavaScript testing framework for browsers and node.js",
"homepage": "https://jasmine.github.io", "homepage": "https://jasmine.github.io",
"main": "./lib/jasmine-core.js", "main": "./lib/jasmine-core.js",
"exports": {
".": "./lib/jasmine-core.js"
},
"files": [ "files": [
"LICENSE", "LICENSE",
"README.md", "README.md",
@@ -43,10 +46,10 @@
"ejs": "^3.1.10", "ejs": "^3.1.10",
"eslint": "^9.24.0", "eslint": "^9.24.0",
"eslint-plugin-compat": "^6.0.2", "eslint-plugin-compat": "^6.0.2",
"glob": "^10.2.3", "glob": "^13.0.0",
"globals": "^16.0.0", "globals": "^16.0.0",
"jasmine": "github:jasmine/jasmine-npm#6.0", "jasmine": "github:jasmine/jasmine-npm#7.0",
"jasmine-browser-runner": "github:jasmine/jasmine-browser-runner#4.0", "jasmine-browser-runner": "github:jasmine/jasmine-browser-runner#5.0",
"jsdom": "^26.0.0", "jsdom": "^26.0.0",
"prettier": "1.17.1", "prettier": "1.17.1",
"sass": "^1.58.3" "sass": "^1.58.3"

44
release_notes/5.13.0.md Normal file
View File

@@ -0,0 +1,44 @@
# Jasmine Core 5.13.0 Release Notes
## Changes to supported environments
Safari 26 is now supported on a best-effort basis.
Due to the limited availability of Safari 18 and later on free CI services,
Safari support in future jasmine-core versions will be limited to:
* Best-effort support for the latest Safari version available on GitHub Actions,
which may change at any time.
* Best-effort support for Safari 16 and 17 for as long as it remains practical.
## New Features
* New `extraItStackFrames` and `extraDescribeStackFrames` config options to fix
the filename properties of reporter events in configurations that wrap
`it`/`describe`, such as zone.js. The `filename` properties of reporter events
are no longer deprecated.
* `jasmine.allOf` asymmetric equality tester
* Merges [#2087](https://github.com/jasmine/jasmine/issues/2083) from @jonahd-g
* Fixes [#2083](https://github.com/jasmine/jasmine/pull/2087)
## Supported environments
This version has been tested in the following environments.
| Environment | Supported versions |
|-------------|--------------------------------|
| Node | 18.20.5**, 20, 22, 24 |
| Safari** | 16, 17, 26.1 |
| Chrome | 142* |
| Firefox | 102**, 115**, 128**, 140, 145* |
| Edge | 142* |
\* Evergreen browser. Each version of Jasmine is tested against the latest
version available at release time.<br>
\** Supported on a best-effort basis. Support for these versions may be dropped
if it becomes impractical, and bugs affecting only these versions may not be
treated as release blockers.
------
_Release Notes generated with _[Anchorman](http://github.com/infews/anchorman)_

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

@@ -0,0 +1,47 @@
# Jasmine Core 6.0.0-beta.1 Release Notes
This is a pre-release, intended to offer a preview of upcoming changes and to
solicit feedback.
A corresponding release of the `jasmine` package is not planned because the
change in this release only affects browser users.
## A Note About Pre-Release Compatibility
There may be additional breaking changes in future 6.0 pre-releases or in the
final 6.0 release. That's allowed by the semver specification, but users are
sometimes unpleasantly surprised by it.
NPM's implementation of carat version ranges assumes that subsequent
pre-releases and final releases are fully compatible with earlier pre-releases.
If your package.json contains `"jasmine-core": "^6.0.0-beta.1`,
NPM might install any later 6.x version even though there is no guarantee of
compatibility. If that isn't ok, you should specify an exact pre-release version:
`"jasmine-core": "6.0.0-beta.1`.
## Bug Fixes
* Revert to using window.onload in boot1.js. This fixes top level await in
jasmine-browser-runner.
## Supported environments
This version has been tested in the following environments.
| Environment | Supported versions |
|-------------------|--------------------------------|
| Node | 20, 22, 24 |
| Safari** | 16, 17, 26.1 |
| Chrome | 143* |
| Firefox | 102**, 115**, 128**, 140, 145* |
| Edge | 142* |
\* Evergreen browser. Each version of Jasmine is tested against the latest
version available at release time.<br>
\** Supported on a best-effort basis. Support for these versions may be dropped
if it becomes impractical, and bugs affecting only these versions may not be
treated as release blockers.
------
_Release Notes generated with _[Anchorman](http://github.com/infews/anchorman)_

190
release_notes/6.0.0.md Normal file
View File

@@ -0,0 +1,190 @@
# Jasmine Core 6.0.0 Release Notes
## Summary
This is a major release that includes breaking changes as well as significant
new features. Many of the breaking changes and deprecations in this release are
intended to improve the stability of the Jasmine ecosystem by making the
distinction between public and private APIs more obvious, reducing exposure of
jasmine-core's internal state, removing ambiguities from the reporter API, and
warning about monkey patching.
6.x is intended to ba a relatively short-lived, transitional series. It is
compatible with the current versions of karma-jasmine and other legacy Angular
tools but emits deprecation warnings when used with them. 7.0 will drop
compatibility with those tools. If you use Karma in a non-Angular context,
consider migrating to a maintained alternative such as jasmine-browser-runner or
web-test-runner. If you use Angular, please direct any questions about support
for future versions of Jasmine to the Angular team.
Please see the [migration guide](https://jasmine.github.io/upgrade-guides/6.0)
for more information. If you use Jasmine via the `jasmine` package, please see
[its release notes](https://github.com/jasmine/jasmine-npm/blob/main/release_notes/6.0.0.md)
as well.
## Changes to supported environments
* Node 18 is no longer supported.
## Breaking changes
### General
* Private APIs have been removed from the `jasmine` namespace.
The purpose of this change is to reduce the risk of users inadvertently
depending on private APIs. Anything not covered by
[the documentation](https://jasmine.github.io/pages/docs_home.html) remains
private regardless of namespacing. Private APIs may be changed or removed in
any release. This change is being made in a major release as a courtesy to
users of libraries that depend on private APIs.
### Changes that affect spec writing
* Global error spies always receive a single argument. Previously, the browser
error event was passed as the second argument.
* If a spy is invoked via `.call(null, ...)` or `.apply(null, ...)`, the spy's
`this` argument will be `null`. Previously it was `globalThis`.
* Mock clock timing functions cannot be spied on. Previously this "worked" but
prevented the mock clock from uninstalling itself.
* The mock clock no longer supports the eval forms of `setTimeout` and
`setInterval`.
* Keys passed to `setSpecProperty`/`setSuiteProperty` must be strings. Values
must be both structured-cloneable and JSON-serializable.
### Changes that affect configuration
* HTML reporters cache configuration throughout each run. Configuration changes
made while specs are running will not affect reporter behavior.
* If an execution order is passed to `Env#execute`, it must not enter any suite
more than once.
* The argument passed to spec filters is a
[spec metadata](https://jasmine.github.io/api/6.0/Spec.html)
instance, not the internal spec object.
* The default value of the `forbidDuplicateNames` config option has been
changed to true.
### Changes that affect reporters
This release includes changes that are intended to streamline and clarify the
reporter interface, prevent sharing of mutable state, and prevent bugs involving
non-serializable objects. These changes should be compatible with most existing
reporters but could break reporters that manage their internal state in unusual
ways.
* Meaningless properties such as `status` and `failedExpectations` are omitted
from the events passed to [suiteStarted](https://jasmine.github.io/api/6.0/global.html#SuiteStartedEvent)
and [specStarted](https://jasmine.github.io/api/6.0/global.html#SpecStartedEvent).
* Reporter events are deep-cloned before being passed to each reporter. This
protects reporters against later mutation by jasmine-core or other reporters.
* The `expected` and `actual` properties of
[passed and failed expectations](https://jasmine.github.io/api/6.0/global.html#ExpectationResult)
have been removed.
* The [order](https://jasmine.github.io/api/6.0/global.html#Order)
property of the`jasmineStarted` and `jasmineDone` reporter events no longer
includes undocumented properties.
* boot1.js no longer adds `jsApiReporter` to the env.
### Changes that affect browser boot files
* The `createElement` and `createTextNode` options of the legacy `HtmlReporter`
are ignored. `HtmlReporter` now unconditionally uses `document.createElement`
and `document.createTextNode`.
### Changes to Node boot functions
* [boot](https://jasmine.github.io/api/6.0/module-jasmine-core.html#.boot)
defaults to creating a new core instance each time it's called. This restores
the pre-5.0 default behavior.
* [noGlobals](https://jasmine.github.io/api/6.0/module-jasmine-core.html#.noGlobals)
no longer takes a parameter. It always returns the same object when called
repeatedly.
## New features
* A new `HtmlReporterV2` with several improvements over the old `HtmlReporter`:
* Clicking a spec/suite link does exact filtering rather than a substring
match.
* The old dots are replaced with a progress bar. This improves usability with
large suites and fixes an accessibility problem.
* Details of failed specs are displayed as soon as each spec finishes.
* A Performance tab shows metrics and a list of the slowest specs.
* Initialization and wire-up in boot files are much simpler.
If you're using jasmine-browser-runner or copying boot1.js from the standalone
distribution, you'll automatically get the new reporter. If you maintain your
own boot files, you'll get the old reporter unless you update your boot files
to match the one that's in this package.
The new reporter produces `spec` query string parameters that are different
from those created by the old reporter. If you use other software that
interprets the `spec` parameter, such as karma-jasmine, you won't be able to
adopt `HtmlReporterV2` unlesss that other software is updated.
* Larger body font size in HTML reporters
* `globalThis` is used to determine the global object during initialization
This makes jasmine-core more tolerant of buggy bundlers or loaders that
cause `this` to be undefined in the global context.
* Experimental [`safariYieldStrategy: "time"`](https://jasmine.github.io/api/6.0/Configuration.html#safariYieldStrategy)
config option, which may make Jasmine run significantly faster in Safari and
similar browsers. So far, this option has not been tested on a wide variety of
workloads. Feedback is appreciated.
* Statically exposed pretty printer as `jasmine.pp()`.
## Deprecations
* Common monkey patching patterns are detected and result in a deprecation
warning. Code that overwrites anything provided by jasmine-core (other than
globals like `it`/`expect`/etc or configuration properties like
`jasmine.DEFAULT_TIMEOUT_INTERVAL`) may be broken by any jasmine-core release.
* Warn if jasmine-core is loaded as an ES module in a browser.
This is an untested and unsupported configuration that has been known to cause
problems.
* `HtmlReporter` and `HtmlSpecFilter` are deprecated in favor of `HtmlReporterV2`.
* `jsApiReporter` is deprecated.
## Documentation improvements
* Improved API reference documentation for APIs that are used from browser boot
files.
* Documented the set of possible spec statuses.
* Documented that globals are overwriteable.
## Internal improvements
* Encapsulated suite and spec result and status management.
* Adopted strict mode throughout the codebase.
* Decomposed `HtmlReporter` into components and converted to ES6 classes.
* Made global error handling more uniform between browsers and Node.
* Removed code to support browsers that don't have `MessageChannel`. Jasmine
hasn't run in any such browsers since 2.x.
* Replaced `isArray` helper with native `Array.isArray`.
## Supported environments
This version has been tested in the following environments.
| Environment | Supported versions |
|-------------------|--------------------------------|
| Node | 20, 22, 24 |
| Safari** | 16, 17, 26.2 |
| Chrome | 143* |
| Firefox | 102**, 115**, 128**, 140, 147* |
| Edge | 143* |
\* Evergreen browser. Each version of Jasmine is tested against the latest
version available at release time.<br>
\** Supported on a best-effort basis. Support for these versions may be dropped
if it becomes impractical, and bugs affecting only these versions may not be
treated as release blockers.
------
_Release Notes generated with _[Anchorman](http://github.com/infews/anchorman)_

29
release_notes/6.0.1.md Normal file
View File

@@ -0,0 +1,29 @@
# Jasmine Core 6.0.1 Release Notes
## Bug fixes
* Don't emit a deprecation warning when `jasmineRequire.core` is called from an
ES module
## Supported environments
This version has been tested in the following environments.
| Environment | Supported versions |
|-------------------|--------------------------------|
| Node | 20, 22, 24 |
| Safari** | 16, 17, 26.2 |
| Chrome | 143* |
| Firefox | 102**, 115**, 128**, 140, 147* |
| Edge | 143* |
\* Evergreen browser. Each version of Jasmine is tested against the latest
version available at release time.<br>
\** Supported on a best-effort basis. Support for these versions may be dropped
if it becomes impractical, and bugs affecting only these versions may not be
treated as release blockers.
------
_Release Notes generated with _[Anchorman](http://github.com/infews/anchorman)_

40
release_notes/6.1.0.md Normal file
View File

@@ -0,0 +1,40 @@
# Jasmine Core 6.1.0 Release Notes
## Changes to supported environments
* Safari 16 and 17 are no longer supported. Although jasmine-core may still work
in those versions, we no longer have a reliable way to test them and won't try
to maintain compatibility with them in future releases.
## New features
* Report the underlying errors that make up an `AggregateError`.
* Merges [#2093](https://github.com/jasmine/jasmine/pull/2093) from @puglyfe
* Fixes [#2063](https://github.com/jasmine/jasmine/issues/2063)
## Documentation improvements
* Fix default MAX_PRETTY_PRINT_CHARS in JsDoc.
* Merges [#2091](https://github.com/jasmine/jasmine/pull/2091) from @HolgerJeromin
## Supported environments
This version has been tested in the following environments.
| Environment | Supported versions |
|-------------------|--------------------------------|
| Node | 20, 22, 24 |
| Safari | 26.3** |
| Chrome | 144* |
| Firefox | 102**, 115**, 128**, 140, 147* |
| Edge | 144* |
\* Evergreen browser. Each version of Jasmine is tested against the latest
version available at release time.<br>
\** Supported on a best-effort basis. Support for these versions may be dropped
if it becomes impractical, and bugs affecting only these versions may not be
treated as release blockers.
------
_Release Notes generated with _[Anchorman](http://github.com/infews/anchorman)_

View File

@@ -0,0 +1,58 @@
# Jasmine Core 7.0.0-pre.0 Release Notes
This is a pre-release, intended to offer a preview of breaking changes and to
solicit feedback.
Before installing this release, update to 6.0.1 or later and fix all
deprecation warnings.
## Breaking changes
* `HtmlReporter`, `HtmlSpecFilter`, and `jsApiReporter`, which were deprecated
in 6.0, have been removed.
* Most private APIs are no longer exposed.
* Monkey patching is blocked. This does not affect globals (`describe`,
`expect`, etc.) or properties that are explicitly documented as writeable.
Those can still be overwritten.
* Redesigned boot process:
* `jasmineRequire`, `boot`, and `noGlobals` have been removed.
* The core instance is automatically created.
* In browsers, globals are automatically created.
* In Node, globals are not automatically created. Call the exported
`installGlobals` function to create them. If you're using the `jasmine`
package, this is done for you by default.
* In Node, the same instance is returned every time jasmine-core is imported.
If you need to do multiple consecutive independent test runs, call the
exported `reset` function to reset all state and configuration between runs.
If you maintain your own browser boot files, you may be able to update by just
removing `boot1.js`. See the `boot.js` file in this package for a working
example. If you boot jasmine-core in Node, remove the call to `boot` or
`noGlobals` and add a call to `installGlobals` if desired:
```javascript
const jasmineCore = require('jasmine-core');
jasmineCore.installGlobals();
```
## Supported environments
This version has been tested in the following environments.
| Environment | Supported versions |
|-------------------|--------------------------------|
| Node | 20, 22, 24 |
| Safari | 26.3** |
| Chrome | 144* |
| Firefox | 102**, 115**, 128**, 140, 147* |
| Edge | 144* |
\* Evergreen browser. Each version of Jasmine is tested against the latest
version available at release time.<br>
\** Supported on a best-effort basis. Support for these versions may be dropped
if it becomes impractical, and bugs affecting only these versions may not be
treated as release blockers.
------
_Release Notes generated with _[Anchorman](http://github.com/infews/anchorman)_

View File

@@ -42,8 +42,7 @@ async function zipStandaloneDist(jasmineVersion) {
'lib/jasmine-core/jasmine.js', 'lib/jasmine-core/jasmine.js',
'lib/jasmine-core/jasmine-html.js', 'lib/jasmine-core/jasmine-html.js',
'lib/jasmine-core/jasmine.css', 'lib/jasmine-core/jasmine.css',
'lib/jasmine-core/boot0.js', 'lib/jasmine-core/boot.js',
'lib/jasmine-core/boot1.js',
], ],
destDir: 'lib/jasmine-' + jasmineVersion destDir: 'lib/jasmine-' + jasmineVersion
}, },

View File

@@ -34,18 +34,20 @@ function concatFiles() {
const configs = [ const configs = [
{ {
src: [ src: [
{ literal: '(function() {' },
'src/html/requireHtml.js', 'src/html/requireHtml.js',
'src/html/HtmlReporter.js',
'src/html/HtmlSpecFilter.js',
'src/html/ResultsNode.js', 'src/html/ResultsNode.js',
'src/html/QueryString.js', 'src/html/QueryString.js',
'src/html/**/*.js' { glob: 'src/html/**/*.js', exclude: 'src/html/requireSuffix.js' },
'src/html/requireSuffix.js',
{ literal: '})()' },
], ],
dest: 'lib/jasmine-core/jasmine-html.js', dest: 'lib/jasmine-core/jasmine-html.js',
}, },
{ {
dest: 'lib/jasmine-core/jasmine.js', dest: 'lib/jasmine-core/jasmine.js',
src: [ src: [
{ literal: '(function() {' },
'src/core/requireCore.js', 'src/core/requireCore.js',
'src/core/matchers/requireMatchers.js', 'src/core/matchers/requireMatchers.js',
'src/core/base.js', 'src/core/base.js',
@@ -53,23 +55,20 @@ function concatFiles() {
'src/core/Spec.js', 'src/core/Spec.js',
'src/core/Order.js', 'src/core/Order.js',
'src/core/Env.js', 'src/core/Env.js',
'src/core/JsApiReporter.js',
'src/core/PrettyPrinter', 'src/core/PrettyPrinter',
'src/core/Suite', 'src/core/Suite',
'src/core/**/*.js', { glob: 'src/core/**/*.js', exclude: 'src/core/requireSuffix.js'},
{ {
template: 'src/version.js', template: 'src/version.js',
data: {version: pkg.version} data: {version: pkg.version}
}, },
'src/core/requireSuffix.js',
{ literal: '})()' },
], ],
}, },
{ {
dest: 'lib/jasmine-core/boot0.js', dest: 'lib/jasmine-core/boot.js',
src: ['src/boot/boot0.js'], src: ['src/boot/boot.js'],
},
{
dest: 'lib/jasmine-core/boot1.js',
src: ['src/boot/boot1.js'],
}, },
{ {
dest: 'lib/jasmine-core.js', dest: 'lib/jasmine-core.js',
@@ -85,25 +84,28 @@ function concatFiles() {
src.unshift(licenseBanner); src.unshift(licenseBanner);
function expand(srcListEntry) { function expand(srcListEntry) {
if (typeof srcListEntry === 'object') { if (typeof srcListEntry === 'object' && !srcListEntry.glob) {
return srcListEntry; return srcListEntry;
} }
return glob.sync(srcListEntry) const matches = glob.sync(
.sort(function (a, b) { srcListEntry.glob ?? srcListEntry,
// Match the sort order of previous build tools, so that the {ignore: srcListEntry.exclude}
// output is the same. );
a = a.toLowerCase(); return matches.sort(function (a, b) {
b = b.toLowerCase(); // Match the sort order of previous build tools, so that the
// output is the same.
a = a.toLowerCase();
b = b.toLowerCase();
if (a < b) { if (a < b) {
return -1; return -1;
} else if (a === b) { } else if (a === b) {
return 0; return 0;
} else { } else {
return 1; return 1;
} }
}); });
} }
const srcs = src.flatMap(expand); const srcs = src.flatMap(expand);
@@ -117,6 +119,8 @@ function concatFiles() {
if (s.template) { if (s.template) {
const template = fs.readFileSync(s.template, {encoding: 'utf8'}); const template = fs.readFileSync(s.template, {encoding: 'utf8'});
content = ejs.render(template, s.data); content = ejs.render(template, s.data);
} else if (s.literal) {
content = s.literal;
} else { } else {
content = fs.readFileSync(s, {encoding: 'utf8'}); content = fs.readFileSync(s, {encoding: 'utf8'});
} }

View File

@@ -1,8 +1,8 @@
#!/bin/sh #!/bin/sh
# Run tests in supported browsers that are available on Saucelabs. # Run tests in supported browsers that are available on Saucelabs.
# Note: The latest Safari version is tested via GitHub Actions because Saucelabs # Note: Safari is tested via GitHub Actions because Saucelabs only makes Safari
# only makes it available to paid enterprise accounts. See # 18 and later available to paid enterprise accounts. See
# .github/workflows/safari.yml. # .github/workflows/safari.yml.
run_browser() { run_browser() {
@@ -44,9 +44,6 @@ else
fi fi
run_browser firefox 102 run_browser firefox 102
run_browser safari 17
run_browser safari 16
run_browser MicrosoftEdge latest run_browser MicrosoftEdge latest
echo echo

View File

@@ -1,8 +1,9 @@
verifyNoGlobals(() => require('../lib/jasmine-core.js').noGlobals()); let jasmineCore;
verifyNoGlobals(() => { jasmineCore = require('../lib/jasmine-core.js'); });
jasmineCore.installGlobals();
const Jasmine = require('jasmine'); const Jasmine = require('jasmine');
const jasmineCore = require('../lib/jasmine-core.js'); const runner = new Jasmine({jasmineCore});
const runner = new Jasmine({jasmineCore: jasmineCore});
runner.loadConfigFile('./spec/support/jasmine.json'); runner.loadConfigFile('./spec/support/jasmine.json');
runner.exitOnCompletion = false; runner.exitOnCompletion = false;

View File

@@ -1247,4 +1247,8 @@ describe('Clock (acceptance)', function() {
clock.tick(400); clock.tick(400);
}); });
isNonMonkeyPatchableClass(privateUnderTest.Clock, function() {
return new privateUnderTest.Clock({}, function() {}, {});
});
}); });

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,8 @@ describe('Env', function() {
}).toThrowError('Jasmine cannot be configured via Env in parallel mode'); }).toThrowError('Jasmine cannot be configured via Env in parallel mode');
}); });
}); });
isNonMonkeyPatchableClass(privateUnderTest.Env, function() {
return new privateUnderTest.Env();
});
}); });

View File

@@ -173,10 +173,13 @@ describe('ExceptionFormatter', function() {
}); });
it('filters Jasmine stack frames in this environment', function() { it('filters Jasmine stack frames in this environment', function() {
const jasmineFile = (function() {
const trace = new privateUnderTest.StackTrace(new Error());
return trace.frames[2].file;
})();
expect(jasmineFile).toMatch(/\/jasmine.js$/);
const error = new Error('an error'); const error = new Error('an error');
const subject = new privateUnderTest.ExceptionFormatter({ const subject = new privateUnderTest.ExceptionFormatter({ jasmineFile });
jasmineFile: jasmine.private.util.jasmineFile()
});
const result = subject.stack(error); const result = subject.stack(error);
jasmine.debugLog('Original stack trace: ' + error.stack); jasmine.debugLog('Original stack trace: ' + error.stack);
jasmine.debugLog('Filtered stack trace: ' + result); jasmine.debugLog('Filtered stack trace: ' + result);
@@ -196,15 +199,18 @@ describe('ExceptionFormatter', function() {
}); });
it('handles multiline error messages in this environment', function() { it('handles multiline error messages in this environment', function() {
const jasmineFile = (function() {
const trace = new privateUnderTest.StackTrace(new Error());
return trace.frames[2].file;
})();
expect(jasmineFile).toMatch(/\/jasmine.js$/);
const msg = 'an error\nwith two lines'; const msg = 'an error\nwith two lines';
const error = new Error(msg); const error = new Error(msg);
if (error.stack.indexOf(msg) === -1) { if (error.stack.indexOf(msg) === -1) {
pending("Stack traces don't have messages in this environment"); pending("Stack traces don't have messages in this environment");
} }
const subject = new privateUnderTest.ExceptionFormatter({ const subject = new privateUnderTest.ExceptionFormatter({ jasmineFile });
jasmineFile: jasmine.private.util.jasmineFile()
});
const result = subject.stack(error); const result = subject.stack(error);
const lines = result.split('\n'); const lines = result.split('\n');
@@ -284,7 +290,7 @@ describe('ExceptionFormatter', function() {
it('ensures that stack traces do not include the message in this environment', function() { it('ensures that stack traces do not include the message in this environment', function() {
const error = new Error('an error'); const error = new Error('an error');
const subject = new privateUnderTest.ExceptionFormatter({ const subject = new privateUnderTest.ExceptionFormatter({
jasmineFile: jasmine.private.util.jasmineFile() jasmineFile: "doesn't matter"
}); });
const result = subject.stack(error, { omitMessage: true }); const result = subject.stack(error, { omitMessage: true });
expect(result).not.toContain('an error'); expect(result).not.toContain('an error');
@@ -346,5 +352,184 @@ describe('ExceptionFormatter', function() {
}).not.toThrowError(); }).not.toThrowError();
}); });
}); });
describe('when the error has an errors array (AggregateError)', function() {
it('includes all aggregated errors in the stack trace', function() {
const subject = new privateUnderTest.ExceptionFormatter();
const error1 = (function fn1() {
return new Error('first error');
})();
const error2 = (function fn2() {
return new Error('second error');
})();
const aggregateError = (function fn3() {
return new Error('Multiple errors occurred');
})();
aggregateError.errors = [error1, error2];
const lines = subject.stack(aggregateError).split('\n');
// TODO: be consistent across environments about whether the message is
// included in the stack trace
if (lines[0] === 'Error: Multiple errors occurred') {
lines.shift();
}
// Exclude lines that vary from environment to environment
const filteredLines = lines.filter(
x =>
!x.includes('/jasmine.js:') &&
// Some Node 20 and 22 minors when running in parallel
!x.includes('process.processTicksAndRejections')
);
for (let i = 0; i < filteredLines.length; i++) {
jasmine.debugLog(`Line ${i} after filtering: ${filteredLines[i]}`);
}
// Inexact matching because stack frame formatting varies from runtime
// to runtime
const expectedPatterns = [
// Overall error
/fn3.*ExceptionFormatterSpec\.js/,
/ExceptionFormatterSpec\.js/,
/^$/,
// First nested error
/^ Error 1: Error: first error$/,
/^ .*fn1.*ExceptionFormatterSpec\.js/,
/^ .*ExceptionFormatterSpec\.js/,
/^$/,
// Second nested error
/^ .*Error 2: Error: second error$/,
/^ .*fn2.*ExceptionFormatterSpec\.js/,
/^ .*ExceptionFormatterSpec\.js/
];
expect(filteredLines).toEqual(
expectedPatterns.map(p => jasmine.stringMatching(p))
);
});
it('handles empty errors array', function() {
const subject = new privateUnderTest.ExceptionFormatter();
const aggregateError = new Error('No errors');
aggregateError.errors = [];
expect(function() {
subject.stack(aggregateError);
}).not.toThrowError();
});
it('handles nested AggregateError', function() {
const subject = new privateUnderTest.ExceptionFormatter();
const innerError1 = new Error('inner error 1');
const innerError2 = new Error('inner error 2');
const innerAggregate = new Error('Inner aggregate');
innerAggregate.errors = [innerError1, innerError2];
const outerError = new Error('outer error');
const outerAggregate = new Error('Outer aggregate');
outerAggregate.errors = [innerAggregate, outerError];
const lines = subject.stack(outerAggregate).split('\n');
const innerAggMsgIx = lines.findIndex(line =>
line.includes('Error 1: Error: Inner aggregate')
);
expect(innerAggMsgIx).toBeGreaterThan(-1);
const innerError1MsgIx = lines.findIndex(line =>
line.includes('Error 1: Error: inner error 1')
);
expect(innerError1MsgIx).toBeGreaterThan(innerAggMsgIx);
const innerError2MsgIx = lines.findIndex(line =>
line.includes('Error 2: Error: inner error 2')
);
expect(innerError2MsgIx).toBeGreaterThan(innerError1MsgIx);
const outerErrorMsgIx = lines.findIndex(line =>
line.includes('Error 2: Error: outer error')
);
expect(outerErrorMsgIx).toBeGreaterThan(innerError2MsgIx);
});
it('handles AggregateError containing error with cause', function() {
const subject = new privateUnderTest.ExceptionFormatter();
const rootCause = new Error('root cause');
const errorWithCause = new Error('error with cause', {
cause: rootCause
});
const aggregateError = new Error('Aggregate with cause chain');
aggregateError.errors = [errorWithCause];
const lines = subject.stack(aggregateError).split('\n');
const error1MsgIx = lines.findIndex(line =>
line.includes('Error 1: Error: error with cause')
);
expect(error1MsgIx).toBeGreaterThan(-1);
const causeMsgIx = lines.findIndex(line =>
line.includes('Caused by: Error: root cause')
);
expect(causeMsgIx).toBeGreaterThan(error1MsgIx);
});
it('skips non-Error items in errors array', function() {
const subject = new privateUnderTest.ExceptionFormatter();
const error1 = new Error('real error');
const aggregateError = new Error('Mixed array');
aggregateError.errors = [
error1,
'string error',
{ message: 'object error' },
null,
undefined,
42
];
const lines = subject.stack(aggregateError).split('\n');
const error1MsgIx = lines.findIndex(line =>
line.includes('Error 1: Error: real error')
);
expect(error1MsgIx).toBeGreaterThan(-1);
const hasStringError = lines.some(line =>
line.includes('string error')
);
expect(hasStringError).toBe(false);
const hasObjectError = lines.some(line =>
line.includes('object error')
);
expect(hasObjectError).toBe(false);
});
it('works with native AggregateError constructor', function() {
const subject = new privateUnderTest.ExceptionFormatter();
const error1 = new Error('first error');
const error2 = new Error('second error');
const aggregateError = new AggregateError(
[error1, error2],
'Multiple errors'
);
const lines = subject.stack(aggregateError).split('\n');
const error1MsgIx = lines.findIndex(line =>
line.includes('Error 1: Error: first error')
);
expect(error1MsgIx).toBeGreaterThan(-1);
const error2MsgIx = lines.findIndex(line =>
line.includes('Error 2: Error: second error')
);
expect(error2MsgIx).toBeGreaterThan(error1MsgIx);
});
});
}); });
}); });

View File

@@ -1,179 +0,0 @@
describe('JsApiReporter', function() {
it('knows when a full environment is started', function() {
const reporter = new privateUnderTest.JsApiReporter({});
expect(reporter.started).toBe(false);
expect(reporter.finished).toBe(false);
reporter.jasmineStarted();
expect(reporter.started).toBe(true);
expect(reporter.finished).toBe(false);
});
it('knows when a full environment is done', function() {
const reporter = new privateUnderTest.JsApiReporter({});
expect(reporter.started).toBe(false);
expect(reporter.finished).toBe(false);
reporter.jasmineStarted();
reporter.jasmineDone({});
expect(reporter.finished).toBe(true);
});
it("defaults to 'loaded' status", function() {
const reporter = new privateUnderTest.JsApiReporter({});
expect(reporter.status()).toEqual('loaded');
});
it("reports 'started' when Jasmine has started", function() {
const reporter = new privateUnderTest.JsApiReporter({});
reporter.jasmineStarted();
expect(reporter.status()).toEqual('started');
});
it("reports 'done' when Jasmine is done", function() {
const reporter = new privateUnderTest.JsApiReporter({});
reporter.jasmineDone({});
expect(reporter.status()).toEqual('done');
});
it('tracks a suite', function() {
const reporter = new privateUnderTest.JsApiReporter({});
reporter.suiteStarted({
id: 123,
description: 'A suite'
});
const suites = reporter.suites();
expect(suites).toEqual({ 123: { id: 123, description: 'A suite' } });
reporter.suiteDone({
id: 123,
description: 'A suite',
status: 'passed'
});
expect(suites).toEqual({
123: { id: 123, description: 'A suite', status: 'passed' }
});
});
describe('#specResults', function() {
let reporter, specResult1, specResult2;
beforeEach(function() {
reporter = new privateUnderTest.JsApiReporter({});
specResult1 = {
id: 1,
description: 'A spec'
};
specResult2 = {
id: 2,
description: 'Another spec'
};
reporter.specDone(specResult1);
reporter.specDone(specResult2);
});
it('should return a slice of results', function() {
expect(reporter.specResults(0, 1)).toEqual([specResult1]);
expect(reporter.specResults(1, 1)).toEqual([specResult2]);
});
describe('when the results do not exist', function() {
it('should return a slice of shorter length', function() {
expect(reporter.specResults(0, 3)).toEqual([specResult1, specResult2]);
expect(reporter.specResults(2, 3)).toEqual([]);
});
});
});
describe('#suiteResults', function() {
let reporter, suiteStarted1, suiteResult1, suiteResult2;
beforeEach(function() {
reporter = new privateUnderTest.JsApiReporter({});
suiteStarted1 = {
id: 1
};
suiteResult1 = {
id: 1,
status: 'failed',
failedExpectations: [{ message: 'My After All Exception' }]
};
suiteResult2 = {
id: 2,
status: 'passed'
};
reporter.suiteStarted(suiteStarted1);
reporter.suiteDone(suiteResult1);
reporter.suiteDone(suiteResult2);
});
it('should not include suite starts', function() {
expect(reporter.suiteResults(0, 3).length).toEqual(2);
});
it('should return a slice of results', function() {
expect(reporter.suiteResults(0, 1)).toEqual([suiteResult1]);
expect(reporter.suiteResults(1, 1)).toEqual([suiteResult2]);
});
it('returns nothing for out of bounds indices', function() {
expect(reporter.suiteResults(0, 3)).toEqual([suiteResult1, suiteResult2]);
expect(reporter.suiteResults(2, 3)).toEqual([]);
});
});
describe('#executionTime', function() {
it('should start the timer when jasmine starts', function() {
const timerSpy = jasmine.createSpyObj('timer', ['start', 'elapsed']),
reporter = new privateUnderTest.JsApiReporter({
timer: timerSpy
});
reporter.jasmineStarted();
expect(timerSpy.start).toHaveBeenCalled();
});
it('should return the time it took the specs to run, in ms', function() {
const timerSpy = jasmine.createSpyObj('timer', ['start', 'elapsed']),
reporter = new privateUnderTest.JsApiReporter({
timer: timerSpy
});
timerSpy.elapsed.and.returnValue(1000);
reporter.jasmineDone();
expect(reporter.executionTime()).toEqual(1000);
});
describe("when the specs haven't finished being run", function() {
it('should return undefined', function() {
const timerSpy = jasmine.createSpyObj('timer', ['start', 'elapsed']),
reporter = new privateUnderTest.JsApiReporter({
timer: timerSpy
});
expect(reporter.executionTime()).toBeUndefined();
});
});
});
describe('#runDetails', function() {
it('should have details about the run', function() {
const reporter = new privateUnderTest.JsApiReporter({});
reporter.jasmineDone({ some: { run: 'details' } });
expect(reporter.runDetails).toEqual({ some: { run: 'details' } });
});
});
});

View File

@@ -160,6 +160,13 @@ describe('ParallelReportDispatcher', function() {
); );
}); });
isNonMonkeyPatchableClass(
jasmineUnderTest.ParallelReportDispatcher,
function() {
return new jasmineUnderTest.ParallelReportDispatcher();
}
);
function mockGlobalErrors() { function mockGlobalErrors() {
const globalErrors = jasmine.createSpyObj('globalErrors', [ const globalErrors = jasmine.createSpyObj('globalErrors', [
'install', 'install',

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

@@ -278,7 +278,7 @@ describe('Spec', function() {
spec.addExpectationResult(true, { message: 'passed' }); spec.addExpectationResult(true, { message: 'passed' });
expect(function() { expect(function() {
spec.addExpectationResult(false, { message: 'failed' }); spec.addExpectationResult(false, { message: 'failed' });
}).toThrowError(jasmineUnderTest.private.errors.ExpectationFailed); }).toThrowError(privateUnderTest.errors.ExpectationFailed);
expect(spec.doneEvent().failedExpectations).toEqual([ expect(spec.doneEvent().failedExpectations).toEqual([
jasmine.objectContaining({ message: 'failed' }) jasmine.objectContaining({ message: 'failed' })
@@ -453,9 +453,7 @@ describe('Spec', function() {
queueableFn: {} queueableFn: {}
}); });
spec.handleException( spec.handleException(new privateUnderTest.errors.ExpectationFailed());
new jasmineUnderTest.private.errors.ExpectationFailed()
);
expect(spec.doneEvent().failedExpectations).toEqual([]); expect(spec.doneEvent().failedExpectations).toEqual([]);
}); });

View File

@@ -138,7 +138,7 @@ describe('Suite', function() {
expect(function() { expect(function() {
suite.addExpectationResult(false, { message: 'failed' }); suite.addExpectationResult(false, { message: 'failed' });
}).toThrowError(jasmineUnderTest.private.errors.ExpectationFailed); }).toThrowError(privateUnderTest.errors.ExpectationFailed);
expect(suite.doneEvent().status).toBe('failed'); expect(suite.doneEvent().status).toBe('failed');
expect(suite.doneEvent().failedExpectations).toEqual([ expect(suite.doneEvent().failedExpectations).toEqual([
@@ -149,9 +149,7 @@ describe('Suite', function() {
it('does not add an additional failure when an expectation fails', function() { it('does not add an additional failure when an expectation fails', function() {
const suite = new privateUnderTest.Suite({}); const suite = new privateUnderTest.Suite({});
suite.handleException( suite.handleException(new privateUnderTest.errors.ExpectationFailed());
new jasmineUnderTest.private.errors.ExpectationFailed()
);
expect(suite.doneEvent().failedExpectations).toEqual([]); expect(suite.doneEvent().failedExpectations).toEqual([]);
}); });

View File

@@ -30,4 +30,8 @@ describe('Timer', function() {
expect(timer.elapsed()).toEqual(jasmine.any(Number)); expect(timer.elapsed()).toEqual(jasmine.any(Number));
}); });
}); });
isNonMonkeyPatchableClass(jasmineUnderTest.Timer, function() {
return new jasmineUnderTest.Timer();
});
}); });

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);
@@ -179,7 +163,6 @@ describe('util', function() {
// Chrome sometimes reports foo.js as foo.js/, so tolerate // Chrome sometimes reports foo.js as foo.js/, so tolerate
// a trailing slash if present. // a trailing slash if present.
expect(privateUnderTest.util.jasmineFile()).toMatch(/util.js\/?$/); expect(privateUnderTest.util.jasmineFile()).toMatch(/util.js\/?$/);
expect(jasmine.private.util.jasmineFile()).toMatch(/jasmine.js\/?$/);
}); });
}); });
}); });

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

@@ -1289,9 +1289,7 @@ describe('Env integration', function() {
await env.execute(); await env.execute();
expect(reporter.specDone).toHaveBeenCalledTimes(1); expect(reporter.specDone).toHaveBeenCalledTimes(1);
const event = reporter.specDone.calls.argsFor(0)[0]; const event = reporter.specDone.calls.argsFor(0)[0];
jasmine.debugLog( jasmine.debugLog('Spec result: ' + jasmine.pp(event));
'Spec result: ' + jasmine.private.basicPrettyPrinter(event)
);
expect(event).toEqual(jasmine.objectContaining({ status: 'passed' })); expect(event).toEqual(jasmine.objectContaining({ status: 'passed' }));
jasmine.clock().tick(1); jasmine.clock().tick(1);
@@ -1557,6 +1555,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 +1591,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 +1648,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 +2062,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 +3844,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,18 +13,65 @@ describe('The jasmine namespace', function() {
expect(setDifference(actualKeys, expectedKeys())).toEqual(new Set()); expect(setDifference(actualKeys, expectedKeys())).toEqual(new Set());
}); });
describe('Preventing monkey patching', function() {
const mutable = mutableKeys();
for (const key of expectedKeys()) {
if (mutable.includes(key)) {
it(`allows overwriting of jasmine.${key}`, function() {
const existingVal = jasmineUnderTest[key];
try {
jasmineUnderTest[key] = 'new value';
expect(jasmineUnderTest[key]).toEqual('new value');
} finally {
jasmineUnderTest[key] = existingVal;
}
});
} else {
it(`prevents overwriting of jasmine.${key}`, function() {
const existingVal = jasmineUnderTest[key];
try {
jasmineUnderTest[key] = 'monkey patch';
expect(jasmineUnderTest[key]).toBe(existingVal);
} finally {
// This will be a no-op if the test passed, but will prevent state
// leakage if it failed.
jasmineUnderTest[key] = existingVal;
}
});
}
}
it('allows additions', function() {
try {
jasmineUnderTest.Ajax = 'it worked';
expect(jasmineUnderTest.Ajax).toEqual('it worked');
} finally {
delete jasmineUnderTest.Ajax;
}
});
});
function mutableKeys() {
return [
'MAX_PRETTY_PRINT_ARRAY_LENGTH',
'MAX_PRETTY_PRINT_CHARS',
'MAX_PRETTY_PRINT_DEPTH',
'DEFAULT_TIMEOUT_INTERVAL'
];
}
function expectedKeys() { function expectedKeys() {
// Does not include properties added by requireInterface(), since that isn't // Does not include properties added by requireInterface(), since that isn't
// called by defineJasmineUnderTest.js/nodeDefineJasmineUnderTest.js. // called by defineJasmineUnderTest.js/nodeDefineJasmineUnderTest.js.
const result = new Set([ const result = new Set([
'MAX_PRETTY_PRINT_ARRAY_LENGTH', ...mutableKeys(),
'MAX_PRETTY_PRINT_CHARS',
'MAX_PRETTY_PRINT_DEPTH',
'debugLog', 'debugLog',
'getEnv', 'getEnv',
'isSpy', 'isSpy',
'ParallelReportDispatcher', 'ParallelReportDispatcher',
'private',
'spyOnGlobalErrorsAsync', 'spyOnGlobalErrorsAsync',
'Timer', 'Timer',
'version', 'version',
@@ -53,10 +100,8 @@ describe('The jasmine namespace', function() {
if (typeof window !== 'undefined') { if (typeof window !== 'undefined') {
// jasmine-html.js // jasmine-html.js
result.add('HtmlReporter');
result.add('HtmlReporterV2'); result.add('HtmlReporterV2');
result.add('HtmlReporterV2Urls'); result.add('HtmlReporterV2Urls');
result.add('HtmlSpecFilter');
result.add('QueryString'); result.add('QueryString');
} }

View File

@@ -768,7 +768,16 @@ describe('matchersUtil', function() {
a2[0] = 1; a2[0] = 1;
const diffBuilder = new privateUnderTest.DiffBuilder(); const diffBuilder = new privateUnderTest.DiffBuilder();
expect(matchersUtil.equals(a1, a2, diffBuilder)).toBe(false); expect(matchersUtil.equals(a1, a2, diffBuilder)).toBe(false);
jasmine.debugLog('Diff: ' + diffBuilder.getMessage()); jasmine.debugLog(
'a1 keys: ' + jasmine.pp(privateUnderTest.MatchersUtil.keys(a1))
);
jasmine.debugLog(
'a2 keys: ' + jasmine.pp(privateUnderTest.MatchersUtil.keys(a2))
);
jasmine.debugLog('a1 length:' + a1.length);
jasmine.debugLog('a2 length:' + a2.length);
jasmine.debugLog('a1[0]: ' + a1[0]);
jasmine.debugLog('a2[0]: ' + a2[0]);
} }
); );

View File

@@ -1,9 +1,11 @@
(function() { (function() {
// By the time onload is called, jasmineRequire will be redefined to point // By the time onload is called, getJasmineRequireObj() and
// to the Jasmine source files (and not jasmine.js). So re-require // getJasmineHtmlRequireObj() will be redefined to point
window.jasmineUnderTest = jasmineRequire.core(jasmineRequire); // to the Jasmine source files (and not jasmine.js). So re-require.
jasmineRequire.html(jasmineUnderTest); const jasmineRequire = getJasmineRequireObj();
const coreUnderTest = jasmineRequire.core(jasmineRequire);
window.jasmineUnderTest = coreUnderTest.jasmine;
window.privateUnderTest = coreUnderTest.private;
// Alias the private namespace so tests can be less verbose getJasmineHtmlRequireObj().html(jasmineUnderTest, privateUnderTest);
window.privateUnderTest = window.jasmineUnderTest.private;
})(); })();

View File

@@ -42,9 +42,9 @@
: 'Expected runnable "' + : 'Expected runnable "' +
fullName + fullName +
'" to have failures ' + '" to have failures ' +
jasmine.private.basicPrettyPrinter(expectedFailures) + jasmine.pp(expectedFailures) +
' but it had ' + ' but it had ' +
jasmine.private.basicPrettyPrinter(foundFailures) jasmine.pp(foundFailures)
}; };
} }
}; };

View File

@@ -0,0 +1,67 @@
globalThis.isNonMonkeyPatchableClass = function(ctor, makeInstance) {
describe('Monkey patching prevention', function() {
it(`prevents overwriting ${ctor.name}.prototype`, function() {
const existing = ctor.prototype;
try {
ctor.prototype = {};
expect(ctor.prototype).toBe(existing);
} finally {
// This will be a no-op if the test passed, but will prevent state
// leakage if it failed.
ctor.prototype = existing;
}
});
it("prevents overwriting an instance's prototype", function() {
const instance = makeInstance();
let thrown;
// The message varies from browser to browser, so we can't rely on it
try {
instance.__proto__ = {};
} catch (e) {
thrown = e;
}
expect(thrown).toBeInstanceOf(TypeError);
});
it('prevents overwriting prototype properties', function() {
let any = false;
for (const k of Object.getOwnPropertyNames(ctor.prototype)) {
any = true;
const existingValue = ctor.prototype[k];
try {
ctor.prototype[k] = {};
expect(ctor.prototype[k])
.withContext(k)
.toBe(existingValue);
} finally {
// This will be a no-op if the test passed, but will prevent state
// leakage if it failed.
ctor.prototype[k] = existingValue;
}
}
expect(any).toBe(true);
});
it('prevents overriding prototype properties', function() {
const instance = makeInstance();
let any = false;
for (const k of Object.getOwnPropertyNames(ctor.prototype)) {
any = true;
instance[k] = {};
expect(instance[k])
.withContext(k)
.toBe(ctor.prototype[k]);
}
expect(any).toBe(true);
});
});
};

View File

@@ -7,24 +7,29 @@
'../../src/core/requireCore.js' '../../src/core/requireCore.js'
)); ));
// Individual source files call getJasmineRequireObj. It's normally defined
// by requireCore.js which is concatenated into jasmine.js before other source
// files. Since we're bypassing that mechanism, we need to provide our own.
global.getJasmineRequireObj = function() { global.getJasmineRequireObj = function() {
return jasmineUnderTestRequire; return jasmineUnderTestRequire;
}; };
function getSourceFiles() { const srcFiles = [
const globs = ['../../src/core/**/*.js', '../../src/version.js']; ...glob.sync('../../src/core/**/*.js', {
const srcFiles = globs.flatMap(g => glob.sync(g, { cwd: __dirname })); ignore: '../../src/core/requireSuffix.js',
cwd: __dirname
}),
'../../src/version.js',
'../../src/core/requireCore.js'
];
for (const file of srcFiles) { for (const file of srcFiles) {
require(file); require(file);
}
} }
getSourceFiles(); delete global.getJasmineRequireObj;
global.jasmineUnderTest = jasmineUnderTestRequire.core(
jasmineUnderTestRequire
);
// Alias the private namespace so tests can be less verbose const built = jasmineUnderTestRequire.core(jasmineUnderTestRequire);
global.privateUnderTest = global.jasmineUnderTest.private; global.jasmineUnderTest = built.jasmine;
global.privateUnderTest = built.private;
})(); })();

File diff suppressed because it is too large Load Diff

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',
@@ -1440,4 +1396,6 @@ describe('HtmlReporterV2', function() {
}); });
}); });
}); });
isNonMonkeyPatchableClass(jasmineUnderTest.HtmlReporterV2, setup);
}); });

View File

@@ -63,4 +63,8 @@ describe('HtmlReporterV2Urls', function() {
return qs; return qs;
} }
}); });
isNonMonkeyPatchableClass(jasmineUnderTest.HtmlReporterV2Urls, function() {
return new jasmineUnderTest.HtmlReporterV2Urls({});
});
}); });

View File

@@ -1,30 +0,0 @@
describe('HtmlSpecFilter', function() {
beforeEach(function() {
spyOn(jasmineUnderTest.getEnv(), 'deprecated');
});
it('emits a deprecation warning', function() {
new jasmineUnderTest.HtmlSpecFilter();
expect(jasmineUnderTest.getEnv().deprecated).toHaveBeenCalledWith(
'HtmlReporter and HtmlSpecFilter are deprecated. Use HtmlReporterV2 instead.'
);
});
it('should match when no string is provided', function() {
const specFilter = new jasmineUnderTest.HtmlSpecFilter();
expect(specFilter.matches('foo')).toBe(true);
expect(specFilter.matches('*bar')).toBe(true);
});
it('should only match the provided string', function() {
const specFilter = new jasmineUnderTest.HtmlSpecFilter({
filterString: function() {
return 'foo';
}
});
expect(specFilter.matches('foo')).toBe(true);
expect(specFilter.matches('bar')).toBe(false);
});
});

View File

@@ -77,4 +77,12 @@ describe('QueryString', function() {
expect(queryString.getParam('baz')).toBeFalsy(); expect(queryString.getParam('baz')).toBeFalsy();
}); });
}); });
isNonMonkeyPatchableClass(jasmineUnderTest.QueryString, function() {
return new jasmineUnderTest.QueryString({
getWindowLocation: function() {
return { search: '' };
}
});
});
}); });

View File

@@ -77,7 +77,7 @@ describe('npm package', function() {
}); });
it('has bootFiles', function() { it('has bootFiles', function() {
expect(this.packagedCore.files.bootFiles).toEqual(['boot0.js', 'boot1.js']); expect(this.packagedCore.files.bootFiles).toEqual(['boot.js']);
for (const fileName of this.packagedCore.files.bootFiles) { for (const fileName of this.packagedCore.files.bootFiles) {
expect(fileName).toExistInPath(this.packagedCore.files.bootDir); expect(fileName).toExistInPath(this.packagedCore.files.bootDir);

View File

@@ -1,4 +1,3 @@
/* eslint-env node, es6 */
const path = require('path'), const path = require('path'),
jasmineBrowser = require('jasmine-browser-runner'), jasmineBrowser = require('jasmine-browser-runner'),
jasmineCore = require('../../lib/jasmine-core'); jasmineCore = require('../../lib/jasmine-core');

View File

@@ -1,4 +1,3 @@
/* eslint-env node, es6 */
module.exports = { module.exports = {
srcDir: 'src', srcDir: 'src',
srcFiles: [ srcFiles: [
@@ -7,13 +6,14 @@ module.exports = {
'core/util.js', 'core/util.js',
'core/Spec.js', 'core/Spec.js',
'core/Env.js', 'core/Env.js',
'core/JsApiReporter.js',
'core/PrettyPrinter.js', 'core/PrettyPrinter.js',
'core/Suite.js', 'core/Suite.js',
'core/**/*.js', 'core/**/*.js',
'html/**/*.js', 'html/**/*.js',
'**/*.js', '**/*.js',
'!boot/**.js' '!boot/**.js',
'!core/requireSuffix.js',
'!html/requireSuffix.js'
], ],
specDir: 'spec', specDir: 'spec',
specFiles: ['**/*[Ss]pec.js', '!npmPackage/**/*'], specFiles: ['**/*[Ss]pec.js', '!npmPackage/**/*'],
@@ -24,6 +24,7 @@ module.exports = {
'helpers/domHelpers.js', 'helpers/domHelpers.js',
'helpers/integrationMatchers.js', 'helpers/integrationMatchers.js',
'helpers/callerFilenameShim.js', 'helpers/callerFilenameShim.js',
'helpers/monkeyPatchingSpecs.js',
'helpers/defineJasmineUnderTest.js', 'helpers/defineJasmineUnderTest.js',
'helpers/resetEnv.js' 'helpers/resetEnv.js'
], ],

View File

@@ -10,6 +10,7 @@
"helpers/integrationMatchers.js", "helpers/integrationMatchers.js",
"helpers/callerFilenameShim.js", "helpers/callerFilenameShim.js",
"helpers/overrideConsoleLogForCircleCi.js", "helpers/overrideConsoleLogForCircleCi.js",
"helpers/monkeyPatchingSpecs.js",
"helpers/nodeDefineJasmineUnderTest.js", "helpers/nodeDefineJasmineUnderTest.js",
"helpers/resetEnv.js" "helpers/resetEnv.js"
], ],

View File

@@ -8,10 +8,10 @@
<link rel="stylesheet" href="lib/jasmine-<%= jasmineVersion %>/jasmine.css"> <link rel="stylesheet" href="lib/jasmine-<%= jasmineVersion %>/jasmine.css">
<script src="lib/jasmine-<%= jasmineVersion %>/jasmine.js"></script> <script src="lib/jasmine-<%= jasmineVersion %>/jasmine.js"></script>
<script src="lib/jasmine-<%= jasmineVersion %>/jasmine-html.js"></script>
<script src="lib/jasmine-<%= jasmineVersion %>/boot0.js"></script> <script src="lib/jasmine-<%= jasmineVersion %>/boot0.js"></script>
<script src="lib/jasmine-<%= jasmineVersion %>/jasmine-html.js"></script>
<!-- optional: include a file here that configures the Jasmine env --> <!-- optional: include a file here that configures the Jasmine env -->
<script src="lib/jasmine-<%= jasmineVersion %>/boot1.js"></script> <script src="lib/jasmine-<%= jasmineVersion %>/boot.js"></script>
<!-- include source files here... --> <!-- include source files here... -->
<script src="src/Player.js"></script> <script src="src/Player.js"></script>

27
src/boot/boot.js Normal file
View File

@@ -0,0 +1,27 @@
'use strict';
(function() {
const env = jasmine.getEnv();
const urls = new jasmine.HtmlReporterV2Urls();
/**
* Configures Jasmine based on the current set of query parameters. This
* supports all parameters set by the HTML reporter as well as
* spec=partialPath, which filters out specs whose paths don't contain the
* parameter.
*/
env.configure(urls.configFromCurrentUrl());
const currentWindowOnload = window.onload;
window.onload = function() {
if (currentWindowOnload) {
currentWindowOnload();
}
// The HTML reporter needs to be set up here so it can access the DOM. Other
// reporters can be added at any time before env.execute() is called.
const htmlReporter = new jasmine.HtmlReporterV2({ env, urls });
env.addReporter(htmlReporter);
env.execute();
};
})();

View File

@@ -1,44 +0,0 @@
'use strict';
/**
This file starts the process of "booting" Jasmine. It initializes Jasmine,
makes its globals available, and creates the env. This file should be loaded
after `jasmine.js` and `jasmine_html.js`, but before `boot1.js` or any project
source files or spec files are loaded.
*/
(function() {
const jasmineRequire = window.jasmineRequire || require('./jasmine.js');
/**
* ## Require &amp; Instantiate
*
* Require Jasmine's core files. Specifically, this requires and attaches all of Jasmine's code to the `jasmine` reference.
*/
const jasmine = jasmineRequire.core(jasmineRequire),
global = jasmine.getGlobal();
global.jasmine = jasmine;
/**
* Since this is being run in a browser and the results should populate to an HTML page, require the HTML-specific Jasmine code, injecting the same reference.
*/
jasmineRequire.html(jasmine);
/**
* Create the Jasmine environment. This is used to run all specs in a project.
*/
const env = jasmine.getEnv();
/**
* ## The Global Interface
*
* Build up the functions that will be exposed as the Jasmine public interface. A project can customize, rename or alias any of these functions as desired, provided the implementation remains unchanged.
*/
const jasmineInterface = jasmineRequire.interface(jasmine, env);
/**
* Add all of the Jasmine global/public interface to the global scope, so a project can use the public interface directly. For example, calling `describe` in specs instead of `jasmine.getEnv().describe`.
*/
for (const property in jasmineInterface) {
global[property] = jasmineInterface[property];
}
})();

View File

@@ -1,59 +0,0 @@
'use strict';
/**
This file finishes 'booting' Jasmine, performing all of the necessary
initialization before executing the loaded environment and all of a project's
specs. This file should be loaded after `boot0.js` but before any project
source files or spec files are loaded. Thus this file can also be used to
customize Jasmine for a project.
If a project is using Jasmine via the standalone distribution, this file can
be customized directly. If you only wish to configure the Jasmine env, you
can load another file that calls `jasmine.getEnv().configure({...})`
after `boot0.js` is loaded and before this file is loaded.
*/
(function() {
const env = jasmine.getEnv();
const urls = new jasmine.HtmlReporterV2Urls();
/**
* ## Reporters
* The `HtmlReporter` builds all of the HTML UI for the runner page. This reporter paints the dots, stars, and x's for specs, as well as all spec names and all failures (if any).
*/
const htmlReporter = new jasmine.HtmlReporterV2({
env,
urls,
getContainer() {
return document.body;
}
});
/**
* The `jsApiReporter` also receives spec results, and is used by any environment that needs to extract the results from JavaScript.
*/
env.addReporter(jsApiReporter);
env.addReporter(htmlReporter);
/**
* Configures Jasmine based on the current set of query parameters. This
* supports all parameters set by the HTML reporter as well as
* spec=partialPath, which filters out specs whose paths don't contain the
* parameter.
*/
env.configure(urls.configFromCurrentUrl());
/**
* ## Execution
*
* Replace the browser window's `onload`, ensure it's called, and then run all of the loaded specs. This includes initializing the `HtmlReporter` instance and then executing the loaded Jasmine environment. All of this will happen after all of the specs are loaded.
*/
const currentWindowOnload = window.onload;
window.onload = function() {
if (currentWindowOnload) {
currentWindowOnload();
}
htmlReporter.initialize();
env.execute();
};
})();

View File

@@ -1,69 +1,25 @@
'use strict'; 'use strict';
/** const path = require('path');
* Note: Only available on Node. const fs = require('fs');
* @module jasmine-core const {
*/ globals,
installGlobals,
version,
private$
} = require('./jasmine-core/jasmine.js');
const jasmineRequire = require('./jasmine-core/jasmine.js'); function reset() {
module.exports = jasmineRequire; private$.currentEnv_ = null;
const env = jasmine.getEnv({ suppressLoadErrors: true });
const bootWithoutGlobals = (function() { rebindInterface(env);
let jasmine, jasmineInterface; }
return function bootWithoutGlobals(reinitialize) {
if (!jasmineInterface || reinitialize === true) {
jasmine = jasmineRequire.core(jasmineRequire);
const env = jasmine.getEnv({ suppressLoadErrors: true });
jasmineInterface = jasmineRequire.interface(jasmine, env);
}
return { jasmine, jasmineInterface };
};
})();
/**
* Boots a copy of Jasmine and returns an object as described in {@link jasmine}.
* @param {boolean} [reinitialize=true] Whether to create a new copy of Jasmine if one already exists
* @type {function}
* @return {jasmine}
*/
module.exports.boot = function(reinitialize) {
if (reinitialize === undefined) {
reinitialize = true;
}
const { jasmine, jasmineInterface } = bootWithoutGlobals(reinitialize);
for (const k in jasmineInterface) {
global[k] = jasmineInterface[k];
}
return jasmine;
};
/**
* Boots a copy of Jasmine and returns an object containing the properties
* that would normally be added to the global object. If noGlobals is called
* multiple times, the same object is returned every time.
*
* @example
* const {describe, beforeEach, it, expect, jasmine} = require('jasmine-core').noGlobals();
*/
module.exports.noGlobals = function() {
const { jasmineInterface } = bootWithoutGlobals(false);
return jasmineInterface;
};
const path = require('path'),
fs = require('fs');
const rootPath = path.join(__dirname, 'jasmine-core'), const rootPath = path.join(__dirname, 'jasmine-core'),
bootFiles = ['boot0.js', 'boot1.js'], bootFiles = ['boot.js'],
legacyBootFiles = ['boot.js'],
cssFiles = [], cssFiles = [],
jsFiles = [], jsFiles = [],
jsFilesToSkip = ['jasmine.js'].concat(bootFiles, legacyBootFiles); jsFilesToSkip = ['jasmine.js'].concat(bootFiles);
fs.readdirSync(rootPath).forEach(function(file) { fs.readdirSync(rootPath).forEach(function(file) {
if (fs.statSync(path.join(rootPath, file)).isFile()) { if (fs.statSync(path.join(rootPath, file)).isFile()) {
@@ -80,12 +36,40 @@ fs.readdirSync(rootPath).forEach(function(file) {
} }
}); });
module.exports.files = { /**
self: __filename, * Note: Only available on Node.
path: rootPath, *
bootDir: rootPath, * In addition to the members documented here, this module's exports include all
bootFiles: bootFiles, * {@link globals}.
cssFiles: cssFiles, * @module jasmine-core
jsFiles: ['jasmine.js'].concat(jsFiles), */
imagesDir: path.join(__dirname, '../images') module.exports = {
...globals,
/**
* Copies Jasmine globals (jasmine, describe, it, etc) to the specified
* object or to globalThis.
* @function
* @param {object} [dest] - The object to copy globals to.
*/
installGlobals,
/**
* Returns the jasmine-core version.
* @function
*/
version,
/**
* Resets all of jasmine-core's state, including removing specs, suites, and
* reporters, and resetting configuration to the default.
* @function
*/
reset,
files: {
self: __filename,
path: rootPath,
bootDir: rootPath,
bootFiles: bootFiles,
cssFiles: cssFiles,
jsFiles: ['jasmine.js'].concat(jsFiles),
imagesDir: path.join(__dirname, '../images')
}
}; };

View File

@@ -1,4 +1,4 @@
getJasmineRequireObj().CallTracker = function(j$) { getJasmineRequireObj().CallTracker = function(j$, private$) {
'use strict'; 'use strict';
/** /**
@@ -125,9 +125,7 @@ getJasmineRequireObj().CallTracker = function(j$) {
* @param {Function} [argsCloner] A function to use to clone the arguments. Defaults to a shallow cloning function. * @param {Function} [argsCloner] A function to use to clone the arguments. Defaults to a shallow cloning function.
* @function * @function
*/ */
this.saveArgumentsByValue = function( this.saveArgumentsByValue = function(argsCloner = private$.util.cloneArgs) {
argsCloner = j$.private.util.cloneArgs
) {
opts.cloneArgs = true; opts.cloneArgs = true;
opts.argsCloner = argsCloner; opts.argsCloner = argsCloner;
}; };

View File

@@ -1,4 +1,4 @@
getJasmineRequireObj().Clock = function() { getJasmineRequireObj().Clock = function(j$, private$) {
'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;
Object.freeze(this);
return this; return this;
// Advances the Clock's time until the mode changes. // Advances the Clock's time until the mode changes.
@@ -344,5 +347,7 @@ callbacks to execute _before_ running the next one.
}; };
Clock.IsMockClockTimingFn = IsMockClockTimingFn; Clock.IsMockClockTimingFn = IsMockClockTimingFn;
Object.freeze(Clock);
Object.freeze(Clock.prototype);
return Clock; return Clock;
}; };

View File

@@ -1,4 +1,4 @@
getJasmineRequireObj().CompleteOnFirstErrorSkipPolicy = function(j$) { getJasmineRequireObj().CompleteOnFirstErrorSkipPolicy = function(j$, private$) {
'use strict'; 'use strict';
function CompleteOnFirstErrorSkipPolicy(queueableFns) { function CompleteOnFirstErrorSkipPolicy(queueableFns) {

View File

@@ -1,4 +1,4 @@
getJasmineRequireObj().Configuration = function(j$) { getJasmineRequireObj().Configuration = function(j$, private$) {
'use strict'; 'use strict';
/** /**

View File

@@ -1,4 +1,4 @@
getJasmineRequireObj().DelayedFunctionScheduler = function(j$) { getJasmineRequireObj().DelayedFunctionScheduler = function(j$, private$) {
'use strict'; 'use strict';
function DelayedFunctionScheduler() { function DelayedFunctionScheduler() {

View File

@@ -1,4 +1,4 @@
getJasmineRequireObj().Deprecator = function(j$) { getJasmineRequireObj().Deprecator = function(j$, private$) {
'use strict'; 'use strict';
function Deprecator(topSuite) { function Deprecator(topSuite) {
@@ -25,7 +25,7 @@ getJasmineRequireObj().Deprecator = function(j$) {
) { ) {
options = options || {}; options = options || {};
if (!this.verbose_ && !j$.private.isError(deprecation)) { if (!this.verbose_ && !private$.isError(deprecation)) {
if (this.toSuppress_.indexOf(deprecation) !== -1) { if (this.toSuppress_.indexOf(deprecation) !== -1) {
return; return;
} }
@@ -37,7 +37,7 @@ getJasmineRequireObj().Deprecator = function(j$) {
}; };
Deprecator.prototype.log_ = function(runnable, deprecation, options) { Deprecator.prototype.log_ = function(runnable, deprecation, options) {
if (j$.private.isError(deprecation)) { if (private$.isError(deprecation)) {
// eslint-disable-next-line no-console // eslint-disable-next-line no-console
console.error(deprecation); console.error(deprecation);
return; return;
@@ -66,7 +66,7 @@ getJasmineRequireObj().Deprecator = function(j$) {
}; };
Deprecator.prototype.stackTrace_ = function() { Deprecator.prototype.stackTrace_ = function() {
const formatter = new j$.private.ExceptionFormatter(); const formatter = new private$.ExceptionFormatter();
return formatter.stack(new Error()).replace(/^Error\n/m, ''); return formatter.stack(new Error()).replace(/^Error\n/m, '');
}; };
@@ -75,7 +75,7 @@ getJasmineRequireObj().Deprecator = function(j$) {
runnable = this.topSuite_; runnable = this.topSuite_;
} }
if (j$.private.isError(deprecation)) { if (private$.isError(deprecation)) {
runnable.addDeprecationWarning(deprecation); runnable.addDeprecationWarning(deprecation);
return; return;
} }

View File

@@ -1,4 +1,4 @@
getJasmineRequireObj().Env = function(j$) { getJasmineRequireObj().Env = function(j$, private$) {
'use strict'; 'use strict';
const DEFAULT_IT_DESCRIBE_STACK_DEPTH = 3; const DEFAULT_IT_DESCRIBE_STACK_DEPTH = 3;
@@ -15,18 +15,18 @@ getJasmineRequireObj().Env = function(j$) {
envOptions = envOptions || {}; envOptions = envOptions || {};
const self = this; const self = this;
const GlobalErrors = envOptions.GlobalErrors || j$.private.GlobalErrors; const GlobalErrors = envOptions.GlobalErrors || private$.GlobalErrors;
const global = envOptions.global || j$.getGlobal(); const global = envOptions.global || j$.getGlobal();
const realSetTimeout = global.setTimeout; const realSetTimeout = global.setTimeout;
const realClearTimeout = global.clearTimeout; const realClearTimeout = global.clearTimeout;
const stackClearer = j$.private.getStackClearer(global); const stackClearer = private$.getStackClearer(global);
this.clock = new j$.private.Clock( this.clock = new private$.Clock(
global, global,
function() { function() {
return new j$.private.DelayedFunctionScheduler(); return new private$.DelayedFunctionScheduler();
}, },
new j$.private.MockDate(global) new private$.MockDate(global)
); );
const globalErrors = new GlobalErrors( const globalErrors = new GlobalErrors(
@@ -54,7 +54,7 @@ getJasmineRequireObj().Env = function(j$) {
}; };
})(); })();
const runableResources = new j$.private.RunableResources({ const runableResources = new private$.RunableResources({
getCurrentRunableId: function() { getCurrentRunableId: function() {
const r = runner.currentRunable(); const r = runner.currentRunable();
return r ? r.id : null; return r ? r.id : null;
@@ -67,7 +67,7 @@ getJasmineRequireObj().Env = function(j$) {
let runner; let runner;
let parallelLoadingState = null; // 'specs', 'helpers', or null for non-parallel let parallelLoadingState = null; // 'specs', 'helpers', or null for non-parallel
const config = new j$.private.Configuration(); const config = new private$.Configuration();
if (!envOptions.suppressLoadErrors) { if (!envOptions.suppressLoadErrors) {
installGlobalErrors(); installGlobalErrors();
@@ -137,11 +137,11 @@ getJasmineRequireObj().Env = function(j$) {
runableResources.customObjectFormatters().push(formatter); runableResources.customObjectFormatters().push(formatter);
}; };
j$.private.Expectation.addCoreMatchers(j$.private.matchers); private$.Expectation.addCoreMatchers(private$.matchers);
j$.private.Expectation.addAsyncCoreMatchers(j$.private.asyncMatchers); private$.Expectation.addAsyncCoreMatchers(private$.asyncMatchers);
const expectationFactory = function(actual, spec) { const expectationFactory = function(actual, spec) {
return j$.private.Expectation.factory({ return private$.Expectation.factory({
matchersUtil: runableResources.makeMatchersUtil(), matchersUtil: runableResources.makeMatchersUtil(),
customMatchers: runableResources.customMatchers(), customMatchers: runableResources.customMatchers(),
actual: actual, actual: actual,
@@ -174,7 +174,7 @@ getJasmineRequireObj().Env = function(j$) {
}; };
const throwUnlessFactory = function(actual, spec) { const throwUnlessFactory = function(actual, spec) {
return j$.private.Expectation.factory({ return private$.Expectation.factory({
matchersUtil: runableResources.makeMatchersUtil(), matchersUtil: runableResources.makeMatchersUtil(),
customMatchers: runableResources.customMatchers(), customMatchers: runableResources.customMatchers(),
actual: actual, actual: actual,
@@ -183,7 +183,7 @@ getJasmineRequireObj().Env = function(j$) {
}; };
const throwUnlessAsyncFactory = function(actual, spec) { const throwUnlessAsyncFactory = function(actual, spec) {
return j$.private.Expectation.asyncFactory({ return private$.Expectation.asyncFactory({
matchersUtil: runableResources.makeMatchersUtil(), matchersUtil: runableResources.makeMatchersUtil(),
customAsyncMatchers: runableResources.customAsyncMatchers(), customAsyncMatchers: runableResources.customAsyncMatchers(),
actual: actual, actual: actual,
@@ -198,7 +198,7 @@ getJasmineRequireObj().Env = function(j$) {
error.matcherName !== undefined && error.passed !== undefined; error.matcherName !== undefined && error.passed !== undefined;
const result = isExpectationResult const result = isExpectationResult
? error ? error
: j$.private.buildExpectationResult({ : private$.buildExpectationResult({
error, error,
passed: false, passed: false,
matcherName: '', matcherName: '',
@@ -259,7 +259,7 @@ getJasmineRequireObj().Env = function(j$) {
} }
const asyncExpectationFactory = function(actual, spec, runableType) { const asyncExpectationFactory = function(actual, spec, runableType) {
return j$.private.Expectation.asyncFactory({ return private$.Expectation.asyncFactory({
matchersUtil: runableResources.makeMatchersUtil(), matchersUtil: runableResources.makeMatchersUtil(),
customAsyncMatchers: runableResources.customAsyncMatchers(), customAsyncMatchers: runableResources.customAsyncMatchers(),
actual: actual, actual: actual,
@@ -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;
@@ -315,10 +318,10 @@ getJasmineRequireObj().Env = function(j$) {
(runner.currentRunable() || topSuite).handleException(e); (runner.currentRunable() || topSuite).handleException(e);
}; };
new j$.private.QueueRunner(options).execute(); new private$.QueueRunner(options).execute();
} }
const suiteBuilder = new j$.private.SuiteBuilder({ const suiteBuilder = new private$.SuiteBuilder({
env: this, env: this,
expectationFactory, expectationFactory,
asyncExpectationFactory, asyncExpectationFactory,
@@ -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 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
@@ -346,23 +350,23 @@ getJasmineRequireObj().Env = function(j$) {
* @interface Reporter * @interface Reporter
* @see custom_reporter * @see custom_reporter
*/ */
reportDispatcher = new j$.private.ReportDispatcher( reportDispatcher = new private$.ReportDispatcher(
j$.private.reporterEvents, private$.reporterEvents,
function(options) { function(options) {
options.SkipPolicy = j$.private.NeverSkipPolicy; options.SkipPolicy = private$.NeverSkipPolicy;
return runQueue(options); return runQueue(options);
}, },
recordLateError recordLateError
); );
runner = new j$.private.Runner({ runner = new private$.Runner({
topSuite, topSuite,
totalSpecsDefined: () => suiteBuilder.totalSpecsDefined, totalSpecsDefined: () => suiteBuilder.totalSpecsDefined,
focusedRunables: () => suiteBuilder.focusedRunables, focusedRunables: () => suiteBuilder.focusedRunables,
runableResources, runableResources,
reportDispatcher, reportDispatcher,
runQueue, runQueue,
TreeProcessor: j$.private.TreeProcessor, TreeProcessor: private$.TreeProcessor,
globalErrors, globalErrors,
getConfig: () => config getConfig: () => config
}); });
@@ -407,7 +411,7 @@ getJasmineRequireObj().Env = function(j$) {
// Karma incorrectly loads jasmine-core as an ES module. It isn't one, // Karma incorrectly loads jasmine-core as an ES module. It isn't one,
// and we don't test that configuration. Warn about it. // and we don't test that configuration. Warn about it.
if (j$.private.loadedAsBrowserEsm) { if (private$.loadedAsBrowserEsm) {
this.deprecated( this.deprecated(
"jasmine-core isn't an ES module but it was loaded as one. This is not a supported configuration." "jasmine-core isn't an ES module but it was loaded as one. This is not a supported configuration."
); );
@@ -536,7 +540,7 @@ getJasmineRequireObj().Env = function(j$) {
try { try {
const maybePromise = fn(spy); const maybePromise = fn(spy);
if (!j$.private.isPromiseLike(maybePromise)) { if (!private$.isPromiseLike(maybePromise)) {
throw new Error( throw new Error(
'The callback to spyOnGlobalErrorsAsync must be an async or promise-returning function' 'The callback to spyOnGlobalErrorsAsync must be an async or promise-returning function'
); );
@@ -779,7 +783,7 @@ getJasmineRequireObj().Env = function(j$) {
}; };
this.pending = function(message) { this.pending = function(message) {
let fullMessage = j$.private.Spec.pendingSpecExceptionMessage; let fullMessage = private$.Spec.pendingSpecExceptionMessage;
if (message) { if (message) {
fullMessage += message; fullMessage += message;
} }
@@ -798,7 +802,7 @@ getJasmineRequireObj().Env = function(j$) {
message += ': '; message += ': ';
if (error.message) { if (error.message) {
message += error.message; message += error.message;
} else if (j$.private.isString(error)) { } else if (private$.isString(error)) {
message += error; message += error;
} else { } else {
// pretty print all kind of objects. This includes arrays. // pretty print all kind of objects. This includes arrays.
@@ -821,18 +825,29 @@ getJasmineRequireObj().Env = function(j$) {
} }
}; };
this.pp = function(value) {
const pp = runner.currentRunable()
? runableResources.makePrettyPrinter()
: private$.basicPrettyPrinter;
return pp(value);
};
this.cleanup_ = function() { this.cleanup_ = function() {
uninstallGlobalErrors(); uninstallGlobalErrors();
}; };
Object.freeze(this);
} }
function indirectCallerFilename(depth) { function indirectCallerFilename(depth) {
const frames = new j$.private.StackTrace(new Error()).frames; const frames = new private$.StackTrace(new Error()).frames;
// The specified frame should always exist except in Jasmine's own tests, // The specified frame should always exist except in Jasmine's own tests,
// which bypass the global it/describe layer, but could be absent in case // which bypass the global it/describe layer, but could be absent in case
// of misconfiguration. Don't crash if it's absent. // of misconfiguration. Don't crash if it's absent.
return frames[depth] && frames[depth].file; return frames[depth] && frames[depth].file;
} }
Object.freeze(Env);
Object.freeze(Env.prototype);
return Env; return Env;
}; };

View File

@@ -1,4 +1,4 @@
getJasmineRequireObj().ExceptionFormatter = function(j$) { getJasmineRequireObj().ExceptionFormatter = function(j$, private$) {
'use strict'; 'use strict';
const ignoredProperties = [ const ignoredProperties = [
@@ -11,12 +11,13 @@ getJasmineRequireObj().ExceptionFormatter = function(j$) {
'lineNumber', 'lineNumber',
'column', 'column',
'description', 'description',
'jasmineMessage' 'jasmineMessage',
'errors'
]; ];
function ExceptionFormatter(options) { function ExceptionFormatter(options) {
const jasmineFile = const jasmineFile =
(options && options.jasmineFile) || j$.private.util.jasmineFile(); (options && options.jasmineFile) || private$.util.jasmineFile();
this.message = function(error) { this.message = function(error) {
let message = ''; let message = '';
@@ -60,7 +61,7 @@ getJasmineRequireObj().ExceptionFormatter = function(j$) {
lines.pop(); lines.pop();
} }
const stackTrace = new j$.private.StackTrace(error); const stackTrace = new private$.StackTrace(error);
lines = lines.concat(filterJasmine(stackTrace)); lines = lines.concat(filterJasmine(stackTrace));
if (messageHandling === 'require') { if (messageHandling === 'require') {
@@ -77,6 +78,19 @@ getJasmineRequireObj().ExceptionFormatter = function(j$) {
lines = lines.concat(substack); lines = lines.concat(substack);
} }
if (Array.isArray(error.errors)) {
for (let i = 0; i < error.errors.length; i++) {
if (error.errors[i] instanceof Error) {
lines.push('');
const substack = this.stack_(error.errors[i], {
messageHandling: 'require'
});
substack[0] = 'Error ' + (i + 1) + ': ' + substack[0];
lines = lines.concat(substack.map(x => ' ' + x));
}
}
}
return lines; return lines;
}; };
@@ -114,7 +128,7 @@ getJasmineRequireObj().ExceptionFormatter = function(j$) {
if (!empty) { if (!empty) {
return ( return (
'error properties: ' + j$.private.basicPrettyPrinter(result) + '\n' 'error properties: ' + private$.basicPrettyPrinter(result) + '\n'
); );
} }

View File

@@ -1,4 +1,4 @@
getJasmineRequireObj().Expectation = function(j$) { getJasmineRequireObj().Expectation = function(j$, private$) {
'use strict'; 'use strict';
/** /**
@@ -6,7 +6,7 @@ getJasmineRequireObj().Expectation = function(j$) {
* @namespace matchers * @namespace matchers
*/ */
function Expectation(options) { function Expectation(options) {
this.expector = new j$.private.Expector(options); this.expector = new private$.Expector(options);
const customMatchers = options.customMatchers || {}; const customMatchers = options.customMatchers || {};
for (const matcherName in customMatchers) { for (const matcherName in customMatchers) {
@@ -82,7 +82,7 @@ getJasmineRequireObj().Expectation = function(j$) {
* @namespace async-matchers * @namespace async-matchers
*/ */
function AsyncExpectation(options) { function AsyncExpectation(options) {
this.expector = new j$.private.Expector(options); this.expector = new private$.Expector(options);
const customAsyncMatchers = options.customAsyncMatchers || {}; const customAsyncMatchers = options.customAsyncMatchers || {};
for (const matcherName in customAsyncMatchers) { for (const matcherName in customAsyncMatchers) {
@@ -175,7 +175,7 @@ getJasmineRequireObj().Expectation = function(j$) {
function negatedFailureMessage(result, matcherName, args, matchersUtil) { function negatedFailureMessage(result, matcherName, args, matchersUtil) {
if (result.message) { if (result.message) {
if (j$.private.isFunction(result.message)) { if (private$.isFunction(result.message)) {
return result.message(); return result.message();
} else { } else {
return result.message; return result.message;
@@ -220,7 +220,7 @@ getJasmineRequireObj().Expectation = function(j$) {
return function(actual) { return function(actual) {
const matcherArgs = arguments; const matcherArgs = arguments;
return j$.private.isPending(actual).then(function(isPending) { return private$.isPending(actual).then(function(isPending) {
if (isPending) { if (isPending) {
return { return {
pass: false, pass: false,

View File

@@ -1,4 +1,4 @@
getJasmineRequireObj().Expector = function(j$) { getJasmineRequireObj().Expector = function(j$, private$) {
'use strict'; 'use strict';
function Expector(options) { function Expector(options) {
@@ -7,7 +7,7 @@ getJasmineRequireObj().Expector = function(j$) {
}; };
this.actual = options.actual; this.actual = options.actual;
this.addExpectationResult = options.addExpectationResult || function() {}; this.addExpectationResult = options.addExpectationResult || function() {};
this.filters = new j$.private.ExpectationFilterChain(); this.filters = new private$.ExpectationFilterChain();
} }
Expector.prototype.instantiateMatcher = function( Expector.prototype.instantiateMatcher = function(
@@ -41,7 +41,7 @@ getJasmineRequireObj().Expector = function(j$) {
this.matchersUtil, this.matchersUtil,
args args
); );
} else if (j$.private.isFunction(result.message)) { } else if (private$.isFunction(result.message)) {
return result.message(); return result.message();
} else { } else {
return result.message; return result.message;

View File

@@ -1,4 +1,4 @@
getJasmineRequireObj().GlobalErrors = function(j$) { getJasmineRequireObj().GlobalErrors = function(j$, private$) {
'use strict'; 'use strict';
class GlobalErrors { class GlobalErrors {
@@ -26,7 +26,7 @@ getJasmineRequireObj().GlobalErrors = function(j$) {
if ( if (
global.process && global.process &&
global.process.listeners && global.process.listeners &&
j$.private.isFunction(global.process.on) private$.isFunction(global.process.on)
) { ) {
this.#adapter = new NodeAdapter(global, dispatch); this.#adapter = new NodeAdapter(global, dispatch);
} else { } else {
@@ -183,7 +183,7 @@ getJasmineRequireObj().GlobalErrors = function(j$) {
const jasmineMessage = 'Unhandled promise rejection: ' + event.reason; const jasmineMessage = 'Unhandled promise rejection: ' + event.reason;
let reason; let reason;
if (j$.private.isError(event.reason)) { if (private$.isError(event.reason)) {
reason = event.reason; reason = event.reason;
reason.jasmineMessage = jasmineMessage; reason.jasmineMessage = jasmineMessage;
} else { } else {
@@ -262,7 +262,7 @@ getJasmineRequireObj().GlobalErrors = function(j$) {
jasmineMessagePrefix = 'Uncaught exception'; jasmineMessagePrefix = 'Uncaught exception';
} }
if (j$.private.isError(error)) { if (private$.isError(error)) {
error.jasmineMessage = jasmineMessagePrefix + ': ' + error; error.jasmineMessage = jasmineMessagePrefix + ': ' + error;
return error; return error;
} else { } else {

View File

@@ -1,131 +0,0 @@
getJasmineRequireObj().JsApiReporter = function(j$) {
'use strict';
/**
* @name jsApiReporter
* @classdesc {@link Reporter} added by default in `boot.js` to record results for retrieval in javascript code. An instance is made available as `jsApiReporter` on the global object.
* @class
* @hideconstructor
*/
function JsApiReporter(options) {
const timer = options.timer || new j$.Timer();
let status = 'loaded';
this.started = false;
this.finished = false;
this.runDetails = {};
this.jasmineStarted = function() {
this.started = true;
status = 'started';
timer.start();
};
let executionTime;
this.jasmineDone = function(runDetails) {
this.finished = true;
this.runDetails = runDetails;
executionTime = timer.elapsed();
status = 'done';
};
/**
* Get the current status for the Jasmine environment.
* @name jsApiReporter#status
* @since 2.0.0
* @function
* @return {String} - One of `loaded`, `started`, or `done`
*/
this.status = function() {
return status;
};
const suites = [],
suites_hash = {};
this.suiteStarted = function(result) {
suites_hash[result.id] = result;
};
this.suiteDone = function(result) {
storeSuite(result);
};
/**
* Get the results for a set of suites.
*
* Retrievable in slices for easier serialization.
* @name jsApiReporter#suiteResults
* @since 2.1.0
* @function
* @param {Number} index - The position in the suites list to start from.
* @param {Number} length - Maximum number of suite results to return.
* @return {SuiteResult[]}
*/
this.suiteResults = function(index, length) {
return suites.slice(index, index + length);
};
function storeSuite(result) {
suites.push(result);
suites_hash[result.id] = result;
}
/**
* Get all of the suites in a single object, with their `id` as the key.
* @name jsApiReporter#suites
* @since 2.0.0
* @function
* @return {Object} - Map of suite id to {@link SuiteResult}
*/
this.suites = function() {
return suites_hash;
};
const specs = [];
this.specDone = function(result) {
specs.push(result);
};
/**
* Get the results for a set of specs.
*
* Retrievable in slices for easier serialization.
* @name jsApiReporter#specResults
* @since 2.0.0
* @function
* @param {Number} index - The position in the specs list to start from.
* @param {Number} length - Maximum number of specs results to return.
* @return {SpecDoneEvent[]}
*/
this.specResults = function(index, length) {
return specs.slice(index, index + length);
};
/**
* Get all spec results.
* @name jsApiReporter#specs
* @since 2.0.0
* @function
* @return {SpecDoneEvent[]}
*/
this.specs = function() {
return specs;
};
/**
* Get the number of milliseconds it took for the full Jasmine suite to run.
* @name jsApiReporter#executionTime
* @since 2.0.0
* @function
* @return {Number}
*/
this.executionTime = function() {
return executionTime;
};
}
return JsApiReporter;
};

View File

@@ -1,4 +1,4 @@
getJasmineRequireObj().MockDate = function(j$) { getJasmineRequireObj().MockDate = function(j$, private$) {
'use strict'; 'use strict';
function MockDate(global) { function MockDate(global) {

View File

@@ -1,4 +1,4 @@
getJasmineRequireObj().NeverSkipPolicy = function(j$) { getJasmineRequireObj().NeverSkipPolicy = function(j$, private$) {
'use strict'; 'use strict';
function NeverSkipPolicy(queueableFns) {} function NeverSkipPolicy(queueableFns) {}

View File

@@ -1,4 +1,4 @@
getJasmineRequireObj().ParallelReportDispatcher = function(j$) { getJasmineRequireObj().ParallelReportDispatcher = function(j$, private$) {
'use strict'; 'use strict';
/** /**
@@ -15,43 +15,43 @@ getJasmineRequireObj().ParallelReportDispatcher = function(j$) {
* Jasmine specs run in. Doing so will break Jasmine's error handling. * Jasmine specs run in. Doing so will break Jasmine's error handling.
* @param onError {function} Function called when an unhandled exception, unhandled promise rejection, or explicit reporter failure occurs * @param onError {function} Function called when an unhandled exception, unhandled promise rejection, or explicit reporter failure occurs
*/ */
function ParallelReportDispatcher(onError, deps = {}) { class ParallelReportDispatcher {
const ReportDispatcher = constructor(onError, deps = {}) {
deps.ReportDispatcher || j$.private.ReportDispatcher; const ReportDispatcher =
const QueueRunner = deps.QueueRunner || j$.private.QueueRunner; deps.ReportDispatcher || private$.ReportDispatcher;
const globalErrors = deps.globalErrors || new j$.private.GlobalErrors(); const QueueRunner = deps.QueueRunner || private$.QueueRunner;
const dispatcher = new ReportDispatcher( const globalErrors = deps.globalErrors || new private$.GlobalErrors();
j$.private.reporterEvents, const dispatcher = new ReportDispatcher(
function(queueRunnerOptions) { private$.reporterEvents,
queueRunnerOptions = { function(queueRunnerOptions) {
...queueRunnerOptions, queueRunnerOptions = {
globalErrors, ...queueRunnerOptions,
timeout: { setTimeout, clearTimeout }, globalErrors,
fail: function(error) { timeout: { setTimeout, clearTimeout },
// A callback-style async reporter called either done.fail() fail: function(error) {
// or done(anError). // A callback-style async reporter called either done.fail()
if (!error) { // or done(anError).
error = new Error('A reporter called done.fail()'); if (!error) {
error = new Error('A reporter called done.fail()');
}
onError(error);
},
onException: function(error) {
// A reporter method threw an exception or returned a rejected
// promise, or there was an unhandled exception or unhandled promise
// rejection while an asynchronous reporter method was running.
onError(error);
} }
};
new QueueRunner(queueRunnerOptions).execute();
},
function(error) {
// A reporter called done() more than once.
onError(error);
}
);
onError(error);
},
onException: function(error) {
// A reporter method threw an exception or returned a rejected
// promise, or there was an unhandled exception or unhandled promise
// rejection while an asynchronous reporter method was running.
onError(error);
}
};
new QueueRunner(queueRunnerOptions).execute();
},
function(error) {
// A reporter called done() more than once.
onError(error);
}
);
const self = {
/** /**
* Adds a reporter to the list of reporters that events will be dispatched to. * Adds a reporter to the list of reporters that events will be dispatched to.
* @function * @function
@@ -59,13 +59,13 @@ getJasmineRequireObj().ParallelReportDispatcher = function(j$) {
* @param {Reporter} reporterToAdd The reporter to be added. * @param {Reporter} reporterToAdd The reporter to be added.
* @see custom_reporter * @see custom_reporter
*/ */
addReporter: dispatcher.addReporter.bind(dispatcher), this.addReporter = dispatcher.addReporter.bind(dispatcher);
/** /**
* Clears all registered reporters. * Clears all registered reporters.
* @function * @function
* @name ParallelReportDispatcher#clearReporters * @name ParallelReportDispatcher#clearReporters
*/ */
clearReporters: dispatcher.clearReporters.bind(dispatcher), this.clearReporters = dispatcher.clearReporters.bind(dispatcher);
/** /**
* Installs a global error handler. After this method is called, any * Installs a global error handler. After this method is called, any
* unhandled exceptions or unhandled promise rejections will be passed to * unhandled exceptions or unhandled promise rejections will be passed to
@@ -73,24 +73,25 @@ getJasmineRequireObj().ParallelReportDispatcher = function(j$) {
* @function * @function
* @name ParallelReportDispatcher#installGlobalErrors * @name ParallelReportDispatcher#installGlobalErrors
*/ */
installGlobalErrors: globalErrors.install.bind(globalErrors), this.installGlobalErrors = globalErrors.install.bind(globalErrors);
/** /**
* Uninstalls the global error handler. * Uninstalls the global error handler.
* @function * @function
* @name ParallelReportDispatcher#uninstallGlobalErrors * @name ParallelReportDispatcher#uninstallGlobalErrors
*/ */
uninstallGlobalErrors: function() { this.uninstallGlobalErrors = function() {
// late-bind uninstall because it doesn't exist until install is called // late-bind uninstall because it doesn't exist until install is called
globalErrors.uninstall(globalErrors); globalErrors.uninstall(globalErrors);
};
for (const eventName of private$.reporterEvents) {
this[eventName] = dispatcher[eventName].bind(dispatcher);
} }
};
for (const eventName of j$.private.reporterEvents) { Object.freeze(this);
self[eventName] = dispatcher[eventName].bind(dispatcher);
} }
return self;
} }
Object.freeze(ParallelReportDispatcher.prototype);
return ParallelReportDispatcher; return ParallelReportDispatcher;
}; };

View File

@@ -1,4 +1,4 @@
getJasmineRequireObj().makePrettyPrinter = function(j$) { getJasmineRequireObj().makePrettyPrinter = function(j$, private$) {
'use strict'; 'use strict';
class SinglePrettyPrintRun { class SinglePrettyPrintRun {
@@ -28,7 +28,7 @@ getJasmineRequireObj().makePrettyPrinter = function(j$) {
this.emitScalar('<global>'); this.emitScalar('<global>');
} else if (value.jasmineToString) { } else if (value.jasmineToString) {
this.emitScalar(value.jasmineToString(this.pp_)); this.emitScalar(value.jasmineToString(this.pp_));
} else if (j$.private.isString(value)) { } else if (private$.isString(value)) {
this.emitString(value); this.emitString(value);
} else if (j$.isSpy(value)) { } else if (j$.isSpy(value)) {
this.emitScalar('spy on ' + value.and.identity); this.emitScalar('spy on ' + value.and.identity);
@@ -42,7 +42,7 @@ getJasmineRequireObj().makePrettyPrinter = function(j$) {
} else { } else {
this.emitScalar('Function'); this.emitScalar('Function');
} }
} else if (j$.private.isDomNode(value)) { } else if (private$.isDomNode(value)) {
if (value.tagName) { if (value.tagName) {
this.emitDomElement(value); this.emitDomElement(value);
} else { } else {
@@ -50,16 +50,16 @@ getJasmineRequireObj().makePrettyPrinter = function(j$) {
} }
} else if (value instanceof Date) { } else if (value instanceof Date) {
this.emitScalar('Date(' + value + ')'); this.emitScalar('Date(' + value + ')');
} else if (j$.private.isSet(value)) { } else if (private$.isSet(value)) {
this.emitSet(value); this.emitSet(value);
} else if (j$.private.isMap(value)) { } else if (private$.isMap(value)) {
this.emitMap(value); this.emitMap(value);
} else if (j$.private.isTypedArray(value)) { } else if (private$.isTypedArray(value)) {
this.emitTypedArray(value); this.emitTypedArray(value);
} 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) || 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 = 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++) {
@@ -214,7 +208,7 @@ getJasmineRequireObj().makePrettyPrinter = function(j$) {
const ctor = obj.constructor; const ctor = obj.constructor;
const constructorName = const constructorName =
typeof ctor === 'function' && obj instanceof ctor typeof ctor === 'function' && obj instanceof ctor
? j$.private.fnNameFor(obj.constructor) ? private$.fnNameFor(obj.constructor)
: 'null'; : 'null';
this.append(constructorName); this.append(constructorName);
@@ -244,7 +238,7 @@ getJasmineRequireObj().makePrettyPrinter = function(j$) {
} }
emitTypedArray(arr) { emitTypedArray(arr) {
const constructorName = j$.private.fnNameFor(arr.constructor); const constructorName = private$.fnNameFor(arr.constructor);
const limitedArray = Array.prototype.slice.call( const limitedArray = Array.prototype.slice.call(
arr, arr,
0, 0,
@@ -313,7 +307,7 @@ getJasmineRequireObj().makePrettyPrinter = function(j$) {
// iframe, web worker) // iframe, web worker)
try { try {
return ( return (
j$.private.isFunction(value.toString) && private$.isFunction(value.toString) &&
value.toString !== Object.prototype.toString && value.toString !== Object.prototype.toString &&
value.toString() !== Object.prototype.toString.call(value) value.toString() !== Object.prototype.toString.call(value)
); );

View File

@@ -1,11 +1,11 @@
getJasmineRequireObj().QueueRunner = function(j$) { getJasmineRequireObj().QueueRunner = function(j$, private$) {
'use strict'; 'use strict';
let nextid = 1; let nextid = 1;
function StopExecutionError() {} function StopExecutionError() {}
StopExecutionError.prototype = new Error(); StopExecutionError.prototype = new Error();
j$.private.StopExecutionError = StopExecutionError; private$.StopExecutionError = StopExecutionError;
function once(fn, onTwice) { function once(fn, onTwice) {
let called = false; let called = false;
@@ -58,7 +58,7 @@ getJasmineRequireObj().QueueRunner = function(j$) {
}; };
this.onException = attrs.onException || emptyFn; this.onException = attrs.onException || emptyFn;
this.onMultipleDone = attrs.onMultipleDone || fallbackOnMultipleDone; this.onMultipleDone = attrs.onMultipleDone || fallbackOnMultipleDone;
this.userContext = attrs.userContext || new j$.private.UserContext(); this.userContext = attrs.userContext || new private$.UserContext();
this.timeout = attrs.timeout || { this.timeout = attrs.timeout || {
setTimeout: setTimeout, setTimeout: setTimeout,
clearTimeout: clearTimeout clearTimeout: clearTimeout
@@ -69,7 +69,7 @@ getJasmineRequireObj().QueueRunner = function(j$) {
popListener: emptyFn popListener: emptyFn
}; };
const SkipPolicy = attrs.SkipPolicy || j$.private.NeverSkipPolicy; const SkipPolicy = attrs.SkipPolicy || private$.NeverSkipPolicy;
this.skipPolicy_ = new SkipPolicy(this.queueableFns); this.skipPolicy_ = new SkipPolicy(this.queueableFns);
this.errored_ = false; this.errored_ = false;
@@ -192,7 +192,7 @@ getJasmineRequireObj().QueueRunner = function(j$) {
if (queueableFn.fn.length === 0) { if (queueableFn.fn.length === 0) {
maybeThenable = queueableFn.fn.call(this.userContext); maybeThenable = queueableFn.fn.call(this.userContext);
if (maybeThenable && j$.private.isFunction(maybeThenable.then)) { if (maybeThenable && private$.isFunction(maybeThenable.then)) {
maybeThenable.then( maybeThenable.then(
wrapInPromiseResolutionHandler(next), wrapInPromiseResolutionHandler(next),
onPromiseRejection onPromiseRejection
@@ -262,11 +262,11 @@ getJasmineRequireObj().QueueRunner = function(j$) {
}; };
QueueRunner.prototype.diagnoseConflictingAsync_ = function(fn, retval) { QueueRunner.prototype.diagnoseConflictingAsync_ = function(fn, retval) {
if (retval && j$.private.isFunction(retval.then)) { if (retval && private$.isFunction(retval.then)) {
// Issue a warning that matches the user's code. // Issue a warning that matches the user's code.
// Omit the stack trace because there's almost certainly no user code // Omit the stack trace because there's almost certainly no user code
// on the stack at this point. // on the stack at this point.
if (j$.private.isAsyncFunction(fn)) { if (private$.isAsyncFunction(fn)) {
this.onException( this.onException(
new Error( new Error(
'An asynchronous before/it/after ' + 'An asynchronous before/it/after ' +
@@ -290,7 +290,7 @@ getJasmineRequireObj().QueueRunner = function(j$) {
function wrapInPromiseResolutionHandler(fn) { function wrapInPromiseResolutionHandler(fn) {
return function(maybeArg) { return function(maybeArg) {
if (j$.private.isError(maybeArg)) { if (private$.isError(maybeArg)) {
fn(maybeArg); fn(maybeArg);
} else { } else {
fn(); fn();

View File

@@ -1,4 +1,4 @@
getJasmineRequireObj().ReportDispatcher = function(j$) { getJasmineRequireObj().ReportDispatcher = function(j$, private$) {
'use strict'; 'use strict';
function ReportDispatcher(methods, runQueue, onLateError) { function ReportDispatcher(methods, runQueue, onLateError) {

View File

@@ -1,4 +1,4 @@
getJasmineRequireObj().RunableResources = function(j$) { getJasmineRequireObj().RunableResources = function(j$, private$) {
'use strict'; 'use strict';
class RunableResources { class RunableResources {
@@ -7,7 +7,7 @@ getJasmineRequireObj().RunableResources = function(j$) {
this.getCurrentRunableId_ = options.getCurrentRunableId; this.getCurrentRunableId_ = options.getCurrentRunableId;
this.globalErrors_ = options.globalErrors; this.globalErrors_ = options.globalErrors;
this.spyFactory = new j$.private.SpyFactory( this.spyFactory = new private$.SpyFactory(
() => { () => {
if (this.getCurrentRunableId_()) { if (this.getCurrentRunableId_()) {
return this.customSpyStrategies(); return this.customSpyStrategies();
@@ -19,7 +19,7 @@ getJasmineRequireObj().RunableResources = function(j$) {
() => this.makeMatchersUtil() () => this.makeMatchersUtil()
); );
this.spyRegistry = new j$.private.SpyRegistry({ this.spyRegistry = new private$.SpyRegistry({
currentSpies: () => this.spies(), currentSpies: () => this.spies(),
createSpy: (name, originalFn) => createSpy: (name, originalFn) =>
this.spyFactory.createSpy(name, originalFn) this.spyFactory.createSpy(name, originalFn)
@@ -50,7 +50,7 @@ getJasmineRequireObj().RunableResources = function(j$) {
]; ];
for (const k of toClone) { for (const k of toClone) {
newRes[k] = j$.private.util.clone(parentRes[k]); newRes[k] = private$.util.clone(parentRes[k]);
} }
} }
} }
@@ -128,18 +128,18 @@ getJasmineRequireObj().RunableResources = function(j$) {
} }
makePrettyPrinter() { makePrettyPrinter() {
return j$.private.makePrettyPrinter(this.customObjectFormatters()); return private$.makePrettyPrinter(this.customObjectFormatters());
} }
makeMatchersUtil() { makeMatchersUtil() {
if (this.getCurrentRunableId_()) { if (this.getCurrentRunableId_()) {
return new j$.private.MatchersUtil({ return new private$.MatchersUtil({
customTesters: this.customEqualityTesters(), customTesters: this.customEqualityTesters(),
pp: this.makePrettyPrinter() pp: this.makePrettyPrinter()
}); });
} else { } else {
return new j$.private.MatchersUtil({ return new private$.MatchersUtil({
pp: j$.private.basicPrettyPrinter pp: private$.basicPrettyPrinter
}); });
} }
} }

View File

@@ -1,4 +1,4 @@
getJasmineRequireObj().Runner = function(j$) { getJasmineRequireObj().Runner = function(j$, private$) {
'use strict'; 'use strict';
class Runner { class Runner {
@@ -26,7 +26,7 @@ getJasmineRequireObj().Runner = function(j$) {
this.#reportDispatcher = options.reportDispatcher; this.#reportDispatcher = options.reportDispatcher;
this.#getConfig = options.getConfig; this.#getConfig = options.getConfig;
this.#executedBefore = false; this.#executedBefore = false;
this.#currentRunableTracker = new j$.private.CurrentRunableTracker(); this.#currentRunableTracker = new private$.CurrentRunableTracker();
} }
currentSpec() { currentSpec() {
@@ -66,9 +66,9 @@ getJasmineRequireObj().Runner = function(j$) {
} }
} }
const order = new j$.private.Order({ const order = new private$.Order({
random: config.random, random: config.random,
seed: j$.private.isNumber(config.seed) ? config.seed + '' : config.seed seed: private$.isNumber(config.seed) ? config.seed + '' : config.seed
}); });
const treeProcessor = new this.#TreeProcessor({ const treeProcessor = new this.#TreeProcessor({
@@ -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,12 +106,13 @@ 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
}); });
this.#currentRunableTracker.pushSuite(this.#topSuite); this.#currentRunableTracker.pushSuite(this.#topSuite);
const treeRunner = new j$.private.TreeRunner({ const treeRunner = new private$.TreeRunner({
executionTree: this.#executionTree, executionTree: this.#executionTree,
globalErrors: this.#globalErrors, globalErrors: this.#globalErrors,
runableResources: this.#runableResources, runableResources: this.#runableResources,

View File

@@ -1,4 +1,4 @@
getJasmineRequireObj().SkipAfterBeforeAllErrorPolicy = function(j$) { getJasmineRequireObj().SkipAfterBeforeAllErrorPolicy = function(j$, private$) {
'use strict'; 'use strict';
function SkipAfterBeforeAllErrorPolicy(queueableFns) { function SkipAfterBeforeAllErrorPolicy(queueableFns) {

View File

@@ -1,4 +1,4 @@
getJasmineRequireObj().Spec = function(j$) { getJasmineRequireObj().Spec = function(j$, private$) {
'use strict'; 'use strict';
class Spec { class Spec {
@@ -46,7 +46,7 @@ getJasmineRequireObj().Spec = function(j$) {
} }
addExpectationResult(passed, data, isError) { addExpectationResult(passed, data, isError) {
const expectationResult = j$.private.buildExpectationResult(data); const expectationResult = private$.buildExpectationResult(data);
if (passed) { if (passed) {
this.#executionState.passedExpectations.push(expectationResult); this.#executionState.passedExpectations.push(expectationResult);
@@ -58,7 +58,7 @@ getJasmineRequireObj().Spec = function(j$) {
} }
if (this.#throwOnExpectationFailure && !isError) { if (this.#throwOnExpectationFailure && !isError) {
throw new j$.private.errors.ExpectationFailed(); throw new private$.errors.ExpectationFailed();
} }
} }
} }
@@ -72,10 +72,10 @@ getJasmineRequireObj().Spec = function(j$) {
// Key and value will eventually be cloned during reporting. The error // Key and value will eventually be cloned during reporting. The error
// thrown at that point if they aren't cloneable isn't very helpful. // thrown at that point if they aren't cloneable isn't very helpful.
// Throw a better one now. // Throw a better one now.
if (!j$.private.isString(key)) { if (!private$.isString(key)) {
throw new Error('Key must be a string'); throw new Error('Key must be a string');
} }
j$.private.util.assertReporterCloneable(value, 'Value'); private$.util.assertReporterCloneable(value, 'Value');
this.#executionState.properties = this.#executionState.properties || {}; this.#executionState.properties = this.#executionState.properties || {};
this.#executionState.properties[key] = value; this.#executionState.properties[key] = value;
@@ -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.
@@ -208,7 +208,7 @@ getJasmineRequireObj().Spec = function(j$) {
return; return;
} }
if (e instanceof j$.private.errors.ExpectationFailed) { if (e instanceof private$.errors.ExpectationFailed) {
return; return;
} }
@@ -275,7 +275,7 @@ getJasmineRequireObj().Spec = function(j$) {
deprecation = { message: deprecation }; deprecation = { message: deprecation };
} }
this.#executionState.deprecationWarnings.push( this.#executionState.deprecationWarnings.push(
j$.private.buildExpectationResult(deprecation) private$.buildExpectationResult(deprecation)
); );
} }

View File

@@ -1,4 +1,4 @@
getJasmineRequireObj().Spy = function(j$) { getJasmineRequireObj().Spy = function(j$, private$) {
'use strict'; 'use strict';
const nextOrder = (function() { const nextOrder = (function() {
@@ -55,7 +55,7 @@ getJasmineRequireObj().Spy = function(j$) {
}, },
matchersUtil matchersUtil
), ),
callTracker = new j$.private.CallTracker(); callTracker = new private$.CallTracker();
function makeFunc(length, fn) { function makeFunc(length, fn) {
switch (length) { switch (length) {
@@ -147,9 +147,9 @@ getJasmineRequireObj().Spy = function(j$) {
} }
function SpyStrategyDispatcher(strategyArgs, matchersUtil) { function SpyStrategyDispatcher(strategyArgs, matchersUtil) {
const baseStrategy = new j$.private.SpyStrategy(strategyArgs); const baseStrategy = new private$.SpyStrategy(strategyArgs);
const argsStrategies = new StrategyDict(function() { const argsStrategies = new StrategyDict(function() {
return new j$.private.SpyStrategy(strategyArgs); return new private$.SpyStrategy(strategyArgs);
}, matchersUtil); }, matchersUtil);
this.and = baseStrategy; this.and = baseStrategy;

View File

@@ -1,4 +1,4 @@
getJasmineRequireObj().SpyFactory = function(j$) { getJasmineRequireObj().SpyFactory = function(j$, private$) {
'use strict'; 'use strict';
function SpyFactory( function SpyFactory(
@@ -7,12 +7,12 @@ getJasmineRequireObj().SpyFactory = function(j$) {
getMatchersUtil getMatchersUtil
) { ) {
this.createSpy = function(name, originalFn) { this.createSpy = function(name, originalFn) {
if (j$.private.isFunction(name) && originalFn === undefined) { if (private$.isFunction(name) && originalFn === undefined) {
originalFn = name; originalFn = name;
name = originalFn.name; name = originalFn.name;
} }
return j$.private.Spy(name, getMatchersUtil(), { return private$.Spy(name, getMatchersUtil(), {
originalFn, originalFn,
customStrategies: getCustomStrategies(), customStrategies: getCustomStrategies(),
defaultStrategyFn: getDefaultStrategyFn() defaultStrategyFn: getDefaultStrategyFn()
@@ -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); private$.isObject(baseName) || Array.isArray(baseName);
if (baseNameIsCollection) { if (baseNameIsCollection) {
propertyNames = methodNames; propertyNames = methodNames;
@@ -67,11 +67,11 @@ 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]]);
} }
} else if (j$.private.isObject(object)) { } else if (private$.isObject(object)) {
for (const key in object) { for (const key in object) {
if (object.hasOwnProperty(key)) { if (object.hasOwnProperty(key)) {
result.push([key, object[key]]); result.push([key, object[key]]);

View File

@@ -1,11 +1,11 @@
getJasmineRequireObj().SpyRegistry = function(j$) { getJasmineRequireObj().SpyRegistry = function(j$, private$) {
'use strict'; 'use strict';
const spyOnMsg = j$.private.formatErrorMsg( const spyOnMsg = private$.formatErrorMsg(
'<spyOn>', '<spyOn>',
'spyOn(<object>, <methodName>)' 'spyOn(<object>, <methodName>)'
); );
const spyOnPropertyMsg = j$.private.formatErrorMsg( const spyOnPropertyMsg = private$.formatErrorMsg(
'<spyOnProperty>', '<spyOnProperty>',
'spyOnProperty(<object>, <propName>, [accessType])' 'spyOnProperty(<object>, <propName>, [accessType])'
); );
@@ -47,7 +47,7 @@ getJasmineRequireObj().SpyRegistry = function(j$) {
// restored. // restored.
if ( if (
obj[methodName] && obj[methodName] &&
obj[methodName][j$.private.Clock.IsMockClockTimingFn] obj[methodName][private$.Clock.IsMockClockTimingFn]
) { ) {
throw new Error("Mock clock timing functions can't be spied on"); throw new Error("Mock clock timing functions can't be spied on");
} }
@@ -102,7 +102,7 @@ getJasmineRequireObj().SpyRegistry = function(j$) {
// localStorage in Firefox and later Safari versions, have no-op setters. // localStorage in Firefox and later Safari versions, have no-op setters.
if (obj[methodName] !== spiedMethod) { if (obj[methodName] !== spiedMethod) {
throw new Error( throw new Error(
j$.private.formatErrorMsg('<spyOn>')( private$.formatErrorMsg('<spyOn>')(
`Can't spy on ${methodName} because assigning to it had no effect` `Can't spy on ${methodName} because assigning to it had no effect`
) )
); );
@@ -130,10 +130,7 @@ getJasmineRequireObj().SpyRegistry = function(j$) {
throw new Error(getErrorMsg('No property name supplied')); throw new Error(getErrorMsg('No property name supplied'));
} }
const descriptor = j$.private.util.getPropertyDescriptor( const descriptor = private$.util.getPropertyDescriptor(obj, propertyName);
obj,
propertyName
);
if (!descriptor) { if (!descriptor) {
throw new Error(getErrorMsg(propertyName + ' property does not exist')); throw new Error(getErrorMsg(propertyName + ' property does not exist'));
@@ -168,7 +165,7 @@ getJasmineRequireObj().SpyRegistry = function(j$) {
} }
} }
const originalDescriptor = j$.private.util.clone(descriptor); const originalDescriptor = private$.util.clone(descriptor);
const spy = createSpy(propertyName, descriptor[accessType]); const spy = createSpy(propertyName, descriptor[accessType]);
let restoreStrategy; let restoreStrategy;

View File

@@ -1,4 +1,4 @@
getJasmineRequireObj().SpyStrategy = function(j$) { getJasmineRequireObj().SpyStrategy = function(j$, private$) {
'use strict'; 'use strict';
/** /**
@@ -21,7 +21,7 @@ getJasmineRequireObj().SpyStrategy = function(j$) {
const cs = options.customStrategies || {}; const cs = options.customStrategies || {};
for (const k in cs) { for (const k in cs) {
if (j$.private.util.has(cs, k) && !this[k]) { if (private$.util.has(cs, k) && !this[k]) {
this[k] = createCustomPlan(cs[k]); this[k] = createCustomPlan(cs[k]);
} }
} }
@@ -59,7 +59,7 @@ getJasmineRequireObj().SpyStrategy = function(j$) {
return function() { return function() {
const plan = factory.apply(null, arguments); const plan = factory.apply(null, arguments);
if (!j$.private.isFunction(plan)) { if (!private$.isFunction(plan)) {
throw new Error('Spy strategy must return a function'); throw new Error('Spy strategy must return a function');
} }
@@ -131,7 +131,7 @@ getJasmineRequireObj().SpyStrategy = function(j$) {
* @param {Error|Object|String} something Thing to throw * @param {Error|Object|String} something Thing to throw
*/ */
SpyStrategy.prototype.throwError = function(something) { SpyStrategy.prototype.throwError = function(something) {
const error = j$.private.isString(something) const error = private$.isString(something)
? new Error(something) ? new Error(something)
: something; : something;
this.plan = function() { this.plan = function() {
@@ -150,9 +150,9 @@ getJasmineRequireObj().SpyStrategy = function(j$) {
SpyStrategy.prototype.callFake = function(fn) { SpyStrategy.prototype.callFake = function(fn) {
if ( if (
!( !(
j$.private.isFunction(fn) || private$.isFunction(fn) ||
j$.private.isAsyncFunction(fn) || private$.isAsyncFunction(fn) ||
j$.private.isGeneratorFunction(fn) private$.isGeneratorFunction(fn)
) )
) { ) {
throw new Error( throw new Error(

View File

@@ -1,4 +1,4 @@
getJasmineRequireObj().StackClearer = function(j$) { getJasmineRequireObj().StackClearer = function(j$, private$) {
'use strict'; 'use strict';
const maxInlineCallCount = 10; const maxInlineCallCount = 10;

View File

@@ -1,4 +1,4 @@
getJasmineRequireObj().StackTrace = function(j$) { getJasmineRequireObj().StackTrace = function(j$, private$) {
'use strict'; 'use strict';
function StackTrace(error) { function StackTrace(error) {

View File

@@ -1,4 +1,4 @@
getJasmineRequireObj().Suite = function(j$) { getJasmineRequireObj().Suite = function(j$, private$) {
'use strict'; 'use strict';
class Suite { class Suite {
@@ -37,10 +37,10 @@ getJasmineRequireObj().Suite = function(j$) {
// Key and value will eventually be cloned during reporting. The error // Key and value will eventually be cloned during reporting. The error
// thrown at that point if they aren't cloneable isn't very helpful. // thrown at that point if they aren't cloneable isn't very helpful.
// Throw a better one now. // Throw a better one now.
if (!j$.private.isString(key)) { if (!private$.isString(key)) {
throw new Error('Key must be a string'); throw new Error('Key must be a string');
} }
j$.private.util.assertReporterCloneable(value, 'Value'); private$.util.assertReporterCloneable(value, 'Value');
this.#result.properties = this.#result.properties || {}; this.#result.properties = this.#result.properties || {};
this.#result.properties[key] = value; this.#result.properties[key] = value;
@@ -217,18 +217,18 @@ getJasmineRequireObj().Suite = function(j$) {
if (!this.sharedContext) { if (!this.sharedContext) {
this.sharedContext = this.parentSuite this.sharedContext = this.parentSuite
? this.parentSuite.clonedSharedUserContext() ? this.parentSuite.clonedSharedUserContext()
: new j$.private.UserContext(); : new private$.UserContext();
} }
return this.sharedContext; return this.sharedContext;
} }
clonedSharedUserContext() { clonedSharedUserContext() {
return j$.private.UserContext.fromExisting(this.sharedUserContext()); return private$.UserContext.fromExisting(this.sharedUserContext());
} }
handleException() { handleException() {
if (arguments[0] instanceof j$.private.errors.ExpectationFailed) { if (arguments[0] instanceof private$.errors.ExpectationFailed) {
return; return;
} }
@@ -237,7 +237,7 @@ getJasmineRequireObj().Suite = function(j$) {
passed: false, passed: false,
error: arguments[0] error: arguments[0]
}; };
const failedExpectation = j$.private.buildExpectationResult(data); const failedExpectation = private$.buildExpectationResult(data);
if (!this.parentSuite) { if (!this.parentSuite) {
failedExpectation.globalErrorType = 'afterAll'; failedExpectation.globalErrorType = 'afterAll';
@@ -279,7 +279,7 @@ getJasmineRequireObj().Suite = function(j$) {
return; return;
} }
const expectationResult = j$.private.buildExpectationResult(data); const expectationResult = private$.buildExpectationResult(data);
if (this.reportedDone) { if (this.reportedDone) {
this.onLateError(expectationResult); this.onLateError(expectationResult);
@@ -288,7 +288,7 @@ getJasmineRequireObj().Suite = function(j$) {
} }
if (this.#throwOnExpectationFailure) { if (this.#throwOnExpectationFailure) {
throw new j$.private.errors.ExpectationFailed(); throw new private$.errors.ExpectationFailed();
} }
} }
@@ -297,7 +297,7 @@ getJasmineRequireObj().Suite = function(j$) {
deprecation = { message: deprecation }; deprecation = { message: deprecation };
} }
this.#result.deprecationWarnings.push( this.#result.deprecationWarnings.push(
j$.private.buildExpectationResult(deprecation) private$.buildExpectationResult(deprecation)
); );
} }

View File

@@ -1,4 +1,4 @@
getJasmineRequireObj().SuiteBuilder = function(j$) { getJasmineRequireObj().SuiteBuilder = function(j$, private$) {
'use strict'; 'use strict';
class SuiteBuilder { class SuiteBuilder {
@@ -94,7 +94,7 @@ getJasmineRequireObj().SuiteBuilder = function(j$) {
ensureIsFunctionOrAsync(fn, 'fit'); ensureIsFunctionOrAsync(fn, 'fit');
if (timeout) { if (timeout) {
j$.private.util.validateTimeout(timeout); private$.util.validateTimeout(timeout);
} }
const spec = this.specFactory_(description, fn, timeout, filename); const spec = this.specFactory_(description, fn, timeout, filename);
this.currentDeclarationSuite_.addChild(spec); this.currentDeclarationSuite_.addChild(spec);
@@ -107,7 +107,7 @@ getJasmineRequireObj().SuiteBuilder = function(j$) {
ensureIsFunctionOrAsync(beforeEachFunction, 'beforeEach'); ensureIsFunctionOrAsync(beforeEachFunction, 'beforeEach');
if (timeout) { if (timeout) {
j$.private.util.validateTimeout(timeout); private$.util.validateTimeout(timeout);
} }
this.currentDeclarationSuite_.beforeEach({ this.currentDeclarationSuite_.beforeEach({
@@ -120,7 +120,7 @@ getJasmineRequireObj().SuiteBuilder = function(j$) {
ensureIsFunctionOrAsync(beforeAllFunction, 'beforeAll'); ensureIsFunctionOrAsync(beforeAllFunction, 'beforeAll');
if (timeout) { if (timeout) {
j$.private.util.validateTimeout(timeout); private$.util.validateTimeout(timeout);
} }
this.currentDeclarationSuite_.beforeAll({ this.currentDeclarationSuite_.beforeAll({
@@ -133,7 +133,7 @@ getJasmineRequireObj().SuiteBuilder = function(j$) {
ensureIsFunctionOrAsync(afterEachFunction, 'afterEach'); ensureIsFunctionOrAsync(afterEachFunction, 'afterEach');
if (timeout) { if (timeout) {
j$.private.util.validateTimeout(timeout); private$.util.validateTimeout(timeout);
} }
afterEachFunction.isCleanup = true; afterEachFunction.isCleanup = true;
@@ -147,7 +147,7 @@ getJasmineRequireObj().SuiteBuilder = function(j$) {
ensureIsFunctionOrAsync(afterAllFunction, 'afterAll'); ensureIsFunctionOrAsync(afterAllFunction, 'afterAll');
if (timeout) { if (timeout) {
j$.private.util.validateTimeout(timeout); private$.util.validateTimeout(timeout);
} }
this.currentDeclarationSuite_.afterAll({ this.currentDeclarationSuite_.afterAll({
@@ -158,7 +158,7 @@ getJasmineRequireObj().SuiteBuilder = function(j$) {
it_(description, fn, timeout, filename) { it_(description, fn, timeout, filename) {
if (timeout) { if (timeout) {
j$.private.util.validateTimeout(timeout); private$.util.validateTimeout(timeout);
} }
this.checkDuplicate_(description, 'spec'); this.checkDuplicate_(description, 'spec');
@@ -197,7 +197,7 @@ getJasmineRequireObj().SuiteBuilder = function(j$) {
const parentSuite = this.currentDeclarationSuite_; const parentSuite = this.currentDeclarationSuite_;
const reportedParentSuiteId = const reportedParentSuiteId =
parentSuite === this.topSuite ? null : parentSuite.id; parentSuite === this.topSuite ? null : parentSuite.id;
return new j$.private.Suite({ return new private$.Suite({
id: 'suite' + this.nextSuiteId_++, id: 'suite' + this.nextSuiteId_++,
description, description,
filename, filename,
@@ -239,7 +239,7 @@ getJasmineRequireObj().SuiteBuilder = function(j$) {
const config = this.env_.configuration(); const config = this.env_.configuration();
const suite = this.currentDeclarationSuite_; const suite = this.currentDeclarationSuite_;
const parentSuiteId = suite === this.topSuite ? null : suite.id; const parentSuiteId = suite === this.topSuite ? null : suite.id;
const spec = new j$.private.Spec({ const spec = new private$.Spec({
id: 'spec' + this.nextSpecId_++, id: 'spec' + this.nextSpecId_++,
filename, filename,
parentSuiteId, parentSuiteId,
@@ -302,21 +302,21 @@ getJasmineRequireObj().SuiteBuilder = function(j$) {
} }
function ensureIsFunction(fn, caller) { function ensureIsFunction(fn, caller) {
if (!j$.private.isFunction(fn)) { if (!private$.isFunction(fn)) {
throw new Error( throw new Error(
caller + caller +
' expects a function argument; received ' + ' expects a function argument; received ' +
j$.private.getType(fn) private$.getType(fn)
); );
} }
} }
function ensureIsFunctionOrAsync(fn, caller) { function ensureIsFunctionOrAsync(fn, caller) {
if (!j$.private.isFunction(fn) && !j$.private.isAsyncFunction(fn)) { if (!private$.isFunction(fn) && !private$.isAsyncFunction(fn)) {
throw new Error( throw new Error(
caller + caller +
' expects a function argument; received ' + ' expects a function argument; received ' +
j$.private.getType(fn) private$.getType(fn)
); );
} }
} }

View File

@@ -39,7 +39,11 @@ getJasmineRequireObj().Timer = function() {
this.elapsed = function() { this.elapsed = function() {
return now() - startTime; return now() - startTime;
}; };
Object.freeze(this);
} }
Object.freeze(Timer);
Object.freeze(Timer.prototype);
return Timer; return Timer;
}; };

View File

@@ -1,4 +1,4 @@
getJasmineRequireObj().TreeProcessor = function(j$) { getJasmineRequireObj().TreeProcessor = function(j$, private$) {
'use strict'; 'use strict';
const defaultMin = Infinity; const defaultMin = Infinity;
@@ -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

@@ -1,4 +1,4 @@
getJasmineRequireObj().TreeRunner = function(j$) { getJasmineRequireObj().TreeRunner = function(j$, private$) {
'use strict'; 'use strict';
class TreeRunner { class TreeRunner {
@@ -83,14 +83,14 @@ getJasmineRequireObj().TreeRunner = function(j$) {
}, },
onComplete: () => { onComplete: () => {
if (spec.status() === 'failed') { if (spec.status() === 'failed') {
specOverallDone(new j$.private.StopExecutionError('spec failed')); specOverallDone(new private$.StopExecutionError('spec failed'));
} else { } else {
specOverallDone(); specOverallDone();
} }
}, },
userContext: spec.userContext(), userContext: spec.userContext(),
runnableName: spec.getFullName.bind(spec), runnableName: spec.getFullName.bind(spec),
SkipPolicy: j$.private.CompleteOnFirstErrorSkipPolicy SkipPolicy: private$.CompleteOnFirstErrorSkipPolicy
}); });
} }
@@ -265,7 +265,7 @@ getJasmineRequireObj().TreeRunner = function(j$) {
async #reportChildrenOfBeforeAllFailure(suite) { async #reportChildrenOfBeforeAllFailure(suite) {
for (const child of suite.children) { for (const child of suite.children) {
if (child instanceof j$.private.Suite) { if (child instanceof private$.Suite) {
await this.#reportDispatcher.suiteStarted(child.startedEvent()); await this.#reportDispatcher.suiteStarted(child.startedEvent());
await this.#reportChildrenOfBeforeAllFailure(child); await this.#reportChildrenOfBeforeAllFailure(child);
await this.#reportDispatcher.suiteDone(child.doneEvent()); await this.#reportDispatcher.suiteDone(child.doneEvent());
@@ -280,9 +280,9 @@ getJasmineRequireObj().TreeRunner = function(j$) {
#suiteSkipPolicy() { #suiteSkipPolicy() {
if (this.#getConfig().stopOnSpecFailure) { if (this.#getConfig().stopOnSpecFailure) {
return j$.private.CompleteOnFirstErrorSkipPolicy; return private$.CompleteOnFirstErrorSkipPolicy;
} else { } else {
return j$.private.SkipAfterBeforeAllErrorPolicy; return private$.SkipAfterBeforeAllErrorPolicy;
} }
} }
} }

View File

@@ -1,4 +1,4 @@
getJasmineRequireObj().UserContext = function(j$) { getJasmineRequireObj().UserContext = function(j$, private$) {
'use strict'; 'use strict';
function UserContext() {} function UserContext() {}

View File

@@ -1,4 +1,4 @@
getJasmineRequireObj().AllOf = function(j$) { getJasmineRequireObj().AllOf = function(j$, private$) {
'use strict'; 'use strict';
function AllOf() { function AllOf() {

View File

@@ -1,4 +1,4 @@
getJasmineRequireObj().Any = function(j$) { getJasmineRequireObj().Any = function(j$, private$) {
'use strict'; 'use strict';
function Any(expectedObject) { function Any(expectedObject) {
@@ -40,7 +40,7 @@ getJasmineRequireObj().Any = function(j$) {
}; };
Any.prototype.jasmineToString = function() { Any.prototype.jasmineToString = function() {
return '<jasmine.any(' + j$.private.fnNameFor(this.expectedObject) + ')>'; return '<jasmine.any(' + private$.fnNameFor(this.expectedObject) + ')>';
}; };
return Any; return Any;

View File

@@ -1,4 +1,4 @@
getJasmineRequireObj().Anything = function(j$) { getJasmineRequireObj().Anything = function(j$, private$) {
'use strict'; 'use strict';
function Anything() {} function Anything() {}

View File

@@ -1,4 +1,4 @@
getJasmineRequireObj().ArrayContaining = function(j$) { getJasmineRequireObj().ArrayContaining = function(j$, private$) {
'use strict'; 'use strict';
function ArrayContaining(sample) { function ArrayContaining(sample) {
@@ -6,10 +6,10 @@ 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) + 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

@@ -1,4 +1,4 @@
getJasmineRequireObj().ArrayWithExactContents = function(j$) { getJasmineRequireObj().ArrayWithExactContents = function(j$, private$) {
'use strict'; 'use strict';
function ArrayWithExactContents(sample) { function ArrayWithExactContents(sample) {
@@ -9,10 +9,10 @@ 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) + private$.basicPrettyPrinter(this.sample) +
'.' '.'
); );
} }

View File

@@ -1,22 +1,22 @@
getJasmineRequireObj().Empty = function(j$) { getJasmineRequireObj().Empty = function(j$, private$) {
'use strict'; 'use strict';
function Empty() {} function Empty() {}
Empty.prototype.asymmetricMatch = function(other) { Empty.prototype.asymmetricMatch = function(other) {
if ( if (
j$.private.isString(other) || private$.isString(other) ||
j$.private.isArray(other) || Array.isArray(other) ||
j$.private.isTypedArray(other) private$.isTypedArray(other)
) { ) {
return other.length === 0; return other.length === 0;
} }
if (j$.private.isMap(other) || j$.private.isSet(other)) { if (private$.isMap(other) || private$.isSet(other)) {
return other.size === 0; return other.size === 0;
} }
if (j$.private.isObject(other)) { if (private$.isObject(other)) {
return Object.keys(other).length === 0; return Object.keys(other).length === 0;
} }
return false; return false;

View File

@@ -1,4 +1,4 @@
getJasmineRequireObj().Falsy = function(j$) { getJasmineRequireObj().Falsy = function(j$, private$) {
'use strict'; 'use strict';
function Falsy() {} function Falsy() {}

View File

@@ -1,4 +1,4 @@
getJasmineRequireObj().Is = function(j$) { getJasmineRequireObj().Is = function(j$, private$) {
'use strict'; 'use strict';
class Is { class Is {

View File

@@ -1,11 +1,11 @@
getJasmineRequireObj().MapContaining = function(j$) { getJasmineRequireObj().MapContaining = function(j$, private$) {
'use strict'; 'use strict';
function MapContaining(sample) { function MapContaining(sample) {
if (!j$.private.isMap(sample)) { if (!private$.isMap(sample)) {
throw new Error( throw new Error(
'You must provide a map to `mapContaining`, not ' + 'You must provide a map to `mapContaining`, not ' +
j$.private.basicPrettyPrinter(sample) private$.basicPrettyPrinter(sample)
); );
} }
@@ -13,7 +13,7 @@ getJasmineRequireObj().MapContaining = function(j$) {
} }
MapContaining.prototype.asymmetricMatch = function(other, matchersUtil) { MapContaining.prototype.asymmetricMatch = function(other, matchersUtil) {
if (!j$.private.isMap(other)) { if (!private$.isMap(other)) {
return false; return false;
} }

View File

@@ -1,22 +1,22 @@
getJasmineRequireObj().NotEmpty = function(j$) { getJasmineRequireObj().NotEmpty = function(j$, private$) {
'use strict'; 'use strict';
function NotEmpty() {} function NotEmpty() {}
NotEmpty.prototype.asymmetricMatch = function(other) { NotEmpty.prototype.asymmetricMatch = function(other) {
if ( if (
j$.private.isString(other) || private$.isString(other) ||
j$.private.isArray(other) || Array.isArray(other) ||
j$.private.isTypedArray(other) private$.isTypedArray(other)
) { ) {
return other.length !== 0; return other.length !== 0;
} }
if (j$.private.isMap(other) || j$.private.isSet(other)) { if (private$.isMap(other) || private$.isSet(other)) {
return other.size !== 0; return other.size !== 0;
} }
if (j$.private.isObject(other)) { if (private$.isObject(other)) {
return Object.keys(other).length !== 0; return Object.keys(other).length !== 0;
} }

View File

@@ -1,4 +1,4 @@
getJasmineRequireObj().ObjectContaining = function(j$) { getJasmineRequireObj().ObjectContaining = function(j$, private$) {
'use strict'; 'use strict';
function ObjectContaining(sample) { function ObjectContaining(sample) {
@@ -42,7 +42,7 @@ getJasmineRequireObj().ObjectContaining = function(j$) {
}; };
ObjectContaining.prototype.valuesForDiff_ = function(other, pp) { ObjectContaining.prototype.valuesForDiff_ = function(other, pp) {
if (!j$.private.isObject(other)) { if (!private$.isObject(other)) {
return { return {
self: this.jasmineToString(pp), self: this.jasmineToString(pp),
other: other other: other

View File

@@ -1,11 +1,11 @@
getJasmineRequireObj().SetContaining = function(j$) { getJasmineRequireObj().SetContaining = function(j$, private$) {
'use strict'; 'use strict';
function SetContaining(sample) { function SetContaining(sample) {
if (!j$.private.isSet(sample)) { if (!private$.isSet(sample)) {
throw new Error( throw new Error(
'You must provide a set to `setContaining`, not ' + 'You must provide a set to `setContaining`, not ' +
j$.private.basicPrettyPrinter(sample) private$.basicPrettyPrinter(sample)
); );
} }
@@ -13,7 +13,7 @@ getJasmineRequireObj().SetContaining = function(j$) {
} }
SetContaining.prototype.asymmetricMatch = function(other, matchersUtil) { SetContaining.prototype.asymmetricMatch = function(other, matchersUtil) {
if (!j$.private.isSet(other)) { if (!private$.isSet(other)) {
return false; return false;
} }

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