Compare commits

..

15 Commits

Author SHA1 Message Date
Steve Gravrock
a6d7eb2a06 Bump version to 3.9.0 2021-08-21 12:00:23 -07:00
Steve Gravrock
dd8a65cb60 Better reporting of unhandled promise rejections with truthy but non-Error reasons on Node
[#179227413]
2021-08-14 14:03:03 -07:00
Steve Gravrock
e72d161fab Return a promise from Env#execute in environments that support promises
[#178373231]
2021-08-07 13:05:55 -07:00
Steve Gravrock
dcaac62a6c Updated deprecaton messages for Env#throwOnExpectationFailure() and Env#stopOnSpecFailure() 2021-07-31 08:02:39 -07:00
Steve Gravrock
b696bec9e3 Renamed failFast and oneFailurePerSpec config props to stopOnSpecFailure and stopSpecOnExpectationFailure
The new names are more self-explanatory and consistent with jasmine-npm. The
old names are deprecated but still work.

[#178682783]
2021-07-31 07:51:50 -07:00
Steve Gravrock
43073b3bc5 Added API docs for Suite#id and Spec#id
These properties are the only way to obtain runnable IDs, without which
you can't call the form of Env#execute that takes an array of IDs.
2021-07-29 19:32:15 -07:00
Steve Gravrock
286524959b Split boot.js in two to allow the env to be configured in between
This is mainly intended to support jasmine-browser-runner, which will load
a script that configures the env in between the two boot files (boot0.js and
boot1.js). The single-file boot.js is retained for now but will be removed
in a future release.
2021-07-26 18:05:36 -07:00
Steve Gravrock
2c32dd5703 Run browser-flakes build before regular cron build 2021-07-20 17:57:54 -07:00
Steve Gravrock
c1d1d69be2 Fixed test failures in Chrome and Edge 2021-07-19 12:08:40 -07:00
Steve Gravrock
3513249d73 Built distribution 2021-07-19 12:08:18 -07:00
Steve Gravrock
21bfbbb721 Merge branch 'iserror-tt' of https://github.com/bjarkler/jasmine into main
* Fixes Trusted Types error in Chromium-based browsers
* Merges #1921 from @bjarkler
* Fixes #1910
2021-07-19 12:06:12 -07:00
Steve Gravrock
88b90ec258 Backfilled unit tests for j$.isError_ 2021-07-19 10:31:53 -07:00
Steve Gravrock
50c88e7774 Mark Env#hideDisabled deprecated in jsdocs 2021-07-08 18:53:21 -07:00
Steve Gravrock
3e64ce3310 Removed property tests for MatchersUtil#equals
These might be useful for a function with a more restricted domain. But for
equals, which accepts two of literally anything, the short run was too short
to catch any problems and the long run tended to exceed the CircleCi timeout.
2021-07-03 08:37:15 -07:00
Bjarki
dc80a282ba Make j$.isError_ compatible with Trusted Types
The isError_ check uses a heuristic that calls the Function constructor
to determine if the given value is an Error object. This results in a
runtime violation in test suites that enforce Trusted Types.

Since Trusted Types are only supported in modern browsers (currently,
Chromium-based browsers), we can use a more straightforward heuristic in
environments where Trusted Types are supported.

Fixes #1910. See that thread for more details.
2021-07-01 20:21:44 +00:00
37 changed files with 1269 additions and 404 deletions

View File

@@ -58,13 +58,6 @@ jobs:
name: Run tests
command: npm test
# Warning: Sometimes takes a very long time (>25 minutes) on Circle.
# Probably not a good idea to run it from anything but a nightly.
test_node_with_long_property_tests:
<<: *test_node
environment:
JASMINE_LONG_PROPERTY_TESTS: y
test_browsers: &test_browsers
executor: node14
environment:
@@ -108,7 +101,7 @@ workflows:
triggers:
- schedule:
# Times are UTC.
cron: "0 10 * * *"
cron: "0 11 * * *"
filters:
branches:
only:
@@ -133,10 +126,6 @@ workflows:
name: test_node_16
requires:
- build_node_16
- test_node_with_long_property_tests:
executor: node14
requires:
- build_node_14
- test_node:
executor: node12
name: test_node_12
@@ -199,7 +188,7 @@ workflows:
triggers:
- schedule:
# Times are UTC.
cron: "0 11 * * *"
cron: "0 10 * * *"
filters:
branches:
only:

View File

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

View File

@@ -29,7 +29,7 @@ module.exports = {
cwd: libJasmineCore("")
},
{
src: [ "boot.js" ],
src: [ "boot0.js", "boot1.js" ],
dest: standaloneLibDir,
expand: true,
cwd: libJasmineCore("boot")

View File

@@ -41,6 +41,14 @@ module.exports = {
src: ['lib/jasmine-core/boot/boot.js'],
dest: 'lib/jasmine-core/boot.js'
},
boot0: {
src: ['lib/jasmine-core/boot/boot0.js'],
dest: 'lib/jasmine-core/boot0.js'
},
boot1: {
src: ['lib/jasmine-core/boot/boot1.js'],
dest: 'lib/jasmine-core/boot1.js'
},
nodeBoot: {
src: ['lib/jasmine-core/boot/node_boot.js'],
dest: 'lib/jasmine-core/node_boot.js'

View File

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

View File

@@ -5,11 +5,12 @@ var path = require('path'),
fs = require('fs');
var rootPath = path.join(__dirname, "jasmine-core"),
bootFiles = ['boot.js'],
bootFiles = ['boot0.js', 'boot1.js'],
legacyBootFiles = ['boot.js'],
nodeBootFiles = ['node_boot.js'],
cssFiles = [],
jsFiles = [],
jsFilesToSkip = ['jasmine.js'].concat(bootFiles, nodeBootFiles);
jsFilesToSkip = ['jasmine.js'].concat(bootFiles, legacyBootFiles, nodeBootFiles);
fs.readdirSync(rootPath).forEach(function(file) {
if(fs.statSync(path.join(rootPath, file)).isFile()) {

View File

@@ -6,7 +6,7 @@ module Jasmine
end
def js_files
(["jasmine.js"] + Dir.glob(File.join(path, "*.js"))).map { |f| File.basename(f) }.uniq - boot_files - node_boot_files
(["jasmine.js"] + Dir.glob(File.join(path, "*.js"))).map { |f| File.basename(f) }.uniq - boot_files - ["boot0.js", "boot1.js"] - node_boot_files
end
SPEC_TYPES = ["core", "html", "node"]

View File

@@ -21,6 +21,10 @@ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
/**
NOTE: This file is deprecated and will be removed in a future release.
Include both boot0.js and boot1.js (in that order) instead.
Starting with version 2.0, this file "boots" 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 `jasmine.js` and `jasmine_html.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 a project is using Jasmine via the [Ruby gem][jasmine-gem], this file can be copied into the support directory via `jasmine copy_boot_js`. Other environments (e.g., Python) will have different mechanisms.

View File

@@ -1,4 +1,8 @@
/**
NOTE: This file is deprecated and will be removed in a future release.
Include both boot0.js and boot1.js (in that order) instead.
Starting with version 2.0, this file "boots" 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 `jasmine.js` and `jasmine_html.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 a project is using Jasmine via the [Ruby gem][jasmine-gem], this file can be copied into the support directory via `jasmine copy_boot_js`. Other environments (e.g., Python) will have different mechanisms.

View File

@@ -0,0 +1,42 @@
/**
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() {
var 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.
*/
var 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.
*/
var 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.
*/
var 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 (var property in jasmineInterface) {
global[property] = jasmineInterface[property];
}
}());

View File

@@ -0,0 +1,111 @@
/**
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() {
var env = jasmine.getEnv();
/**
* ## Runner Parameters
*
* More browser specific code - wrap the query string in an object and to allow for getting/setting parameters from the runner user interface.
*/
var queryString = new jasmine.QueryString({
getWindowLocation: function() { return window.location; }
});
var filterSpecs = !!queryString.getParam("spec");
var config = {
failFast: queryString.getParam("failFast"),
oneFailurePerSpec: queryString.getParam("oneFailurePerSpec"),
hideDisabled: queryString.getParam("hideDisabled")
};
var random = queryString.getParam("random");
if (random !== undefined && random !== "") {
config.random = random;
}
var seed = queryString.getParam("seed");
if (seed) {
config.seed = seed;
}
/**
* ## 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).
*/
var htmlReporter = new jasmine.HtmlReporter({
env: env,
navigateWithNewParam: function(key, value) { return queryString.navigateWithNewParam(key, value); },
addToExistingQueryString: function(key, value) { return queryString.fullStringWithNewParam(key, value); },
getContainer: function() { return document.body; },
createElement: function() { return document.createElement.apply(document, arguments); },
createTextNode: function() { return document.createTextNode.apply(document, arguments); },
timer: new jasmine.Timer(),
filterSpecs: filterSpecs
});
/**
* 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);
/**
* Filter which specs will be run by matching the start of the full name against the `spec` query param.
*/
var specFilter = new jasmine.HtmlSpecFilter({
filterString: function() { return queryString.getParam("spec"); }
});
config.specFilter = function(spec) {
return specFilter.matches(spec.getFullName());
};
env.configure(config);
/**
* Setting up timing functions to be able to be overridden. Certain browsers (Safari, IE 8, phantomjs) require this hack.
*/
window.setTimeout = window.setTimeout;
window.setInterval = window.setInterval;
window.clearTimeout = window.clearTimeout;
window.clearInterval = window.clearInterval;
/**
* ## 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.
*/
var currentWindowOnload = window.onload;
window.onload = function() {
if (currentWindowOnload) {
currentWindowOnload();
}
htmlReporter.initialize();
env.execute();
};
/**
* Helper function for readability above.
*/
function extend(destination, source) {
for (var property in source) destination[property] = source[property];
return destination;
}
}());

64
lib/jasmine-core/boot0.js Normal file
View File

@@ -0,0 +1,64 @@
/*
Copyright (c) 2008-2021 Pivotal Labs
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.
*/
/**
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() {
var 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.
*/
var 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.
*/
var 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.
*/
var 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 (var property in jasmineInterface) {
global[property] = jasmineInterface[property];
}
}());

133
lib/jasmine-core/boot1.js Normal file
View File

@@ -0,0 +1,133 @@
/*
Copyright (c) 2008-2021 Pivotal Labs
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.
*/
/**
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() {
var env = jasmine.getEnv();
/**
* ## Runner Parameters
*
* More browser specific code - wrap the query string in an object and to allow for getting/setting parameters from the runner user interface.
*/
var queryString = new jasmine.QueryString({
getWindowLocation: function() { return window.location; }
});
var filterSpecs = !!queryString.getParam("spec");
var config = {
failFast: queryString.getParam("failFast"),
oneFailurePerSpec: queryString.getParam("oneFailurePerSpec"),
hideDisabled: queryString.getParam("hideDisabled")
};
var random = queryString.getParam("random");
if (random !== undefined && random !== "") {
config.random = random;
}
var seed = queryString.getParam("seed");
if (seed) {
config.seed = seed;
}
/**
* ## 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).
*/
var htmlReporter = new jasmine.HtmlReporter({
env: env,
navigateWithNewParam: function(key, value) { return queryString.navigateWithNewParam(key, value); },
addToExistingQueryString: function(key, value) { return queryString.fullStringWithNewParam(key, value); },
getContainer: function() { return document.body; },
createElement: function() { return document.createElement.apply(document, arguments); },
createTextNode: function() { return document.createTextNode.apply(document, arguments); },
timer: new jasmine.Timer(),
filterSpecs: filterSpecs
});
/**
* 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);
/**
* Filter which specs will be run by matching the start of the full name against the `spec` query param.
*/
var specFilter = new jasmine.HtmlSpecFilter({
filterString: function() { return queryString.getParam("spec"); }
});
config.specFilter = function(spec) {
return specFilter.matches(spec.getFullName());
};
env.configure(config);
/**
* Setting up timing functions to be able to be overridden. Certain browsers (Safari, IE 8, phantomjs) require this hack.
*/
window.setTimeout = window.setTimeout;
window.setInterval = window.setInterval;
window.clearTimeout = window.clearTimeout;
window.clearInterval = window.clearInterval;
/**
* ## 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.
*/
var currentWindowOnload = window.onload;
window.onload = function() {
if (currentWindowOnload) {
currentWindowOnload();
}
htmlReporter.initialize();
env.execute();
};
/**
* Helper function for readability above.
*/
function extend(destination, source) {
for (var property in source) destination[property] = source[property];
return destination;
}
}());

View File

@@ -58,6 +58,11 @@ class Core(object):
js_files.remove('boot.js')
js_files.append('boot.js')
# Remove the new boot files. jasmine-py will continue to use the legacy
# boot.js.
js_files.remove('boot0.js')
js_files.remove('boot1.js')
return cls._uniq(js_files)
@classmethod
@@ -86,4 +91,4 @@ class Core(object):
seen[marker] = 1
result.append(item)
return result
return result

View File

@@ -558,17 +558,20 @@ jasmineRequire.HtmlReporter = function(j$) {
);
var failFastCheckbox = optionsMenuDom.querySelector('#jasmine-fail-fast');
failFastCheckbox.checked = config.failFast;
failFastCheckbox.checked = config.stopOnSpecFailure;
failFastCheckbox.onclick = function() {
navigateWithNewParam('failFast', !config.failFast);
navigateWithNewParam('failFast', !config.stopOnSpecFailure);
};
var throwCheckbox = optionsMenuDom.querySelector(
'#jasmine-throw-failures'
);
throwCheckbox.checked = config.oneFailurePerSpec;
throwCheckbox.checked = config.stopSpecOnExpectationFailure;
throwCheckbox.onclick = function() {
navigateWithNewParam('oneFailurePerSpec', !config.oneFailurePerSpec);
navigateWithNewParam(
'oneFailurePerSpec',
!config.stopSpecOnExpectationFailure
);
};
var randomCheckbox = optionsMenuDom.querySelector(

View File

@@ -267,9 +267,21 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) {
};
j$.isError_ = function(value) {
if (!value) {
return false;
}
if (value instanceof Error) {
return true;
}
if (
typeof window !== 'undefined' &&
typeof window.trustedTypes !== 'undefined'
) {
return (
typeof value.stack === 'string' && typeof value.message === 'string'
);
}
if (value && value.constructor && value.constructor.constructor) {
var valueGlobal = value.constructor.constructor('return this');
if (j$.isFunction_(valueGlobal)) {
@@ -700,6 +712,12 @@ getJasmineRequireObj().Spec = function(j$) {
this.expectationFactory = attrs.expectationFactory;
this.asyncExpectationFactory = attrs.asyncExpectationFactory;
this.resultCallback = attrs.resultCallback || function() {};
/**
* The unique ID of this spec.
* @name Spec#id
* @readonly
* @type {string}
*/
this.id = attrs.id;
/**
* The description passed to the {@link it} that created this spec.
@@ -1057,8 +1075,17 @@ getJasmineRequireObj().Env = function(j$) {
* @since 3.3.0
* @type Boolean
* @default false
* @deprecated Use the `stopOnSpecFailure` config property instead.
*/
failFast: false,
/**
* Whether to stop execution of the suite after the first spec failure
* @name Configuration#stopOnSpecFailure
* @since 3.9.0
* @type Boolean
* @default false
*/
stopOnSpecFailure: false,
/**
* Whether to fail the spec if it ran no expectations. By default
* a spec that ran no expectations is reported as passed. Setting this
@@ -1075,8 +1102,17 @@ getJasmineRequireObj().Env = function(j$) {
* @since 3.3.0
* @type Boolean
* @default false
* @deprecated Use the `stopSpecOnExpectationFailure` config property instead.
*/
oneFailurePerSpec: false,
/**
* Whether to cause specs to only have one expectation failure.
* @name Configuration#stopSpecOnExpectationFailure
* @since 3.3.0
* @type Boolean
* @default false
*/
stopSpecOnExpectationFailure: false,
/**
* A function that takes a spec and returns true if it should be executed
* or false if it should be skipped.
@@ -1162,35 +1198,66 @@ getJasmineRequireObj().Env = function(j$) {
* @function
*/
this.configure = function(configuration) {
var booleanProps = [
'random',
'failSpecWithNoExpectations',
'hideDisabled'
];
booleanProps.forEach(function(prop) {
if (typeof configuration[prop] !== 'undefined') {
config[prop] = !!configuration[prop];
}
});
if (typeof configuration.failFast !== 'undefined') {
if (typeof configuration.stopOnSpecFailure !== 'undefined') {
if (configuration.stopOnSpecFailure !== configuration.failFast) {
throw new Error(
'stopOnSpecFailure and failFast are aliases for ' +
"each other. Don't set failFast if you also set stopOnSpecFailure."
);
}
}
config.failFast = configuration.failFast;
config.stopOnSpecFailure = configuration.failFast;
} else if (typeof configuration.stopOnSpecFailure !== 'undefined') {
config.failFast = configuration.stopOnSpecFailure;
config.stopOnSpecFailure = configuration.stopOnSpecFailure;
}
if (typeof configuration.oneFailurePerSpec !== 'undefined') {
if (typeof configuration.stopSpecOnExpectationFailure !== 'undefined') {
if (
configuration.stopSpecOnExpectationFailure !==
configuration.oneFailurePerSpec
) {
throw new Error(
'stopSpecOnExpectationFailure and oneFailurePerSpec are aliases for ' +
"each other. Don't set oneFailurePerSpec if you also set stopSpecOnExpectationFailure."
);
}
}
config.oneFailurePerSpec = configuration.oneFailurePerSpec;
config.stopSpecOnExpectationFailure = configuration.oneFailurePerSpec;
} else if (
typeof configuration.stopSpecOnExpectationFailure !== 'undefined'
) {
config.oneFailurePerSpec = configuration.stopSpecOnExpectationFailure;
config.stopSpecOnExpectationFailure =
configuration.stopSpecOnExpectationFailure;
}
if (configuration.specFilter) {
config.specFilter = configuration.specFilter;
}
if (configuration.hasOwnProperty('random')) {
config.random = !!configuration.random;
}
if (configuration.hasOwnProperty('seed')) {
if (typeof configuration.seed !== 'undefined') {
config.seed = configuration.seed;
}
if (configuration.hasOwnProperty('failFast')) {
config.failFast = configuration.failFast;
}
if (configuration.hasOwnProperty('failSpecWithNoExpectations')) {
config.failSpecWithNoExpectations =
configuration.failSpecWithNoExpectations;
}
if (configuration.hasOwnProperty('oneFailurePerSpec')) {
config.oneFailurePerSpec = configuration.oneFailurePerSpec;
}
if (configuration.hasOwnProperty('hideDisabled')) {
config.hideDisabled = configuration.hideDisabled;
}
// Don't use hasOwnProperty to check for Promise existence because Promise
// can be initialized to undefined, either explicitly or by using the
// object returned from Env#configuration. In particular, Karma does this.
@@ -1486,18 +1553,22 @@ getJasmineRequireObj().Env = function(j$) {
* @since 2.3.0
* @function
* @param {Boolean} value Whether to throw when a expectation fails
* @deprecated Use the `oneFailurePerSpec` option with {@link Env#configure}
* @deprecated Use the `stopSpecOnExpectationFailure` option with {@link Env#configure}
*/
this.throwOnExpectationFailure = function(value) {
this.deprecated(
'Setting throwOnExpectationFailure directly on Env is deprecated and will be removed in a future version of Jasmine, please use the oneFailurePerSpec option in `configure`'
'Setting throwOnExpectationFailure directly on Env is deprecated and ' +
'will be removed in a future version of Jasmine. Please use the ' +
'stopSpecOnExpectationFailure option in `configure`.'
);
this.configure({ oneFailurePerSpec: !!value });
};
this.throwingExpectationFailures = function() {
this.deprecated(
'Getting throwingExpectationFailures directly from Env is deprecated and will be removed in a future version of Jasmine, please check the oneFailurePerSpec option from `configuration`'
'Getting throwingExpectationFailures directly from Env is deprecated ' +
'and will be removed in a future version of Jasmine. Please check ' +
'the stopSpecOnExpectationFailure option from `configuration`.'
);
return config.oneFailurePerSpec;
};
@@ -1508,18 +1579,22 @@ getJasmineRequireObj().Env = function(j$) {
* @since 2.7.0
* @function
* @param {Boolean} value Whether to stop suite execution when a spec fails
* @deprecated Use the `failFast` option with {@link Env#configure}
* @deprecated Use the `stopOnSpecFailure` option with {@link Env#configure}
*/
this.stopOnSpecFailure = function(value) {
this.deprecated(
'Setting stopOnSpecFailure directly is deprecated and will be removed in a future version of Jasmine, please use the failFast option in `configure`'
'Setting stopOnSpecFailure directly is deprecated and will be ' +
'removed in a future version of Jasmine. Please use the ' +
'stopOnSpecFailure option in `configure`.'
);
this.configure({ failFast: !!value });
this.configure({ stopOnSpecFailure: !!value });
};
this.stoppingOnSpecFailure = function() {
this.deprecated(
'Getting stoppingOnSpecFailure directly from Env is deprecated and will be removed in a future version of Jasmine, please check the failFast option from `configuration`'
'Getting stoppingOnSpecFailure directly from Env is deprecated and ' +
'will be removed in a future version of Jasmine. Please check the ' +
'stopOnSpecFailure option from `configuration`.'
);
return config.failFast;
};
@@ -1575,6 +1650,7 @@ getJasmineRequireObj().Env = function(j$) {
* @name Env#hideDisabled
* @since 3.2.0
* @function
* @deprecated Use the `hideDisabled` option with {@link Env#configure}
*/
this.hideDisabled = function(value) {
this.deprecated(
@@ -1607,9 +1683,9 @@ getJasmineRequireObj().Env = function(j$) {
var queueRunnerFactory = function(options, args) {
var failFast = false;
if (options.isLeaf) {
failFast = config.oneFailurePerSpec;
failFast = config.stopSpecOnExpectationFailure;
} else if (!options.isReporter) {
failFast = config.failFast;
failFast = config.stopOnSpecFailure;
}
options.clearStack = options.clearStack || clearStack;
options.timeout = {
@@ -1741,11 +1817,17 @@ getJasmineRequireObj().Env = function(j$) {
*
* execute should not be called more than once.
*
* If the environment supports promises, execute will return a promise that
* is resolved after the suite finishes executing. The promise will be
* resolved (not rejected) as long as the suite runs to completion. Use a
* {@link Reporter} to determine whether or not the suite passed.
*
* @name Env#execute
* @since 2.0.0
* @function
* @param {(string[])=} runnablesToRun IDs of suites and/or specs to run
* @param {Function=} onComplete Function that will be called after all specs have run
* @return {Promise<undefined>}
*/
this.execute = function(runnablesToRun, onComplete) {
installGlobalErrors();
@@ -1805,65 +1887,86 @@ getJasmineRequireObj().Env = function(j$) {
var jasmineTimer = new j$.Timer();
jasmineTimer.start();
/**
* Information passed to the {@link Reporter#jasmineStarted} event.
* @typedef JasmineStartedInfo
* @property {Int} totalSpecsDefined - The total number of specs defined in this suite.
* @property {Order} order - Information about the ordering (random or not) of this execution of the suite.
*/
reporter.jasmineStarted(
{
totalSpecsDefined: totalSpecsDefined,
order: order
},
function() {
currentlyExecutingSuites.push(topSuite);
var Promise = customPromise || global.Promise;
processor.execute(function() {
clearResourcesForRunnable(topSuite.id);
currentlyExecutingSuites.pop();
var overallStatus, incompleteReason;
if (hasFailures || topSuite.result.failedExpectations.length > 0) {
overallStatus = 'failed';
} else if (focusedRunnables.length > 0) {
overallStatus = 'incomplete';
incompleteReason = 'fit() or fdescribe() was found';
} else if (totalSpecsDefined === 0) {
overallStatus = 'incomplete';
incompleteReason = 'No specs found';
} else {
overallStatus = 'passed';
if (Promise) {
return new Promise(function(resolve) {
runAll(function() {
if (onComplete) {
onComplete();
}
/**
* Information passed to the {@link Reporter#jasmineDone} event.
* @typedef JasmineDoneInfo
* @property {OverallStatus} overallStatus - The overall result of the suite: 'passed', 'failed', or 'incomplete'.
* @property {Int} totalTime - The total time (in ms) that it took to execute the suite
* @property {IncompleteReason} incompleteReason - Explanation of why the suite was incomplete.
* @property {Order} order - Information about the ordering (random or not) of this execution of the suite.
* @property {Expectation[]} failedExpectations - List of expectations that failed in an {@link afterAll} at the global level.
* @property {Expectation[]} deprecationWarnings - List of deprecation warnings that occurred at the global level.
*/
reporter.jasmineDone(
{
overallStatus: overallStatus,
totalTime: jasmineTimer.elapsed(),
incompleteReason: incompleteReason,
order: order,
failedExpectations: topSuite.result.failedExpectations,
deprecationWarnings: topSuite.result.deprecationWarnings
},
function() {
if (onComplete) {
onComplete();
}
}
);
resolve();
});
}
);
});
} else {
runAll(function() {
if (onComplete) {
onComplete();
}
});
}
function runAll(done) {
/**
* Information passed to the {@link Reporter#jasmineStarted} event.
* @typedef JasmineStartedInfo
* @property {Int} totalSpecsDefined - The total number of specs defined in this suite.
* @property {Order} order - Information about the ordering (random or not) of this execution of the suite.
*/
reporter.jasmineStarted(
{
totalSpecsDefined: totalSpecsDefined,
order: order
},
function() {
currentlyExecutingSuites.push(topSuite);
processor.execute(function() {
clearResourcesForRunnable(topSuite.id);
currentlyExecutingSuites.pop();
var overallStatus, incompleteReason;
if (
hasFailures ||
topSuite.result.failedExpectations.length > 0
) {
overallStatus = 'failed';
} else if (focusedRunnables.length > 0) {
overallStatus = 'incomplete';
incompleteReason = 'fit() or fdescribe() was found';
} else if (totalSpecsDefined === 0) {
overallStatus = 'incomplete';
incompleteReason = 'No specs found';
} else {
overallStatus = 'passed';
}
/**
* Information passed to the {@link Reporter#jasmineDone} event.
* @typedef JasmineDoneInfo
* @property {OverallStatus} overallStatus - The overall result of the suite: 'passed', 'failed', or 'incomplete'.
* @property {Int} totalTime - The total time (in ms) that it took to execute the suite
* @property {IncompleteReason} incompleteReason - Explanation of why the suite was incomplete.
* @property {Order} order - Information about the ordering (random or not) of this execution of the suite.
* @property {Expectation[]} failedExpectations - List of expectations that failed in an {@link afterAll} at the global level.
* @property {Expectation[]} deprecationWarnings - List of deprecation warnings that occurred at the global level.
*/
reporter.jasmineDone(
{
overallStatus: overallStatus,
totalTime: jasmineTimer.elapsed(),
incompleteReason: incompleteReason,
order: order,
failedExpectations: topSuite.result.failedExpectations,
deprecationWarnings: topSuite.result.deprecationWarnings
},
done
);
});
}
);
}
};
/**
@@ -4230,16 +4333,22 @@ getJasmineRequireObj().GlobalErrors = function(j$) {
function taggedOnError(error) {
var substituteMsg;
if (error) {
if (j$.isError_(error)) {
error.jasmineMessage = jasmineMessage + ': ' + error;
} else {
substituteMsg = jasmineMessage + ' with no error or message';
if (error) {
substituteMsg = jasmineMessage + ': ' + error;
} else {
substituteMsg = jasmineMessage + ' with no error or message';
}
if (errorType === 'unhandledRejection') {
substituteMsg +=
'\n' +
'(Tip: to get a useful stack trace, use ' +
'Promise.reject(new Error(...)) instead of Promise.reject().)';
'Promise.reject(new Error(...)) instead of Promise.reject(' +
(error ? '...' : '') +
').)';
}
error = new Error(substituteMsg);
@@ -9236,6 +9345,12 @@ getJasmineRequireObj().Suite = function(j$) {
*/
function Suite(attrs) {
this.env = attrs.env;
/**
* The unique ID of this suite.
* @name Suite#id
* @readonly
* @type {string}
*/
this.id = attrs.id;
/**
* The parent of this suite, or null if this is the top suite.
@@ -9757,5 +9872,5 @@ getJasmineRequireObj().UserContext = function(j$) {
};
getJasmineRequireObj().version = function() {
return '3.8.0';
return '3.9.0';
};

View File

@@ -4,6 +4,6 @@
#
module Jasmine
module Core
VERSION = "3.8.0"
VERSION = "3.9.0"
end
end

View File

@@ -1,7 +1,7 @@
{
"name": "jasmine-core",
"license": "MIT",
"version": "3.8.0",
"version": "3.9.0",
"repository": {
"type": "git",
"url": "https://github.com/jasmine/jasmine.git"
@@ -37,7 +37,6 @@
"ejs": "^2.5.5",
"eslint": "^6.8.0",
"eslint-plugin-compat": "^3.8.0",
"fast-check": "^1.21.0",
"fast-glob": "^2.2.6",
"grunt": "^1.0.4",
"grunt-cli": "^1.3.2",

65
release_notes/3.9.0.md Normal file
View File

@@ -0,0 +1,65 @@
# Jasmine Core 3.9 Release Notes
## New features and bug fixes
* Fixed Trusted Types error in `j$.isError_` in Chromium-based browsers
* Merges [#1921](https://github.com/jasmine/jasmine/pull/1921) from @bjarkler
* Fixes [#1910](https://github.com/jasmine/jasmine/issues/1910)
* Fixes [#1653](https://github.com/jasmine/jasmine/issues/1653)
* Better reporting of unhandled promise rejections with truthy but non-`Error`
reasons on Node
* `Env#execute` returns a promise in environments that support promises
* Renamed `failFast` and `oneFailurePerSpec` config props to `stopOnSpecFailure`
and `stopSpecOnExpectationFailure`
The new names are more self-explanatory and consistent with jasmine-npm. The
old names are deprecated but will still work until the next major release.
* Split `boot.js` into two files to allow the env to be configured in between
This is mainly intended to support jasmine-browser-runner, which will load
a script that configures the env in between the two boot files (`boot0.js` and
`boot1.js`). The single-file `boot.js` will still be included until the next
major release.
## Ruby deprecation
The Jasmine Ruby gems are deprecated. There will be no further releases after
the end of the Jasmine 3.x series. We recommend that most users migrate to the
[jasmine-browser-runner](https://github.com/jasmine/jasmine-browser)
npm package, which is the direct replacement for the `jasmine` gem.
If `jasmine-browser-runner` doesn't meet your needs, one of these might:
* The [jasmine](https://github.com/jasmine/jasmine-npm) npm package to run
specs in Node.js.
* The [standalone distribution](https://github.com/jasmine/jasmine#installation)
to run specs in browsers with no additional tools.
* The [jasmine-core](https://github.com/jasmine/jasmine) npm package if all
you need is the Jasmine assets. This is the direct equivalent of the
`jasmine-core` Ruby gem.
## Documentation updates
* Added API docs for `Suite#id` and `Spec#id`
* Marked `Env#hideDisabled` deprecated in jsdocs
------
## Supported environments
jasmine-core 3.8.0 has been tested in the following environments.
| Environment | Supported versions |
|-------------------|--------------------|
| Node | 10, 12, 14, 16 |
| Safari | 8-14 |
| Chrome | 92 |
| Firefox | 91, 78, 68 |
| Edge | 92 |
| Internet Explorer | 10, 11 |
_Release Notes generated with _[Anchorman](http://github.com/infews/anchorman)_

View File

@@ -60,6 +60,93 @@ describe('Env', function() {
);
});
it('ignores configuration properties that are present but undefined', function() {
var initialConfig = {
random: true,
seed: '123',
failFast: true,
failSpecWithNoExpectations: true,
oneFailurePerSpec: true,
stopSpecOnExpectationFailure: true,
stopOnSpecFailure: true,
hideDisabled: true
};
env.configure(initialConfig);
env.configure({
random: undefined,
seed: undefined,
failFast: undefined,
failSpecWithNoExpectations: undefined,
oneFailurePerSpec: undefined,
stopSpecOnExpectationFailure: undefined,
stopOnSpecFailure: undefined,
hideDisabled: undefined
});
expect(env.configuration()).toEqual(
jasmine.objectContaining(initialConfig)
);
});
it('sets stopOnSpecFailure when failFast is set, and vice versa', function() {
env.configure({ failFast: true });
expect(env.configuration()).toEqual(
jasmine.objectContaining({
failFast: true,
stopOnSpecFailure: true
})
);
env.configure({ stopOnSpecFailure: false });
expect(env.configuration()).toEqual(
jasmine.objectContaining({
failFast: false,
stopOnSpecFailure: false
})
);
});
it('rejects a single call that sets stopOnSpecFailure and failFast to different values', function() {
expect(function() {
env.configure({ failFast: true, stopOnSpecFailure: false });
}).toThrowError(
'stopOnSpecFailure and failFast are aliases for each ' +
"other. Don't set failFast if you also set stopOnSpecFailure."
);
});
it('sets stopSpecOnExpectationFailure when oneFailurePerSpec is set, and vice versa', function() {
env.configure({ oneFailurePerSpec: true });
expect(env.configuration()).toEqual(
jasmine.objectContaining({
oneFailurePerSpec: true,
stopSpecOnExpectationFailure: true
})
);
env.configure({ stopSpecOnExpectationFailure: false });
expect(env.configuration()).toEqual(
jasmine.objectContaining({
oneFailurePerSpec: false,
stopSpecOnExpectationFailure: false
})
);
});
it('rejects a single call that sets stopSpecOnExpectationFailure and oneFailurePerSpec to different values', function() {
expect(function() {
env.configure({
oneFailurePerSpec: true,
stopSpecOnExpectationFailure: false
});
}).toThrowError(
'stopSpecOnExpectationFailure and oneFailurePerSpec are ' +
"aliases for each other. Don't set oneFailurePerSpec if you also set " +
'stopSpecOnExpectationFailure.'
);
});
describe('promise library', function() {
it('can be configured without a custom library', function() {
env.configure({});
@@ -378,4 +465,25 @@ describe('Env', function() {
done();
});
});
describe('#execute', function() {
it('returns a promise when the environment supports promises', function() {
jasmine.getEnv().requirePromises();
expect(env.execute()).toBeInstanceOf(Promise);
});
it('returns a promise when a custom promise constructor is provided', function() {
function CustomPromise() {}
CustomPromise.resolve = function() {};
CustomPromise.reject = function() {};
env.configure({ Promise: CustomPromise });
expect(env.execute()).toBeInstanceOf(CustomPromise);
});
it('returns undefined when promises are unavailable', function() {
jasmine.getEnv().requireNoPromises();
expect(env.execute()).toBeUndefined();
});
});
});

View File

@@ -170,84 +170,118 @@ describe('GlobalErrors', function() {
);
});
it('reports unhandled promise rejections in node.js', function() {
var fakeGlobal = {
process: {
on: jasmine.createSpy('process.on'),
removeListener: jasmine.createSpy('process.removeListener'),
listeners: jasmine
.createSpy('process.listeners')
.and.returnValue(['foo']),
removeAllListeners: jasmine.createSpy('process.removeAllListeners')
}
},
handler = jasmine.createSpy('errorHandler'),
errors = new jasmineUnderTest.GlobalErrors(fakeGlobal);
describe('Reporting unhandled promise rejections in node.js', function() {
it('reports rejections with `Error` reasons', function() {
var fakeGlobal = {
process: {
on: jasmine.createSpy('process.on'),
removeListener: jasmine.createSpy('process.removeListener'),
listeners: jasmine
.createSpy('process.listeners')
.and.returnValue(['foo']),
removeAllListeners: jasmine.createSpy('process.removeAllListeners')
}
},
handler = jasmine.createSpy('errorHandler'),
errors = new jasmineUnderTest.GlobalErrors(fakeGlobal);
errors.install();
expect(fakeGlobal.process.on).toHaveBeenCalledWith(
'unhandledRejection',
jasmine.any(Function)
);
expect(fakeGlobal.process.listeners).toHaveBeenCalledWith(
'unhandledRejection'
);
expect(fakeGlobal.process.removeAllListeners).toHaveBeenCalledWith(
'unhandledRejection'
);
errors.install();
expect(fakeGlobal.process.on).toHaveBeenCalledWith(
'unhandledRejection',
jasmine.any(Function)
);
expect(fakeGlobal.process.listeners).toHaveBeenCalledWith(
'unhandledRejection'
);
expect(fakeGlobal.process.removeAllListeners).toHaveBeenCalledWith(
'unhandledRejection'
);
errors.pushListener(handler);
errors.pushListener(handler);
var addedListener = fakeGlobal.process.on.calls.argsFor(1)[1];
addedListener(new Error('bar'));
var addedListener = fakeGlobal.process.on.calls.argsFor(1)[1];
addedListener(new Error('bar'));
expect(handler).toHaveBeenCalledWith(new Error('bar'));
expect(handler.calls.argsFor(0)[0].jasmineMessage).toBe(
'Unhandled promise rejection: Error: bar'
);
expect(handler).toHaveBeenCalledWith(new Error('bar'));
expect(handler.calls.argsFor(0)[0].jasmineMessage).toBe(
'Unhandled promise rejection: Error: bar'
);
errors.uninstall();
errors.uninstall();
expect(fakeGlobal.process.removeListener).toHaveBeenCalledWith(
'unhandledRejection',
addedListener
);
expect(fakeGlobal.process.on).toHaveBeenCalledWith(
'unhandledRejection',
'foo'
);
});
expect(fakeGlobal.process.removeListener).toHaveBeenCalledWith(
'unhandledRejection',
addedListener
);
expect(fakeGlobal.process.on).toHaveBeenCalledWith(
'unhandledRejection',
'foo'
);
});
it('reports unhandled promise rejections in node.js when no error is provided', function() {
var fakeGlobal = {
process: {
on: jasmine.createSpy('process.on'),
removeListener: function() {},
listeners: function() {
return [];
},
removeAllListeners: function() {}
}
},
handler = jasmine.createSpy('errorHandler'),
errors = new jasmineUnderTest.GlobalErrors(fakeGlobal);
it('reports rejections with non-`Error` reasons', function() {
var fakeGlobal = {
process: {
on: jasmine.createSpy('process.on'),
removeListener: function() {},
listeners: function() {
return [];
},
removeAllListeners: function() {}
}
},
handler = jasmine.createSpy('errorHandler'),
errors = new jasmineUnderTest.GlobalErrors(fakeGlobal);
errors.install();
errors.pushListener(handler);
errors.install();
errors.pushListener(handler);
expect(fakeGlobal.process.on.calls.argsFor(1)[0]).toEqual(
'unhandledRejection'
);
var addedListener = fakeGlobal.process.on.calls.argsFor(1)[1];
addedListener(undefined);
expect(fakeGlobal.process.on.calls.argsFor(1)[0]).toEqual(
'unhandledRejection'
);
var addedListener = fakeGlobal.process.on.calls.argsFor(1)[1];
addedListener(17);
expect(handler).toHaveBeenCalledWith(
new Error(
'Unhandled promise rejection with no error or message\n' +
'(Tip: to get a useful stack trace, use ' +
'Promise.reject(new Error(...)) instead of Promise.reject().)'
)
);
expect(handler).toHaveBeenCalledWith(
new Error(
'Unhandled promise rejection: 17\n' +
'(Tip: to get a useful stack trace, use ' +
'Promise.reject(new Error(...)) instead of Promise.reject(...).)'
)
);
});
it('reports rejections with no reason provided', function() {
var fakeGlobal = {
process: {
on: jasmine.createSpy('process.on'),
removeListener: function() {},
listeners: function() {
return [];
},
removeAllListeners: function() {}
}
},
handler = jasmine.createSpy('errorHandler'),
errors = new jasmineUnderTest.GlobalErrors(fakeGlobal);
errors.install();
errors.pushListener(handler);
expect(fakeGlobal.process.on.calls.argsFor(1)[0]).toEqual(
'unhandledRejection'
);
var addedListener = fakeGlobal.process.on.calls.argsFor(1)[1];
addedListener(undefined);
expect(handler).toHaveBeenCalledWith(
new Error(
'Unhandled promise rejection with no error or message\n' +
'(Tip: to get a useful stack trace, use ' +
'Promise.reject(new Error(...)) instead of Promise.reject().)'
)
);
});
});
describe('Reporting unhandled promise rejections in the browser', function() {

View File

@@ -29,6 +29,43 @@ describe('base helpers', function() {
}
}, 100);
});
it('returns true for an Error subclass', function() {
function MyError() {}
MyError.prototype = new Error();
expect(jasmineUnderTest.isError_(new MyError())).toBe(true);
});
it('returns true for an un-thrown Error with no message in this environment', function() {
expect(jasmineUnderTest.isError_(new Error())).toBe(true);
});
it('returns true for an Error that originated from another frame', function() {
var iframe, error;
if (typeof window === 'undefined') {
pending('This test only runs in browsers.');
}
iframe = document.createElement('iframe');
iframe.style.display = 'none';
document.body.appendChild(iframe);
try {
error = iframe.contentWindow.eval('new Error()');
expect(jasmineUnderTest.isError_(error)).toBe(true);
} finally {
document.body.removeChild(iframe);
}
});
it('returns false for a falsy value', function() {
expect(jasmineUnderTest.isError_(undefined)).toBe(false);
});
it('returns false for a non-Error object', function() {
expect(jasmineUnderTest.isError_({})).toBe(false);
});
});
describe('isAsymmetricEqualityTester_', function() {

View File

@@ -3038,6 +3038,112 @@ describe('Env integration', function() {
env.execute(null, done);
});
describe('The promise returned by #execute', function() {
beforeEach(function() {
this.savedInterval = jasmineUnderTest.DEFAULT_TIMEOUT_INTERVAL;
});
afterEach(function() {
jasmineUnderTest.DEFAULT_TIMEOUT_INTERVAL = this.savedInterval;
});
it('is resolved after reporter events are dispatched', function() {
jasmine.getEnv().requirePromises();
var reporter = jasmine.createSpyObj('reporter', [
'specDone',
'suiteDone',
'jasmineDone'
]);
env.addReporter(reporter);
env.describe('suite', function() {
env.it('spec', function() {});
});
return env.execute(null).then(function() {
expect(reporter.specDone).toHaveBeenCalled();
expect(reporter.suiteDone).toHaveBeenCalled();
expect(reporter.jasmineDone).toHaveBeenCalled();
});
});
it('is resolved after the stack is cleared', function(done) {
jasmine.getEnv().requirePromises();
var realClearStack = jasmineUnderTest.getClearStack(
jasmineUnderTest.getGlobal()
),
clearStackSpy = jasmine
.createSpy('clearStack')
.and.callFake(realClearStack);
spyOn(jasmineUnderTest, 'getClearStack').and.returnValue(clearStackSpy);
// Create a new env that has the clearStack defined above
env.cleanup_();
env = new jasmineUnderTest.Env();
env.describe('suite', function() {
env.it('spec', function() {});
});
env.execute(null).then(function() {
expect(clearStackSpy).toHaveBeenCalled(); // (many times)
clearStackSpy.calls.reset();
setTimeout(function() {
expect(clearStackSpy).not.toHaveBeenCalled();
done();
});
});
});
it('is resolved after QueueRunner timeouts are cleared', function() {
jasmine.getEnv().requirePromises();
var setTimeoutSpy = spyOn(
jasmineUnderTest.getGlobal(),
'setTimeout'
).and.callThrough();
var clearTimeoutSpy = spyOn(
jasmineUnderTest.getGlobal(),
'clearTimeout'
).and.callThrough();
jasmineUnderTest.DEFAULT_TIMEOUT_INTERVAL = 123456; // a distinctive value
env = new jasmineUnderTest.Env();
env.describe('suite', function() {
env.it('spec', function() {});
});
return env.execute(null).then(function() {
var timeoutIds = setTimeoutSpy.calls
.all()
.filter(function(call) {
return call.args[1] === 123456;
})
.map(function(call) {
return call.returnValue;
});
expect(timeoutIds.length).toBeGreaterThan(0);
timeoutIds.forEach(function(timeoutId) {
expect(clearTimeoutSpy).toHaveBeenCalledWith(timeoutId);
});
});
});
it('is resolved even if specs fail', function() {
jasmine.getEnv().requirePromises();
env.describe('suite', function() {
env.it('spec', function() {
env.expect(true).toBe(false);
});
});
return expectAsync(env.execute(null)).toBeResolved();
});
});
describe('The optional callback argument to #execute', function() {
beforeEach(function() {
this.savedInterval = jasmineUnderTest.DEFAULT_TIMEOUT_INTERVAL;

View File

@@ -980,35 +980,10 @@ describe('spec running', function() {
});
});
describe('when stopOnSpecFailure is on', function() {
function behavesLikeStopOnSpecFailureIsOn(configureFn) {
it('does not run further specs when one fails', function(done) {
var actions = [];
env.describe('wrapper', function() {
env.it('fails', function() {
actions.push('fails');
env.expect(1).toBe(2);
});
});
env.describe('holder', function() {
env.it('does not run', function() {
actions.push('does not run');
});
});
env.configure({ random: false, failFast: true });
env.execute(null, function() {
expect(actions).toEqual(['fails']);
done();
});
});
it('does not run further specs when one fails when configured with deprecated option', function(done) {
var actions = [];
spyOn(env, 'deprecated');
var actions = [],
config;
env.describe('wrapper', function() {
env.it('fails', function() {
@@ -1024,13 +999,31 @@ describe('spec running', function() {
});
env.configure({ random: false });
env.stopOnSpecFailure(true);
configureFn(env);
env.execute(null, function() {
expect(actions).toEqual(['fails']);
expect(env.deprecated).toHaveBeenCalled();
done();
});
});
}
describe('when failFast is on', function() {
behavesLikeStopOnSpecFailureIsOn(function(env) {
env.configure({ failFast: true });
});
});
describe('when stopOnSpecFailure is on', function() {
behavesLikeStopOnSpecFailureIsOn(function(env) {
env.configure({ stopOnSpecFailure: true });
});
});
describe('when stopOnSpecFailure is enabled via the deprecated method', function() {
behavesLikeStopOnSpecFailureIsOn(function(env) {
spyOn(env, 'deprecated');
env.stopOnSpecFailure(true);
});
});
});

View File

@@ -7,78 +7,6 @@ describe('matchersUtil', function() {
});
describe('equals', function() {
describe('Properties', function() {
var fc;
beforeEach(function() {
fc = jasmine.getEnv().requireFastCheck();
});
function basicAnythingSettings() {
return {
key: fc.oneof(fc.string(), fc.constantFrom('k1', 'k2', 'k3')),
// Limiting depth & number of keys allows fast-check to try
// a lot more scalar values.
maxDepth: 2,
maxKeys: 5,
withBoxedValues: true,
withMap: true,
withSet: true
};
}
function numRuns() {
var many = 5000000;
// Be thorough but very slow when specified (usually on CI).
if (process.env.JASMINE_LONG_PROPERTY_TESTS) {
/* eslint-disable-next-line no-console */
console.log(
'Using',
many,
'runs of fc.assert because JASMINE_LONG_PROPERTY_TESTS was set. This may take several minutes.'
);
return many;
} else {
return undefined;
}
}
it('is symmetric', function() {
fc.assert(
fc.property(
fc.anything(basicAnythingSettings()),
fc.anything(basicAnythingSettings()),
function(a, b) {
return (
jasmineUnderTest.matchersUtil.equals(a, b) ===
jasmineUnderTest.matchersUtil.equals(b, a)
);
}
),
{
numRuns: numRuns(),
examples: [[0, 5e-324]]
}
);
});
it('is reflexive', function() {
var anythingSettings = basicAnythingSettings();
anythingSettings.withMap = false;
fc.assert(
fc.property(fc.dedup(fc.anything(anythingSettings), 2), function(
values
) {
return jasmineUnderTest.matchersUtil.equals(values[0], values[1]);
}),
{
numRuns: numRuns()
}
);
});
});
it('passes for literals that are triple-equal', function() {
var matchersUtil = new jasmineUnderTest.MatchersUtil();
expect(matchersUtil.equals(null, null)).toBe(true);

View File

@@ -4,4 +4,10 @@
env.pending('Environment does not support promises');
}
};
env.requireNoPromises = function() {
if (typeof Promise === 'function') {
env.pending('Environment supports promises');
}
};
})(jasmine.getEnv());

View File

@@ -1,16 +0,0 @@
(function(env) {
var NODE_JS =
typeof process !== 'undefined' &&
process.versions &&
typeof process.versions.node === 'string';
env.requireFastCheck = function() {
if (!NODE_JS) {
env.pending(
"Property tests don't run in the browser. Use `npm test` to run them."
);
}
return require('fast-check');
};
})(jasmine.getEnv());

View File

@@ -663,7 +663,7 @@ describe('HtmlReporter', function() {
}
});
env.configure({ failFast: true });
env.configure({ stopOnSpecFailure: true });
reporter.initialize();
reporter.jasmineDone({});
@@ -717,7 +717,7 @@ describe('HtmlReporter', function() {
}
});
env.configure({ failFast: true });
env.configure({ stopOnSpecFailure: true });
reporter.initialize();
reporter.jasmineDone({});
@@ -769,7 +769,7 @@ describe('HtmlReporter', function() {
}
});
env.configure({ oneFailurePerSpec: true });
env.configure({ stopSpecOnExpectationFailure: true });
reporter.initialize();
reporter.jasmineDone({});
@@ -823,7 +823,7 @@ describe('HtmlReporter', function() {
}
});
env.configure({ oneFailurePerSpec: true });
env.configure({ stopSpecOnExpectationFailure: true });
reporter.initialize();
reporter.jasmineDone({});

View File

@@ -75,7 +75,7 @@ describe('npm package', function() {
});
it('has bootFiles', function() {
expect(this.packagedCore.files.bootFiles).toEqual(['boot.js']);
expect(this.packagedCore.files.bootFiles).toEqual(['boot0.js', 'boot1.js']);
expect(this.packagedCore.files.nodeBootFiles).toEqual(['node_boot.js']);
var packagedCore = this.packagedCore;
@@ -83,6 +83,10 @@ describe('npm package', function() {
expect(fileName).toExistInPath(packagedCore.files.bootDir);
});
// For backwards compatibility, boot.js should be packaged even though
// it is no longer in bootFiles.
expect('boot.js').toExistInPath(packagedCore.files.bootDir);
var packagedCore = this.packagedCore;
this.packagedCore.files.nodeBootFiles.forEach(function(fileName) {
expect(fileName).toExistInPath(packagedCore.files.bootDir);

View File

@@ -28,7 +28,6 @@ module.exports = {
'helpers/domHelpers.js',
'helpers/integrationMatchers.js',
'helpers/promises.js',
'helpers/requireFastCheck.js',
'helpers/defineJasmineUnderTest.js'
],
random: true,

View File

@@ -15,7 +15,6 @@
"helpers/domHelpers.js",
"helpers/integrationMatchers.js",
"helpers/promises.js",
"helpers/requireFastCheck.js",
"helpers/overrideConsoleLogForCircleCi.js",
"helpers/nodeDefineJasmineUnderTest.js"
],

View File

@@ -65,8 +65,17 @@ getJasmineRequireObj().Env = function(j$) {
* @since 3.3.0
* @type Boolean
* @default false
* @deprecated Use the `stopOnSpecFailure` config property instead.
*/
failFast: false,
/**
* Whether to stop execution of the suite after the first spec failure
* @name Configuration#stopOnSpecFailure
* @since 3.9.0
* @type Boolean
* @default false
*/
stopOnSpecFailure: false,
/**
* Whether to fail the spec if it ran no expectations. By default
* a spec that ran no expectations is reported as passed. Setting this
@@ -83,8 +92,17 @@ getJasmineRequireObj().Env = function(j$) {
* @since 3.3.0
* @type Boolean
* @default false
* @deprecated Use the `stopSpecOnExpectationFailure` config property instead.
*/
oneFailurePerSpec: false,
/**
* Whether to cause specs to only have one expectation failure.
* @name Configuration#stopSpecOnExpectationFailure
* @since 3.3.0
* @type Boolean
* @default false
*/
stopSpecOnExpectationFailure: false,
/**
* A function that takes a spec and returns true if it should be executed
* or false if it should be skipped.
@@ -170,35 +188,66 @@ getJasmineRequireObj().Env = function(j$) {
* @function
*/
this.configure = function(configuration) {
var booleanProps = [
'random',
'failSpecWithNoExpectations',
'hideDisabled'
];
booleanProps.forEach(function(prop) {
if (typeof configuration[prop] !== 'undefined') {
config[prop] = !!configuration[prop];
}
});
if (typeof configuration.failFast !== 'undefined') {
if (typeof configuration.stopOnSpecFailure !== 'undefined') {
if (configuration.stopOnSpecFailure !== configuration.failFast) {
throw new Error(
'stopOnSpecFailure and failFast are aliases for ' +
"each other. Don't set failFast if you also set stopOnSpecFailure."
);
}
}
config.failFast = configuration.failFast;
config.stopOnSpecFailure = configuration.failFast;
} else if (typeof configuration.stopOnSpecFailure !== 'undefined') {
config.failFast = configuration.stopOnSpecFailure;
config.stopOnSpecFailure = configuration.stopOnSpecFailure;
}
if (typeof configuration.oneFailurePerSpec !== 'undefined') {
if (typeof configuration.stopSpecOnExpectationFailure !== 'undefined') {
if (
configuration.stopSpecOnExpectationFailure !==
configuration.oneFailurePerSpec
) {
throw new Error(
'stopSpecOnExpectationFailure and oneFailurePerSpec are aliases for ' +
"each other. Don't set oneFailurePerSpec if you also set stopSpecOnExpectationFailure."
);
}
}
config.oneFailurePerSpec = configuration.oneFailurePerSpec;
config.stopSpecOnExpectationFailure = configuration.oneFailurePerSpec;
} else if (
typeof configuration.stopSpecOnExpectationFailure !== 'undefined'
) {
config.oneFailurePerSpec = configuration.stopSpecOnExpectationFailure;
config.stopSpecOnExpectationFailure =
configuration.stopSpecOnExpectationFailure;
}
if (configuration.specFilter) {
config.specFilter = configuration.specFilter;
}
if (configuration.hasOwnProperty('random')) {
config.random = !!configuration.random;
}
if (configuration.hasOwnProperty('seed')) {
if (typeof configuration.seed !== 'undefined') {
config.seed = configuration.seed;
}
if (configuration.hasOwnProperty('failFast')) {
config.failFast = configuration.failFast;
}
if (configuration.hasOwnProperty('failSpecWithNoExpectations')) {
config.failSpecWithNoExpectations =
configuration.failSpecWithNoExpectations;
}
if (configuration.hasOwnProperty('oneFailurePerSpec')) {
config.oneFailurePerSpec = configuration.oneFailurePerSpec;
}
if (configuration.hasOwnProperty('hideDisabled')) {
config.hideDisabled = configuration.hideDisabled;
}
// Don't use hasOwnProperty to check for Promise existence because Promise
// can be initialized to undefined, either explicitly or by using the
// object returned from Env#configuration. In particular, Karma does this.
@@ -494,18 +543,22 @@ getJasmineRequireObj().Env = function(j$) {
* @since 2.3.0
* @function
* @param {Boolean} value Whether to throw when a expectation fails
* @deprecated Use the `oneFailurePerSpec` option with {@link Env#configure}
* @deprecated Use the `stopSpecOnExpectationFailure` option with {@link Env#configure}
*/
this.throwOnExpectationFailure = function(value) {
this.deprecated(
'Setting throwOnExpectationFailure directly on Env is deprecated and will be removed in a future version of Jasmine, please use the oneFailurePerSpec option in `configure`'
'Setting throwOnExpectationFailure directly on Env is deprecated and ' +
'will be removed in a future version of Jasmine. Please use the ' +
'stopSpecOnExpectationFailure option in `configure`.'
);
this.configure({ oneFailurePerSpec: !!value });
};
this.throwingExpectationFailures = function() {
this.deprecated(
'Getting throwingExpectationFailures directly from Env is deprecated and will be removed in a future version of Jasmine, please check the oneFailurePerSpec option from `configuration`'
'Getting throwingExpectationFailures directly from Env is deprecated ' +
'and will be removed in a future version of Jasmine. Please check ' +
'the stopSpecOnExpectationFailure option from `configuration`.'
);
return config.oneFailurePerSpec;
};
@@ -516,18 +569,22 @@ getJasmineRequireObj().Env = function(j$) {
* @since 2.7.0
* @function
* @param {Boolean} value Whether to stop suite execution when a spec fails
* @deprecated Use the `failFast` option with {@link Env#configure}
* @deprecated Use the `stopOnSpecFailure` option with {@link Env#configure}
*/
this.stopOnSpecFailure = function(value) {
this.deprecated(
'Setting stopOnSpecFailure directly is deprecated and will be removed in a future version of Jasmine, please use the failFast option in `configure`'
'Setting stopOnSpecFailure directly is deprecated and will be ' +
'removed in a future version of Jasmine. Please use the ' +
'stopOnSpecFailure option in `configure`.'
);
this.configure({ failFast: !!value });
this.configure({ stopOnSpecFailure: !!value });
};
this.stoppingOnSpecFailure = function() {
this.deprecated(
'Getting stoppingOnSpecFailure directly from Env is deprecated and will be removed in a future version of Jasmine, please check the failFast option from `configuration`'
'Getting stoppingOnSpecFailure directly from Env is deprecated and ' +
'will be removed in a future version of Jasmine. Please check the ' +
'stopOnSpecFailure option from `configuration`.'
);
return config.failFast;
};
@@ -583,6 +640,7 @@ getJasmineRequireObj().Env = function(j$) {
* @name Env#hideDisabled
* @since 3.2.0
* @function
* @deprecated Use the `hideDisabled` option with {@link Env#configure}
*/
this.hideDisabled = function(value) {
this.deprecated(
@@ -615,9 +673,9 @@ getJasmineRequireObj().Env = function(j$) {
var queueRunnerFactory = function(options, args) {
var failFast = false;
if (options.isLeaf) {
failFast = config.oneFailurePerSpec;
failFast = config.stopSpecOnExpectationFailure;
} else if (!options.isReporter) {
failFast = config.failFast;
failFast = config.stopOnSpecFailure;
}
options.clearStack = options.clearStack || clearStack;
options.timeout = {
@@ -749,11 +807,17 @@ getJasmineRequireObj().Env = function(j$) {
*
* execute should not be called more than once.
*
* If the environment supports promises, execute will return a promise that
* is resolved after the suite finishes executing. The promise will be
* resolved (not rejected) as long as the suite runs to completion. Use a
* {@link Reporter} to determine whether or not the suite passed.
*
* @name Env#execute
* @since 2.0.0
* @function
* @param {(string[])=} runnablesToRun IDs of suites and/or specs to run
* @param {Function=} onComplete Function that will be called after all specs have run
* @return {Promise<undefined>}
*/
this.execute = function(runnablesToRun, onComplete) {
installGlobalErrors();
@@ -813,65 +877,86 @@ getJasmineRequireObj().Env = function(j$) {
var jasmineTimer = new j$.Timer();
jasmineTimer.start();
/**
* Information passed to the {@link Reporter#jasmineStarted} event.
* @typedef JasmineStartedInfo
* @property {Int} totalSpecsDefined - The total number of specs defined in this suite.
* @property {Order} order - Information about the ordering (random or not) of this execution of the suite.
*/
reporter.jasmineStarted(
{
totalSpecsDefined: totalSpecsDefined,
order: order
},
function() {
currentlyExecutingSuites.push(topSuite);
var Promise = customPromise || global.Promise;
processor.execute(function() {
clearResourcesForRunnable(topSuite.id);
currentlyExecutingSuites.pop();
var overallStatus, incompleteReason;
if (hasFailures || topSuite.result.failedExpectations.length > 0) {
overallStatus = 'failed';
} else if (focusedRunnables.length > 0) {
overallStatus = 'incomplete';
incompleteReason = 'fit() or fdescribe() was found';
} else if (totalSpecsDefined === 0) {
overallStatus = 'incomplete';
incompleteReason = 'No specs found';
} else {
overallStatus = 'passed';
if (Promise) {
return new Promise(function(resolve) {
runAll(function() {
if (onComplete) {
onComplete();
}
/**
* Information passed to the {@link Reporter#jasmineDone} event.
* @typedef JasmineDoneInfo
* @property {OverallStatus} overallStatus - The overall result of the suite: 'passed', 'failed', or 'incomplete'.
* @property {Int} totalTime - The total time (in ms) that it took to execute the suite
* @property {IncompleteReason} incompleteReason - Explanation of why the suite was incomplete.
* @property {Order} order - Information about the ordering (random or not) of this execution of the suite.
* @property {Expectation[]} failedExpectations - List of expectations that failed in an {@link afterAll} at the global level.
* @property {Expectation[]} deprecationWarnings - List of deprecation warnings that occurred at the global level.
*/
reporter.jasmineDone(
{
overallStatus: overallStatus,
totalTime: jasmineTimer.elapsed(),
incompleteReason: incompleteReason,
order: order,
failedExpectations: topSuite.result.failedExpectations,
deprecationWarnings: topSuite.result.deprecationWarnings
},
function() {
if (onComplete) {
onComplete();
}
}
);
resolve();
});
}
);
});
} else {
runAll(function() {
if (onComplete) {
onComplete();
}
});
}
function runAll(done) {
/**
* Information passed to the {@link Reporter#jasmineStarted} event.
* @typedef JasmineStartedInfo
* @property {Int} totalSpecsDefined - The total number of specs defined in this suite.
* @property {Order} order - Information about the ordering (random or not) of this execution of the suite.
*/
reporter.jasmineStarted(
{
totalSpecsDefined: totalSpecsDefined,
order: order
},
function() {
currentlyExecutingSuites.push(topSuite);
processor.execute(function() {
clearResourcesForRunnable(topSuite.id);
currentlyExecutingSuites.pop();
var overallStatus, incompleteReason;
if (
hasFailures ||
topSuite.result.failedExpectations.length > 0
) {
overallStatus = 'failed';
} else if (focusedRunnables.length > 0) {
overallStatus = 'incomplete';
incompleteReason = 'fit() or fdescribe() was found';
} else if (totalSpecsDefined === 0) {
overallStatus = 'incomplete';
incompleteReason = 'No specs found';
} else {
overallStatus = 'passed';
}
/**
* Information passed to the {@link Reporter#jasmineDone} event.
* @typedef JasmineDoneInfo
* @property {OverallStatus} overallStatus - The overall result of the suite: 'passed', 'failed', or 'incomplete'.
* @property {Int} totalTime - The total time (in ms) that it took to execute the suite
* @property {IncompleteReason} incompleteReason - Explanation of why the suite was incomplete.
* @property {Order} order - Information about the ordering (random or not) of this execution of the suite.
* @property {Expectation[]} failedExpectations - List of expectations that failed in an {@link afterAll} at the global level.
* @property {Expectation[]} deprecationWarnings - List of deprecation warnings that occurred at the global level.
*/
reporter.jasmineDone(
{
overallStatus: overallStatus,
totalTime: jasmineTimer.elapsed(),
incompleteReason: incompleteReason,
order: order,
failedExpectations: topSuite.result.failedExpectations,
deprecationWarnings: topSuite.result.deprecationWarnings
},
done
);
});
}
);
}
};
/**

View File

@@ -19,16 +19,22 @@ getJasmineRequireObj().GlobalErrors = function(j$) {
function taggedOnError(error) {
var substituteMsg;
if (error) {
if (j$.isError_(error)) {
error.jasmineMessage = jasmineMessage + ': ' + error;
} else {
substituteMsg = jasmineMessage + ' with no error or message';
if (error) {
substituteMsg = jasmineMessage + ': ' + error;
} else {
substituteMsg = jasmineMessage + ' with no error or message';
}
if (errorType === 'unhandledRejection') {
substituteMsg +=
'\n' +
'(Tip: to get a useful stack trace, use ' +
'Promise.reject(new Error(...)) instead of Promise.reject().)';
'Promise.reject(new Error(...)) instead of Promise.reject(' +
(error ? '...' : '') +
').)';
}
error = new Error(substituteMsg);

View File

@@ -7,6 +7,12 @@ getJasmineRequireObj().Spec = function(j$) {
this.expectationFactory = attrs.expectationFactory;
this.asyncExpectationFactory = attrs.asyncExpectationFactory;
this.resultCallback = attrs.resultCallback || function() {};
/**
* The unique ID of this spec.
* @name Spec#id
* @readonly
* @type {string}
*/
this.id = attrs.id;
/**
* The description passed to the {@link it} that created this spec.

View File

@@ -5,6 +5,12 @@ getJasmineRequireObj().Suite = function(j$) {
*/
function Suite(attrs) {
this.env = attrs.env;
/**
* The unique ID of this suite.
* @name Suite#id
* @readonly
* @type {string}
*/
this.id = attrs.id;
/**
* The parent of this suite, or null if this is the top suite.

View File

@@ -99,9 +99,21 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) {
};
j$.isError_ = function(value) {
if (!value) {
return false;
}
if (value instanceof Error) {
return true;
}
if (
typeof window !== 'undefined' &&
typeof window.trustedTypes !== 'undefined'
) {
return (
typeof value.stack === 'string' && typeof value.message === 'string'
);
}
if (value && value.constructor && value.constructor.constructor) {
var valueGlobal = value.constructor.constructor('return this');
if (j$.isFunction_(valueGlobal)) {

View File

@@ -527,17 +527,20 @@ jasmineRequire.HtmlReporter = function(j$) {
);
var failFastCheckbox = optionsMenuDom.querySelector('#jasmine-fail-fast');
failFastCheckbox.checked = config.failFast;
failFastCheckbox.checked = config.stopOnSpecFailure;
failFastCheckbox.onclick = function() {
navigateWithNewParam('failFast', !config.failFast);
navigateWithNewParam('failFast', !config.stopOnSpecFailure);
};
var throwCheckbox = optionsMenuDom.querySelector(
'#jasmine-throw-failures'
);
throwCheckbox.checked = config.oneFailurePerSpec;
throwCheckbox.checked = config.stopSpecOnExpectationFailure;
throwCheckbox.onclick = function() {
navigateWithNewParam('oneFailurePerSpec', !config.oneFailurePerSpec);
navigateWithNewParam(
'oneFailurePerSpec',
!config.stopSpecOnExpectationFailure
);
};
var randomCheckbox = optionsMenuDom.querySelector(