Compare commits
45 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e86a7f00a6 | ||
|
|
504ef27899 | ||
|
|
572452a15a | ||
|
|
896412367a | ||
|
|
503a7409f0 | ||
|
|
bb9175cb66 | ||
|
|
469b557828 | ||
|
|
503715c275 | ||
|
|
4482355885 | ||
|
|
6542364381 | ||
|
|
1fc911e0fa | ||
|
|
fdad8849df | ||
|
|
7a289f1de7 | ||
|
|
ef981bb794 | ||
|
|
c3fb3e985a | ||
|
|
7fc3408051 | ||
|
|
af1b43eeff | ||
|
|
4c043717a9 | ||
|
|
40be00310d | ||
|
|
1f318c3c93 | ||
|
|
be29aa95eb | ||
|
|
e3c9a59c6c | ||
|
|
b312ed4940 | ||
|
|
00f6708e1f | ||
|
|
3a47a3bd04 | ||
|
|
1c9382c990 | ||
|
|
394be99832 | ||
|
|
62a667a8e3 | ||
|
|
d277827d5e | ||
|
|
644c175338 | ||
|
|
a6d7eb2a06 | ||
|
|
dd8a65cb60 | ||
|
|
e72d161fab | ||
|
|
dcaac62a6c | ||
|
|
b696bec9e3 | ||
|
|
43073b3bc5 | ||
|
|
286524959b | ||
|
|
2c32dd5703 | ||
|
|
c1d1d69be2 | ||
|
|
3513249d73 | ||
|
|
21bfbbb721 | ||
|
|
88b90ec258 | ||
|
|
50c88e7774 | ||
|
|
3e64ce3310 | ||
|
|
dc80a282ba |
@@ -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,11 +188,11 @@ workflows:
|
||||
triggers:
|
||||
- schedule:
|
||||
# Times are UTC.
|
||||
cron: "0 11 * * *"
|
||||
cron: "0 10 * * *"
|
||||
filters:
|
||||
branches:
|
||||
only:
|
||||
- main
|
||||
- browser-flakes
|
||||
jobs:
|
||||
- build:
|
||||
executor: node14
|
||||
|
||||
8
.github/CONTRIBUTING.md
vendored
8
.github/CONTRIBUTING.md
vendored
@@ -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
|
||||
|
||||
|
||||
3
.gitmodules
vendored
3
.gitmodules
vendored
@@ -1,3 +0,0 @@
|
||||
[submodule "pages"]
|
||||
path = pages
|
||||
url = https://github.com/pivotal/jasmine.git
|
||||
@@ -29,7 +29,7 @@ module.exports = {
|
||||
cwd: libJasmineCore("")
|
||||
},
|
||||
{
|
||||
src: [ "boot.js" ],
|
||||
src: [ "boot0.js", "boot1.js" ],
|
||||
dest: standaloneLibDir,
|
||||
expand: true,
|
||||
cwd: libJasmineCore("boot")
|
||||
|
||||
@@ -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'
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -8,7 +8,18 @@ Gem::Specification.new do |s|
|
||||
s.platform = Gem::Platform::RUBY
|
||||
s.authors = ["Gregg Van Hove"]
|
||||
s.summary = %q{JavaScript BDD framework}
|
||||
s.description = %q{Test your JavaScript without any framework dependencies, in any environment, and with a nice descriptive syntax.}
|
||||
s.description = <<~DESC
|
||||
Test your JavaScript without any framework dependencies, in any environment,
|
||||
and with a nice descriptive syntax.
|
||||
|
||||
Jasmine for Ruby is deprecated. The direct replacment for the jasmine-core
|
||||
gem is the jasmine-core NPM package. If you are also using the jasmine gem,
|
||||
we recommend using the jasmine-browser-runner NPM package instead. It
|
||||
supports all the same scenarios as the jasmine gem gem plus Webpacker. See
|
||||
https://jasmine.github.io/setup/browser.html for setup instructions, and
|
||||
https://github.com/jasmine/jasmine-gem/blob/main/release_notes/3.9.0.md
|
||||
for other options.
|
||||
DESC
|
||||
s.email = %q{jasmine-js@googlegroups.com}
|
||||
s.homepage = "http://jasmine.github.io"
|
||||
s.license = "MIT"
|
||||
|
||||
@@ -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()) {
|
||||
|
||||
@@ -1,3 +1,28 @@
|
||||
if ENV["SUPPRESS_JASMINE_DEPRECATION"].nil?
|
||||
puts <<~END_DEPRECATION_MSG
|
||||
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 npm package, which is the direct replacement for the
|
||||
jasmine gem. See <https://jasmine.github.io/setup/browser.html> for setup
|
||||
instructions, including for Rails applications that use either Sprockets or
|
||||
Webpacker.
|
||||
|
||||
If jasmine-browser-runner doesn't meet your needs, one of these might:
|
||||
|
||||
* The jasmine npm package to run specs in Node.js:
|
||||
<https://github.com/jasmine/jasmine-npm>
|
||||
* The standalone distribution to run specs in browsers with no additional
|
||||
tools: <https://github.com/jasmine/jasmine#installation>
|
||||
* The jasmine-core npm package if all you need is the Jasmine assets:
|
||||
<https://github.com/jasmine/jasmine>. This is the direct equivalent of the
|
||||
jasmine-core Ruby gem.
|
||||
|
||||
To prevent this message from appearing, set the SUPPRESS_JASMINE_DEPRECATION
|
||||
environment variable.
|
||||
|
||||
END_DEPRECATION_MSG
|
||||
end
|
||||
|
||||
module Jasmine
|
||||
module Core
|
||||
class << self
|
||||
@@ -6,7 +31,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"]
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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.
|
||||
|
||||
42
lib/jasmine-core/boot/boot0.js
Normal file
42
lib/jasmine-core/boot/boot0.js
Normal 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 & 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];
|
||||
}
|
||||
}());
|
||||
111
lib/jasmine-core/boot/boot1.js
Normal file
111
lib/jasmine-core/boot/boot1.js
Normal 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
64
lib/jasmine-core/boot0.js
Normal 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 & 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
133
lib/jasmine-core/boot1.js
Normal 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;
|
||||
}
|
||||
|
||||
}());
|
||||
@@ -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
|
||||
|
||||
@@ -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(
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -4,6 +4,6 @@
|
||||
#
|
||||
module Jasmine
|
||||
module Core
|
||||
VERSION = "3.8.0"
|
||||
VERSION = "3.10.1"
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "jasmine-core",
|
||||
"license": "MIT",
|
||||
"version": "3.8.0",
|
||||
"version": "3.10.1",
|
||||
"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",
|
||||
|
||||
57
release_notes/3.10.0.md
Normal file
57
release_notes/3.10.0.md
Normal file
@@ -0,0 +1,57 @@
|
||||
# Jasmine Core 3.10 Release Notes
|
||||
|
||||
## New features and bug fixes
|
||||
|
||||
* Added support for running Jasmine multiple times
|
||||
* If the env is configured with `autoCleanClosures: false`, then it can be
|
||||
executed repeatedly.
|
||||
* Merges #1934 from @nicojs
|
||||
* Fixes #1925
|
||||
|
||||
* Improved error message when an async expectation occurs after the spec
|
||||
finishes
|
||||
* Merges #1937 from @AndreWillomitzer
|
||||
* Fixes #1854
|
||||
|
||||
* Reject timeout values that are too large for setTimeout
|
||||
* See #1930
|
||||
|
||||
* Don't immediately move to the next queueable fn on async error
|
||||
|
||||
This allows assertion failures and other errors that occur after the async
|
||||
error to be routed to the correct spec/suite.
|
||||
|
||||
* Added a stringContaining asymmetric equality tester
|
||||
* Fixes #1923.
|
||||
|
||||
* The jasmine-core Ruby gem now prints a deprecation message when loaded unless
|
||||
the SUPPRESS_JASMINE_DEPRECATION environment variable is set.
|
||||
|
||||
|
||||
## Documentation updates
|
||||
|
||||
* Added discussion of max timeout value to jsdocs
|
||||
* Merges #1931 from @trusktr
|
||||
|
||||
* Added missing @since annotations
|
||||
|
||||
* Improved jsdocs for asymmetric equality testers
|
||||
|
||||
* Added a deprecation notice to the jasmine-core Ruby gem's description
|
||||
|
||||
## Supported environments
|
||||
|
||||
jasmine-core 3.10.0 has been tested in the following environments.
|
||||
|
||||
| Environment | Supported versions |
|
||||
|-------------------|--------------------|
|
||||
| Node | 10, 12, 14, 16 |
|
||||
| Safari | 8-14 |
|
||||
| Chrome | 94 |
|
||||
| Firefox | 93, 78, 68 |
|
||||
| Edge | 94 |
|
||||
| Internet Explorer | 10, 11 |
|
||||
|
||||
------
|
||||
|
||||
_Release Notes generated with _[Anchorman](http://github.com/infews/anchorman)_
|
||||
12
release_notes/3.10.1.md
Normal file
12
release_notes/3.10.1.md
Normal file
@@ -0,0 +1,12 @@
|
||||
# Jasmine Core 3.10.1 Release Notes
|
||||
|
||||
## Bugfixes
|
||||
|
||||
* Fixed missing pendingReason in pending spec results
|
||||
* Fixes [#1939](https://github.com/jasmine/jasmine/issues/1939)
|
||||
* Merges [#1940](https://github.com/jasmine/jasmine/pull/1940) from @jan-molak
|
||||
|
||||
|
||||
------
|
||||
|
||||
_Release Notes generated with _[Anchorman](http://github.com/infews/anchorman)_
|
||||
65
release_notes/3.9.0.md
Normal file
65
release_notes/3.9.0.md
Normal 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.9.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)_
|
||||
@@ -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({});
|
||||
@@ -169,12 +256,30 @@ describe('Env', function() {
|
||||
env.it('async', jasmine.getEnv().makeAsyncAwaitFunction());
|
||||
}).not.toThrow();
|
||||
});
|
||||
|
||||
it('throws an error when the timeout value is too large for setTimeout', function() {
|
||||
expect(function() {
|
||||
env.it('huge timeout', function() {}, 2147483648);
|
||||
}).toThrowError('Timeout value cannot be greater than 2147483647');
|
||||
});
|
||||
});
|
||||
|
||||
describe('#xit', function() {
|
||||
it('calls spec.exclude with "Temporarily disabled with xit"', function() {
|
||||
var excludeSpy = jasmine.createSpy();
|
||||
spyOn(env, 'it').and.returnValue({
|
||||
exclude: excludeSpy
|
||||
});
|
||||
env.xit('foo', function() {});
|
||||
expect(excludeSpy).toHaveBeenCalledWith('Temporarily disabled with xit');
|
||||
});
|
||||
|
||||
it('calls spec.pend with "Temporarily disabled with xit"', function() {
|
||||
var pendSpy = jasmine.createSpy();
|
||||
var realExclude = jasmineUnderTest.Spec.prototype.exclude;
|
||||
|
||||
spyOn(env, 'it').and.returnValue({
|
||||
exclude: realExclude,
|
||||
pend: pendSpy
|
||||
});
|
||||
env.xit('foo', function() {});
|
||||
@@ -211,6 +316,12 @@ describe('Env', function() {
|
||||
/fit expects a function argument; received \[object (Undefined|DOMWindow|Object)\]/
|
||||
);
|
||||
});
|
||||
|
||||
it('throws an error when the timeout value is too large for setTimeout', function() {
|
||||
expect(function() {
|
||||
env.fit('huge timeout', function() {}, 2147483648);
|
||||
}).toThrowError('Timeout value cannot be greater than 2147483647');
|
||||
});
|
||||
});
|
||||
|
||||
describe('#beforeEach', function() {
|
||||
@@ -228,6 +339,12 @@ describe('Env', function() {
|
||||
env.beforeEach(jasmine.getEnv().makeAsyncAwaitFunction());
|
||||
}).not.toThrow();
|
||||
});
|
||||
|
||||
it('throws an error when the timeout value is too large for setTimeout', function() {
|
||||
expect(function() {
|
||||
env.beforeEach(function() {}, 2147483648);
|
||||
}).toThrowError('Timeout value cannot be greater than 2147483647');
|
||||
});
|
||||
});
|
||||
|
||||
describe('#beforeAll', function() {
|
||||
@@ -245,6 +362,12 @@ describe('Env', function() {
|
||||
env.beforeAll(jasmine.getEnv().makeAsyncAwaitFunction());
|
||||
}).not.toThrow();
|
||||
});
|
||||
|
||||
it('throws an error when the timeout value is too large for setTimeout', function() {
|
||||
expect(function() {
|
||||
env.beforeAll(function() {}, 2147483648);
|
||||
}).toThrowError('Timeout value cannot be greater than 2147483647');
|
||||
});
|
||||
});
|
||||
|
||||
describe('#afterEach', function() {
|
||||
@@ -262,6 +385,12 @@ describe('Env', function() {
|
||||
env.afterEach(jasmine.getEnv().makeAsyncAwaitFunction());
|
||||
}).not.toThrow();
|
||||
});
|
||||
|
||||
it('throws an error when the timeout value is too large for setTimeout', function() {
|
||||
expect(function() {
|
||||
env.afterEach(function() {}, 2147483648);
|
||||
}).toThrowError('Timeout value cannot be greater than 2147483647');
|
||||
});
|
||||
});
|
||||
|
||||
describe('#afterAll', function() {
|
||||
@@ -279,6 +408,12 @@ describe('Env', function() {
|
||||
env.afterAll(jasmine.getEnv().makeAsyncAwaitFunction());
|
||||
}).not.toThrow();
|
||||
});
|
||||
|
||||
it('throws an error when the timeout value is too large for setTimeout', function() {
|
||||
expect(function() {
|
||||
env.afterAll(function() {}, 2147483648);
|
||||
}).toThrowError('Timeout value cannot be greater than 2147483647');
|
||||
});
|
||||
});
|
||||
|
||||
describe('when not constructed with suppressLoadErrors: true', function() {
|
||||
@@ -378,4 +513,38 @@ 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();
|
||||
});
|
||||
|
||||
it('should reset the topSuite when run twice', function() {
|
||||
jasmine.getEnv().requirePromises();
|
||||
spyOn(env.topSuite(), 'reset');
|
||||
return env
|
||||
.execute() // 1
|
||||
.then(function() {
|
||||
return env.execute(); // 2
|
||||
})
|
||||
.then(function() {
|
||||
expect(env.topSuite().reset).toHaveBeenCalledOnceWith();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -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() {
|
||||
|
||||
@@ -669,9 +669,13 @@ describe('QueueRunner', function() {
|
||||
jasmine.clock().uninstall();
|
||||
});
|
||||
|
||||
it('skips to cleanup functions on the first exception', function() {
|
||||
it('skips to cleanup functions once the fn completes after an unhandled exception', function() {
|
||||
var errorListeners = [],
|
||||
queueableFn = { fn: function(done) {} },
|
||||
queueableFn = {
|
||||
fn: function(done) {
|
||||
queueableFnDone = done;
|
||||
}
|
||||
},
|
||||
nextQueueableFn = { fn: jasmine.createSpy('nextFunction') },
|
||||
cleanupFn = { fn: jasmine.createSpy('cleanup') },
|
||||
queueRunner = new jasmineUnderTest.QueueRunner({
|
||||
@@ -686,10 +690,13 @@ describe('QueueRunner', function() {
|
||||
queueableFns: [queueableFn, nextQueueableFn],
|
||||
cleanupFns: [cleanupFn],
|
||||
completeOnFirstError: true
|
||||
});
|
||||
}),
|
||||
queueableFnDone;
|
||||
|
||||
queueRunner.execute();
|
||||
errorListeners[errorListeners.length - 1](new Error('error'));
|
||||
expect(cleanupFn.fn).not.toHaveBeenCalled();
|
||||
queueableFnDone();
|
||||
expect(nextQueueableFn.fn).not.toHaveBeenCalled();
|
||||
expect(cleanupFn.fn).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
@@ -142,4 +142,86 @@ describe('Suite', function() {
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe('attr.autoCleanClosures', function() {
|
||||
function arrangeSuite(attrs) {
|
||||
var suite = new jasmineUnderTest.Suite(attrs);
|
||||
suite.beforeAll(function() {});
|
||||
suite.beforeEach(function() {});
|
||||
suite.afterEach(function() {});
|
||||
suite.afterAll(function() {});
|
||||
return suite;
|
||||
}
|
||||
|
||||
it('should clean closures when "attr.autoCleanClosures" is missing', function() {
|
||||
var suite = arrangeSuite({});
|
||||
suite.cleanupBeforeAfter();
|
||||
expect(suite.beforeAllFns[0].fn).toBe(null);
|
||||
expect(suite.beforeFns[0].fn).toBe(null);
|
||||
expect(suite.afterFns[0].fn).toBe(null);
|
||||
expect(suite.afterAllFns[0].fn).toBe(null);
|
||||
});
|
||||
|
||||
it('should clean closures when "attr.autoCleanClosures" is true', function() {
|
||||
var suite = arrangeSuite({ autoCleanClosures: true });
|
||||
suite.cleanupBeforeAfter();
|
||||
expect(suite.beforeAllFns[0].fn).toBe(null);
|
||||
expect(suite.beforeFns[0].fn).toBe(null);
|
||||
expect(suite.afterFns[0].fn).toBe(null);
|
||||
expect(suite.afterAllFns[0].fn).toBe(null);
|
||||
});
|
||||
|
||||
it('should NOT clean closures when "attr.autoCleanClosures" is false', function() {
|
||||
var suite = arrangeSuite({ autoCleanClosures: false });
|
||||
suite.cleanupBeforeAfter();
|
||||
expect(suite.beforeAllFns[0].fn).not.toBe(null);
|
||||
expect(suite.beforeFns[0].fn).not.toBe(null);
|
||||
expect(suite.afterFns[0].fn).not.toBe(null);
|
||||
expect(suite.afterAllFns[0].fn).not.toBe(null);
|
||||
});
|
||||
});
|
||||
|
||||
describe('#reset', function() {
|
||||
it('should reset the "pending" status', function() {
|
||||
var suite = new jasmineUnderTest.Suite({});
|
||||
suite.pend();
|
||||
suite.reset();
|
||||
expect(suite.getResult().status).toBe('passed');
|
||||
});
|
||||
|
||||
it('should not reset the "pending" status when the suite was excluded', function() {
|
||||
var suite = new jasmineUnderTest.Suite({});
|
||||
suite.exclude();
|
||||
suite.reset();
|
||||
expect(suite.getResult().status).toBe('pending');
|
||||
});
|
||||
|
||||
it('should also reset the children', function() {
|
||||
var suite = new jasmineUnderTest.Suite({});
|
||||
var child1 = jasmine.createSpyObj(['reset']);
|
||||
var child2 = jasmine.createSpyObj(['reset']);
|
||||
suite.addChild(child1);
|
||||
suite.addChild(child2);
|
||||
|
||||
suite.reset();
|
||||
|
||||
expect(child1.reset).toHaveBeenCalled();
|
||||
expect(child2.reset).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should reset the failedExpectations', function() {
|
||||
var suite = new jasmineUnderTest.Suite({
|
||||
expectationResultFactory: function(error) {
|
||||
return error;
|
||||
}
|
||||
});
|
||||
suite.onException(new Error());
|
||||
|
||||
suite.reset();
|
||||
|
||||
var result = suite.getResult();
|
||||
expect(result.status).toBe('passed');
|
||||
expect(result.failedExpectations).toHaveSize(0);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
27
spec/core/asymmetric_equality/StringContainingSpec.js
Normal file
27
spec/core/asymmetric_equality/StringContainingSpec.js
Normal file
@@ -0,0 +1,27 @@
|
||||
describe('StringContaining', function() {
|
||||
it('searches for a provided substring when the expected is a String', function() {
|
||||
var matcher = new jasmineUnderTest.StringContaining('foo');
|
||||
|
||||
expect(matcher.asymmetricMatch('barfoobaz')).toBe(true);
|
||||
expect(matcher.asymmetricMatch('barbaz')).toBe(false);
|
||||
});
|
||||
|
||||
it('raises an Error when the expected is not a String', function() {
|
||||
expect(function() {
|
||||
new jasmineUnderTest.StringContaining(/foo/);
|
||||
}).toThrowError(/not a String/);
|
||||
});
|
||||
|
||||
it('fails when the actual is not a String', function() {
|
||||
var matcher = new jasmineUnderTest.StringContaining('x');
|
||||
expect(matcher.asymmetricMatch(['x'])).toBe(false);
|
||||
});
|
||||
|
||||
it("jasmineToString's itself", function() {
|
||||
var matching = new jasmineUnderTest.StringContaining('foo');
|
||||
|
||||
expect(matching.jasmineToString()).toEqual(
|
||||
'<jasmine.stringContaining("foo")>'
|
||||
);
|
||||
});
|
||||
});
|
||||
@@ -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() {
|
||||
@@ -104,4 +141,49 @@ describe('base helpers', function() {
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe('DEFAULT_TIMEOUT_INTERVAL setter', function() {
|
||||
var max = 2147483647;
|
||||
|
||||
beforeEach(function() {
|
||||
this.initialValue = jasmineUnderTest.DEFAULT_TIMEOUT_INTERVAL;
|
||||
});
|
||||
|
||||
afterEach(function() {
|
||||
jasmineUnderTest.DEFAULT_TIMEOUT_INTERVAL = this.initialValue;
|
||||
});
|
||||
|
||||
it('accepts only values <= ' + max, function() {
|
||||
expect(function() {
|
||||
jasmineUnderTest.DEFAULT_TIMEOUT_INTERVAL = max + 1;
|
||||
}).toThrowError(
|
||||
'jasmine.DEFAULT_TIMEOUT_INTERVAL cannot be greater than ' + max
|
||||
);
|
||||
|
||||
jasmineUnderTest.DEFAULT_TIMEOUT_INTERVAL = max;
|
||||
expect(jasmineUnderTest.DEFAULT_TIMEOUT_INTERVAL).toEqual(max);
|
||||
});
|
||||
|
||||
it('is consistent with setTimeout in this environment', function(done) {
|
||||
var f1 = jasmine.createSpy('setTimeout callback for ' + max),
|
||||
f2 = jasmine.createSpy('setTimeout callback for ' + (max + 1)),
|
||||
id;
|
||||
|
||||
// Suppress printing of TimeoutOverflowWarning in node
|
||||
spyOn(console, 'error');
|
||||
|
||||
id = setTimeout(f1, max);
|
||||
setTimeout(function() {
|
||||
clearTimeout(id);
|
||||
expect(f1).not.toHaveBeenCalled();
|
||||
|
||||
id = setTimeout(f2, max + 1);
|
||||
setTimeout(function() {
|
||||
clearTimeout(id);
|
||||
expect(f2).toHaveBeenCalled();
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -231,6 +231,16 @@ describe('Asymmetric equality testers (Integration)', function() {
|
||||
});
|
||||
});
|
||||
|
||||
describe('stringContaining', function() {
|
||||
verifyPasses(function(env) {
|
||||
env.expect('foo').toEqual(jasmineUnderTest.stringContaining('o'));
|
||||
});
|
||||
|
||||
verifyFails(function(env) {
|
||||
env.expect('bar').toEqual(jasmineUnderTest.stringContaining('o'));
|
||||
});
|
||||
});
|
||||
|
||||
describe('truthy', function() {
|
||||
verifyPasses(function(env) {
|
||||
env.expect(true).toEqual(jasmineUnderTest.truthy());
|
||||
|
||||
@@ -465,7 +465,7 @@ describe('Env integration', function() {
|
||||
|
||||
var global = {
|
||||
setTimeout: function(fn, delay) {
|
||||
setTimeout(fn, delay);
|
||||
return setTimeout(fn, delay);
|
||||
},
|
||||
clearTimeout: function(fn, delay) {
|
||||
clearTimeout(fn, delay);
|
||||
@@ -1018,7 +1018,7 @@ describe('Env integration', function() {
|
||||
var globalSetTimeout = jasmine
|
||||
.createSpy('globalSetTimeout')
|
||||
.and.callFake(function(cb, t) {
|
||||
setTimeout(cb, t);
|
||||
return setTimeout(cb, t);
|
||||
}),
|
||||
delayedFunctionForGlobalClock = jasmine.createSpy(
|
||||
'delayedFunctionForGlobalClock'
|
||||
@@ -1033,7 +1033,7 @@ describe('Env integration', function() {
|
||||
setTimeout: globalSetTimeout,
|
||||
clearTimeout: clearTimeout,
|
||||
setImmediate: function(cb) {
|
||||
setTimeout(cb, 0);
|
||||
return setTimeout(cb, 0);
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -1108,7 +1108,7 @@ describe('Env integration', function() {
|
||||
setInterval: setInterval,
|
||||
clearInterval: clearInterval,
|
||||
setImmediate: function(cb) {
|
||||
realSetTimeout(cb, 0);
|
||||
return realSetTimeout(cb, 0);
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -2255,7 +2255,7 @@ describe('Env integration', function() {
|
||||
it('reports errors that occur during loading', function(done) {
|
||||
var global = {
|
||||
setTimeout: function(fn, delay) {
|
||||
setTimeout(fn, delay);
|
||||
return setTimeout(fn, delay);
|
||||
},
|
||||
clearTimeout: function(fn, delay) {
|
||||
clearTimeout(fn, delay);
|
||||
@@ -2312,7 +2312,7 @@ describe('Env integration', function() {
|
||||
var originalOnerror = jasmine.createSpy('original onerror');
|
||||
var global = {
|
||||
setTimeout: function(fn, delay) {
|
||||
setTimeout(fn, delay);
|
||||
return setTimeout(fn, delay);
|
||||
},
|
||||
clearTimeout: function(fn, delay) {
|
||||
clearTimeout(fn, delay);
|
||||
@@ -2513,7 +2513,7 @@ describe('Env integration', function() {
|
||||
it('is "failed"', function(done) {
|
||||
var global = {
|
||||
setTimeout: function(fn, delay) {
|
||||
setTimeout(fn, delay);
|
||||
return setTimeout(fn, delay);
|
||||
},
|
||||
clearTimeout: function(fn, delay) {
|
||||
clearTimeout(fn, delay);
|
||||
@@ -2835,10 +2835,6 @@ describe('Env integration', function() {
|
||||
});
|
||||
|
||||
it('provides custom equality testers to async matchers', function(done) {
|
||||
if (jasmine.getEnv().skipBrowserFlake) {
|
||||
jasmine.getEnv().skipBrowserFlake();
|
||||
}
|
||||
|
||||
jasmine.getEnv().requirePromises();
|
||||
|
||||
var specDone = jasmine.createSpy('specDone');
|
||||
@@ -2936,7 +2932,9 @@ describe('Env integration', function() {
|
||||
message:
|
||||
'Spec "a suite does not wait" ran a "toBeResolved" expectation ' +
|
||||
'after it finished.\n' +
|
||||
'Did you forget to return or await the result of expectAsync?',
|
||||
'1. Did you forget to return or await the result of expectAsync?\n' +
|
||||
'2. Was done() invoked before an async operation completed?\n' +
|
||||
'3. Did an expectation follow a call to done()?',
|
||||
matcherName: 'toBeResolved'
|
||||
}),
|
||||
jasmine.objectContaining({
|
||||
@@ -2947,7 +2945,9 @@ describe('Env integration', function() {
|
||||
'after it finished.\n' +
|
||||
"Message: \"Expected a promise to be resolved to 'something else' " +
|
||||
'but it was resolved to undefined."\n' +
|
||||
'Did you forget to return or await the result of expectAsync?',
|
||||
'1. Did you forget to return or await the result of expectAsync?\n' +
|
||||
'2. Was done() invoked before an async operation completed?\n' +
|
||||
'3. Did an expectation follow a call to done()?',
|
||||
matcherName: 'toBeResolvedTo'
|
||||
})
|
||||
]);
|
||||
@@ -3000,7 +3000,9 @@ describe('Env integration', function() {
|
||||
message:
|
||||
'Suite "a suite" ran a "toBeResolved" expectation ' +
|
||||
'after it finished.\n' +
|
||||
'Did you forget to return or await the result of expectAsync?',
|
||||
'1. Did you forget to return or await the result of expectAsync?\n' +
|
||||
'2. Was done() invoked before an async operation completed?\n' +
|
||||
'3. Did an expectation follow a call to done()?',
|
||||
matcherName: 'toBeResolved'
|
||||
})
|
||||
]);
|
||||
@@ -3038,6 +3040,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;
|
||||
|
||||
@@ -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,238 @@ 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);
|
||||
});
|
||||
});
|
||||
|
||||
describe('run multiple times', function() {
|
||||
beforeEach(function() {
|
||||
env.configure({ autoCleanClosures: false, random: false });
|
||||
});
|
||||
|
||||
it('should be able to run multiple times', function(done) {
|
||||
var actions = [];
|
||||
|
||||
env.describe('Suite', function() {
|
||||
env.it('spec1', function() {
|
||||
actions.push('spec1');
|
||||
});
|
||||
env.describe('inner suite', function() {
|
||||
env.it('spec2', function() {
|
||||
actions.push('spec2');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
env.execute(null, function() {
|
||||
expect(actions).toEqual(['spec1', 'spec2']);
|
||||
env.execute(null, function() {
|
||||
expect(actions).toEqual(['spec1', 'spec2', 'spec1', 'spec2']);
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it('should reset results between runs', function(done) {
|
||||
var specResults = {};
|
||||
var suiteResults = {};
|
||||
var firstExecution = true;
|
||||
|
||||
env.addReporter({
|
||||
specDone: function(spec) {
|
||||
specResults[spec.description] = spec.status;
|
||||
},
|
||||
suiteDone: function(suite) {
|
||||
suiteResults[suite.description] = suite.status;
|
||||
},
|
||||
jasmineDone: function() {
|
||||
firstExecution = false;
|
||||
}
|
||||
});
|
||||
|
||||
env.describe('suite0', function() {
|
||||
env.it('spec1', function() {
|
||||
if (firstExecution) {
|
||||
env.expect(1).toBe(2);
|
||||
}
|
||||
});
|
||||
env.describe('suite1', function() {
|
||||
env.it('spec2', function() {
|
||||
if (firstExecution) {
|
||||
env.pending();
|
||||
}
|
||||
});
|
||||
env.xit('spec3', function() {}); // Always pending
|
||||
});
|
||||
env.describe('suite2', function() {
|
||||
env.it('spec4', function() {
|
||||
if (firstExecution) {
|
||||
throw new Error('spec 3 fails');
|
||||
}
|
||||
});
|
||||
});
|
||||
env.describe('suite3', function() {
|
||||
env.beforeEach(function() {
|
||||
throw new Error('suite 3 fails');
|
||||
});
|
||||
env.it('spec5', function() {});
|
||||
});
|
||||
env.xdescribe('suite4', function() {
|
||||
// Always pending
|
||||
env.it('spec6', function() {});
|
||||
});
|
||||
env.describe('suite5', function() {
|
||||
env.it('spec7');
|
||||
});
|
||||
});
|
||||
|
||||
env.execute(null, function() {
|
||||
expect(specResults).toEqual({
|
||||
spec1: 'failed',
|
||||
spec2: 'pending',
|
||||
spec3: 'pending',
|
||||
spec4: 'failed',
|
||||
spec5: 'failed',
|
||||
spec6: 'pending',
|
||||
spec7: 'pending'
|
||||
});
|
||||
expect(suiteResults).toEqual({
|
||||
suite0: 'passed',
|
||||
suite1: 'passed',
|
||||
suite2: 'passed',
|
||||
suite3: 'passed',
|
||||
suite4: 'pending',
|
||||
suite5: 'passed'
|
||||
});
|
||||
env.execute(null, function() {
|
||||
expect(specResults).toEqual({
|
||||
spec1: 'passed',
|
||||
spec2: 'passed',
|
||||
spec3: 'pending',
|
||||
spec4: 'passed',
|
||||
spec5: 'failed',
|
||||
spec6: 'pending',
|
||||
spec7: 'pending'
|
||||
});
|
||||
expect(suiteResults).toEqual({
|
||||
suite0: 'passed',
|
||||
suite1: 'passed',
|
||||
suite2: 'passed',
|
||||
suite3: 'passed',
|
||||
suite4: 'pending',
|
||||
suite5: 'passed'
|
||||
});
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it('should execute before and after hooks per run', function(done) {
|
||||
var timeline = [];
|
||||
var timelineFn = function(hookName) {
|
||||
return function() {
|
||||
timeline.push(hookName);
|
||||
};
|
||||
};
|
||||
var expectedTimeLine = [
|
||||
'beforeAll',
|
||||
'beforeEach',
|
||||
'spec1',
|
||||
'afterEach',
|
||||
'beforeEach',
|
||||
'spec2',
|
||||
'afterEach',
|
||||
'afterAll'
|
||||
];
|
||||
|
||||
env.describe('suite0', function() {
|
||||
env.beforeAll(timelineFn('beforeAll'));
|
||||
env.beforeEach(timelineFn('beforeEach'));
|
||||
env.afterEach(timelineFn('afterEach'));
|
||||
env.afterAll(timelineFn('afterAll'));
|
||||
env.it('spec1', timelineFn('spec1'));
|
||||
env.it('spec2', timelineFn('spec2'));
|
||||
});
|
||||
env.execute(null, function() {
|
||||
expect(timeline).toEqual(expectedTimeLine);
|
||||
timeline = [];
|
||||
env.execute(null, function() {
|
||||
expect(timeline).toEqual(expectedTimeLine);
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it('should be able to filter out different tests in subsequent runs', function(done) {
|
||||
var specResults = {};
|
||||
var focussedSpec = 'spec1';
|
||||
|
||||
env.configure({
|
||||
specFilter: function(spec) {
|
||||
return spec.description === focussedSpec;
|
||||
}
|
||||
});
|
||||
|
||||
env.addReporter({
|
||||
specDone: function(spec) {
|
||||
specResults[spec.description] = spec.status;
|
||||
}
|
||||
});
|
||||
|
||||
env.describe('suite0', function() {
|
||||
env.it('spec1', function() {});
|
||||
env.it('spec2', function() {});
|
||||
env.it('spec3', function() {});
|
||||
});
|
||||
|
||||
env.execute(null, function() {
|
||||
expect(specResults).toEqual({
|
||||
spec1: 'passed',
|
||||
spec2: 'excluded',
|
||||
spec3: 'excluded'
|
||||
});
|
||||
focussedSpec = 'spec2';
|
||||
env.execute(null, function() {
|
||||
expect(specResults).toEqual({
|
||||
spec1: 'excluded',
|
||||
spec2: 'passed',
|
||||
spec3: 'excluded'
|
||||
});
|
||||
focussedSpec = 'spec3';
|
||||
env.execute(null, function() {
|
||||
expect(specResults).toEqual({
|
||||
spec1: 'excluded',
|
||||
spec2: 'excluded',
|
||||
spec3: 'passed'
|
||||
});
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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());
|
||||
|
||||
@@ -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());
|
||||
@@ -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({});
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -28,7 +28,6 @@ module.exports = {
|
||||
'helpers/domHelpers.js',
|
||||
'helpers/integrationMatchers.js',
|
||||
'helpers/promises.js',
|
||||
'helpers/requireFastCheck.js',
|
||||
'helpers/defineJasmineUnderTest.js'
|
||||
],
|
||||
random: true,
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
"helpers/domHelpers.js",
|
||||
"helpers/integrationMatchers.js",
|
||||
"helpers/promises.js",
|
||||
"helpers/requireFastCheck.js",
|
||||
"helpers/overrideConsoleLogForCircleCi.js",
|
||||
"helpers/nodeDefineJasmineUnderTest.js"
|
||||
],
|
||||
|
||||
@@ -52,6 +52,7 @@ getJasmineRequireObj().CallTracker = function(j$) {
|
||||
/**
|
||||
* Get the "this" object that was passed to a specific invocation of this spy.
|
||||
* @name Spy#calls#thisFor
|
||||
* @since 3.8.0
|
||||
* @function
|
||||
* @param {Integer} index The 0-based invocation index.
|
||||
* @return {Object?}
|
||||
|
||||
@@ -7,6 +7,7 @@ getJasmineRequireObj().Clock = function() {
|
||||
|
||||
/**
|
||||
* @class Clock
|
||||
* @since 1.3.0
|
||||
* @classdesc Jasmine's mock clock is used when testing time dependent code.<br>
|
||||
* _Note:_ Do not construct this directly. You can get the current clock with
|
||||
* {@link jasmine.clock}.
|
||||
|
||||
335
src/core/Env.js
335
src/core/Env.js
@@ -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.
|
||||
@@ -120,7 +138,16 @@ getJasmineRequireObj().Env = function(j$) {
|
||||
* @type function
|
||||
* @default undefined
|
||||
*/
|
||||
Promise: undefined
|
||||
Promise: undefined,
|
||||
/**
|
||||
* Clean closures when a suite is done running (done by clearing the stored function reference).
|
||||
* This prevents memory leaks, but you won't be able to run jasmine multiple times.
|
||||
* @name Configuration#autoCleanClosures
|
||||
* @since 3.10.0
|
||||
* @type boolean
|
||||
* @default true
|
||||
*/
|
||||
autoCleanClosures: true
|
||||
};
|
||||
|
||||
var currentSuite = function() {
|
||||
@@ -170,35 +197,67 @@ getJasmineRequireObj().Env = function(j$) {
|
||||
* @function
|
||||
*/
|
||||
this.configure = function(configuration) {
|
||||
var booleanProps = [
|
||||
'random',
|
||||
'failSpecWithNoExpectations',
|
||||
'hideDisabled',
|
||||
'autoCleanClosures'
|
||||
];
|
||||
|
||||
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.
|
||||
@@ -383,7 +442,9 @@ getJasmineRequireObj().Env = function(j$) {
|
||||
}
|
||||
|
||||
delayedExpectationResult.message +=
|
||||
'Did you forget to return or await the result of expectAsync?';
|
||||
'1. Did you forget to return or await the result of expectAsync?\n' +
|
||||
'2. Was done() invoked before an async operation completed?\n' +
|
||||
'3. Did an expectation follow a call to done()?';
|
||||
|
||||
topSuite.result.failedExpectations.push(delayedExpectationResult);
|
||||
}
|
||||
@@ -448,10 +509,11 @@ getJasmineRequireObj().Env = function(j$) {
|
||||
delete runnableResources[id];
|
||||
};
|
||||
|
||||
var beforeAndAfterFns = function(suite) {
|
||||
var beforeAndAfterFns = function(targetSuite) {
|
||||
return function() {
|
||||
var befores = [],
|
||||
afters = [];
|
||||
afters = [],
|
||||
suite = targetSuite;
|
||||
|
||||
while (suite) {
|
||||
befores = befores.concat(suite.beforeFns);
|
||||
@@ -494,18 +556,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 +582,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 +653,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 +686,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 = {
|
||||
@@ -643,9 +714,9 @@ getJasmineRequireObj().Env = function(j$) {
|
||||
description: 'Jasmine__TopLevel__Suite',
|
||||
expectationFactory: expectationFactory,
|
||||
asyncExpectationFactory: suiteAsyncExpectationFactory,
|
||||
expectationResultFactory: expectationResultFactory
|
||||
expectationResultFactory: expectationResultFactory,
|
||||
autoCleanClosures: config.autoCleanClosures
|
||||
});
|
||||
defaultResourcesForRunnable(topSuite.id);
|
||||
currentDeclarationSuite = topSuite;
|
||||
|
||||
/**
|
||||
@@ -654,6 +725,7 @@ getJasmineRequireObj().Env = function(j$) {
|
||||
* @function
|
||||
* @name Env#topSuite
|
||||
* @return {Suite} the root suite
|
||||
* @since 2.0.0
|
||||
*/
|
||||
this.topSuite = function() {
|
||||
return topSuite;
|
||||
@@ -749,13 +821,24 @@ 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) {
|
||||
if (this._executedBefore) {
|
||||
topSuite.reset();
|
||||
}
|
||||
this._executedBefore = true;
|
||||
defaultResourcesForRunnable(topSuite.id);
|
||||
installGlobalErrors();
|
||||
|
||||
if (!runnablesToRun) {
|
||||
@@ -813,65 +896,88 @@ 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.
|
||||
* @since 2.0.0
|
||||
*/
|
||||
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.
|
||||
* @since 2.4.0
|
||||
*/
|
||||
reporter.jasmineDone(
|
||||
{
|
||||
overallStatus: overallStatus,
|
||||
totalTime: jasmineTimer.elapsed(),
|
||||
incompleteReason: incompleteReason,
|
||||
order: order,
|
||||
failedExpectations: topSuite.result.failedExpectations,
|
||||
deprecationWarnings: topSuite.result.deprecationWarnings
|
||||
},
|
||||
done
|
||||
);
|
||||
});
|
||||
}
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -1019,7 +1125,8 @@ getJasmineRequireObj().Env = function(j$) {
|
||||
expectationFactory: expectationFactory,
|
||||
asyncExpectationFactory: suiteAsyncExpectationFactory,
|
||||
expectationResultFactory: expectationResultFactory,
|
||||
throwOnExpectationFailure: config.oneFailurePerSpec
|
||||
throwOnExpectationFailure: config.oneFailurePerSpec,
|
||||
autoCleanClosures: config.autoCleanClosures
|
||||
});
|
||||
|
||||
return suite;
|
||||
@@ -1032,8 +1139,8 @@ getJasmineRequireObj().Env = function(j$) {
|
||||
if (specDefinitions.length > 0) {
|
||||
throw new Error('describe does not expect any arguments');
|
||||
}
|
||||
if (currentDeclarationSuite.markedPending) {
|
||||
suite.pend();
|
||||
if (currentDeclarationSuite.markedExcluding) {
|
||||
suite.exclude();
|
||||
}
|
||||
addSpecsToSuite(suite, specDefinitions);
|
||||
return suite;
|
||||
@@ -1043,7 +1150,7 @@ getJasmineRequireObj().Env = function(j$) {
|
||||
ensureIsNotNested('xdescribe');
|
||||
ensureIsFunction(specDefinitions, 'xdescribe');
|
||||
var suite = suiteFactory(description);
|
||||
suite.pend();
|
||||
suite.exclude();
|
||||
addSpecsToSuite(suite, specDefinitions);
|
||||
return suite;
|
||||
};
|
||||
@@ -1128,6 +1235,7 @@ getJasmineRequireObj().Env = function(j$) {
|
||||
timeout: timeout || 0
|
||||
},
|
||||
throwOnExpectationFailure: config.oneFailurePerSpec,
|
||||
autoCleanClosures: config.autoCleanClosures,
|
||||
timer: new j$.Timer()
|
||||
});
|
||||
return spec;
|
||||
@@ -1157,9 +1265,14 @@ getJasmineRequireObj().Env = function(j$) {
|
||||
if (arguments.length > 1 && typeof fn !== 'undefined') {
|
||||
ensureIsFunctionOrAsync(fn, 'it');
|
||||
}
|
||||
|
||||
if (timeout) {
|
||||
j$.util.validateTimeout(timeout);
|
||||
}
|
||||
|
||||
var spec = specFactory(description, fn, currentDeclarationSuite, timeout);
|
||||
if (currentDeclarationSuite.markedPending) {
|
||||
spec.pend();
|
||||
if (currentDeclarationSuite.markedExcluding) {
|
||||
spec.exclude();
|
||||
}
|
||||
currentDeclarationSuite.addChild(spec);
|
||||
return spec;
|
||||
@@ -1173,13 +1286,17 @@ getJasmineRequireObj().Env = function(j$) {
|
||||
ensureIsFunctionOrAsync(fn, 'xit');
|
||||
}
|
||||
var spec = this.it.apply(this, arguments);
|
||||
spec.pend('Temporarily disabled with xit');
|
||||
spec.exclude('Temporarily disabled with xit');
|
||||
return spec;
|
||||
};
|
||||
|
||||
this.fit = function(description, fn, timeout) {
|
||||
ensureIsNotNested('fit');
|
||||
ensureIsFunctionOrAsync(fn, 'fit');
|
||||
|
||||
if (timeout) {
|
||||
j$.util.validateTimeout(timeout);
|
||||
}
|
||||
var spec = specFactory(description, fn, currentDeclarationSuite, timeout);
|
||||
currentDeclarationSuite.addChild(spec);
|
||||
focusedRunnables.push(spec.id);
|
||||
@@ -1244,6 +1361,11 @@ getJasmineRequireObj().Env = function(j$) {
|
||||
this.beforeEach = function(beforeEachFunction, timeout) {
|
||||
ensureIsNotNested('beforeEach');
|
||||
ensureIsFunctionOrAsync(beforeEachFunction, 'beforeEach');
|
||||
|
||||
if (timeout) {
|
||||
j$.util.validateTimeout(timeout);
|
||||
}
|
||||
|
||||
currentDeclarationSuite.beforeEach({
|
||||
fn: beforeEachFunction,
|
||||
timeout: timeout || 0
|
||||
@@ -1253,6 +1375,11 @@ getJasmineRequireObj().Env = function(j$) {
|
||||
this.beforeAll = function(beforeAllFunction, timeout) {
|
||||
ensureIsNotNested('beforeAll');
|
||||
ensureIsFunctionOrAsync(beforeAllFunction, 'beforeAll');
|
||||
|
||||
if (timeout) {
|
||||
j$.util.validateTimeout(timeout);
|
||||
}
|
||||
|
||||
currentDeclarationSuite.beforeAll({
|
||||
fn: beforeAllFunction,
|
||||
timeout: timeout || 0
|
||||
@@ -1262,6 +1389,11 @@ getJasmineRequireObj().Env = function(j$) {
|
||||
this.afterEach = function(afterEachFunction, timeout) {
|
||||
ensureIsNotNested('afterEach');
|
||||
ensureIsFunctionOrAsync(afterEachFunction, 'afterEach');
|
||||
|
||||
if (timeout) {
|
||||
j$.util.validateTimeout(timeout);
|
||||
}
|
||||
|
||||
afterEachFunction.isCleanup = true;
|
||||
currentDeclarationSuite.afterEach({
|
||||
fn: afterEachFunction,
|
||||
@@ -1272,6 +1404,11 @@ getJasmineRequireObj().Env = function(j$) {
|
||||
this.afterAll = function(afterAllFunction, timeout) {
|
||||
ensureIsNotNested('afterAll');
|
||||
ensureIsFunctionOrAsync(afterAllFunction, 'afterAll');
|
||||
|
||||
if (timeout) {
|
||||
j$.util.validateTimeout(timeout);
|
||||
}
|
||||
|
||||
currentDeclarationSuite.afterAll({
|
||||
fn: afterAllFunction,
|
||||
timeout: timeout || 0
|
||||
|
||||
@@ -126,6 +126,7 @@ getJasmineRequireObj().Expectation = function(j$) {
|
||||
* Otherwise evaluate the matcher.
|
||||
* @member
|
||||
* @name async-matchers#already
|
||||
* @since 3.8.0
|
||||
* @type {async-matchers}
|
||||
* @example
|
||||
* await expectAsync(myPromise).already.toBeResolved();
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -89,7 +89,6 @@ getJasmineRequireObj().QueueRunner = function(j$) {
|
||||
completedSynchronously = true,
|
||||
handleError = function handleError(error) {
|
||||
onException(error);
|
||||
next(error);
|
||||
},
|
||||
cleanup = once(function cleanup() {
|
||||
if (timeoutId !== void 0) {
|
||||
|
||||
@@ -2,17 +2,26 @@ getJasmineRequireObj().Spec = function(j$) {
|
||||
/**
|
||||
* @interface Spec
|
||||
* @see Configuration#specFilter
|
||||
* @since 2.0.0
|
||||
*/
|
||||
function Spec(attrs) {
|
||||
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}
|
||||
* @since 2.0.0
|
||||
*/
|
||||
this.id = attrs.id;
|
||||
/**
|
||||
* The description passed to the {@link it} that created this spec.
|
||||
* @name Spec#description
|
||||
* @readonly
|
||||
* @type {string}
|
||||
* @since 2.0.0
|
||||
*/
|
||||
this.description = attrs.description || '';
|
||||
this.queueableFn = attrs.queueableFn;
|
||||
@@ -27,6 +36,8 @@ getJasmineRequireObj().Spec = function(j$) {
|
||||
return {};
|
||||
};
|
||||
this.onStart = attrs.onStart || function() {};
|
||||
this.autoCleanClosures =
|
||||
attrs.autoCleanClosures === undefined ? true : !!attrs.autoCleanClosures;
|
||||
this.getSpecName =
|
||||
attrs.getSpecName ||
|
||||
function() {
|
||||
@@ -44,7 +55,7 @@ getJasmineRequireObj().Spec = function(j$) {
|
||||
this.timer = attrs.timer || new j$.Timer();
|
||||
|
||||
if (!this.queueableFn.fn) {
|
||||
this.pend();
|
||||
this.exclude();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -59,7 +70,8 @@ getJasmineRequireObj().Spec = function(j$) {
|
||||
* @property {String} status - Once the spec has completed, this string represents the pass/fail status of this spec.
|
||||
* @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}
|
||||
*/
|
||||
* @since 2.0.0
|
||||
x */
|
||||
this.result = {
|
||||
id: this.id,
|
||||
description: this.description,
|
||||
@@ -111,7 +123,9 @@ getJasmineRequireObj().Spec = function(j$) {
|
||||
|
||||
var complete = {
|
||||
fn: function(done) {
|
||||
self.queueableFn.fn = null;
|
||||
if (self.autoCleanClosures) {
|
||||
self.queueableFn.fn = null;
|
||||
}
|
||||
self.result.status = self.status(excluded, failSpecWithNoExp);
|
||||
self.result.duration = self.timer.elapsed();
|
||||
self.resultCallback(self.result, done);
|
||||
@@ -148,6 +162,36 @@ getJasmineRequireObj().Spec = function(j$) {
|
||||
this.queueRunnerFactory(runnerConfig);
|
||||
};
|
||||
|
||||
Spec.prototype.reset = function() {
|
||||
/**
|
||||
* @typedef SpecResult
|
||||
* @property {Int} id - The unique id of this spec.
|
||||
* @property {String} description - The description passed to the {@link it} that created this spec.
|
||||
* @property {String} fullName - The full description including all ancestors of this spec.
|
||||
* @property {Expectation[]} failedExpectations - The list of expectations that failed during execution of this spec.
|
||||
* @property {Expectation[]} passedExpectations - The list of expectations that passed during execution of this spec.
|
||||
* @property {Expectation[]} deprecationWarnings - The list of deprecation warnings that occurred during execution this spec.
|
||||
* @property {String} pendingReason - If the spec is {@link pending}, this will be the reason.
|
||||
* @property {String} status - Once the spec has completed, this string represents the pass/fail status of this spec.
|
||||
* @property {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}
|
||||
* @since 2.0.0
|
||||
*/
|
||||
this.result = {
|
||||
id: this.id,
|
||||
description: this.description,
|
||||
fullName: this.getFullName(),
|
||||
failedExpectations: [],
|
||||
passedExpectations: [],
|
||||
deprecationWarnings: [],
|
||||
pendingReason: this.excludeMessage,
|
||||
duration: null,
|
||||
properties: null,
|
||||
trace: null
|
||||
};
|
||||
this.markedPending = this.markedExcluding;
|
||||
};
|
||||
|
||||
Spec.prototype.onException = function onException(e) {
|
||||
if (Spec.isPendingSpecException(e)) {
|
||||
this.pend(extractCustomPendingMessage(e));
|
||||
@@ -171,6 +215,10 @@ getJasmineRequireObj().Spec = function(j$) {
|
||||
);
|
||||
};
|
||||
|
||||
/*
|
||||
* Marks state as pending
|
||||
* @param {string} [message] An optional reason message
|
||||
*/
|
||||
Spec.prototype.pend = function(message) {
|
||||
this.markedPending = true;
|
||||
if (message) {
|
||||
@@ -178,6 +226,19 @@ getJasmineRequireObj().Spec = function(j$) {
|
||||
}
|
||||
};
|
||||
|
||||
/*
|
||||
* Like {@link Spec#pend}, but pending state will survive {@link Spec#reset}
|
||||
* Useful for fit, xit, where pending state remains.
|
||||
* @param {string} [message] An optional reason message
|
||||
*/
|
||||
Spec.prototype.exclude = function(message) {
|
||||
this.markedExcluding = true;
|
||||
if (this.message) {
|
||||
this.excludeMessage = message;
|
||||
}
|
||||
this.pend(message);
|
||||
};
|
||||
|
||||
Spec.prototype.getResult = function() {
|
||||
this.result.status = this.status();
|
||||
return this.result;
|
||||
@@ -210,6 +271,7 @@ getJasmineRequireObj().Spec = function(j$) {
|
||||
* @name Spec#getFullName
|
||||
* @function
|
||||
* @returns {string}
|
||||
* @since 2.0.0
|
||||
*/
|
||||
Spec.prototype.getFullName = function() {
|
||||
return this.getSpecName(this);
|
||||
|
||||
@@ -2,9 +2,17 @@ getJasmineRequireObj().Suite = function(j$) {
|
||||
/**
|
||||
* @interface Suite
|
||||
* @see Env#topSuite
|
||||
* @since 2.0.0
|
||||
*/
|
||||
function Suite(attrs) {
|
||||
this.env = attrs.env;
|
||||
/**
|
||||
* The unique ID of this suite.
|
||||
* @name Suite#id
|
||||
* @readonly
|
||||
* @type {string}
|
||||
* @since 2.0.0
|
||||
*/
|
||||
this.id = attrs.id;
|
||||
/**
|
||||
* The parent of this suite, or null if this is the top suite.
|
||||
@@ -18,12 +26,15 @@ getJasmineRequireObj().Suite = function(j$) {
|
||||
* @name Suite#description
|
||||
* @readonly
|
||||
* @type {string}
|
||||
* @since 2.0.0
|
||||
*/
|
||||
this.description = attrs.description;
|
||||
this.expectationFactory = attrs.expectationFactory;
|
||||
this.asyncExpectationFactory = attrs.asyncExpectationFactory;
|
||||
this.expectationResultFactory = attrs.expectationResultFactory;
|
||||
this.throwOnExpectationFailure = !!attrs.throwOnExpectationFailure;
|
||||
this.autoCleanClosures =
|
||||
attrs.autoCleanClosures === undefined ? true : !!attrs.autoCleanClosures;
|
||||
|
||||
this.beforeFns = [];
|
||||
this.afterFns = [];
|
||||
@@ -36,29 +47,11 @@ getJasmineRequireObj().Suite = function(j$) {
|
||||
* The suite's children.
|
||||
* @name Suite#children
|
||||
* @type {Array.<(Spec|Suite)>}
|
||||
* @since 2.0.0
|
||||
*/
|
||||
this.children = [];
|
||||
|
||||
/**
|
||||
* @typedef SuiteResult
|
||||
* @property {Int} id - The unique id of this suite.
|
||||
* @property {String} description - The description text passed to the {@link describe} that made this suite.
|
||||
* @property {String} fullName - The full description including all ancestors of this suite.
|
||||
* @property {Expectation[]} failedExpectations - The list of expectations that failed in an {@link afterAll} for this suite.
|
||||
* @property {Expectation[]} deprecationWarnings - The list of deprecation warnings that occurred on this suite.
|
||||
* @property {String} status - Once the suite has completed, this string represents the pass/fail status of this suite.
|
||||
* @property {number} duration - The time in ms for Suite execution, including any before/afterAll, before/afterEach.
|
||||
* @property {Object} properties - User-supplied properties, if any, that were set using {@link Env#setSuiteProperty}
|
||||
*/
|
||||
this.result = {
|
||||
id: this.id,
|
||||
description: this.description,
|
||||
fullName: this.getFullName(),
|
||||
failedExpectations: [],
|
||||
deprecationWarnings: [],
|
||||
duration: null,
|
||||
properties: null
|
||||
};
|
||||
this.reset();
|
||||
}
|
||||
|
||||
Suite.prototype.setSuiteProperty = function(key, value) {
|
||||
@@ -79,6 +72,7 @@ getJasmineRequireObj().Suite = function(j$) {
|
||||
* @name Suite#getFullName
|
||||
* @function
|
||||
* @returns {string}
|
||||
* @since 2.0.0
|
||||
*/
|
||||
Suite.prototype.getFullName = function() {
|
||||
var fullName = [];
|
||||
@@ -94,10 +88,22 @@ getJasmineRequireObj().Suite = function(j$) {
|
||||
return fullName.join(' ');
|
||||
};
|
||||
|
||||
/*
|
||||
* Mark the suite with "pending" status
|
||||
*/
|
||||
Suite.prototype.pend = function() {
|
||||
this.markedPending = true;
|
||||
};
|
||||
|
||||
/*
|
||||
* Like {@link Suite#pend}, but pending state will survive {@link Spec#reset}
|
||||
* Useful for fdescribe, xdescribe, where pending state should remain.
|
||||
*/
|
||||
Suite.prototype.exclude = function() {
|
||||
this.pend();
|
||||
this.markedExcluding = true;
|
||||
};
|
||||
|
||||
Suite.prototype.beforeEach = function(fn) {
|
||||
this.beforeFns.unshift(fn);
|
||||
};
|
||||
@@ -129,10 +135,40 @@ getJasmineRequireObj().Suite = function(j$) {
|
||||
}
|
||||
|
||||
Suite.prototype.cleanupBeforeAfter = function() {
|
||||
removeFns(this.beforeAllFns);
|
||||
removeFns(this.afterAllFns);
|
||||
removeFns(this.beforeFns);
|
||||
removeFns(this.afterFns);
|
||||
if (this.autoCleanClosures) {
|
||||
removeFns(this.beforeAllFns);
|
||||
removeFns(this.afterAllFns);
|
||||
removeFns(this.beforeFns);
|
||||
removeFns(this.afterFns);
|
||||
}
|
||||
};
|
||||
|
||||
Suite.prototype.reset = function() {
|
||||
/**
|
||||
* @typedef SuiteResult
|
||||
* @property {Int} id - The unique id of this suite.
|
||||
* @property {String} description - The description text passed to the {@link describe} that made this suite.
|
||||
* @property {String} fullName - The full description including all ancestors of this suite.
|
||||
* @property {Expectation[]} failedExpectations - The list of expectations that failed in an {@link afterAll} for this suite.
|
||||
* @property {Expectation[]} deprecationWarnings - The list of deprecation warnings that occurred on this suite.
|
||||
* @property {String} status - Once the suite has completed, this string represents the pass/fail status of this suite.
|
||||
* @property {number} duration - The time in ms for Suite execution, including any before/afterAll, before/afterEach.
|
||||
* @property {Object} properties - User-supplied properties, if any, that were set using {@link Env#setSuiteProperty}
|
||||
* @since 2.0.0
|
||||
*/
|
||||
this.result = {
|
||||
id: this.id,
|
||||
description: this.description,
|
||||
fullName: this.getFullName(),
|
||||
failedExpectations: [],
|
||||
deprecationWarnings: [],
|
||||
duration: null,
|
||||
properties: null
|
||||
};
|
||||
this.markedPending = this.markedExcluding;
|
||||
this.children.forEach(function(child) {
|
||||
child.reset();
|
||||
});
|
||||
};
|
||||
|
||||
Suite.prototype.addChild = function(child) {
|
||||
|
||||
24
src/core/asymmetric_equality/StringContaining.js
Normal file
24
src/core/asymmetric_equality/StringContaining.js
Normal file
@@ -0,0 +1,24 @@
|
||||
getJasmineRequireObj().StringContaining = function(j$) {
|
||||
function StringContaining(expected) {
|
||||
if (!j$.isString_(expected)) {
|
||||
throw new Error('Expected is not a String');
|
||||
}
|
||||
|
||||
this.expected = expected;
|
||||
}
|
||||
|
||||
StringContaining.prototype.asymmetricMatch = function(other) {
|
||||
if (!j$.isString_(other)) {
|
||||
// Arrays, etc. don't match no matter what their indexOf returns.
|
||||
return false;
|
||||
}
|
||||
|
||||
return other.indexOf(this.expected) !== -1;
|
||||
};
|
||||
|
||||
StringContaining.prototype.jasmineToString = function() {
|
||||
return '<jasmine.stringContaining("' + this.expected + '")>';
|
||||
};
|
||||
|
||||
return StringContaining;
|
||||
};
|
||||
@@ -7,6 +7,7 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) {
|
||||
* Maximum object depth the pretty printer will print to.
|
||||
* Set this to a lower value to speed up pretty printing if you have large objects.
|
||||
* @name jasmine.MAX_PRETTY_PRINT_DEPTH
|
||||
* @default 8
|
||||
* @since 1.3.0
|
||||
*/
|
||||
j$.MAX_PRETTY_PRINT_DEPTH = 8;
|
||||
@@ -15,6 +16,7 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) {
|
||||
* This will also limit the number of keys and values displayed for an object.
|
||||
* Elements past this number will be ellipised.
|
||||
* @name jasmine.MAX_PRETTY_PRINT_ARRAY_LENGTH
|
||||
* @default 50
|
||||
* @since 2.7.0
|
||||
*/
|
||||
j$.MAX_PRETTY_PRINT_ARRAY_LENGTH = 50;
|
||||
@@ -22,15 +24,35 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) {
|
||||
* Maximum number of characters to display when pretty printing objects.
|
||||
* Characters past this number will be ellipised.
|
||||
* @name jasmine.MAX_PRETTY_PRINT_CHARS
|
||||
* @default 100
|
||||
* @since 2.9.0
|
||||
*/
|
||||
j$.MAX_PRETTY_PRINT_CHARS = 1000;
|
||||
/**
|
||||
* Default number of milliseconds Jasmine will wait for an asynchronous spec to complete.
|
||||
* Default number of milliseconds Jasmine will wait for an asynchronous spec,
|
||||
* before, or after function to complete. This can be overridden on a case by
|
||||
* case basis by passing a time limit as the third argument to {@link it},
|
||||
* {@link beforeEach}, {@link afterEach}, {@link beforeAll}, or
|
||||
* {@link afterAll}. The value must be no greater than the largest number of
|
||||
* milliseconds supported by setTimeout, which is usually 2147483647.
|
||||
*
|
||||
* While debugging tests, you may want to set this to a large number (or pass
|
||||
* a large number to one of the functions mentioned above) so that Jasmine
|
||||
* does not move on to after functions or the next spec while you're debugging.
|
||||
* @name jasmine.DEFAULT_TIMEOUT_INTERVAL
|
||||
* @default 5000
|
||||
* @since 1.3.0
|
||||
*/
|
||||
j$.DEFAULT_TIMEOUT_INTERVAL = 5000;
|
||||
var DEFAULT_TIMEOUT_INTERVAL = 5000;
|
||||
Object.defineProperty(j$, 'DEFAULT_TIMEOUT_INTERVAL', {
|
||||
get: function() {
|
||||
return DEFAULT_TIMEOUT_INTERVAL;
|
||||
},
|
||||
set: function(newValue) {
|
||||
j$.util.validateTimeout(newValue, 'jasmine.DEFAULT_TIMEOUT_INTERVAL');
|
||||
DEFAULT_TIMEOUT_INTERVAL = newValue;
|
||||
}
|
||||
});
|
||||
|
||||
j$.getGlobal = function() {
|
||||
return jasmineGlobal;
|
||||
@@ -99,9 +121,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)) {
|
||||
@@ -217,7 +251,7 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) {
|
||||
};
|
||||
|
||||
/**
|
||||
* Get a matcher, usable in any {@link matchers|matcher} that uses Jasmine's equality (e.g. {@link matchers#toEqual|toEqual}, {@link matchers#toContain|toContain}, or {@link matchers#toHaveBeenCalledWith|toHaveBeenCalledWith}),
|
||||
* Get an {@link AsymmetricEqualityTester}, usable in any {@link matchers|matcher} that uses Jasmine's equality (e.g. {@link matchers#toEqual|toEqual}, {@link matchers#toContain|toContain}, or {@link matchers#toHaveBeenCalledWith|toHaveBeenCalledWith}),
|
||||
* that will succeed if the actual value being compared is an instance of the specified class/constructor.
|
||||
* @name jasmine.any
|
||||
* @since 1.3.0
|
||||
@@ -229,7 +263,7 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) {
|
||||
};
|
||||
|
||||
/**
|
||||
* Get a matcher, usable in any {@link matchers|matcher} that uses Jasmine's equality (e.g. {@link matchers#toEqual|toEqual}, {@link matchers#toContain|toContain}, or {@link matchers#toHaveBeenCalledWith|toHaveBeenCalledWith}),
|
||||
* Get an {@link AsymmetricEqualityTester}, usable in any {@link matchers|matcher} that uses Jasmine's equality (e.g. {@link matchers#toEqual|toEqual}, {@link matchers#toContain|toContain}, or {@link matchers#toHaveBeenCalledWith|toHaveBeenCalledWith}),
|
||||
* that will succeed if the actual value being compared is not `null` and not `undefined`.
|
||||
* @name jasmine.anything
|
||||
* @since 2.2.0
|
||||
@@ -240,7 +274,7 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) {
|
||||
};
|
||||
|
||||
/**
|
||||
* Get a matcher, usable in any {@link matchers|matcher} that uses Jasmine's equality (e.g. {@link matchers#toEqual|toEqual}, {@link matchers#toContain|toContain}, or {@link matchers#toHaveBeenCalledWith|toHaveBeenCalledWith}),
|
||||
* Get an {@link AsymmetricEqualityTester}, usable in any {@link matchers|matcher} that uses Jasmine's equality (e.g. {@link matchers#toEqual|toEqual}, {@link matchers#toContain|toContain}, or {@link matchers#toHaveBeenCalledWith|toHaveBeenCalledWith}),
|
||||
* that will succeed if the actual value being compared is `true` or anything truthy.
|
||||
* @name jasmine.truthy
|
||||
* @since 3.1.0
|
||||
@@ -251,7 +285,7 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) {
|
||||
};
|
||||
|
||||
/**
|
||||
* Get a matcher, usable in any {@link matchers|matcher} that uses Jasmine's equality (e.g. {@link matchers#toEqual|toEqual}, {@link matchers#toContain|toContain}, or {@link matchers#toHaveBeenCalledWith|toHaveBeenCalledWith}),
|
||||
* Get an {@link AsymmetricEqualityTester}, usable in any {@link matchers|matcher} that uses Jasmine's equality (e.g. {@link matchers#toEqual|toEqual}, {@link matchers#toContain|toContain}, or {@link matchers#toHaveBeenCalledWith|toHaveBeenCalledWith}),
|
||||
* that will succeed if the actual value being compared is `null`, `undefined`, `0`, `false` or anything falsey.
|
||||
* @name jasmine.falsy
|
||||
* @since 3.1.0
|
||||
@@ -262,7 +296,7 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) {
|
||||
};
|
||||
|
||||
/**
|
||||
* Get a matcher, usable in any {@link matchers|matcher} that uses Jasmine's equality (e.g. {@link matchers#toEqual|toEqual}, {@link matchers#toContain|toContain}, or {@link matchers#toHaveBeenCalledWith|toHaveBeenCalledWith}),
|
||||
* Get an {@link AsymmetricEqualityTester}, usable in any {@link matchers|matcher} that uses Jasmine's equality (e.g. {@link matchers#toEqual|toEqual}, {@link matchers#toContain|toContain}, or {@link matchers#toHaveBeenCalledWith|toHaveBeenCalledWith}),
|
||||
* that will succeed if the actual value being compared is empty.
|
||||
* @name jasmine.empty
|
||||
* @since 3.1.0
|
||||
@@ -273,7 +307,7 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) {
|
||||
};
|
||||
|
||||
/**
|
||||
* Get a matcher, usable in any {@link matchers|matcher} that uses Jasmine's equality (e.g. {@link matchers#toEqual|toEqual}, {@link matchers#toContain|toContain}, or {@link matchers#toHaveBeenCalledWith|toHaveBeenCalledWith}),
|
||||
* Get an {@link AsymmetricEqualityTester}, usable in any {@link matchers|matcher} that uses Jasmine's equality (e.g. {@link matchers#toEqual|toEqual}, {@link matchers#toContain|toContain}, or {@link matchers#toHaveBeenCalledWith|toHaveBeenCalledWith}),
|
||||
* that will succeed if the actual value being compared is not empty.
|
||||
* @name jasmine.notEmpty
|
||||
* @since 3.1.0
|
||||
@@ -284,7 +318,7 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) {
|
||||
};
|
||||
|
||||
/**
|
||||
* Get a matcher, usable in any {@link matchers|matcher} that uses Jasmine's equality (e.g. {@link matchers#toEqual|toEqual}, {@link matchers#toContain|toContain}, or {@link matchers#toHaveBeenCalledWith|toHaveBeenCalledWith}),
|
||||
* Get an {@link AsymmetricEqualityTester}, usable in any {@link matchers|matcher} that uses Jasmine's equality (e.g. {@link matchers#toEqual|toEqual}, {@link matchers#toContain|toContain}, or {@link matchers#toHaveBeenCalledWith|toHaveBeenCalledWith}),
|
||||
* that will succeed if the actual value being compared contains at least the keys and values.
|
||||
* @name jasmine.objectContaining
|
||||
* @since 1.3.0
|
||||
@@ -296,7 +330,7 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) {
|
||||
};
|
||||
|
||||
/**
|
||||
* Get a matcher, usable in any {@link matchers|matcher} that uses Jasmine's equality (e.g. {@link matchers#toEqual|toEqual}, {@link matchers#toContain|toContain}, or {@link matchers#toHaveBeenCalledWith|toHaveBeenCalledWith}),
|
||||
* Get an {@link AsymmetricEqualityTester}, usable in any {@link matchers|matcher} that uses Jasmine's equality (e.g. {@link matchers#toEqual|toEqual}, {@link matchers#toContain|toContain}, or {@link matchers#toHaveBeenCalledWith|toHaveBeenCalledWith}),
|
||||
* that will succeed if the actual value is a `String` that matches the `RegExp` or `String`.
|
||||
* @name jasmine.stringMatching
|
||||
* @since 2.2.0
|
||||
@@ -308,7 +342,19 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) {
|
||||
};
|
||||
|
||||
/**
|
||||
* Get a matcher, usable in any {@link matchers|matcher} that uses Jasmine's equality (e.g. {@link matchers#toEqual|toEqual}, {@link matchers#toContain|toContain}, or {@link matchers#toHaveBeenCalledWith|toHaveBeenCalledWith}),
|
||||
* Get an {@link AsymmetricEqualityTester}, usable in any {@link matchers|matcher} that uses Jasmine's equality (e.g. {@link matchers#toEqual|toEqual}, {@link matchers#toContain|toContain}, or {@link matchers#toHaveBeenCalledWith|toHaveBeenCalledWith}),
|
||||
* that will succeed if the actual value is a `String` that contains the specified `String`.
|
||||
* @name jasmine.stringContaining
|
||||
* @since 3.10.0
|
||||
* @function
|
||||
* @param {String} expected
|
||||
*/
|
||||
j$.stringContaining = function(expected) {
|
||||
return new j$.StringContaining(expected);
|
||||
};
|
||||
|
||||
/**
|
||||
* Get an {@link AsymmetricEqualityTester}, usable in any {@link matchers|matcher} that uses Jasmine's equality (e.g. {@link matchers#toEqual|toEqual}, {@link matchers#toContain|toContain}, or {@link matchers#toHaveBeenCalledWith|toHaveBeenCalledWith}),
|
||||
* that will succeed if the actual value is an `Array` that contains at least the elements in the sample.
|
||||
* @name jasmine.arrayContaining
|
||||
* @since 2.2.0
|
||||
@@ -320,7 +366,7 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) {
|
||||
};
|
||||
|
||||
/**
|
||||
* Get a matcher, usable in any {@link matchers|matcher} that uses Jasmine's equality (e.g. {@link matchers#toEqual|toEqual}, {@link matchers#toContain|toContain}, or {@link matchers#toHaveBeenCalledWith|toHaveBeenCalledWith}),
|
||||
* Get an {@link AsymmetricEqualityTester}, usable in any {@link matchers|matcher} that uses Jasmine's equality (e.g. {@link matchers#toEqual|toEqual}, {@link matchers#toContain|toContain}, or {@link matchers#toHaveBeenCalledWith|toHaveBeenCalledWith}),
|
||||
* that will succeed if the actual value is an `Array` that contains all of the elements in the sample in any order.
|
||||
* @name jasmine.arrayWithExactContents
|
||||
* @since 2.8.0
|
||||
@@ -332,7 +378,7 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) {
|
||||
};
|
||||
|
||||
/**
|
||||
* Get a matcher, usable in any {@link matchers|matcher} that uses Jasmine's equality (e.g. {@link matchers#toEqual|toEqual}, {@link matchers#toContain|toContain}, or {@link matchers#toHaveBeenCalledWith|toHaveBeenCalledWith}),
|
||||
* Get an {@link AsymmetricEqualityTester}, usable in any {@link matchers|matcher} that uses Jasmine's equality (e.g. {@link matchers#toEqual|toEqual}, {@link matchers#toContain|toContain}, or {@link matchers#toHaveBeenCalledWith|toHaveBeenCalledWith}),
|
||||
* that will succeed if every key/value pair in the sample passes the deep equality comparison
|
||||
* with at least one key/value pair in the actual value being compared
|
||||
* @name jasmine.mapContaining
|
||||
@@ -345,7 +391,7 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) {
|
||||
};
|
||||
|
||||
/**
|
||||
* Get a matcher, usable in any {@link matchers|matcher} that uses Jasmine's equality (e.g. {@link matchers#toEqual|toEqual}, {@link matchers#toContain|toContain}, or {@link matchers#toHaveBeenCalledWith|toHaveBeenCalledWith}),
|
||||
* Get an {@link AsymmetricEqualityTester}, usable in any {@link matchers|matcher} that uses Jasmine's equality (e.g. {@link matchers#toEqual|toEqual}, {@link matchers#toContain|toContain}, or {@link matchers#toHaveBeenCalledWith|toHaveBeenCalledWith}),
|
||||
* that will succeed if every item in the sample passes the deep equality comparison
|
||||
* with at least one item in the actual value being compared
|
||||
* @name jasmine.setContaining
|
||||
|
||||
@@ -659,9 +659,33 @@ getJasmineRequireObj().MatchersUtil = function(j$) {
|
||||
/**
|
||||
* @interface AsymmetricEqualityTester
|
||||
* @classdesc An asymmetric equality tester is an object that can match multiple
|
||||
* objects. Examples include jasmine.any() and jasmine.stringMatching().
|
||||
* User-defined asymmetric equality testers can also be defined and used in
|
||||
* expectations.
|
||||
* objects. Examples include jasmine.any() and jasmine.stringMatching(). Jasmine
|
||||
* includes a number of built-in asymmetric equality testers, such as
|
||||
* {@link jasmine.objectContaining}. User-defined asymmetric equality testers are
|
||||
* also supported.
|
||||
*
|
||||
* Asymmetric equality testers work with any matcher, including user-defined
|
||||
* custom matchers, that uses {@link MatchersUtil#equals} or
|
||||
* {@link MatchersUtil#contains}.
|
||||
*
|
||||
* @example
|
||||
* function numberDivisibleBy(divisor) {
|
||||
* return {
|
||||
* asymmetricMatch: function(n) {
|
||||
* return typeof n === 'number' && n % divisor === 0;
|
||||
* },
|
||||
* jasmineToString: function() {
|
||||
* return `<a number divisible by ${divisor}>`;
|
||||
* }
|
||||
* };
|
||||
* }
|
||||
*
|
||||
* var actual = {
|
||||
* n: 2,
|
||||
* otherFields: "don't care"
|
||||
* };
|
||||
*
|
||||
* expect(actual).toEqual(jasmine.objectContaining({n: numberDivisibleBy(2)}));
|
||||
* @see custom_asymmetric_equality_testers
|
||||
* @since 2.0.0
|
||||
*/
|
||||
|
||||
@@ -74,6 +74,7 @@ var getJasmineRequireObj = (function(jasmineGlobal) {
|
||||
j$.SpyRegistry = jRequire.SpyRegistry(j$);
|
||||
j$.SpyStrategy = jRequire.SpyStrategy(j$);
|
||||
j$.StringMatching = jRequire.StringMatching(j$);
|
||||
j$.StringContaining = jRequire.StringContaining(j$);
|
||||
j$.UserContext = jRequire.UserContext(j$);
|
||||
j$.Suite = jRequire.Suite(j$);
|
||||
j$.Timer = jRequire.Timer();
|
||||
|
||||
@@ -142,5 +142,20 @@ getJasmineRequireObj().util = function(j$) {
|
||||
}
|
||||
};
|
||||
|
||||
util.validateTimeout = function(timeout, msgPrefix) {
|
||||
// Timeouts are implemented with setTimeout, which only supports a limited
|
||||
// range of values. The limit is unspecified, as is the behavior when it's
|
||||
// exceeded. But on all currently supported JS runtimes, setTimeout calls
|
||||
// the callback immediately when the timeout is greater than 2147483647
|
||||
// (the maximum value of a signed 32 bit integer).
|
||||
var max = 2147483647;
|
||||
|
||||
if (timeout > max) {
|
||||
throw new Error(
|
||||
(msgPrefix || 'Timeout value') + ' cannot be greater than ' + max
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
return util;
|
||||
};
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
@use "sass:math";
|
||||
|
||||
$line-height: 14px;
|
||||
$margin-unit: 14px;
|
||||
|
||||
@@ -117,7 +119,7 @@ body {
|
||||
|
||||
li {
|
||||
display: inline-block;
|
||||
height: ($line-height / 2) + 3;
|
||||
height: math.div($line-height, 2) + 3;
|
||||
width: $line-height;
|
||||
|
||||
font-size: 16px;
|
||||
@@ -132,7 +134,7 @@ body {
|
||||
}
|
||||
|
||||
&.jasmine-failed {
|
||||
line-height: ($line-height / 2) + 2;
|
||||
line-height: math.div($line-height, 2) + 2;
|
||||
|
||||
&:before {
|
||||
color: $failing-color;
|
||||
@@ -282,8 +284,8 @@ body {
|
||||
padding-left: 0;
|
||||
|
||||
&.jasmine-suite {
|
||||
margin-top: $margin-unit/2;
|
||||
margin-bottom: $margin-unit/2
|
||||
margin-top: math.div($margin-unit, 2);
|
||||
margin-bottom: math.div($margin-unit, 2)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user