Compare commits
126 Commits
v6.0.0-alp
...
v7.0.0-pre
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d9023b1fde | ||
|
|
27319fd6ae | ||
|
|
3de4512681 | ||
|
|
d230b0500d | ||
|
|
c6520763d8 | ||
|
|
e087ebc419 | ||
|
|
4bf333ed38 | ||
|
|
4f5ef7c2d7 | ||
|
|
63ac7da082 | ||
|
|
281c0d1ee8 | ||
|
|
8bb325628f | ||
|
|
ff0699035f | ||
|
|
f12f4395f0 | ||
|
|
5de03beea1 | ||
|
|
42baa422b3 | ||
|
|
6af5d24b3b | ||
|
|
b88ce2d49f | ||
|
|
c216ae1d13 | ||
|
|
319776d241 | ||
|
|
1d0718dc2f | ||
|
|
929694310e | ||
|
|
7379a3a11b | ||
|
|
4db18aafce | ||
|
|
066669cfee | ||
|
|
87177d9d43 | ||
|
|
0c75a154a8 | ||
|
|
0a6f6d2b0e | ||
|
|
6755b03f12 | ||
|
|
e759ddced2 | ||
|
|
1ad28d8515 | ||
|
|
3d36b11c8f | ||
|
|
a15df6d455 | ||
|
|
9f0488dc32 | ||
|
|
f3dba82b04 | ||
|
|
c999ce0787 | ||
|
|
5b76bf9552 | ||
|
|
9cf9b856b0 | ||
|
|
db6c142afd | ||
|
|
79405426fa | ||
|
|
03006080d4 | ||
|
|
876de65803 | ||
|
|
8b3c4ce3b4 | ||
|
|
00b09a9a04 | ||
|
|
f5e9b61f73 | ||
|
|
4371081763 | ||
|
|
9530ff68ab | ||
|
|
51dc79dc22 | ||
|
|
b559faec2a | ||
|
|
d7b1456584 | ||
|
|
23894c1a0a | ||
|
|
1e691b2470 | ||
|
|
c5555dd8cc | ||
|
|
32168be6c7 | ||
|
|
78c14f81a8 | ||
|
|
788eba34b6 | ||
|
|
1f31b4b0f6 | ||
|
|
00a8a11904 | ||
|
|
3899d83fb6 | ||
|
|
8f13684a01 | ||
|
|
bdf63f2402 | ||
|
|
9c2ffae2f9 | ||
|
|
7b2807b321 | ||
|
|
e930622548 | ||
|
|
56e2832ebe | ||
|
|
d31d33aeb3 | ||
|
|
e4c69e960e | ||
|
|
a8431f33bd | ||
|
|
4995c967ac | ||
|
|
9a9d3994da | ||
|
|
ff9feb29d3 | ||
|
|
fee7e6e64e | ||
|
|
18d4d38655 | ||
|
|
53e9bc68d2 | ||
|
|
2be50e1b87 | ||
|
|
27a1257b6d | ||
|
|
75658e0566 | ||
|
|
85322d1877 | ||
|
|
6667a42301 | ||
|
|
020dffd504 | ||
|
|
4201fd848f | ||
|
|
9a67c4e24d | ||
|
|
d66d0d9d2e | ||
|
|
f4b9c889b9 | ||
|
|
388d7fb1a2 | ||
|
|
e993a4a363 | ||
|
|
54ac39a192 | ||
|
|
ea882c2f1e | ||
|
|
4cc605756a | ||
|
|
b6426d2414 | ||
|
|
2352249441 | ||
|
|
4dfc34a7a0 | ||
|
|
695a805844 | ||
|
|
10bc655622 | ||
|
|
4663280528 | ||
|
|
75347d9ba0 | ||
|
|
86387c9068 | ||
|
|
9b3cc08818 | ||
|
|
0ad54fc6f0 | ||
|
|
c042665d9c | ||
|
|
a457cf1b81 | ||
|
|
fb814b5f94 | ||
|
|
77c3b8b07e | ||
|
|
bd89ef66c8 | ||
|
|
01f050eeaa | ||
|
|
de44e909f2 | ||
|
|
10ad40357a | ||
|
|
1f521f2a7f | ||
|
|
5b3e12e4c5 | ||
|
|
7ba53b25f7 | ||
|
|
cfd8f11b30 | ||
|
|
d95ebf303a | ||
|
|
dbc1f9244e | ||
|
|
489b83c61b | ||
|
|
b881b0077d | ||
|
|
67ef721c85 | ||
|
|
c4abf3265d | ||
|
|
68a7cbb991 | ||
|
|
73a30ffc3e | ||
|
|
18491e9b84 | ||
|
|
0738ba6462 | ||
|
|
712f9bac29 | ||
|
|
d99bc3ab58 | ||
|
|
418393c496 | ||
|
|
2a83f5cc30 | ||
|
|
bca56032e0 | ||
|
|
c590095662 |
@@ -1,5 +1,5 @@
|
||||
# Run tests against supported Node versions, and (except for pull requests)
|
||||
# against supported browsers.
|
||||
# against supported browsers that are available on Saucelabs.
|
||||
|
||||
version: 2.1
|
||||
|
||||
@@ -89,7 +89,7 @@ jobs:
|
||||
export SAUCE_TUNNEL_NAME=$CIRCLE_WORKFLOW_JOB_ID
|
||||
scripts/start-sauce-connect
|
||||
set +o errexit
|
||||
scripts/run-all-browsers
|
||||
scripts/run-sauce-browsers
|
||||
exitcode=$?
|
||||
set -o errexit
|
||||
scripts/stop-sauce-connect
|
||||
|
||||
10
.github/CONTRIBUTING.md
vendored
10
.github/CONTRIBUTING.md
vendored
@@ -41,13 +41,11 @@ Jasmine tests itself. The files in `lib` are loaded first, defining the referenc
|
||||
|
||||
The tests should always use `jasmineUnderTest` to refer to the objects and functions that are being tested. But the tests can use functions on `jasmine` as needed. _Be careful how you structure any new test code_. Copy the patterns you see in the existing code - this ensures that the code you're testing is not leaking into the `jasmine` reference and vice-versa.
|
||||
|
||||
### `boot0.js` and `boot1.js`
|
||||
### `boot.js`
|
||||
|
||||
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.
|
||||
This file does all the setup necessary for Jasmine to work in a browser. While
|
||||
the default in `lib`is appropriate for most uses, users may wish to customize
|
||||
this file.
|
||||
|
||||
### Compatibility
|
||||
|
||||
|
||||
23
.github/workflows/safari.yml
vendored
Normal file
23
.github/workflows/safari.yml
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
name: Test in latest available Safari
|
||||
|
||||
on:
|
||||
push:
|
||||
pull_request:
|
||||
workflow_dispatch:
|
||||
schedule:
|
||||
- cron: '0 0 * * *'
|
||||
jobs:
|
||||
build:
|
||||
runs-on: macos-latest
|
||||
|
||||
steps:
|
||||
- name: Report Safari version
|
||||
run: osascript -e 'get version of application "Safari"'
|
||||
- uses: actions/checkout@v4
|
||||
- name: Use Node.js 22.x
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 22.x
|
||||
- run: npm install
|
||||
- run: npm run build
|
||||
- run: JASMINE_BROWSER=safari npm run ci
|
||||
2
LICENSE
2
LICENSE
@@ -1,5 +1,5 @@
|
||||
Copyright (c) 2008-2019 Pivotal Labs
|
||||
Copyright (c) 2008-2025 The Jasmine developers
|
||||
Copyright (c) 2008-2026 The Jasmine developers
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
|
||||
@@ -30,7 +30,7 @@ Microsoft Edge) as well as Node.
|
||||
| Environment | Supported versions |
|
||||
|-------------------|----------------------------------|
|
||||
| Node | 20, 22, 24 |
|
||||
| Safari | 16*, 17* |
|
||||
| Safari | 26* |
|
||||
| Chrome | Evergreen |
|
||||
| Firefox | Evergreen, 102*, 115*, 128*, 140 |
|
||||
| Edge | Evergreen |
|
||||
@@ -60,5 +60,5 @@ To find out what environments work with a particular Jasmine release, see the [r
|
||||
* Sheel Choksi
|
||||
|
||||
Copyright (c) 2008-2019 Pivotal Labs<br>
|
||||
Copyright (c) 2008-2025 The Jasmine developers<br>
|
||||
Copyright (c) 2008-2026 The Jasmine developers<br>
|
||||
This software is licensed under the [MIT License](https://github.com/jasmine/jasmine/blob/main/LICENSE).
|
||||
|
||||
15
RELEASE.md
15
RELEASE.md
@@ -28,9 +28,18 @@ should also rev to that version.
|
||||
|
||||
When ready to release - specs are all green and the stories are done:
|
||||
|
||||
1. Update the release notes in `release_notes` - use the Anchorman gem to generate the markdown file and edit accordingly. Include a list of supported environments.
|
||||
1. Update the version in `package.json`
|
||||
1. Run `npm run build`.
|
||||
1. Update the release notes in `release_notes` - use the Anchorman gem to
|
||||
generate the Markdown file and edit accordingly. Include a list of supported
|
||||
environments. Get that information from these places:
|
||||
* For Node, see .circleci/config.yml or the README.
|
||||
* For Firefox ESR and Safari <=17, see scripts/run-sauce-browsers or the README.
|
||||
* For evergreen browsers, trigger a Circle CI run and check the
|
||||
[Saucelabs dashboard](https://app.saucelabs.com/dashboard/tests?ownerId=90a771d55857492da3bd5251a2d92457&ownerType=user&ownerName=jasmine-js&start=last7days)
|
||||
once it's finished.
|
||||
* For Safari >17, trigger the [Safari action](https://github.com/jasmine/jasmine/actions/workflows/safari.yml)
|
||||
and get the version from the output.
|
||||
2. Update the version in `package.json`
|
||||
3. Run `npm run build`.
|
||||
|
||||
### Commit and push core changes
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Copyright (c) 2008-2019 Pivotal Labs
|
||||
Copyright (c) 2008-2025 The Jasmine developers
|
||||
Copyright (c) 2008-2026 The Jasmine developers
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
@@ -22,70 +22,28 @@ 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: Only available on Node.
|
||||
* @module jasmine-core
|
||||
*/
|
||||
'use strict';
|
||||
|
||||
const jasmineRequire = require('./jasmine-core/jasmine.js');
|
||||
module.exports = jasmineRequire;
|
||||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
const {
|
||||
globals,
|
||||
installGlobals,
|
||||
version,
|
||||
private$
|
||||
} = require('./jasmine-core/jasmine.js');
|
||||
|
||||
const bootWithoutGlobals = (function() {
|
||||
let jasmine, jasmineInterface;
|
||||
|
||||
return function bootWithoutGlobals(reinitialize) {
|
||||
if (!jasmineInterface || reinitialize === true) {
|
||||
jasmine = jasmineRequire.core(jasmineRequire);
|
||||
const env = jasmine.getEnv({ suppressLoadErrors: true });
|
||||
jasmineInterface = jasmineRequire.interface(jasmine, env);
|
||||
}
|
||||
|
||||
return { jasmine, jasmineInterface };
|
||||
};
|
||||
})();
|
||||
|
||||
/**
|
||||
* Boots a copy of Jasmine and returns an object as described in {@link jasmine}.
|
||||
* @param {boolean} [reinitialize=true] Whether to create a new copy of Jasmine if one already exists
|
||||
* @type {function}
|
||||
* @return {jasmine}
|
||||
*/
|
||||
module.exports.boot = function(reinitialize) {
|
||||
if (reinitialize === undefined) {
|
||||
reinitialize = true;
|
||||
}
|
||||
|
||||
const { jasmine, jasmineInterface } = bootWithoutGlobals(reinitialize);
|
||||
|
||||
for (const k in jasmineInterface) {
|
||||
global[k] = jasmineInterface[k];
|
||||
}
|
||||
|
||||
return jasmine;
|
||||
};
|
||||
|
||||
/**
|
||||
* Boots a copy of Jasmine and returns an object containing the properties
|
||||
* that would normally be added to the global object. If noGlobals is called
|
||||
* multiple times, the same object is returned every time.
|
||||
*
|
||||
* @example
|
||||
* const {describe, beforeEach, it, expect, jasmine} = require('jasmine-core').noGlobals();
|
||||
*/
|
||||
module.exports.noGlobals = function() {
|
||||
const { jasmineInterface } = bootWithoutGlobals(false);
|
||||
return jasmineInterface;
|
||||
};
|
||||
|
||||
const path = require('path'),
|
||||
fs = require('fs');
|
||||
function reset() {
|
||||
private$.currentEnv_ = null;
|
||||
const env = jasmine.getEnv({ suppressLoadErrors: true });
|
||||
rebindInterface(env);
|
||||
}
|
||||
|
||||
const rootPath = path.join(__dirname, 'jasmine-core'),
|
||||
bootFiles = ['boot0.js', 'boot1.js'],
|
||||
legacyBootFiles = ['boot.js'],
|
||||
bootFiles = ['boot.js'],
|
||||
cssFiles = [],
|
||||
jsFiles = [],
|
||||
jsFilesToSkip = ['jasmine.js'].concat(bootFiles, legacyBootFiles);
|
||||
jsFilesToSkip = ['jasmine.js'].concat(bootFiles);
|
||||
|
||||
fs.readdirSync(rootPath).forEach(function(file) {
|
||||
if (fs.statSync(path.join(rootPath, file)).isFile()) {
|
||||
@@ -102,12 +60,40 @@ fs.readdirSync(rootPath).forEach(function(file) {
|
||||
}
|
||||
});
|
||||
|
||||
module.exports.files = {
|
||||
self: __filename,
|
||||
path: rootPath,
|
||||
bootDir: rootPath,
|
||||
bootFiles: bootFiles,
|
||||
cssFiles: cssFiles,
|
||||
jsFiles: ['jasmine.js'].concat(jsFiles),
|
||||
imagesDir: path.join(__dirname, '../images')
|
||||
/**
|
||||
* Note: Only available on Node.
|
||||
*
|
||||
* In addition to the members documented here, this module's exports include all
|
||||
* {@link globals}.
|
||||
* @module jasmine-core
|
||||
*/
|
||||
module.exports = {
|
||||
...globals,
|
||||
/**
|
||||
* Copies Jasmine globals (jasmine, describe, it, etc) to the specified
|
||||
* object or to globalThis.
|
||||
* @function
|
||||
* @param {object} [dest] - The object to copy globals to.
|
||||
*/
|
||||
installGlobals,
|
||||
/**
|
||||
* Returns the jasmine-core version.
|
||||
* @function
|
||||
*/
|
||||
version,
|
||||
/**
|
||||
* Resets all of jasmine-core's state, including removing specs, suites, and
|
||||
* reporters, and resetting configuration to the default.
|
||||
* @function
|
||||
*/
|
||||
reset,
|
||||
files: {
|
||||
self: __filename,
|
||||
path: rootPath,
|
||||
bootDir: rootPath,
|
||||
bootFiles: bootFiles,
|
||||
cssFiles: cssFiles,
|
||||
jsFiles: ['jasmine.js'].concat(jsFiles),
|
||||
imagesDir: path.join(__dirname, '../images')
|
||||
}
|
||||
};
|
||||
|
||||
51
lib/jasmine-core/boot.js
Normal file
51
lib/jasmine-core/boot.js
Normal file
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
Copyright (c) 2008-2019 Pivotal Labs
|
||||
Copyright (c) 2008-2026 The Jasmine developers
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
(function() {
|
||||
const env = jasmine.getEnv();
|
||||
const urls = new jasmine.HtmlReporterV2Urls();
|
||||
|
||||
/**
|
||||
* Configures Jasmine based on the current set of query parameters. This
|
||||
* supports all parameters set by the HTML reporter as well as
|
||||
* spec=partialPath, which filters out specs whose paths don't contain the
|
||||
* parameter.
|
||||
*/
|
||||
env.configure(urls.configFromCurrentUrl());
|
||||
|
||||
const currentWindowOnload = window.onload;
|
||||
window.onload = function() {
|
||||
if (currentWindowOnload) {
|
||||
currentWindowOnload();
|
||||
}
|
||||
|
||||
// The HTML reporter needs to be set up here so it can access the DOM. Other
|
||||
// reporters can be added at any time before env.execute() is called.
|
||||
const htmlReporter = new jasmine.HtmlReporterV2({ env, urls });
|
||||
env.addReporter(htmlReporter);
|
||||
env.execute();
|
||||
};
|
||||
})();
|
||||
@@ -1,66 +0,0 @@
|
||||
/*
|
||||
Copyright (c) 2008-2019 Pivotal Labs
|
||||
Copyright (c) 2008-2025 The Jasmine developers
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
/**
|
||||
This file starts the process of "booting" Jasmine. It initializes Jasmine,
|
||||
makes its globals available, and creates the env. This file should be loaded
|
||||
after `jasmine.js` and `jasmine_html.js`, but before `boot1.js` or any project
|
||||
source files or spec files are loaded.
|
||||
*/
|
||||
(function() {
|
||||
const jasmineRequire = window.jasmineRequire || require('./jasmine.js');
|
||||
|
||||
/**
|
||||
* ## Require & Instantiate
|
||||
*
|
||||
* Require Jasmine's core files. Specifically, this requires and attaches all of Jasmine's code to the `jasmine` reference.
|
||||
*/
|
||||
const jasmine = jasmineRequire.core(jasmineRequire),
|
||||
global = jasmine.getGlobal();
|
||||
global.jasmine = jasmine;
|
||||
|
||||
/**
|
||||
* Since this is being run in a browser and the results should populate to an HTML page, require the HTML-specific Jasmine code, injecting the same reference.
|
||||
*/
|
||||
jasmineRequire.html(jasmine);
|
||||
|
||||
/**
|
||||
* Create the Jasmine environment. This is used to run all specs in a project.
|
||||
*/
|
||||
const env = jasmine.getEnv();
|
||||
|
||||
/**
|
||||
* ## The Global Interface
|
||||
*
|
||||
* Build up the functions that will be exposed as the Jasmine public interface. A project can customize, rename or alias any of these functions as desired, provided the implementation remains unchanged.
|
||||
*/
|
||||
const jasmineInterface = jasmineRequire.interface(jasmine, env);
|
||||
|
||||
/**
|
||||
* Add all of the Jasmine global/public interface to the global scope, so a project can use the public interface directly. For example, calling `describe` in specs instead of `jasmine.getEnv().describe`.
|
||||
*/
|
||||
for (const property in jasmineInterface) {
|
||||
global[property] = jasmineInterface[property];
|
||||
}
|
||||
})();
|
||||
@@ -1,121 +0,0 @@
|
||||
/*
|
||||
Copyright (c) 2008-2019 Pivotal Labs
|
||||
Copyright (c) 2008-2025 The Jasmine developers
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
/**
|
||||
This file finishes 'booting' Jasmine, performing all of the necessary
|
||||
initialization before executing the loaded environment and all of a project's
|
||||
specs. This file should be loaded after `boot0.js` but before any project
|
||||
source files or spec files are loaded. Thus this file can also be used to
|
||||
customize Jasmine for a project.
|
||||
|
||||
If a project is using Jasmine via the standalone distribution, this file can
|
||||
be customized directly. If you only wish to configure the Jasmine env, you
|
||||
can load another file that calls `jasmine.getEnv().configure({...})`
|
||||
after `boot0.js` is loaded and before this file is loaded.
|
||||
*/
|
||||
|
||||
(function() {
|
||||
const env = jasmine.getEnv();
|
||||
|
||||
const queryString = new jasmine.QueryString({
|
||||
getWindowLocation: function() {
|
||||
return window.location;
|
||||
}
|
||||
});
|
||||
|
||||
const config = {
|
||||
stopOnSpecFailure: queryString.getParam('stopOnSpecFailure'),
|
||||
stopSpecOnExpectationFailure: queryString.getParam(
|
||||
'stopSpecOnExpectationFailure'
|
||||
),
|
||||
hideDisabled: queryString.getParam('hideDisabled')
|
||||
};
|
||||
|
||||
const random = queryString.getParam('random');
|
||||
|
||||
if (random !== undefined && random !== '') {
|
||||
config.random = random;
|
||||
}
|
||||
|
||||
const 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).
|
||||
*/
|
||||
const 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(),
|
||||
queryString
|
||||
});
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
const specFilter = new jasmine.HtmlExactSpecFilter({ queryString });
|
||||
config.specFilter = function(spec) {
|
||||
return specFilter.matches(spec);
|
||||
};
|
||||
|
||||
env.configure(config);
|
||||
|
||||
/**
|
||||
* ## Execution
|
||||
*
|
||||
* Replace the browser window's `onload`, ensure it's called, and then run all of the loaded specs. This includes initializing the `HtmlReporter` instance and then executing the loaded Jasmine environment. All of this will happen after all of the specs are loaded.
|
||||
*/
|
||||
const currentWindowOnload = window.onload;
|
||||
|
||||
window.onload = function() {
|
||||
if (currentWindowOnload) {
|
||||
currentWindowOnload();
|
||||
}
|
||||
htmlReporter.initialize();
|
||||
env.execute();
|
||||
};
|
||||
})();
|
||||
File diff suppressed because it is too large
Load Diff
@@ -8,7 +8,7 @@ body {
|
||||
background-color: #eee;
|
||||
padding: 5px;
|
||||
margin: -8px;
|
||||
font-size: 11px;
|
||||
font-size: 12px;
|
||||
font-family: Monaco, "Lucida Console", monospace;
|
||||
line-height: 14px;
|
||||
color: #333;
|
||||
@@ -24,7 +24,6 @@ body {
|
||||
line-height: 14px;
|
||||
}
|
||||
.jasmine_html-reporter .jasmine-banner,
|
||||
.jasmine_html-reporter .jasmine-symbol-summary,
|
||||
.jasmine_html-reporter .jasmine-summary,
|
||||
.jasmine_html-reporter .jasmine-result-message,
|
||||
.jasmine_html-reporter .jasmine-spec .jasmine-description,
|
||||
@@ -63,57 +62,24 @@ body {
|
||||
float: right;
|
||||
line-height: 28px;
|
||||
padding-right: 9px;
|
||||
font-size: 12px;
|
||||
}
|
||||
.jasmine_html-reporter .jasmine-symbol-summary {
|
||||
overflow: hidden;
|
||||
margin: 14px 0;
|
||||
.jasmine_html-reporter progress {
|
||||
width: 100%;
|
||||
}
|
||||
.jasmine_html-reporter .jasmine-symbol-summary li {
|
||||
display: inline-block;
|
||||
height: 10px;
|
||||
width: 14px;
|
||||
font-size: 16px;
|
||||
.jasmine_html-reporter progress[value] {
|
||||
-webkit-appearance: none;
|
||||
-moz-appearance: none;
|
||||
appearance: none;
|
||||
}
|
||||
.jasmine_html-reporter .jasmine-symbol-summary li.jasmine-passed {
|
||||
font-size: 14px;
|
||||
.jasmine_html-reporter progress[value]::-webkit-progress-value, .jasmine_html-reporter progress[value]::-moz-progress-bar {
|
||||
background: #007069;
|
||||
}
|
||||
.jasmine_html-reporter .jasmine-symbol-summary li.jasmine-passed:before {
|
||||
color: #007069;
|
||||
content: "•";
|
||||
.failed .jasmine_html-reporter progress[value]::-webkit-progress-value, .failed .jasmine_html-reporter progress[value]::-moz-progress-bar {
|
||||
background: #ca3a11;
|
||||
}
|
||||
.jasmine_html-reporter .jasmine-symbol-summary li.jasmine-failed {
|
||||
line-height: 9px;
|
||||
}
|
||||
.jasmine_html-reporter .jasmine-symbol-summary li.jasmine-failed:before {
|
||||
color: #ca3a11;
|
||||
content: "×";
|
||||
font-weight: bold;
|
||||
margin-left: -1px;
|
||||
}
|
||||
.jasmine_html-reporter .jasmine-symbol-summary li.jasmine-excluded {
|
||||
font-size: 14px;
|
||||
}
|
||||
.jasmine_html-reporter .jasmine-symbol-summary li.jasmine-excluded:before {
|
||||
color: #bababa;
|
||||
content: "•";
|
||||
}
|
||||
.jasmine_html-reporter .jasmine-symbol-summary li.jasmine-excluded-no-display {
|
||||
font-size: 14px;
|
||||
display: none;
|
||||
}
|
||||
.jasmine_html-reporter .jasmine-symbol-summary li.jasmine-pending {
|
||||
line-height: 17px;
|
||||
}
|
||||
.jasmine_html-reporter .jasmine-symbol-summary li.jasmine-pending:before {
|
||||
color: #ba9d37;
|
||||
content: "*";
|
||||
}
|
||||
.jasmine_html-reporter .jasmine-symbol-summary li.jasmine-empty {
|
||||
font-size: 14px;
|
||||
}
|
||||
.jasmine_html-reporter .jasmine-symbol-summary li.jasmine-empty:before {
|
||||
color: #ba9d37;
|
||||
content: "•";
|
||||
.jasmine_html-reporter progress.failed[value]::-webkit-progress-value, .jasmine_html-reporter progress.failed[value]::-moz-progress-bar {
|
||||
background: #ca3a11;
|
||||
}
|
||||
.jasmine_html-reporter .jasmine-run-options {
|
||||
float: right;
|
||||
@@ -145,8 +111,12 @@ body {
|
||||
display: block;
|
||||
color: #eee;
|
||||
}
|
||||
.jasmine_html-reporter .jasmine-bar.jasmine-in-progress {
|
||||
color: #333;
|
||||
}
|
||||
.jasmine_html-reporter .jasmine-bar.jasmine-failed, .jasmine_html-reporter .jasmine-bar.jasmine-errored {
|
||||
background-color: #ca3a11;
|
||||
color: #eee;
|
||||
border-bottom: 1px solid #eee;
|
||||
}
|
||||
.jasmine_html-reporter .jasmine-bar.jasmine-passed {
|
||||
@@ -175,12 +145,16 @@ body {
|
||||
.jasmine_html-reporter .jasmine-bar a {
|
||||
color: white;
|
||||
}
|
||||
.jasmine_html-reporter.jasmine-spec-list .jasmine-bar.jasmine-menu.jasmine-failure-list,
|
||||
.jasmine_html-reporter.jasmine-spec-list .jasmine-results .jasmine-failures {
|
||||
.jasmine_html-reporter.jasmine-spec-list .jasmine-results .jasmine-failures,
|
||||
.jasmine_html-reporter.jasmine-spec-list .jasmine-performance-view {
|
||||
display: none;
|
||||
}
|
||||
.jasmine_html-reporter.jasmine-failure-list .jasmine-bar.jasmine-menu.jasmine-spec-list,
|
||||
.jasmine_html-reporter.jasmine-failure-list .jasmine-summary {
|
||||
.jasmine_html-reporter.jasmine-failure-list .jasmine-summary,
|
||||
.jasmine_html-reporter.jasmine-failure-list .jasmine-performance-view {
|
||||
display: none;
|
||||
}
|
||||
.jasmine_html-reporter.jasmine-performance .jasmine-results .jasmine-failures,
|
||||
.jasmine_html-reporter.jasmine-performance .jasmine-summary {
|
||||
display: none;
|
||||
}
|
||||
.jasmine_html-reporter .jasmine-results {
|
||||
@@ -301,4 +275,23 @@ body {
|
||||
}
|
||||
.jasmine_html-reporter .jasmine-debug-log .jasmine-debug-log-msg {
|
||||
white-space: pre;
|
||||
}
|
||||
|
||||
.jasmine-hidden {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.jasmine-tab + .jasmine-tab:before {
|
||||
content: " | ";
|
||||
}
|
||||
|
||||
.jasmine-performance-view h2, .jasmine-performance-view h3 {
|
||||
margin-top: 1em;
|
||||
margin-bottom: 1em;
|
||||
}
|
||||
.jasmine-performance-view table {
|
||||
border-spacing: 5px;
|
||||
}
|
||||
.jasmine-performance-view th, .jasmine-performance-view td {
|
||||
text-align: left;
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
11
package.json
11
package.json
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "jasmine-core",
|
||||
"license": "MIT",
|
||||
"version": "6.0.0-alpha.0",
|
||||
"version": "7.0.0-pre.0",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/jasmine/jasmine.git"
|
||||
@@ -28,6 +28,9 @@
|
||||
"description": "Simple JavaScript testing framework for browsers and node.js",
|
||||
"homepage": "https://jasmine.github.io",
|
||||
"main": "./lib/jasmine-core.js",
|
||||
"exports": {
|
||||
".": "./lib/jasmine-core.js"
|
||||
},
|
||||
"files": [
|
||||
"LICENSE",
|
||||
"README.md",
|
||||
@@ -43,10 +46,10 @@
|
||||
"ejs": "^3.1.10",
|
||||
"eslint": "^9.24.0",
|
||||
"eslint-plugin-compat": "^6.0.2",
|
||||
"glob": "^10.2.3",
|
||||
"glob": "^13.0.0",
|
||||
"globals": "^16.0.0",
|
||||
"jasmine": "^5.0.0",
|
||||
"jasmine-browser-runner": "github:jasmine/jasmine-browser-runner#4.0",
|
||||
"jasmine": "github:jasmine/jasmine-npm#7.0",
|
||||
"jasmine-browser-runner": "github:jasmine/jasmine-browser-runner#5.0",
|
||||
"jsdom": "^26.0.0",
|
||||
"prettier": "1.17.1",
|
||||
"sass": "^1.58.3"
|
||||
|
||||
27
release_notes/5.12.0.md
Normal file
27
release_notes/5.12.0.md
Normal file
@@ -0,0 +1,27 @@
|
||||
# Jasmine Core 5.12.0 Release Notes
|
||||
|
||||
This release reverts the exact spec filtering feature introduced in 5.11.0,
|
||||
which broke spec filtering in Karma.
|
||||
|
||||
## Supported environments
|
||||
|
||||
This version has been tested in the following environments.
|
||||
|
||||
| Environment | Supported versions |
|
||||
|-------------|--------------------------------|
|
||||
| Node | 18.20.5**, 20, 22, 24 |
|
||||
| Safari | 16**, 17** |
|
||||
| Chrome | 141* |
|
||||
| Firefox | 102**, 115**, 128**, 140, 143* |
|
||||
| Edge | 140* |
|
||||
|
||||
\* Evergreen browser. Each version of Jasmine is tested against the latest
|
||||
version available at release time.<br>
|
||||
\** Supported on a best-effort basis. Support for these versions may be dropped
|
||||
if it becomes impractical, and bugs affecting only these versions may not be
|
||||
treated as release blockers.
|
||||
|
||||
|
||||
------
|
||||
|
||||
_Release Notes generated with _[Anchorman](http://github.com/infews/anchorman)_
|
||||
29
release_notes/5.12.1.md
Normal file
29
release_notes/5.12.1.md
Normal file
@@ -0,0 +1,29 @@
|
||||
Jasmine Core 5.12.1 Release Notes
|
||||
|
||||
## Bug fixes
|
||||
|
||||
* Fix custom matchers in top-level specs
|
||||
* Merges [#2088](https://github.com/jasmine/jasmine/pull/2088) from @bonkevin
|
||||
|
||||
## Supported environments
|
||||
|
||||
This version has been tested in the following environments.
|
||||
|
||||
| Environment | Supported versions |
|
||||
|-------------|--------------------------------|
|
||||
| Node | 18.20.5**, 20, 22, 24 |
|
||||
| Safari | 16**, 17** |
|
||||
| Chrome | 141* |
|
||||
| Firefox | 102**, 115**, 128**, 140, 144* |
|
||||
| Edge | 141* |
|
||||
|
||||
\* Evergreen browser. Each version of Jasmine is tested against the latest
|
||||
version available at release time.<br>
|
||||
\** Supported on a best-effort basis. Support for these versions may be dropped
|
||||
if it becomes impractical, and bugs affecting only these versions may not be
|
||||
treated as release blockers.
|
||||
|
||||
|
||||
------
|
||||
|
||||
_Release Notes generated with _[Anchorman](http://github.com/infews/anchorman)_
|
||||
44
release_notes/5.13.0.md
Normal file
44
release_notes/5.13.0.md
Normal file
@@ -0,0 +1,44 @@
|
||||
# Jasmine Core 5.13.0 Release Notes
|
||||
|
||||
## Changes to supported environments
|
||||
|
||||
Safari 26 is now supported on a best-effort basis.
|
||||
|
||||
Due to the limited availability of Safari 18 and later on free CI services,
|
||||
Safari support in future jasmine-core versions will be limited to:
|
||||
|
||||
* Best-effort support for the latest Safari version available on GitHub Actions,
|
||||
which may change at any time.
|
||||
* Best-effort support for Safari 16 and 17 for as long as it remains practical.
|
||||
|
||||
## New Features
|
||||
|
||||
* New `extraItStackFrames` and `extraDescribeStackFrames` config options to fix
|
||||
the filename properties of reporter events in configurations that wrap
|
||||
`it`/`describe`, such as zone.js. The `filename` properties of reporter events
|
||||
are no longer deprecated.
|
||||
* `jasmine.allOf` asymmetric equality tester
|
||||
* Merges [#2087](https://github.com/jasmine/jasmine/issues/2083) from @jonahd-g
|
||||
* Fixes [#2083](https://github.com/jasmine/jasmine/pull/2087)
|
||||
|
||||
## Supported environments
|
||||
|
||||
This version has been tested in the following environments.
|
||||
|
||||
| Environment | Supported versions |
|
||||
|-------------|--------------------------------|
|
||||
| Node | 18.20.5**, 20, 22, 24 |
|
||||
| Safari** | 16, 17, 26.1 |
|
||||
| Chrome | 142* |
|
||||
| Firefox | 102**, 115**, 128**, 140, 145* |
|
||||
| Edge | 142* |
|
||||
|
||||
\* Evergreen browser. Each version of Jasmine is tested against the latest
|
||||
version available at release time.<br>
|
||||
\** Supported on a best-effort basis. Support for these versions may be dropped
|
||||
if it becomes impractical, and bugs affecting only these versions may not be
|
||||
treated as release blockers.
|
||||
|
||||
------
|
||||
|
||||
_Release Notes generated with _[Anchorman](http://github.com/infews/anchorman)_
|
||||
116
release_notes/6.0.0-alpha.1.md
Normal file
116
release_notes/6.0.0-alpha.1.md
Normal file
@@ -0,0 +1,116 @@
|
||||
# Jasmine Core 6.0.0-alpha.1 Release Notes
|
||||
|
||||
This is a pre-release, intended to offer a preview of breaking changes and to
|
||||
solicit feedback.
|
||||
|
||||
## A Note About Pre-Release Compatibility
|
||||
|
||||
There may be additional breaking changes in future 6.0 pre-releases or in the
|
||||
final 6.0 release. That's allowed by the semver specification, but users are
|
||||
sometimes unpleasantly surprised by it.
|
||||
|
||||
NPM's implementation of carat version ranges assumes that subsequent
|
||||
pre-releases and final releases are fully compatible with earlier pre-releases.
|
||||
If your package.json contains `"jasmine-core": "^6.0.0-alpha.1`,
|
||||
NPM might install any later 6.x version even though there is no guarantee of
|
||||
compatibility. If that isn't ok, you should specify an exact pre-release version:
|
||||
`"jasmine-core": "6.0.0-alpha.1`.
|
||||
|
||||
|
||||
## Breaking changes
|
||||
|
||||
### Changes that affect reporters
|
||||
|
||||
* Irrelevant properties such as `status` and `failedExpectations` are omitted
|
||||
from [the event passed to suiteStarted](https://jasmine.github.io/api/6.0.0-alpha.1/global.html#SuiteStartedEvent).
|
||||
|
||||
This change should be compatible with most existing reporters but could break
|
||||
reporters that manage their internal state in unusual ways. Please
|
||||
[open an issue](https://github.com/jasmine/jasmine/issues/new?template=bug_report.yml)
|
||||
if you find a published reporter package that works with jasmine-core 5.x but
|
||||
not with this release.
|
||||
|
||||
### Changes that affect browser boot files
|
||||
|
||||
* The `createElement` and `createTextNode` options of `HtmlReporter` are ignored.
|
||||
`HtmlReporter` now unconditionally uses `document.createElement` and
|
||||
`document.createTextNode`.
|
||||
|
||||
### Changes that affect spec writing
|
||||
|
||||
* HTML reporters cache configuration throughout each run. Configuration changes
|
||||
made while specs are running will not affect reporter behavior.
|
||||
* Global error spies always receive a single argument. Previously, the browser
|
||||
error event was passed as the second argument.
|
||||
|
||||
## New features
|
||||
|
||||
* A new `HtmlReporterV2` with several improvements over the old `HtmlReporter`:
|
||||
* Clicking a spec/suite link does exact filtering rather than a substring
|
||||
match.
|
||||
* The old dots are replaced with a progress bar. This improves usability with
|
||||
large suites and fixes an accessibility problem.
|
||||
* Details of failed specs are displayed as soon as each spec finishes.
|
||||
* Initialization and wire-up in boot files are much simpler.
|
||||
|
||||
If you're using jasmine-browser-runner or copying boot1.js from the standalone
|
||||
distribution, you'll automatically get the new reporter. If you maintain your
|
||||
own boot files, you'll get the old reporter unless you update your boot1.js
|
||||
to match the one that's in this package.
|
||||
|
||||
The new reporter produces `spec` query string parameters that are different
|
||||
from those created by the old reporter. If you use non-Jasmine software that
|
||||
interprets the `spec` parameter, such as karma-jasmine, you may not be able to
|
||||
adopt `HtmlReporterV2` unlesss it's updated.
|
||||
* Use `globalThis` to determine the global object during initialization
|
||||
This makes jasmine-core more tolerant of buggy bundlers or loaders that
|
||||
cause `this` to be undefined in the global context.
|
||||
|
||||
|
||||
## Deprecations
|
||||
|
||||
* Warn if jasmine-core is loaded as an ES module in a browser.
|
||||
This is an untested and unsupported configuration that has been known to cause
|
||||
problems in the past.
|
||||
* Deprecated `HtmlReporter` and `HtmlSpecFilter` in favor of `HtmlReporterV2`.
|
||||
|
||||
|
||||
## Documentation improvements
|
||||
|
||||
* Improved API reference documentation for APIs that are used from browser boot
|
||||
files.
|
||||
|
||||
|
||||
## Internal improvements
|
||||
|
||||
* Removed remaining code that supported suite re-entry.
|
||||
* Encapsulated suite and spec result and status management.
|
||||
* Adopted strict mode throughout the codebase.
|
||||
* Decomposed `HtmlReporter` into components and converted to ES6 classes.
|
||||
* Made global error handling more uniform between browsers and Node.
|
||||
|
||||
|
||||
## Supported environments
|
||||
|
||||
This version has been tested in the following environments.
|
||||
|
||||
| Environment | Supported versions |
|
||||
|-------------------|--------------------------------|
|
||||
| Node | 20, 22, 24 |
|
||||
| Safari | 16**, 17** |
|
||||
| Chrome | 141* |
|
||||
| Firefox | 102**, 115**, 128**, 140, 143* |
|
||||
| Edge | 141* |
|
||||
|
||||
\* Evergreen browser. Each version of Jasmine is tested against the latest
|
||||
version available at release time.<br>
|
||||
\** Supported on a best-effort basis. Support for these versions may be dropped
|
||||
if it becomes impractical, and bugs affecting only these versions may not be
|
||||
treated as release blockers.
|
||||
|
||||
|
||||
|
||||
|
||||
------
|
||||
|
||||
_Release Notes generated with _[Anchorman](http://github.com/infews/anchorman)_
|
||||
90
release_notes/6.0.0-alpha.2.md
Normal file
90
release_notes/6.0.0-alpha.2.md
Normal file
@@ -0,0 +1,90 @@
|
||||
# Jasmine Core 6.0.0-alpha.2 Release Notes
|
||||
|
||||
This is a pre-release, intended to offer a preview of upcoming changes and to
|
||||
solicit feedback.
|
||||
|
||||
## A Note About Pre-Release Compatibility
|
||||
|
||||
There may be additional breaking changes in future 6.0 pre-releases or in the
|
||||
final 6.0 release. That's allowed by the semver specification, but users are
|
||||
sometimes unpleasantly surprised by it.
|
||||
|
||||
NPM's implementation of carat version ranges assumes that subsequent
|
||||
pre-releases and final releases are fully compatible with earlier pre-releases.
|
||||
If your package.json contains `"jasmine-core": "^6.0.0-alpha.2`,
|
||||
NPM might install any later 6.x version even though there is no guarantee of
|
||||
compatibility. If that isn't ok, you should specify an exact pre-release version:
|
||||
`"jasmine-core": "6.0.0-alpha.2`.
|
||||
|
||||
|
||||
## Changes to supported environments
|
||||
|
||||
Safari 26 is now supported on a best-effort basis.†
|
||||
|
||||
Due to the limited availability of Safari 18 and later on free CI services,
|
||||
Safari support in future jasmine-core versions will be limited to:
|
||||
|
||||
* Best-effort support for the latest Safari version available on GitHub Actions,
|
||||
which may change at any time.
|
||||
* Best-effort support for Safari 16 and 17 for as long as it remains practical.
|
||||
|
||||
## Bug Fixes
|
||||
|
||||
* Fix custom matchers in top-level specs††
|
||||
* Merges [#2088](https://github.com/jasmine/jasmine/pull/2088) from @bonkevin
|
||||
|
||||
## New features
|
||||
|
||||
* Larger body font size in HTML reporters
|
||||
* New Performance tab in HtmlReporterV2 shows metrics and a list of the slowest
|
||||
specs.
|
||||
* Experimental `safariYieldStrategy: "time"` config option, which may make
|
||||
Jasmine run significantly faster in Safari and similar browsers. So far, this
|
||||
option has not been tested on a wide variety of workloads. Feedback is
|
||||
appreciated.
|
||||
* New `extraItStackFrames` and `extraDescribeStackFrames` config options to fix
|
||||
the filename properties of reporter events in configurations that wrap
|
||||
`it`/`describe`, such as zone.js.†
|
||||
* `jasmine.allOf asymmetric` equality tester†
|
||||
* Merges [#2087](https://github.com/jasmine/jasmine/pull/2087) from @jonahd-g
|
||||
* Fixes [#2083](https://github.com/jasmine/jasmine/issues/2083)
|
||||
* Re-add support for partial spec name filtering via `spec` query parameter
|
||||
* Fixes [#2085](https://github.com/jasmine/jasmine/issues/2085).
|
||||
* Require spec/suite property keys to be strings, not just anything that's
|
||||
cloneable and serializable. This matches the existing API reference
|
||||
documentation.
|
||||
|
||||
## Documentation improvements
|
||||
|
||||
* Fix HtmlReporterV2 ctor example
|
||||
|
||||
## Internal Improvements
|
||||
|
||||
* Remove code to support browsers that don't have MessageChannel. Jasmine hasn't
|
||||
run in any such browsers since 2.x.
|
||||
|
||||
† Also likely to be included in a future 5.x release.<br>
|
||||
†† Also released in 5.12.1.
|
||||
|
||||
## Supported environments
|
||||
|
||||
This version has been tested in the following environments.
|
||||
|
||||
| Environment | Supported versions |
|
||||
|-------------------|--------------------------------|
|
||||
| Node | 20, 22, 24 |
|
||||
| Safari | 16**, 17**, 26** |
|
||||
| Chrome | 142* |
|
||||
| Firefox | 102**, 115**, 128**, 140, 145* |
|
||||
| Edge | 142* |
|
||||
|
||||
\* Evergreen browser. Each version of Jasmine is tested against the latest
|
||||
version available at release time.<br>
|
||||
\** Supported on a best-effort basis. Support for these versions may be dropped
|
||||
if it becomes impractical, and bugs affecting only these versions may not be
|
||||
treated as release blockers.
|
||||
|
||||
|
||||
------
|
||||
|
||||
_Release Notes generated with _[Anchorman](http://github.com/infews/anchorman)_
|
||||
74
release_notes/6.0.0-beta.0.md
Normal file
74
release_notes/6.0.0-beta.0.md
Normal file
@@ -0,0 +1,74 @@
|
||||
# Jasmine Core 6.0.0-beta.0 Release Notes
|
||||
|
||||
This is a pre-release, intended to offer a preview of upcoming changes and to
|
||||
solicit feedback.
|
||||
|
||||
## A Note About Pre-Release Compatibility
|
||||
|
||||
There may be additional breaking changes in future 6.0 pre-releases or in the
|
||||
final 6.0 release. That's allowed by the semver specification, but users are
|
||||
sometimes unpleasantly surprised by it.
|
||||
|
||||
NPM's implementation of carat version ranges assumes that subsequent
|
||||
pre-releases and final releases are fully compatible with earlier pre-releases.
|
||||
If your package.json contains `"jasmine-core": "^6.0.0-beta.0`,
|
||||
NPM might install any later 6.x version even though there is no guarantee of
|
||||
compatibility. If that isn't ok, you should specify an exact pre-release version:
|
||||
`"jasmine-core": "6.0.0-beta.0`.
|
||||
|
||||
|
||||
## Breaking changes
|
||||
|
||||
* boot1.js no longer adds jsApiReporter to the env.
|
||||
* HtmlReporterV2 initialization and boot1.js have been simplified. If you
|
||||
maintain your own boot file, update it to match the boot1.js included in this
|
||||
package.
|
||||
|
||||
|
||||
## New features
|
||||
|
||||
* Statically exposed pretty printer as jasmine.pp().
|
||||
|
||||
## Bug fixes
|
||||
|
||||
* Fixed HtmlReporterV2 progress bar when running a subset of specs.
|
||||
|
||||
|
||||
## Deprecations
|
||||
|
||||
* jsApiReporter is deprecated.
|
||||
* Detect monkey patching and emit a deprecation warning.
|
||||
|
||||
## Documentation improvements
|
||||
|
||||
* Documented the set of possible spec statuses.
|
||||
|
||||
|
||||
## Internal improvements
|
||||
|
||||
* Replaced isArray helper with native Array.isArray
|
||||
|
||||
|
||||
## Supported environments
|
||||
|
||||
This version has been tested in the following environments.
|
||||
|
||||
| Environment | Supported versions |
|
||||
|-------------------|--------------------------------|
|
||||
| Node | 20, 22, 24 |
|
||||
| Safari | 16**, 17**, 26.1** |
|
||||
| Chrome | 142* |
|
||||
| Firefox | 102**, 115**, 128**, 140, 145* |
|
||||
| Edge | 142* |
|
||||
|
||||
\* Evergreen browser. Each version of Jasmine is tested against the latest
|
||||
version available at release time.<br>
|
||||
\** Supported on a best-effort basis. Support for these versions may be dropped
|
||||
if it becomes impractical, and bugs affecting only these versions may not be
|
||||
treated as release blockers.
|
||||
|
||||
|
||||
|
||||
------
|
||||
|
||||
_Release Notes generated with _[Anchorman](http://github.com/infews/anchorman)_
|
||||
47
release_notes/6.0.0-beta.1.md
Normal file
47
release_notes/6.0.0-beta.1.md
Normal file
@@ -0,0 +1,47 @@
|
||||
# Jasmine Core 6.0.0-beta.1 Release Notes
|
||||
|
||||
This is a pre-release, intended to offer a preview of upcoming changes and to
|
||||
solicit feedback.
|
||||
|
||||
A corresponding release of the `jasmine` package is not planned because the
|
||||
change in this release only affects browser users.
|
||||
|
||||
## A Note About Pre-Release Compatibility
|
||||
|
||||
There may be additional breaking changes in future 6.0 pre-releases or in the
|
||||
final 6.0 release. That's allowed by the semver specification, but users are
|
||||
sometimes unpleasantly surprised by it.
|
||||
|
||||
NPM's implementation of carat version ranges assumes that subsequent
|
||||
pre-releases and final releases are fully compatible with earlier pre-releases.
|
||||
If your package.json contains `"jasmine-core": "^6.0.0-beta.1`,
|
||||
NPM might install any later 6.x version even though there is no guarantee of
|
||||
compatibility. If that isn't ok, you should specify an exact pre-release version:
|
||||
`"jasmine-core": "6.0.0-beta.1`.
|
||||
|
||||
## Bug Fixes
|
||||
|
||||
* Revert to using window.onload in boot1.js. This fixes top level await in
|
||||
jasmine-browser-runner.
|
||||
|
||||
## Supported environments
|
||||
|
||||
This version has been tested in the following environments.
|
||||
|
||||
| Environment | Supported versions |
|
||||
|-------------------|--------------------------------|
|
||||
| Node | 20, 22, 24 |
|
||||
| Safari** | 16, 17, 26.1 |
|
||||
| Chrome | 143* |
|
||||
| Firefox | 102**, 115**, 128**, 140, 145* |
|
||||
| Edge | 142* |
|
||||
|
||||
\* Evergreen browser. Each version of Jasmine is tested against the latest
|
||||
version available at release time.<br>
|
||||
\** Supported on a best-effort basis. Support for these versions may be dropped
|
||||
if it becomes impractical, and bugs affecting only these versions may not be
|
||||
treated as release blockers.
|
||||
|
||||
------
|
||||
|
||||
_Release Notes generated with _[Anchorman](http://github.com/infews/anchorman)_
|
||||
190
release_notes/6.0.0.md
Normal file
190
release_notes/6.0.0.md
Normal file
@@ -0,0 +1,190 @@
|
||||
# Jasmine Core 6.0.0 Release Notes
|
||||
|
||||
## Summary
|
||||
|
||||
This is a major release that includes breaking changes as well as significant
|
||||
new features. Many of the breaking changes and deprecations in this release are
|
||||
intended to improve the stability of the Jasmine ecosystem by making the
|
||||
distinction between public and private APIs more obvious, reducing exposure of
|
||||
jasmine-core's internal state, removing ambiguities from the reporter API, and
|
||||
warning about monkey patching.
|
||||
|
||||
6.x is intended to ba a relatively short-lived, transitional series. It is
|
||||
compatible with the current versions of karma-jasmine and other legacy Angular
|
||||
tools but emits deprecation warnings when used with them. 7.0 will drop
|
||||
compatibility with those tools. If you use Karma in a non-Angular context,
|
||||
consider migrating to a maintained alternative such as jasmine-browser-runner or
|
||||
web-test-runner. If you use Angular, please direct any questions about support
|
||||
for future versions of Jasmine to the Angular team.
|
||||
|
||||
Please see the [migration guide](https://jasmine.github.io/upgrade-guides/6.0)
|
||||
for more information. If you use Jasmine via the `jasmine` package, please see
|
||||
[its release notes](https://github.com/jasmine/jasmine-npm/blob/main/release_notes/6.0.0.md)
|
||||
as well.
|
||||
|
||||
|
||||
## Changes to supported environments
|
||||
|
||||
* Node 18 is no longer supported.
|
||||
|
||||
|
||||
## Breaking changes
|
||||
|
||||
### General
|
||||
|
||||
* Private APIs have been removed from the `jasmine` namespace.
|
||||
|
||||
The purpose of this change is to reduce the risk of users inadvertently
|
||||
depending on private APIs. Anything not covered by
|
||||
[the documentation](https://jasmine.github.io/pages/docs_home.html) remains
|
||||
private regardless of namespacing. Private APIs may be changed or removed in
|
||||
any release. This change is being made in a major release as a courtesy to
|
||||
users of libraries that depend on private APIs.
|
||||
|
||||
### Changes that affect spec writing
|
||||
|
||||
* Global error spies always receive a single argument. Previously, the browser
|
||||
error event was passed as the second argument.
|
||||
* If a spy is invoked via `.call(null, ...)` or `.apply(null, ...)`, the spy's
|
||||
`this` argument will be `null`. Previously it was `globalThis`.
|
||||
* Mock clock timing functions cannot be spied on. Previously this "worked" but
|
||||
prevented the mock clock from uninstalling itself.
|
||||
* The mock clock no longer supports the eval forms of `setTimeout` and
|
||||
`setInterval`.
|
||||
* Keys passed to `setSpecProperty`/`setSuiteProperty` must be strings. Values
|
||||
must be both structured-cloneable and JSON-serializable.
|
||||
|
||||
### Changes that affect configuration
|
||||
|
||||
* HTML reporters cache configuration throughout each run. Configuration changes
|
||||
made while specs are running will not affect reporter behavior.
|
||||
* If an execution order is passed to `Env#execute`, it must not enter any suite
|
||||
more than once.
|
||||
* The argument passed to spec filters is a
|
||||
[spec metadata](https://jasmine.github.io/api/6.0/Spec.html)
|
||||
instance, not the internal spec object.
|
||||
* The default value of the `forbidDuplicateNames` config option has been
|
||||
changed to true.
|
||||
|
||||
### Changes that affect reporters
|
||||
|
||||
This release includes changes that are intended to streamline and clarify the
|
||||
reporter interface, prevent sharing of mutable state, and prevent bugs involving
|
||||
non-serializable objects. These changes should be compatible with most existing
|
||||
reporters but could break reporters that manage their internal state in unusual
|
||||
ways.
|
||||
|
||||
* Meaningless properties such as `status` and `failedExpectations` are omitted
|
||||
from the events passed to [suiteStarted](https://jasmine.github.io/api/6.0/global.html#SuiteStartedEvent)
|
||||
and [specStarted](https://jasmine.github.io/api/6.0/global.html#SpecStartedEvent).
|
||||
* Reporter events are deep-cloned before being passed to each reporter. This
|
||||
protects reporters against later mutation by jasmine-core or other reporters.
|
||||
* The `expected` and `actual` properties of
|
||||
[passed and failed expectations](https://jasmine.github.io/api/6.0/global.html#ExpectationResult)
|
||||
have been removed.
|
||||
* The [order](https://jasmine.github.io/api/6.0/global.html#Order)
|
||||
property of the`jasmineStarted` and `jasmineDone` reporter events no longer
|
||||
includes undocumented properties.
|
||||
* boot1.js no longer adds `jsApiReporter` to the env.
|
||||
|
||||
### Changes that affect browser boot files
|
||||
|
||||
* The `createElement` and `createTextNode` options of the legacy `HtmlReporter`
|
||||
are ignored. `HtmlReporter` now unconditionally uses `document.createElement`
|
||||
and `document.createTextNode`.
|
||||
|
||||
### Changes to Node boot functions
|
||||
|
||||
* [boot](https://jasmine.github.io/api/6.0/module-jasmine-core.html#.boot)
|
||||
defaults to creating a new core instance each time it's called. This restores
|
||||
the pre-5.0 default behavior.
|
||||
* [noGlobals](https://jasmine.github.io/api/6.0/module-jasmine-core.html#.noGlobals)
|
||||
no longer takes a parameter. It always returns the same object when called
|
||||
repeatedly.
|
||||
|
||||
|
||||
## New features
|
||||
|
||||
* A new `HtmlReporterV2` with several improvements over the old `HtmlReporter`:
|
||||
* Clicking a spec/suite link does exact filtering rather than a substring
|
||||
match.
|
||||
* The old dots are replaced with a progress bar. This improves usability with
|
||||
large suites and fixes an accessibility problem.
|
||||
* Details of failed specs are displayed as soon as each spec finishes.
|
||||
* A Performance tab shows metrics and a list of the slowest specs.
|
||||
* Initialization and wire-up in boot files are much simpler.
|
||||
|
||||
If you're using jasmine-browser-runner or copying boot1.js from the standalone
|
||||
distribution, you'll automatically get the new reporter. If you maintain your
|
||||
own boot files, you'll get the old reporter unless you update your boot files
|
||||
to match the one that's in this package.
|
||||
|
||||
The new reporter produces `spec` query string parameters that are different
|
||||
from those created by the old reporter. If you use other software that
|
||||
interprets the `spec` parameter, such as karma-jasmine, you won't be able to
|
||||
adopt `HtmlReporterV2` unlesss that other software is updated.
|
||||
|
||||
* Larger body font size in HTML reporters
|
||||
* `globalThis` is used to determine the global object during initialization
|
||||
This makes jasmine-core more tolerant of buggy bundlers or loaders that
|
||||
cause `this` to be undefined in the global context.
|
||||
* Experimental [`safariYieldStrategy: "time"`](https://jasmine.github.io/api/6.0/Configuration.html#safariYieldStrategy)
|
||||
config option, which may make Jasmine run significantly faster in Safari and
|
||||
similar browsers. So far, this option has not been tested on a wide variety of
|
||||
workloads. Feedback is appreciated.
|
||||
* Statically exposed pretty printer as `jasmine.pp()`.
|
||||
|
||||
|
||||
## Deprecations
|
||||
|
||||
* Common monkey patching patterns are detected and result in a deprecation
|
||||
warning. Code that overwrites anything provided by jasmine-core (other than
|
||||
globals like `it`/`expect`/etc or configuration properties like
|
||||
`jasmine.DEFAULT_TIMEOUT_INTERVAL`) may be broken by any jasmine-core release.
|
||||
* Warn if jasmine-core is loaded as an ES module in a browser.
|
||||
This is an untested and unsupported configuration that has been known to cause
|
||||
problems.
|
||||
* `HtmlReporter` and `HtmlSpecFilter` are deprecated in favor of `HtmlReporterV2`.
|
||||
* `jsApiReporter` is deprecated.
|
||||
|
||||
|
||||
## Documentation improvements
|
||||
|
||||
* Improved API reference documentation for APIs that are used from browser boot
|
||||
files.
|
||||
* Documented the set of possible spec statuses.
|
||||
* Documented that globals are overwriteable.
|
||||
|
||||
|
||||
## Internal improvements
|
||||
|
||||
* Encapsulated suite and spec result and status management.
|
||||
* Adopted strict mode throughout the codebase.
|
||||
* Decomposed `HtmlReporter` into components and converted to ES6 classes.
|
||||
* Made global error handling more uniform between browsers and Node.
|
||||
* Removed code to support browsers that don't have `MessageChannel`. Jasmine
|
||||
hasn't run in any such browsers since 2.x.
|
||||
* Replaced `isArray` helper with native `Array.isArray`.
|
||||
|
||||
## Supported environments
|
||||
|
||||
This version has been tested in the following environments.
|
||||
|
||||
| Environment | Supported versions |
|
||||
|-------------------|--------------------------------|
|
||||
| Node | 20, 22, 24 |
|
||||
| Safari** | 16, 17, 26.2 |
|
||||
| Chrome | 143* |
|
||||
| Firefox | 102**, 115**, 128**, 140, 147* |
|
||||
| Edge | 143* |
|
||||
|
||||
\* Evergreen browser. Each version of Jasmine is tested against the latest
|
||||
version available at release time.<br>
|
||||
\** Supported on a best-effort basis. Support for these versions may be dropped
|
||||
if it becomes impractical, and bugs affecting only these versions may not be
|
||||
treated as release blockers.
|
||||
|
||||
|
||||
------
|
||||
|
||||
_Release Notes generated with _[Anchorman](http://github.com/infews/anchorman)_
|
||||
29
release_notes/6.0.1.md
Normal file
29
release_notes/6.0.1.md
Normal file
@@ -0,0 +1,29 @@
|
||||
# Jasmine Core 6.0.1 Release Notes
|
||||
|
||||
## Bug fixes
|
||||
|
||||
* Don't emit a deprecation warning when `jasmineRequire.core` is called from an
|
||||
ES module
|
||||
|
||||
## Supported environments
|
||||
|
||||
This version has been tested in the following environments.
|
||||
|
||||
| Environment | Supported versions |
|
||||
|-------------------|--------------------------------|
|
||||
| Node | 20, 22, 24 |
|
||||
| Safari** | 16, 17, 26.2 |
|
||||
| Chrome | 143* |
|
||||
| Firefox | 102**, 115**, 128**, 140, 147* |
|
||||
| Edge | 143* |
|
||||
|
||||
\* Evergreen browser. Each version of Jasmine is tested against the latest
|
||||
version available at release time.<br>
|
||||
\** Supported on a best-effort basis. Support for these versions may be dropped
|
||||
if it becomes impractical, and bugs affecting only these versions may not be
|
||||
treated as release blockers.
|
||||
|
||||
|
||||
------
|
||||
|
||||
_Release Notes generated with _[Anchorman](http://github.com/infews/anchorman)_
|
||||
40
release_notes/6.1.0.md
Normal file
40
release_notes/6.1.0.md
Normal file
@@ -0,0 +1,40 @@
|
||||
# Jasmine Core 6.1.0 Release Notes
|
||||
|
||||
## Changes to supported environments
|
||||
|
||||
* Safari 16 and 17 are no longer supported. Although jasmine-core may still work
|
||||
in those versions, we no longer have a reliable way to test them and won't try
|
||||
to maintain compatibility with them in future releases.
|
||||
|
||||
## New features
|
||||
|
||||
* Report the underlying errors that make up an `AggregateError`.
|
||||
* Merges [#2093](https://github.com/jasmine/jasmine/pull/2093) from @puglyfe
|
||||
* Fixes [#2063](https://github.com/jasmine/jasmine/issues/2063)
|
||||
|
||||
## Documentation improvements
|
||||
|
||||
* Fix default MAX_PRETTY_PRINT_CHARS in JsDoc.
|
||||
* Merges [#2091](https://github.com/jasmine/jasmine/pull/2091) from @HolgerJeromin
|
||||
|
||||
## Supported environments
|
||||
|
||||
This version has been tested in the following environments.
|
||||
|
||||
| Environment | Supported versions |
|
||||
|-------------------|--------------------------------|
|
||||
| Node | 20, 22, 24 |
|
||||
| Safari | 26.3** |
|
||||
| Chrome | 144* |
|
||||
| Firefox | 102**, 115**, 128**, 140, 147* |
|
||||
| Edge | 144* |
|
||||
|
||||
\* Evergreen browser. Each version of Jasmine is tested against the latest
|
||||
version available at release time.<br>
|
||||
\** Supported on a best-effort basis. Support for these versions may be dropped
|
||||
if it becomes impractical, and bugs affecting only these versions may not be
|
||||
treated as release blockers.
|
||||
|
||||
------
|
||||
|
||||
_Release Notes generated with _[Anchorman](http://github.com/infews/anchorman)_
|
||||
58
release_notes/7.0.0-pre.0.md
Normal file
58
release_notes/7.0.0-pre.0.md
Normal file
@@ -0,0 +1,58 @@
|
||||
# Jasmine Core 7.0.0-pre.0 Release Notes
|
||||
|
||||
This is a pre-release, intended to offer a preview of breaking changes and to
|
||||
solicit feedback.
|
||||
|
||||
Before installing this release, update to 6.0.1 or later and fix all
|
||||
deprecation warnings.
|
||||
|
||||
## Breaking changes
|
||||
|
||||
* `HtmlReporter`, `HtmlSpecFilter`, and `jsApiReporter`, which were deprecated
|
||||
in 6.0, have been removed.
|
||||
* Most private APIs are no longer exposed.
|
||||
* Monkey patching is blocked. This does not affect globals (`describe`,
|
||||
`expect`, etc.) or properties that are explicitly documented as writeable.
|
||||
Those can still be overwritten.
|
||||
* Redesigned boot process:
|
||||
* `jasmineRequire`, `boot`, and `noGlobals` have been removed.
|
||||
* The core instance is automatically created.
|
||||
* In browsers, globals are automatically created.
|
||||
* In Node, globals are not automatically created. Call the exported
|
||||
`installGlobals` function to create them. If you're using the `jasmine`
|
||||
package, this is done for you by default.
|
||||
* In Node, the same instance is returned every time jasmine-core is imported.
|
||||
If you need to do multiple consecutive independent test runs, call the
|
||||
exported `reset` function to reset all state and configuration between runs.
|
||||
|
||||
If you maintain your own browser boot files, you may be able to update by just
|
||||
removing `boot1.js`. See the `boot.js` file in this package for a working
|
||||
example. If you boot jasmine-core in Node, remove the call to `boot` or
|
||||
`noGlobals` and add a call to `installGlobals` if desired:
|
||||
|
||||
```javascript
|
||||
const jasmineCore = require('jasmine-core');
|
||||
jasmineCore.installGlobals();
|
||||
```
|
||||
|
||||
## Supported environments
|
||||
|
||||
This version has been tested in the following environments.
|
||||
|
||||
| Environment | Supported versions |
|
||||
|-------------------|--------------------------------|
|
||||
| Node | 20, 22, 24 |
|
||||
| Safari | 26.3** |
|
||||
| Chrome | 144* |
|
||||
| Firefox | 102**, 115**, 128**, 140, 147* |
|
||||
| Edge | 144* |
|
||||
|
||||
\* Evergreen browser. Each version of Jasmine is tested against the latest
|
||||
version available at release time.<br>
|
||||
\** Supported on a best-effort basis. Support for these versions may be dropped
|
||||
if it becomes impractical, and bugs affecting only these versions may not be
|
||||
treated as release blockers.
|
||||
|
||||
------
|
||||
|
||||
_Release Notes generated with _[Anchorman](http://github.com/infews/anchorman)_
|
||||
@@ -42,8 +42,7 @@ async function zipStandaloneDist(jasmineVersion) {
|
||||
'lib/jasmine-core/jasmine.js',
|
||||
'lib/jasmine-core/jasmine-html.js',
|
||||
'lib/jasmine-core/jasmine.css',
|
||||
'lib/jasmine-core/boot0.js',
|
||||
'lib/jasmine-core/boot1.js',
|
||||
'lib/jasmine-core/boot.js',
|
||||
],
|
||||
destDir: 'lib/jasmine-' + jasmineVersion
|
||||
},
|
||||
|
||||
@@ -34,18 +34,20 @@ function concatFiles() {
|
||||
const configs = [
|
||||
{
|
||||
src: [
|
||||
{ literal: '(function() {' },
|
||||
'src/html/requireHtml.js',
|
||||
'src/html/HtmlReporter.js',
|
||||
'src/html/HtmlSpecFilter.js',
|
||||
'src/html/ResultsNode.js',
|
||||
'src/html/QueryString.js',
|
||||
'src/html/**/*.js'
|
||||
{ glob: 'src/html/**/*.js', exclude: 'src/html/requireSuffix.js' },
|
||||
'src/html/requireSuffix.js',
|
||||
{ literal: '})()' },
|
||||
],
|
||||
dest: 'lib/jasmine-core/jasmine-html.js',
|
||||
},
|
||||
{
|
||||
dest: 'lib/jasmine-core/jasmine.js',
|
||||
src: [
|
||||
{ literal: '(function() {' },
|
||||
'src/core/requireCore.js',
|
||||
'src/core/matchers/requireMatchers.js',
|
||||
'src/core/base.js',
|
||||
@@ -53,23 +55,20 @@ function concatFiles() {
|
||||
'src/core/Spec.js',
|
||||
'src/core/Order.js',
|
||||
'src/core/Env.js',
|
||||
'src/core/JsApiReporter.js',
|
||||
'src/core/PrettyPrinter',
|
||||
'src/core/Suite',
|
||||
'src/core/**/*.js',
|
||||
{ glob: 'src/core/**/*.js', exclude: 'src/core/requireSuffix.js'},
|
||||
{
|
||||
template: 'src/version.js',
|
||||
data: {version: pkg.version}
|
||||
},
|
||||
'src/core/requireSuffix.js',
|
||||
{ literal: '})()' },
|
||||
],
|
||||
},
|
||||
{
|
||||
dest: 'lib/jasmine-core/boot0.js',
|
||||
src: ['src/boot/boot0.js'],
|
||||
},
|
||||
{
|
||||
dest: 'lib/jasmine-core/boot1.js',
|
||||
src: ['src/boot/boot1.js'],
|
||||
dest: 'lib/jasmine-core/boot.js',
|
||||
src: ['src/boot/boot.js'],
|
||||
},
|
||||
{
|
||||
dest: 'lib/jasmine-core.js',
|
||||
@@ -85,25 +84,28 @@ function concatFiles() {
|
||||
src.unshift(licenseBanner);
|
||||
|
||||
function expand(srcListEntry) {
|
||||
if (typeof srcListEntry === 'object') {
|
||||
if (typeof srcListEntry === 'object' && !srcListEntry.glob) {
|
||||
return srcListEntry;
|
||||
}
|
||||
|
||||
return glob.sync(srcListEntry)
|
||||
.sort(function (a, b) {
|
||||
// Match the sort order of previous build tools, so that the
|
||||
// output is the same.
|
||||
a = a.toLowerCase();
|
||||
b = b.toLowerCase();
|
||||
const matches = glob.sync(
|
||||
srcListEntry.glob ?? srcListEntry,
|
||||
{ignore: srcListEntry.exclude}
|
||||
);
|
||||
return matches.sort(function (a, b) {
|
||||
// Match the sort order of previous build tools, so that the
|
||||
// output is the same.
|
||||
a = a.toLowerCase();
|
||||
b = b.toLowerCase();
|
||||
|
||||
if (a < b) {
|
||||
return -1;
|
||||
} else if (a === b) {
|
||||
return 0;
|
||||
} else {
|
||||
return 1;
|
||||
}
|
||||
});
|
||||
if (a < b) {
|
||||
return -1;
|
||||
} else if (a === b) {
|
||||
return 0;
|
||||
} else {
|
||||
return 1;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
const srcs = src.flatMap(expand);
|
||||
@@ -117,6 +119,8 @@ function concatFiles() {
|
||||
if (s.template) {
|
||||
const template = fs.readFileSync(s.template, {encoding: 'utf8'});
|
||||
content = ejs.render(template, s.data);
|
||||
} else if (s.literal) {
|
||||
content = s.literal;
|
||||
} else {
|
||||
content = fs.readFileSync(s, {encoding: 'utf8'});
|
||||
}
|
||||
|
||||
@@ -1,5 +1,10 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Run tests in supported browsers that are available on Saucelabs.
|
||||
# Note: Safari is tested via GitHub Actions because Saucelabs only makes Safari
|
||||
# 18 and later available to paid enterprise accounts. See
|
||||
# .github/workflows/safari.yml.
|
||||
|
||||
run_browser() {
|
||||
browser=$1
|
||||
version=$2
|
||||
@@ -39,9 +44,6 @@ else
|
||||
fi
|
||||
run_browser firefox 102
|
||||
|
||||
run_browser safari 17
|
||||
run_browser safari 16
|
||||
|
||||
run_browser MicrosoftEdge latest
|
||||
|
||||
echo
|
||||
@@ -1,8 +1,9 @@
|
||||
verifyNoGlobals(() => require('../lib/jasmine-core.js').noGlobals());
|
||||
let jasmineCore;
|
||||
verifyNoGlobals(() => { jasmineCore = require('../lib/jasmine-core.js'); });
|
||||
jasmineCore.installGlobals();
|
||||
|
||||
const Jasmine = require('jasmine');
|
||||
const jasmineCore = require('../lib/jasmine-core.js');
|
||||
const runner = new Jasmine({jasmineCore: jasmineCore});
|
||||
const runner = new Jasmine({jasmineCore});
|
||||
|
||||
runner.loadConfigFile('./spec/support/jasmine.json');
|
||||
runner.exitOnCompletion = false;
|
||||
|
||||
@@ -1247,4 +1247,8 @@ describe('Clock (acceptance)', function() {
|
||||
|
||||
clock.tick(400);
|
||||
});
|
||||
|
||||
isNonMonkeyPatchableClass(privateUnderTest.Clock, function() {
|
||||
return new privateUnderTest.Clock({}, function() {}, {});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -10,7 +10,14 @@ describe('Configuration', function() {
|
||||
'detectLateRejectionHandling',
|
||||
'verboseDeprecations'
|
||||
];
|
||||
const allKeys = [...standardBooleanKeys, 'seed', 'specFilter'];
|
||||
const allKeys = [
|
||||
...standardBooleanKeys,
|
||||
'seed',
|
||||
'specFilter',
|
||||
'extraItStackFrames',
|
||||
'extraDescribeStackFrames',
|
||||
'safariYieldStrategy'
|
||||
];
|
||||
Object.freeze(standardBooleanKeys);
|
||||
Object.freeze(allKeys);
|
||||
|
||||
@@ -28,6 +35,9 @@ describe('Configuration', function() {
|
||||
expect(subject.forbidDuplicateNames).toEqual(true);
|
||||
expect(subject.verboseDeprecations).toEqual(false);
|
||||
expect(subject.detectLateRejectionHandling).toEqual(false);
|
||||
expect(subject.extraItStackFrames).toEqual(0);
|
||||
expect(subject.extraDescribeStackFrames).toEqual(0);
|
||||
expect(subject.safariYieldStrategy).toEqual('count');
|
||||
});
|
||||
|
||||
describe('copy()', function() {
|
||||
@@ -109,5 +119,48 @@ describe('Configuration', function() {
|
||||
subject.update({ seed: null });
|
||||
expect(subject.seed).toBeNull();
|
||||
});
|
||||
|
||||
it('sets extraItStackFrames when not undefined', function() {
|
||||
const subject = new privateUnderTest.Configuration();
|
||||
|
||||
subject.update({ extraItStackFrames: undefined });
|
||||
expect(subject.extraItStackFrames).toEqual(0);
|
||||
|
||||
subject.update({ extraItStackFrames: 100000 });
|
||||
expect(subject.extraItStackFrames).toEqual(100000);
|
||||
});
|
||||
|
||||
it('sets extraDescribeStackFrames when not undefined', function() {
|
||||
const subject = new privateUnderTest.Configuration();
|
||||
|
||||
subject.update({ extraDescribeStackFrames: undefined });
|
||||
expect(subject.extraDescribeStackFrames).toEqual(0);
|
||||
|
||||
subject.update({ extraDescribeStackFrames: 100000 });
|
||||
expect(subject.extraDescribeStackFrames).toEqual(100000);
|
||||
});
|
||||
|
||||
it('sets safariYieldStrategy when valid', function() {
|
||||
const subject = new privateUnderTest.Configuration();
|
||||
|
||||
subject.update({ safariYieldStrategy: undefined });
|
||||
expect(subject.safariYieldStrategy).toEqual('count');
|
||||
|
||||
subject.update({ safariYieldStrategy: 'time' });
|
||||
expect(subject.safariYieldStrategy).toEqual('time');
|
||||
|
||||
subject.update({ safariYieldStrategy: 'count' });
|
||||
expect(subject.safariYieldStrategy).toEqual('count');
|
||||
});
|
||||
|
||||
it('rejcts invalid safariYieldStrategy values', function() {
|
||||
const subject = new privateUnderTest.Configuration();
|
||||
|
||||
expect(function() {
|
||||
subject.update({ safariYieldStrategy: 'thyme' });
|
||||
}).toThrowError(
|
||||
"Invalid safariYieldStrategy value. Valid values are 'count' and 'time'."
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
// TODO: Fix these unit tests!
|
||||
describe('Env', function() {
|
||||
let env;
|
||||
beforeEach(function() {
|
||||
@@ -27,8 +26,6 @@ describe('Env', function() {
|
||||
|
||||
describe('#topSuite', function() {
|
||||
it('returns an object that describes the tree of suites and specs', function() {
|
||||
spyOn(env, 'deprecated');
|
||||
|
||||
env.it('a top level spec');
|
||||
env.describe('a suite', function() {
|
||||
env.it('a spec');
|
||||
@@ -95,7 +92,7 @@ describe('Env', function() {
|
||||
});
|
||||
});
|
||||
|
||||
it('accepts its own current configureation', function() {
|
||||
it('accepts its own current configuration', function() {
|
||||
env.configure(env.configuration());
|
||||
});
|
||||
|
||||
@@ -124,7 +121,6 @@ describe('Env', function() {
|
||||
});
|
||||
|
||||
it('ignores configuration properties that are present but undefined', function() {
|
||||
spyOn(env, 'deprecated');
|
||||
const initialConfig = {
|
||||
random: true,
|
||||
seed: '123',
|
||||
@@ -198,6 +194,29 @@ describe('Env', function() {
|
||||
expect(innerSuite.parentSuite).toBe(suite);
|
||||
expect(spec.getFullName()).toEqual('outer suite inner suite a spec');
|
||||
});
|
||||
|
||||
it('sets the caller filename correctly when extraDescribeStackFrames is not set', function() {
|
||||
// IIFE is used to match the stack depth when global describe() is called
|
||||
const suite = (function() {
|
||||
return env[methodName]('a suite', function() {
|
||||
env.it('a spec');
|
||||
});
|
||||
})();
|
||||
expect(suite.filename).toMatch(/EnvSpec\.js$/);
|
||||
});
|
||||
|
||||
it('sets the caller filename correctly when extraDescribeStackFrames is set', function() {
|
||||
env.configure({ extraDescribeStackFrames: 2 });
|
||||
// IIFE is used to match the stack depth when global describe() is called
|
||||
const suite = (function() {
|
||||
return specHelpers.callerFilenameShim(function() {
|
||||
return env[methodName]('a suite', function() {
|
||||
env.it('a spec');
|
||||
});
|
||||
});
|
||||
})();
|
||||
expect(suite.filename).toMatch(/EnvSpec\.js$/);
|
||||
});
|
||||
}
|
||||
|
||||
describe('#describe', function() {
|
||||
@@ -300,6 +319,25 @@ describe('Env', function() {
|
||||
.not.toEqual('');
|
||||
expect(spec.pend).toBeFalsy();
|
||||
});
|
||||
|
||||
it('sets the caller filename correctly when extraItStackFrames is not set', function() {
|
||||
// IIFE is used to match the stack depth when global it() is called
|
||||
const spec = (function() {
|
||||
return env[methodName]('a spec', function() {});
|
||||
})();
|
||||
expect(spec.filename).toMatch(/EnvSpec\.js$/);
|
||||
});
|
||||
|
||||
it('sets the caller filename correctly when extraItStackFrames is set', function() {
|
||||
env.configure({ extraItStackFrames: 2 });
|
||||
// IIFE is used to match the stack depth when global it() is called
|
||||
const spec = (function() {
|
||||
return specHelpers.callerFilenameShim(function() {
|
||||
return env[methodName]('a spec', function() {});
|
||||
});
|
||||
})();
|
||||
expect(spec.filename).toMatch(/EnvSpec\.js$/);
|
||||
});
|
||||
}
|
||||
|
||||
describe('#it', function() {
|
||||
@@ -722,7 +760,6 @@ describe('Env', function() {
|
||||
|
||||
it("does not expose the suite as 'this'", function() {
|
||||
let suiteThis;
|
||||
spyOn(env, 'deprecated');
|
||||
|
||||
env.describe('a suite', function() {
|
||||
suiteThis = this;
|
||||
@@ -837,4 +874,8 @@ describe('Env', function() {
|
||||
}).toThrowError('Jasmine cannot be configured via Env in parallel mode');
|
||||
});
|
||||
});
|
||||
|
||||
isNonMonkeyPatchableClass(privateUnderTest.Env, function() {
|
||||
return new privateUnderTest.Env();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -173,10 +173,13 @@ describe('ExceptionFormatter', function() {
|
||||
});
|
||||
|
||||
it('filters Jasmine stack frames in this environment', function() {
|
||||
const jasmineFile = (function() {
|
||||
const trace = new privateUnderTest.StackTrace(new Error());
|
||||
return trace.frames[2].file;
|
||||
})();
|
||||
expect(jasmineFile).toMatch(/\/jasmine.js$/);
|
||||
const error = new Error('an error');
|
||||
const subject = new privateUnderTest.ExceptionFormatter({
|
||||
jasmineFile: jasmine.private.util.jasmineFile()
|
||||
});
|
||||
const subject = new privateUnderTest.ExceptionFormatter({ jasmineFile });
|
||||
const result = subject.stack(error);
|
||||
jasmine.debugLog('Original stack trace: ' + error.stack);
|
||||
jasmine.debugLog('Filtered stack trace: ' + result);
|
||||
@@ -196,15 +199,18 @@ describe('ExceptionFormatter', function() {
|
||||
});
|
||||
|
||||
it('handles multiline error messages in this environment', function() {
|
||||
const jasmineFile = (function() {
|
||||
const trace = new privateUnderTest.StackTrace(new Error());
|
||||
return trace.frames[2].file;
|
||||
})();
|
||||
expect(jasmineFile).toMatch(/\/jasmine.js$/);
|
||||
const msg = 'an error\nwith two lines';
|
||||
const error = new Error(msg);
|
||||
|
||||
if (error.stack.indexOf(msg) === -1) {
|
||||
pending("Stack traces don't have messages in this environment");
|
||||
}
|
||||
const subject = new privateUnderTest.ExceptionFormatter({
|
||||
jasmineFile: jasmine.private.util.jasmineFile()
|
||||
});
|
||||
const subject = new privateUnderTest.ExceptionFormatter({ jasmineFile });
|
||||
const result = subject.stack(error);
|
||||
const lines = result.split('\n');
|
||||
|
||||
@@ -284,7 +290,7 @@ describe('ExceptionFormatter', function() {
|
||||
it('ensures that stack traces do not include the message in this environment', function() {
|
||||
const error = new Error('an error');
|
||||
const subject = new privateUnderTest.ExceptionFormatter({
|
||||
jasmineFile: jasmine.private.util.jasmineFile()
|
||||
jasmineFile: "doesn't matter"
|
||||
});
|
||||
const result = subject.stack(error, { omitMessage: true });
|
||||
expect(result).not.toContain('an error');
|
||||
@@ -346,5 +352,184 @@ describe('ExceptionFormatter', function() {
|
||||
}).not.toThrowError();
|
||||
});
|
||||
});
|
||||
|
||||
describe('when the error has an errors array (AggregateError)', function() {
|
||||
it('includes all aggregated errors in the stack trace', function() {
|
||||
const subject = new privateUnderTest.ExceptionFormatter();
|
||||
const error1 = (function fn1() {
|
||||
return new Error('first error');
|
||||
})();
|
||||
const error2 = (function fn2() {
|
||||
return new Error('second error');
|
||||
})();
|
||||
const aggregateError = (function fn3() {
|
||||
return new Error('Multiple errors occurred');
|
||||
})();
|
||||
aggregateError.errors = [error1, error2];
|
||||
|
||||
const lines = subject.stack(aggregateError).split('\n');
|
||||
|
||||
// TODO: be consistent across environments about whether the message is
|
||||
// included in the stack trace
|
||||
if (lines[0] === 'Error: Multiple errors occurred') {
|
||||
lines.shift();
|
||||
}
|
||||
|
||||
// Exclude lines that vary from environment to environment
|
||||
const filteredLines = lines.filter(
|
||||
x =>
|
||||
!x.includes('/jasmine.js:') &&
|
||||
// Some Node 20 and 22 minors when running in parallel
|
||||
!x.includes('process.processTicksAndRejections')
|
||||
);
|
||||
|
||||
for (let i = 0; i < filteredLines.length; i++) {
|
||||
jasmine.debugLog(`Line ${i} after filtering: ${filteredLines[i]}`);
|
||||
}
|
||||
|
||||
// Inexact matching because stack frame formatting varies from runtime
|
||||
// to runtime
|
||||
const expectedPatterns = [
|
||||
// Overall error
|
||||
/fn3.*ExceptionFormatterSpec\.js/,
|
||||
/ExceptionFormatterSpec\.js/,
|
||||
/^$/,
|
||||
|
||||
// First nested error
|
||||
/^ Error 1: Error: first error$/,
|
||||
/^ .*fn1.*ExceptionFormatterSpec\.js/,
|
||||
/^ .*ExceptionFormatterSpec\.js/,
|
||||
/^$/,
|
||||
|
||||
// Second nested error
|
||||
/^ .*Error 2: Error: second error$/,
|
||||
/^ .*fn2.*ExceptionFormatterSpec\.js/,
|
||||
/^ .*ExceptionFormatterSpec\.js/
|
||||
];
|
||||
|
||||
expect(filteredLines).toEqual(
|
||||
expectedPatterns.map(p => jasmine.stringMatching(p))
|
||||
);
|
||||
});
|
||||
|
||||
it('handles empty errors array', function() {
|
||||
const subject = new privateUnderTest.ExceptionFormatter();
|
||||
const aggregateError = new Error('No errors');
|
||||
aggregateError.errors = [];
|
||||
|
||||
expect(function() {
|
||||
subject.stack(aggregateError);
|
||||
}).not.toThrowError();
|
||||
});
|
||||
|
||||
it('handles nested AggregateError', function() {
|
||||
const subject = new privateUnderTest.ExceptionFormatter();
|
||||
const innerError1 = new Error('inner error 1');
|
||||
const innerError2 = new Error('inner error 2');
|
||||
const innerAggregate = new Error('Inner aggregate');
|
||||
innerAggregate.errors = [innerError1, innerError2];
|
||||
|
||||
const outerError = new Error('outer error');
|
||||
const outerAggregate = new Error('Outer aggregate');
|
||||
outerAggregate.errors = [innerAggregate, outerError];
|
||||
|
||||
const lines = subject.stack(outerAggregate).split('\n');
|
||||
|
||||
const innerAggMsgIx = lines.findIndex(line =>
|
||||
line.includes('Error 1: Error: Inner aggregate')
|
||||
);
|
||||
expect(innerAggMsgIx).toBeGreaterThan(-1);
|
||||
|
||||
const innerError1MsgIx = lines.findIndex(line =>
|
||||
line.includes('Error 1: Error: inner error 1')
|
||||
);
|
||||
expect(innerError1MsgIx).toBeGreaterThan(innerAggMsgIx);
|
||||
|
||||
const innerError2MsgIx = lines.findIndex(line =>
|
||||
line.includes('Error 2: Error: inner error 2')
|
||||
);
|
||||
expect(innerError2MsgIx).toBeGreaterThan(innerError1MsgIx);
|
||||
|
||||
const outerErrorMsgIx = lines.findIndex(line =>
|
||||
line.includes('Error 2: Error: outer error')
|
||||
);
|
||||
expect(outerErrorMsgIx).toBeGreaterThan(innerError2MsgIx);
|
||||
});
|
||||
|
||||
it('handles AggregateError containing error with cause', function() {
|
||||
const subject = new privateUnderTest.ExceptionFormatter();
|
||||
const rootCause = new Error('root cause');
|
||||
const errorWithCause = new Error('error with cause', {
|
||||
cause: rootCause
|
||||
});
|
||||
const aggregateError = new Error('Aggregate with cause chain');
|
||||
aggregateError.errors = [errorWithCause];
|
||||
|
||||
const lines = subject.stack(aggregateError).split('\n');
|
||||
|
||||
const error1MsgIx = lines.findIndex(line =>
|
||||
line.includes('Error 1: Error: error with cause')
|
||||
);
|
||||
expect(error1MsgIx).toBeGreaterThan(-1);
|
||||
|
||||
const causeMsgIx = lines.findIndex(line =>
|
||||
line.includes('Caused by: Error: root cause')
|
||||
);
|
||||
expect(causeMsgIx).toBeGreaterThan(error1MsgIx);
|
||||
});
|
||||
|
||||
it('skips non-Error items in errors array', function() {
|
||||
const subject = new privateUnderTest.ExceptionFormatter();
|
||||
const error1 = new Error('real error');
|
||||
const aggregateError = new Error('Mixed array');
|
||||
aggregateError.errors = [
|
||||
error1,
|
||||
'string error',
|
||||
{ message: 'object error' },
|
||||
null,
|
||||
undefined,
|
||||
42
|
||||
];
|
||||
|
||||
const lines = subject.stack(aggregateError).split('\n');
|
||||
|
||||
const error1MsgIx = lines.findIndex(line =>
|
||||
line.includes('Error 1: Error: real error')
|
||||
);
|
||||
expect(error1MsgIx).toBeGreaterThan(-1);
|
||||
|
||||
const hasStringError = lines.some(line =>
|
||||
line.includes('string error')
|
||||
);
|
||||
expect(hasStringError).toBe(false);
|
||||
|
||||
const hasObjectError = lines.some(line =>
|
||||
line.includes('object error')
|
||||
);
|
||||
expect(hasObjectError).toBe(false);
|
||||
});
|
||||
|
||||
it('works with native AggregateError constructor', function() {
|
||||
const subject = new privateUnderTest.ExceptionFormatter();
|
||||
const error1 = new Error('first error');
|
||||
const error2 = new Error('second error');
|
||||
const aggregateError = new AggregateError(
|
||||
[error1, error2],
|
||||
'Multiple errors'
|
||||
);
|
||||
|
||||
const lines = subject.stack(aggregateError).split('\n');
|
||||
|
||||
const error1MsgIx = lines.findIndex(line =>
|
||||
line.includes('Error 1: Error: first error')
|
||||
);
|
||||
expect(error1MsgIx).toBeGreaterThan(-1);
|
||||
|
||||
const error2MsgIx = lines.findIndex(line =>
|
||||
line.includes('Error 2: Error: second error')
|
||||
);
|
||||
expect(error2MsgIx).toBeGreaterThan(error1MsgIx);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -13,10 +13,7 @@ describe('GlobalErrors', function() {
|
||||
const error = new Error('nope');
|
||||
dispatchEvent(globals.listeners, 'error', { error });
|
||||
|
||||
expect(handler).toHaveBeenCalledWith(
|
||||
jasmine.is(error),
|
||||
jasmine.objectContaining({ error: jasmine.is(error) })
|
||||
);
|
||||
expect(handler).toHaveBeenCalledWith(jasmine.is(error));
|
||||
});
|
||||
|
||||
it('is not affected by overriding global.onerror', function() {
|
||||
@@ -35,10 +32,7 @@ describe('GlobalErrors', function() {
|
||||
const error = new Error('nope');
|
||||
dispatchEvent(globals.listeners, 'error', { error });
|
||||
|
||||
expect(handler).toHaveBeenCalledWith(
|
||||
jasmine.is(error),
|
||||
jasmine.objectContaining({ error: jasmine.is(error) })
|
||||
);
|
||||
expect(handler).toHaveBeenCalledWith(jasmine.is(error));
|
||||
});
|
||||
|
||||
it('only calls the most recent handler', function() {
|
||||
@@ -58,10 +52,7 @@ describe('GlobalErrors', function() {
|
||||
dispatchEvent(globals.listeners, 'error', { error });
|
||||
|
||||
expect(handler1).not.toHaveBeenCalled();
|
||||
expect(handler2).toHaveBeenCalledWith(
|
||||
jasmine.is(error),
|
||||
jasmine.objectContaining({ error: jasmine.is(error) })
|
||||
);
|
||||
expect(handler2).toHaveBeenCalledWith(jasmine.is(error));
|
||||
});
|
||||
|
||||
it('calls previous handlers when one is removed', function() {
|
||||
@@ -82,10 +73,7 @@ describe('GlobalErrors', function() {
|
||||
const error = new Error('nope');
|
||||
dispatchEvent(globals.listeners, 'error', { error });
|
||||
|
||||
expect(handler1).toHaveBeenCalledWith(
|
||||
jasmine.is(error),
|
||||
jasmine.objectContaining({ error: jasmine.is(error) })
|
||||
);
|
||||
expect(handler1).toHaveBeenCalledWith(jasmine.is(error));
|
||||
expect(handler2).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
@@ -130,6 +118,32 @@ describe('GlobalErrors', function() {
|
||||
errors.uninstall();
|
||||
});
|
||||
|
||||
it("reports browser error events that don't have errors", function() {
|
||||
const globals = browserGlobals();
|
||||
const handler = jasmine.createSpy('errorHandler');
|
||||
const errors = new privateUnderTest.GlobalErrors(
|
||||
globals.global,
|
||||
() => ({})
|
||||
);
|
||||
errors.install();
|
||||
errors.pushListener(handler);
|
||||
|
||||
const event = {
|
||||
message: 'Uncaught SyntaxError: Unexpected end of input',
|
||||
error: undefined,
|
||||
filename: 'borkenSpec.js',
|
||||
lineno: 42
|
||||
};
|
||||
dispatchEvent(globals.listeners, 'error', event);
|
||||
|
||||
expect(handler).toHaveBeenCalledWith({
|
||||
message: 'Uncaught SyntaxError: Unexpected end of input',
|
||||
filename: 'borkenSpec.js',
|
||||
lineno: 42,
|
||||
stack: '@borkenSpec.js:42'
|
||||
});
|
||||
});
|
||||
|
||||
it('reports uncaught exceptions in node.js', function() {
|
||||
const globals = nodeGlobals();
|
||||
const errors = new privateUnderTest.GlobalErrors(
|
||||
@@ -152,7 +166,7 @@ describe('GlobalErrors', function() {
|
||||
|
||||
dispatchEvent(globals.listeners, 'uncaughtException', new Error('bar'));
|
||||
|
||||
expect(handler).toHaveBeenCalledWith(new Error('bar'), undefined);
|
||||
expect(handler).toHaveBeenCalledWith(new Error('bar'));
|
||||
expect(handler.calls.argsFor(0)[0].jasmineMessage).toBe(
|
||||
'Uncaught exception: Error: bar'
|
||||
);
|
||||
@@ -185,7 +199,7 @@ describe('GlobalErrors', function() {
|
||||
|
||||
dispatchEvent(globals.listeners, 'unhandledRejection', new Error('bar'));
|
||||
|
||||
expect(handler).toHaveBeenCalledWith(new Error('bar'), undefined);
|
||||
expect(handler).toHaveBeenCalledWith(new Error('bar'));
|
||||
expect(handler.calls.argsFor(0)[0].jasmineMessage).toBe(
|
||||
'Unhandled promise rejection: Error: bar'
|
||||
);
|
||||
@@ -213,8 +227,7 @@ describe('GlobalErrors', function() {
|
||||
'Unhandled promise rejection: 17\n' +
|
||||
'(Tip: to get a useful stack trace, use ' +
|
||||
'Promise.reject(new Error(...)) instead of Promise.reject(...).)'
|
||||
),
|
||||
undefined
|
||||
)
|
||||
);
|
||||
});
|
||||
|
||||
@@ -236,8 +249,7 @@ describe('GlobalErrors', function() {
|
||||
'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().)'
|
||||
),
|
||||
undefined
|
||||
)
|
||||
);
|
||||
});
|
||||
|
||||
@@ -281,7 +293,7 @@ describe('GlobalErrors', function() {
|
||||
undefined
|
||||
);
|
||||
|
||||
expect(handler).toHaveBeenCalledWith(new Error('nope'), undefined);
|
||||
expect(handler).toHaveBeenCalledWith(new Error('nope'));
|
||||
expect(handler.calls.argsFor(0)[0].jasmineMessage).toBe(
|
||||
'Unhandled promise rejection: Error: nope'
|
||||
);
|
||||
@@ -324,7 +336,7 @@ describe('GlobalErrors', function() {
|
||||
);
|
||||
errors.reportUnhandledRejections();
|
||||
|
||||
expect(handler).toHaveBeenCalledWith(new Error('nope'), undefined);
|
||||
expect(handler).toHaveBeenCalledWith(new Error('nope'));
|
||||
expect(handler.calls.argsFor(0)[0].jasmineMessage).toBe(
|
||||
'Unhandled promise rejection: Error: nope'
|
||||
);
|
||||
@@ -407,10 +419,7 @@ describe('GlobalErrors', function() {
|
||||
const event = { reason: 'nope' };
|
||||
dispatchEvent(globals.listeners, 'unhandledrejection', event);
|
||||
|
||||
expect(handler).toHaveBeenCalledWith(
|
||||
'Unhandled promise rejection: nope',
|
||||
event
|
||||
);
|
||||
expect(handler).toHaveBeenCalledWith('Unhandled promise rejection: nope');
|
||||
});
|
||||
|
||||
it('reports rejections whose reason is an Error', function() {
|
||||
@@ -428,13 +437,15 @@ describe('GlobalErrors', function() {
|
||||
const event = { reason };
|
||||
dispatchEvent(globals.listeners, 'unhandledrejection', event);
|
||||
|
||||
expect(handler).toHaveBeenCalledWith(
|
||||
expect(handler).toHaveBeenCalledTimes(1);
|
||||
const received = handler.calls.argsFor(0)[0];
|
||||
expect(received).toBeInstanceOf(Error);
|
||||
expect(received).toEqual(
|
||||
jasmine.objectContaining({
|
||||
jasmineMessage: 'Unhandled promise rejection: Error: bar',
|
||||
message: reason.message,
|
||||
stack: reason.stack
|
||||
}),
|
||||
event
|
||||
})
|
||||
);
|
||||
});
|
||||
|
||||
@@ -469,8 +480,7 @@ describe('GlobalErrors', function() {
|
||||
dispatchEvent(globals.listeners, 'unhandledrejection', event);
|
||||
|
||||
expect(handler).toHaveBeenCalledWith(
|
||||
'Unhandled promise rejection: nope',
|
||||
event
|
||||
'Unhandled promise rejection: nope'
|
||||
);
|
||||
});
|
||||
});
|
||||
@@ -507,8 +517,7 @@ describe('GlobalErrors', function() {
|
||||
errors.reportUnhandledRejections();
|
||||
|
||||
expect(handler).toHaveBeenCalledWith(
|
||||
'Unhandled promise rejection: nope',
|
||||
{ reason: 'nope', promise }
|
||||
'Unhandled promise rejection: nope'
|
||||
);
|
||||
});
|
||||
|
||||
@@ -567,10 +576,7 @@ describe('GlobalErrors', function() {
|
||||
|
||||
dispatchEvent(globals.listeners, 'uncaughtException', 17);
|
||||
|
||||
expect(handler).toHaveBeenCalledWith(
|
||||
new Error('Uncaught exception: 17'),
|
||||
undefined
|
||||
);
|
||||
expect(handler).toHaveBeenCalledWith(new Error('Uncaught exception: 17'));
|
||||
});
|
||||
|
||||
it('substitutes a descriptive message when the error is falsy', function() {
|
||||
@@ -587,8 +593,7 @@ describe('GlobalErrors', function() {
|
||||
dispatchEvent(globals.listeners, 'uncaughtException', undefined);
|
||||
|
||||
expect(handler).toHaveBeenCalledWith(
|
||||
new Error('Uncaught exception with no error or message'),
|
||||
undefined
|
||||
new Error('Uncaught exception with no error or message')
|
||||
);
|
||||
});
|
||||
});
|
||||
@@ -619,7 +624,7 @@ describe('GlobalErrors', function() {
|
||||
const event = { error: 'baz' };
|
||||
dispatchEvent(globals.listeners, 'error', event);
|
||||
expect(overrideHandler).not.toHaveBeenCalledWith('baz');
|
||||
expect(handler1).toHaveBeenCalledWith('baz', event);
|
||||
expect(handler1).toHaveBeenCalledWith('baz');
|
||||
});
|
||||
|
||||
it('overrides the existing handlers in Node until removed', function() {
|
||||
@@ -648,7 +653,7 @@ describe('GlobalErrors', function() {
|
||||
|
||||
dispatchEvent(globals.listeners, 'uncaughtException', new Error('bar'));
|
||||
expect(overrideHandler).not.toHaveBeenCalled();
|
||||
expect(handler1).toHaveBeenCalledWith(new Error('bar'), undefined);
|
||||
expect(handler1).toHaveBeenCalledWith(new Error('bar'));
|
||||
});
|
||||
|
||||
it('handles unhandled promise rejections in browsers', function() {
|
||||
|
||||
@@ -1,179 +0,0 @@
|
||||
describe('JsApiReporter', function() {
|
||||
it('knows when a full environment is started', function() {
|
||||
const reporter = new privateUnderTest.JsApiReporter({});
|
||||
|
||||
expect(reporter.started).toBe(false);
|
||||
expect(reporter.finished).toBe(false);
|
||||
|
||||
reporter.jasmineStarted();
|
||||
|
||||
expect(reporter.started).toBe(true);
|
||||
expect(reporter.finished).toBe(false);
|
||||
});
|
||||
|
||||
it('knows when a full environment is done', function() {
|
||||
const reporter = new privateUnderTest.JsApiReporter({});
|
||||
|
||||
expect(reporter.started).toBe(false);
|
||||
expect(reporter.finished).toBe(false);
|
||||
|
||||
reporter.jasmineStarted();
|
||||
reporter.jasmineDone({});
|
||||
|
||||
expect(reporter.finished).toBe(true);
|
||||
});
|
||||
|
||||
it("defaults to 'loaded' status", function() {
|
||||
const reporter = new privateUnderTest.JsApiReporter({});
|
||||
|
||||
expect(reporter.status()).toEqual('loaded');
|
||||
});
|
||||
|
||||
it("reports 'started' when Jasmine has started", function() {
|
||||
const reporter = new privateUnderTest.JsApiReporter({});
|
||||
|
||||
reporter.jasmineStarted();
|
||||
|
||||
expect(reporter.status()).toEqual('started');
|
||||
});
|
||||
|
||||
it("reports 'done' when Jasmine is done", function() {
|
||||
const reporter = new privateUnderTest.JsApiReporter({});
|
||||
|
||||
reporter.jasmineDone({});
|
||||
|
||||
expect(reporter.status()).toEqual('done');
|
||||
});
|
||||
|
||||
it('tracks a suite', function() {
|
||||
const reporter = new privateUnderTest.JsApiReporter({});
|
||||
|
||||
reporter.suiteStarted({
|
||||
id: 123,
|
||||
description: 'A suite'
|
||||
});
|
||||
|
||||
const suites = reporter.suites();
|
||||
|
||||
expect(suites).toEqual({ 123: { id: 123, description: 'A suite' } });
|
||||
|
||||
reporter.suiteDone({
|
||||
id: 123,
|
||||
description: 'A suite',
|
||||
status: 'passed'
|
||||
});
|
||||
|
||||
expect(suites).toEqual({
|
||||
123: { id: 123, description: 'A suite', status: 'passed' }
|
||||
});
|
||||
});
|
||||
|
||||
describe('#specResults', function() {
|
||||
let reporter, specResult1, specResult2;
|
||||
beforeEach(function() {
|
||||
reporter = new privateUnderTest.JsApiReporter({});
|
||||
specResult1 = {
|
||||
id: 1,
|
||||
description: 'A spec'
|
||||
};
|
||||
specResult2 = {
|
||||
id: 2,
|
||||
description: 'Another spec'
|
||||
};
|
||||
|
||||
reporter.specDone(specResult1);
|
||||
reporter.specDone(specResult2);
|
||||
});
|
||||
|
||||
it('should return a slice of results', function() {
|
||||
expect(reporter.specResults(0, 1)).toEqual([specResult1]);
|
||||
expect(reporter.specResults(1, 1)).toEqual([specResult2]);
|
||||
});
|
||||
|
||||
describe('when the results do not exist', function() {
|
||||
it('should return a slice of shorter length', function() {
|
||||
expect(reporter.specResults(0, 3)).toEqual([specResult1, specResult2]);
|
||||
expect(reporter.specResults(2, 3)).toEqual([]);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('#suiteResults', function() {
|
||||
let reporter, suiteStarted1, suiteResult1, suiteResult2;
|
||||
beforeEach(function() {
|
||||
reporter = new privateUnderTest.JsApiReporter({});
|
||||
suiteStarted1 = {
|
||||
id: 1
|
||||
};
|
||||
suiteResult1 = {
|
||||
id: 1,
|
||||
status: 'failed',
|
||||
failedExpectations: [{ message: 'My After All Exception' }]
|
||||
};
|
||||
suiteResult2 = {
|
||||
id: 2,
|
||||
status: 'passed'
|
||||
};
|
||||
|
||||
reporter.suiteStarted(suiteStarted1);
|
||||
reporter.suiteDone(suiteResult1);
|
||||
reporter.suiteDone(suiteResult2);
|
||||
});
|
||||
|
||||
it('should not include suite starts', function() {
|
||||
expect(reporter.suiteResults(0, 3).length).toEqual(2);
|
||||
});
|
||||
|
||||
it('should return a slice of results', function() {
|
||||
expect(reporter.suiteResults(0, 1)).toEqual([suiteResult1]);
|
||||
expect(reporter.suiteResults(1, 1)).toEqual([suiteResult2]);
|
||||
});
|
||||
|
||||
it('returns nothing for out of bounds indices', function() {
|
||||
expect(reporter.suiteResults(0, 3)).toEqual([suiteResult1, suiteResult2]);
|
||||
expect(reporter.suiteResults(2, 3)).toEqual([]);
|
||||
});
|
||||
});
|
||||
|
||||
describe('#executionTime', function() {
|
||||
it('should start the timer when jasmine starts', function() {
|
||||
const timerSpy = jasmine.createSpyObj('timer', ['start', 'elapsed']),
|
||||
reporter = new privateUnderTest.JsApiReporter({
|
||||
timer: timerSpy
|
||||
});
|
||||
|
||||
reporter.jasmineStarted();
|
||||
expect(timerSpy.start).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should return the time it took the specs to run, in ms', function() {
|
||||
const timerSpy = jasmine.createSpyObj('timer', ['start', 'elapsed']),
|
||||
reporter = new privateUnderTest.JsApiReporter({
|
||||
timer: timerSpy
|
||||
});
|
||||
|
||||
timerSpy.elapsed.and.returnValue(1000);
|
||||
reporter.jasmineDone();
|
||||
expect(reporter.executionTime()).toEqual(1000);
|
||||
});
|
||||
|
||||
describe("when the specs haven't finished being run", function() {
|
||||
it('should return undefined', function() {
|
||||
const timerSpy = jasmine.createSpyObj('timer', ['start', 'elapsed']),
|
||||
reporter = new privateUnderTest.JsApiReporter({
|
||||
timer: timerSpy
|
||||
});
|
||||
|
||||
expect(reporter.executionTime()).toBeUndefined();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('#runDetails', function() {
|
||||
it('should have details about the run', function() {
|
||||
const reporter = new privateUnderTest.JsApiReporter({});
|
||||
reporter.jasmineDone({ some: { run: 'details' } });
|
||||
expect(reporter.runDetails).toEqual({ some: { run: 'details' } });
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -160,6 +160,13 @@ describe('ParallelReportDispatcher', function() {
|
||||
);
|
||||
});
|
||||
|
||||
isNonMonkeyPatchableClass(
|
||||
jasmineUnderTest.ParallelReportDispatcher,
|
||||
function() {
|
||||
return new jasmineUnderTest.ParallelReportDispatcher();
|
||||
}
|
||||
);
|
||||
|
||||
function mockGlobalErrors() {
|
||||
const globalErrors = jasmine.createSpyObj('globalErrors', [
|
||||
'install',
|
||||
|
||||
@@ -471,31 +471,6 @@ describe('QueueRunner', function() {
|
||||
expect(nextQueueableFn.fn).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('handles a global error event with a message but no error', function() {
|
||||
const queueableFn = {
|
||||
fn: function(done) {
|
||||
const currentHandler = globalErrors.pushListener.calls.mostRecent()
|
||||
.args[0];
|
||||
currentHandler(undefined, { message: 'nope' });
|
||||
},
|
||||
timeout: 1
|
||||
};
|
||||
const onException = jasmine.createSpy('onException');
|
||||
const globalErrors = {
|
||||
pushListener: jasmine.createSpy('pushListener'),
|
||||
popListener: jasmine.createSpy('popListener')
|
||||
};
|
||||
const queueRunner = new privateUnderTest.QueueRunner({
|
||||
queueableFns: [queueableFn],
|
||||
onException: onException,
|
||||
globalErrors: globalErrors
|
||||
});
|
||||
|
||||
queueRunner.execute();
|
||||
|
||||
expect(onException).toHaveBeenCalledWith('nope');
|
||||
});
|
||||
|
||||
it('handles exceptions thrown while waiting for the stack to clear', function() {
|
||||
const queueableFn = {
|
||||
fn: function(done) {
|
||||
@@ -511,7 +486,7 @@ describe('QueueRunner', function() {
|
||||
errorListeners.pop();
|
||||
}
|
||||
},
|
||||
clearStack = jasmine.createSpy('clearStack'),
|
||||
clearStack = jasmine.createSpyObj('clearStack', ['clearStack']),
|
||||
onException = jasmine.createSpy('onException'),
|
||||
queueRunner = new privateUnderTest.QueueRunner({
|
||||
queueableFns: [queueableFn],
|
||||
@@ -523,46 +498,12 @@ describe('QueueRunner', function() {
|
||||
|
||||
queueRunner.execute();
|
||||
jasmine.clock().tick();
|
||||
expect(clearStack).toHaveBeenCalled();
|
||||
expect(clearStack.clearStack).toHaveBeenCalled();
|
||||
expect(errorListeners.length).toEqual(1);
|
||||
errorListeners[0](error);
|
||||
clearStack.calls.argsFor(0)[0]();
|
||||
clearStack.clearStack.calls.argsFor(0)[0]();
|
||||
expect(onException).toHaveBeenCalledWith(error);
|
||||
});
|
||||
|
||||
it('handles a global error event with no error while waiting for the stack to clear', function() {
|
||||
const queueableFn = {
|
||||
fn: function(done) {
|
||||
done();
|
||||
}
|
||||
};
|
||||
const errorListeners = [];
|
||||
const globalErrors = {
|
||||
pushListener: function(f) {
|
||||
errorListeners.push(f);
|
||||
},
|
||||
popListener: function() {
|
||||
errorListeners.pop();
|
||||
}
|
||||
};
|
||||
const clearStack = jasmine.createSpy('clearStack');
|
||||
const onException = jasmine.createSpy('onException');
|
||||
const queueRunner = new privateUnderTest.QueueRunner({
|
||||
queueableFns: [queueableFn],
|
||||
globalErrors: globalErrors,
|
||||
clearStack: clearStack,
|
||||
onException: onException
|
||||
});
|
||||
|
||||
queueRunner.execute();
|
||||
jasmine.clock().tick();
|
||||
expect(clearStack).toHaveBeenCalled();
|
||||
expect(errorListeners.length).toEqual(1);
|
||||
errorListeners[0](undefined, { message: 'nope' });
|
||||
|
||||
clearStack.calls.argsFor(0)[0]();
|
||||
expect(onException).toHaveBeenCalledWith('nope');
|
||||
});
|
||||
});
|
||||
|
||||
describe('with a function that returns a promise', function() {
|
||||
@@ -967,22 +908,22 @@ describe('QueueRunner', function() {
|
||||
},
|
||||
afterFn = { fn: jasmine.createSpy('afterFn') },
|
||||
completeCallback = jasmine.createSpy('completeCallback'),
|
||||
clearStack = jasmine.createSpy('clearStack'),
|
||||
clearStack = jasmine.createSpyObj('clearStack', ['clearStack']),
|
||||
queueRunner = new privateUnderTest.QueueRunner({
|
||||
queueableFns: [asyncFn, afterFn],
|
||||
clearStack: clearStack,
|
||||
onComplete: completeCallback
|
||||
});
|
||||
|
||||
clearStack.and.callFake(function(fn) {
|
||||
clearStack.clearStack.and.callFake(function(fn) {
|
||||
fn();
|
||||
});
|
||||
|
||||
queueRunner.execute();
|
||||
jasmine.clock().tick();
|
||||
expect(afterFn.fn).toHaveBeenCalled();
|
||||
expect(clearStack).toHaveBeenCalled();
|
||||
clearStack.calls.argsFor(0)[0]();
|
||||
expect(clearStack.clearStack).toHaveBeenCalled();
|
||||
clearStack.clearStack.calls.argsFor(0)[0]();
|
||||
expect(completeCallback).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -33,18 +33,15 @@ describe('Runner', function() {
|
||||
attrs = attrs || {};
|
||||
this.id = 'suite' + suiteNumber++;
|
||||
this.children = attrs.children || [];
|
||||
this.canBeReentered = function() {
|
||||
return !attrs.noReenter;
|
||||
};
|
||||
this.markedPending = attrs.markedPending || false;
|
||||
this.sharedUserContext = function() {
|
||||
return attrs.userContext || {};
|
||||
};
|
||||
this.result = {
|
||||
id: this.id,
|
||||
failedExpectations: []
|
||||
};
|
||||
this.getResult = jasmine.createSpy('getResult');
|
||||
this.startedEvent = jasmine.createSpy('startedEvent');
|
||||
this.doneEvent = jasmine.createSpy('doneEvent');
|
||||
this.hasOwnFailedExpectations = jasmine.createSpy(
|
||||
'hasOwnFailedExpectations'
|
||||
);
|
||||
this.beforeAllFns = attrs.beforeAllFns || [];
|
||||
this.afterAllFns = attrs.afterAllFns || [];
|
||||
this.cleanupBeforeAfter = function() {};
|
||||
@@ -90,7 +87,7 @@ describe('Runner', function() {
|
||||
function arrayNotContaining(item) {
|
||||
return {
|
||||
asymmetricMatch(other, matchersUtil) {
|
||||
if (!jasmine.private.isArray(other)) {
|
||||
if (!Array.isArray(other)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -130,6 +127,7 @@ describe('Runner', function() {
|
||||
children: [spec],
|
||||
userContext: { root: 'context' }
|
||||
});
|
||||
topSuite.doneEvent.and.returnValue({});
|
||||
detectLateRejectionHandling = true;
|
||||
const subject = makeRunner(topSuite);
|
||||
|
||||
@@ -157,6 +155,7 @@ describe('Runner', function() {
|
||||
children: [suite],
|
||||
userContext: { for: 'topSuite' }
|
||||
});
|
||||
topSuite.doneEvent.and.returnValue({});
|
||||
suite.parentSuite = topSuite;
|
||||
const subject = makeRunner(topSuite);
|
||||
|
||||
@@ -185,10 +184,13 @@ describe('Runner', function() {
|
||||
SkipPolicy: privateUnderTest.SkipAfterBeforeAllErrorPolicy
|
||||
});
|
||||
|
||||
suite.startedEvent.and.returnValue('suite started event');
|
||||
runQueue.calls.mostRecent().args[0].queueableFns[0].fn('foo');
|
||||
expect(reportDispatcher.suiteStarted).toHaveBeenCalledWith(suite.result);
|
||||
expect(reportDispatcher.suiteStarted).toHaveBeenCalledWith(
|
||||
'suite started event'
|
||||
);
|
||||
|
||||
suite.getResult.and.returnValue({ my: 'result' });
|
||||
suite.doneEvent.and.returnValue({ my: 'result' });
|
||||
|
||||
runQueue.calls.mostRecent().args[0].onComplete();
|
||||
expect(reportDispatcher.suiteDone).toHaveBeenCalledWith({ my: 'result' });
|
||||
@@ -236,14 +238,19 @@ describe('Runner', function() {
|
||||
queueableFns = runQueue.calls.mostRecent().args[0].queueableFns;
|
||||
expect(queueableFns.length).toBe(2);
|
||||
|
||||
parent.startedEvent.and.returnValue('parent suite started event');
|
||||
queueableFns[0].fn();
|
||||
expect(reportDispatcher.suiteStarted).toHaveBeenCalledWith(parent.result);
|
||||
expect(reportDispatcher.suiteStarted).toHaveBeenCalledWith(
|
||||
'parent suite started event'
|
||||
);
|
||||
|
||||
verifyAndFinishSpec(spec, queueableFns[1], true);
|
||||
|
||||
parent.getResult.and.returnValue(parent.result);
|
||||
parent.doneEvent.and.returnValue('parent suite done event');
|
||||
runQueue.calls.argsFor(1)[0].onComplete();
|
||||
expect(reportDispatcher.suiteDone).toHaveBeenCalledWith(parent.result);
|
||||
expect(reportDispatcher.suiteDone).toHaveBeenCalledWith(
|
||||
'parent suite done event'
|
||||
);
|
||||
await expectAsync(promise).toBePending();
|
||||
});
|
||||
|
||||
|
||||
@@ -85,7 +85,7 @@ describe('Spec', function() {
|
||||
|
||||
spec.setSpecProperty('a', 4);
|
||||
|
||||
expect(spec.result.properties).toEqual({ a: 4 });
|
||||
expect(spec.doneEvent().properties).toEqual({ a: 4 });
|
||||
});
|
||||
|
||||
it('replace the property result when it was previously set', function() {
|
||||
@@ -97,32 +97,20 @@ describe('Spec', function() {
|
||||
spec.setSpecProperty('b', 'original-value');
|
||||
spec.setSpecProperty('a', 'new-value');
|
||||
|
||||
expect(spec.result.properties).toEqual({
|
||||
expect(spec.doneEvent().properties).toEqual({
|
||||
a: 'new-value',
|
||||
b: 'original-value'
|
||||
});
|
||||
});
|
||||
|
||||
it('throws if the key is not structured-cloneable', function() {
|
||||
it('throws if the key is not a string', function() {
|
||||
const spec = new privateUnderTest.Spec({
|
||||
queueableFn: { fn: () => {} }
|
||||
});
|
||||
|
||||
expect(function() {
|
||||
spec.setSpecProperty(new Promise(() => {}), '');
|
||||
}).toThrowError("Key can't be cloned");
|
||||
});
|
||||
|
||||
it('throws if the key is not JSON-serializable', function() {
|
||||
const spec = new privateUnderTest.Spec({
|
||||
queueableFn: { fn: () => {} }
|
||||
});
|
||||
|
||||
expect(function() {
|
||||
const k = {};
|
||||
k.self = k;
|
||||
spec.setSpecProperty(k, '');
|
||||
}).toThrowError("Key can't be cloned");
|
||||
spec.setSpecProperty({}, '');
|
||||
}).toThrowError('Key must be a string');
|
||||
});
|
||||
|
||||
it('throws if the value is not structured-cloneable', function() {
|
||||
@@ -149,11 +137,16 @@ describe('Spec', function() {
|
||||
});
|
||||
|
||||
describe('status', function() {
|
||||
it('is "passed" by default', function() {
|
||||
it('returns "passed" by default', function() {
|
||||
const spec = new privateUnderTest.Spec({
|
||||
queueableFn: { fn: () => {} }
|
||||
});
|
||||
expect(spec.getResult().status).toBe('passed');
|
||||
expect(spec.status())
|
||||
.withContext('status()')
|
||||
.toBe('passed');
|
||||
expect(spec.doneEvent().status)
|
||||
.withContext('doneEvent().status')
|
||||
.toBe('passed');
|
||||
});
|
||||
|
||||
it('is "passed" if all expectations passed', function() {
|
||||
@@ -163,7 +156,12 @@ describe('Spec', function() {
|
||||
|
||||
spec.addExpectationResult(true, {});
|
||||
|
||||
expect(spec.getResult().status).toBe('passed');
|
||||
expect(spec.status())
|
||||
.withContext('status()')
|
||||
.toBe('passed');
|
||||
expect(spec.doneEvent().status)
|
||||
.withContext('doneEvent().status')
|
||||
.toBe('passed');
|
||||
});
|
||||
|
||||
it('is "failed" if any expectation failed', function() {
|
||||
@@ -174,7 +172,12 @@ describe('Spec', function() {
|
||||
spec.addExpectationResult(true, {});
|
||||
spec.addExpectationResult(false, {});
|
||||
|
||||
expect(spec.getResult().status).toBe('failed');
|
||||
expect(spec.status())
|
||||
.withContext('status()')
|
||||
.toBe('failed');
|
||||
expect(spec.doneEvent().status)
|
||||
.withContext('doneEvent().status')
|
||||
.toBe('failed');
|
||||
});
|
||||
|
||||
it('is "pending" if created without a function body', function() {
|
||||
@@ -186,7 +189,65 @@ describe('Spec', function() {
|
||||
resultCallback: resultCallback
|
||||
});
|
||||
|
||||
expect(spec.getResult().status).toBe('pending');
|
||||
expect(spec.status())
|
||||
.withContext('status()')
|
||||
.toBe('pending');
|
||||
expect(spec.doneEvent().status)
|
||||
.withContext('doneEvent().status')
|
||||
.toBe('pending');
|
||||
});
|
||||
|
||||
describe('after a call to executionFinished()', function() {
|
||||
describe('with excluded true', function() {
|
||||
it("is 'excluded'", function() {
|
||||
const spec = new privateUnderTest.Spec({
|
||||
queueableFn: { fn: () => {} }
|
||||
});
|
||||
|
||||
spec.executionFinished(true, false);
|
||||
|
||||
expect(spec.status())
|
||||
.withContext('status()')
|
||||
.toBe('excluded');
|
||||
expect(spec.doneEvent().status)
|
||||
.withContext('doneEvent().status')
|
||||
.toBe('excluded');
|
||||
});
|
||||
});
|
||||
|
||||
describe('with failSpecWithNoExp true', function() {
|
||||
it("is 'failed' if there were no expectations", function() {
|
||||
const spec = new privateUnderTest.Spec({
|
||||
queueableFn: { fn: () => {} }
|
||||
});
|
||||
|
||||
spec.executionFinished(false, true);
|
||||
|
||||
expect(spec.status())
|
||||
.withContext('status()')
|
||||
.toBe('failed');
|
||||
expect(spec.doneEvent().status)
|
||||
.withContext('doneEvent().status')
|
||||
.toBe('failed');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('after a call to hadBeforeAllFailure()', function() {
|
||||
it("is 'failed'", function() {
|
||||
const spec = new privateUnderTest.Spec({
|
||||
queueableFn: { fn: () => {} }
|
||||
});
|
||||
|
||||
spec.hadBeforeAllFailure();
|
||||
|
||||
expect(spec.status())
|
||||
.withContext('status()')
|
||||
.toBe('failed');
|
||||
expect(spec.doneEvent().status)
|
||||
.withContext('doneEvent().status')
|
||||
.toBe('failed');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -199,10 +260,10 @@ describe('Spec', function() {
|
||||
spec.addExpectationResult(true, { message: 'expectation1' });
|
||||
spec.addExpectationResult(false, { message: 'expectation2' });
|
||||
|
||||
expect(spec.result.passedExpectations).toEqual([
|
||||
expect(spec.doneEvent().passedExpectations).toEqual([
|
||||
jasmine.objectContaining({ message: 'expectation1' })
|
||||
]);
|
||||
expect(spec.result.failedExpectations).toEqual([
|
||||
expect(spec.doneEvent().failedExpectations).toEqual([
|
||||
jasmine.objectContaining({ message: 'expectation2' })
|
||||
]);
|
||||
});
|
||||
@@ -217,9 +278,9 @@ describe('Spec', function() {
|
||||
spec.addExpectationResult(true, { message: 'passed' });
|
||||
expect(function() {
|
||||
spec.addExpectationResult(false, { message: 'failed' });
|
||||
}).toThrowError(jasmineUnderTest.private.errors.ExpectationFailed);
|
||||
}).toThrowError(privateUnderTest.errors.ExpectationFailed);
|
||||
|
||||
expect(spec.result.failedExpectations).toEqual([
|
||||
expect(spec.doneEvent().failedExpectations).toEqual([
|
||||
jasmine.objectContaining({ message: 'failed' })
|
||||
]);
|
||||
});
|
||||
@@ -233,7 +294,7 @@ describe('Spec', function() {
|
||||
|
||||
spec.addExpectationResult(false, { message: 'failed' });
|
||||
|
||||
expect(spec.result.failedExpectations).toEqual([
|
||||
expect(spec.doneEvent().failedExpectations).toEqual([
|
||||
jasmine.objectContaining({ message: 'failed' })
|
||||
]);
|
||||
});
|
||||
@@ -262,7 +323,7 @@ describe('Spec', function() {
|
||||
message: jasmine.stringMatching(/^Error: nope/)
|
||||
})
|
||||
);
|
||||
expect(spec.result.failedExpectations).toEqual([]);
|
||||
expect(spec.doneEvent().failedExpectations).toEqual([]);
|
||||
});
|
||||
|
||||
it('does not forward non-late expectation failures to onLateError', function() {
|
||||
@@ -299,7 +360,7 @@ describe('Spec', function() {
|
||||
message: jasmine.stringMatching(/^Error: oops/)
|
||||
})
|
||||
);
|
||||
expect(spec.result.failedExpectations).toEqual([]);
|
||||
expect(spec.doneEvent().failedExpectations).toEqual([]);
|
||||
});
|
||||
|
||||
it('does not forward non-late handleException calls to onLateError', function() {
|
||||
@@ -313,7 +374,7 @@ describe('Spec', function() {
|
||||
spec.handleException(error);
|
||||
|
||||
expect(onLateError).not.toHaveBeenCalled();
|
||||
expect(spec.result.failedExpectations.length).toEqual(1);
|
||||
expect(spec.doneEvent().failedExpectations.length).toEqual(1);
|
||||
});
|
||||
|
||||
it('clears the reportedDone flag when reset', function() {
|
||||
@@ -376,7 +437,7 @@ describe('Spec', function() {
|
||||
|
||||
spec.handleException('foo');
|
||||
|
||||
expect(spec.result.failedExpectations).toEqual([
|
||||
expect(spec.doneEvent().failedExpectations).toEqual([
|
||||
{
|
||||
message: 'foo thrown',
|
||||
matcherName: '',
|
||||
@@ -392,11 +453,9 @@ describe('Spec', function() {
|
||||
queueableFn: {}
|
||||
});
|
||||
|
||||
spec.handleException(
|
||||
new jasmineUnderTest.private.errors.ExpectationFailed()
|
||||
);
|
||||
spec.handleException(new privateUnderTest.errors.ExpectationFailed());
|
||||
|
||||
expect(spec.result.failedExpectations).toEqual([]);
|
||||
expect(spec.doneEvent().failedExpectations).toEqual([]);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -410,15 +469,15 @@ describe('Spec', function() {
|
||||
const t1 = 123;
|
||||
const t2 = 456;
|
||||
|
||||
expect(spec.result.debugLogs).toBeNull();
|
||||
expect(spec.doneEvent().debugLogs).toBeNull();
|
||||
timer.elapsed.and.returnValue(t1);
|
||||
spec.debugLog('msg 1');
|
||||
expect(spec.result.debugLogs).toEqual([
|
||||
expect(spec.doneEvent().debugLogs).toEqual([
|
||||
{ message: 'msg 1', timestamp: t1 }
|
||||
]);
|
||||
timer.elapsed.and.returnValue(t2);
|
||||
spec.debugLog('msg 2');
|
||||
expect(spec.result.debugLogs).toEqual([
|
||||
expect(spec.doneEvent().debugLogs).toEqual([
|
||||
{ message: 'msg 1', timestamp: t1 },
|
||||
{ message: 'msg 2', timestamp: t2 }
|
||||
]);
|
||||
@@ -433,7 +492,7 @@ describe('Spec', function() {
|
||||
spec.debugLog('msg');
|
||||
spec.executionFinished();
|
||||
|
||||
expect(spec.result.debugLogs).toBeNull();
|
||||
expect(spec.doneEvent().debugLogs).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -452,7 +511,7 @@ describe('Spec', function() {
|
||||
spec.handleException(new Error('nope'));
|
||||
spec.executionFinished();
|
||||
|
||||
expect(spec.result.debugLogs).toEqual([
|
||||
expect(spec.doneEvent().debugLogs).toEqual([
|
||||
{ message: 'msg', timestamp: timestamp }
|
||||
]);
|
||||
});
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
describe('ClearStack', function() {
|
||||
describe('StackClearer', function() {
|
||||
it('works in an integrationy way', function(done) {
|
||||
const clearStack = privateUnderTest.getClearStack(
|
||||
const { clearStack } = privateUnderTest.getStackClearer(
|
||||
jasmineUnderTest.getGlobal()
|
||||
);
|
||||
|
||||
@@ -36,7 +36,7 @@ describe('ClearStack', function() {
|
||||
queueMicrotask
|
||||
};
|
||||
|
||||
const clearStack = privateUnderTest.getClearStack(global);
|
||||
const { clearStack } = privateUnderTest.getStackClearer(global);
|
||||
|
||||
for (let i = 0; i < 9; i++) {
|
||||
clearStack(function() {});
|
||||
@@ -73,17 +73,6 @@ describe('ClearStack', function() {
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
describe('when MessageChannel is unavailable', function() {
|
||||
usesQueueMicrotaskWithSetTimeout(function() {
|
||||
return {
|
||||
navigator: {
|
||||
userAgent: 'CERN-LineMode/2.15 libwww/2.17b3',
|
||||
MessageChannel: undefined
|
||||
}
|
||||
};
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('in Node', function() {
|
||||
@@ -104,7 +93,7 @@ describe('ClearStack', function() {
|
||||
...makeGlobal(),
|
||||
MessageChannel: fakeMessageChannel
|
||||
};
|
||||
const clearStack = privateUnderTest.getClearStack(global);
|
||||
const { clearStack } = privateUnderTest.getStackClearer(global);
|
||||
let called = false;
|
||||
|
||||
clearStack(function() {
|
||||
@@ -125,7 +114,7 @@ describe('ClearStack', function() {
|
||||
return fakeChannel;
|
||||
}
|
||||
};
|
||||
const clearStack = privateUnderTest.getClearStack(global);
|
||||
const { clearStack } = privateUnderTest.getStackClearer(global);
|
||||
|
||||
for (let i = 0; i < 9; i++) {
|
||||
clearStack(function() {});
|
||||
@@ -150,7 +139,7 @@ describe('ClearStack', function() {
|
||||
setTimeout,
|
||||
MessageChannel: fakeMessageChannel
|
||||
};
|
||||
const clearStack = privateUnderTest.getClearStack(global);
|
||||
const { clearStack } = privateUnderTest.getStackClearer(global);
|
||||
const fn = jasmine.createSpy('second clearStack function');
|
||||
|
||||
clearStack(function() {
|
||||
@@ -170,7 +159,7 @@ describe('ClearStack', function() {
|
||||
fn();
|
||||
}
|
||||
};
|
||||
const clearStack = privateUnderTest.getClearStack(global);
|
||||
const { clearStack } = privateUnderTest.getStackClearer(global);
|
||||
let called = false;
|
||||
|
||||
clearStack(function() {
|
||||
@@ -180,30 +169,82 @@ describe('ClearStack', function() {
|
||||
expect(called).toBe(true);
|
||||
});
|
||||
|
||||
it('uses setTimeout instead of queueMicrotask every 10 calls to make sure we release the CPU', function() {
|
||||
const queueMicrotask = jasmine.createSpy('queueMicrotask');
|
||||
const setTimeout = jasmine.createSpy('setTimeout');
|
||||
const global = {
|
||||
...makeGlobal(),
|
||||
queueMicrotask,
|
||||
setTimeout
|
||||
};
|
||||
const clearStack = privateUnderTest.getClearStack(global);
|
||||
function hasSetTimeoutBehavior(configure) {
|
||||
it('uses setTimeout instead of queueMicrotask every 10 calls', function() {
|
||||
const queueMicrotask = jasmine.createSpy('queueMicrotask');
|
||||
const setTimeout = jasmine.createSpy('setTimeout');
|
||||
const global = {
|
||||
...makeGlobal(),
|
||||
queueMicrotask,
|
||||
setTimeout
|
||||
};
|
||||
const stackClearer = privateUnderTest.getStackClearer(global);
|
||||
|
||||
for (let i = 0; i < 9; i++) {
|
||||
clearStack(function() {});
|
||||
}
|
||||
if (configure) {
|
||||
configure(stackClearer);
|
||||
}
|
||||
|
||||
expect(queueMicrotask).toHaveBeenCalled();
|
||||
expect(setTimeout).not.toHaveBeenCalled();
|
||||
for (let i = 0; i < 9; i++) {
|
||||
stackClearer.clearStack(function() {});
|
||||
}
|
||||
|
||||
clearStack(function() {});
|
||||
expect(queueMicrotask).toHaveBeenCalledTimes(9);
|
||||
expect(setTimeout).toHaveBeenCalledTimes(1);
|
||||
expect(queueMicrotask).toHaveBeenCalled();
|
||||
expect(setTimeout).not.toHaveBeenCalled();
|
||||
|
||||
clearStack(function() {});
|
||||
expect(queueMicrotask).toHaveBeenCalledTimes(10);
|
||||
expect(setTimeout).toHaveBeenCalledTimes(1);
|
||||
stackClearer.clearStack(function() {});
|
||||
expect(queueMicrotask).toHaveBeenCalledTimes(9);
|
||||
expect(setTimeout).toHaveBeenCalledTimes(1);
|
||||
|
||||
stackClearer.clearStack(function() {});
|
||||
expect(queueMicrotask).toHaveBeenCalledTimes(10);
|
||||
expect(setTimeout).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
}
|
||||
|
||||
hasSetTimeoutBehavior();
|
||||
|
||||
describe('With yield strategy explicitly set to count', function() {
|
||||
hasSetTimeoutBehavior(function(stackClearer) {
|
||||
stackClearer.setSafariYieldStrategy('count');
|
||||
});
|
||||
});
|
||||
|
||||
describe('With yield strategy set to time', function() {
|
||||
beforeEach(function() {
|
||||
jasmine.clock().install();
|
||||
jasmine.clock().mockDate();
|
||||
});
|
||||
|
||||
afterEach(function() {
|
||||
jasmine.clock().uninstall();
|
||||
});
|
||||
|
||||
it('uses setTimeout instead of queueMicrotask every 25 milliseconds', function() {
|
||||
const queueMicrotask = jasmine.createSpy('queueMicrotask');
|
||||
const setTimeout = jasmine.createSpy('setTimeout');
|
||||
const global = {
|
||||
...makeGlobal(),
|
||||
queueMicrotask,
|
||||
setTimeout
|
||||
};
|
||||
const stackClearer = privateUnderTest.getStackClearer(global);
|
||||
stackClearer.setSafariYieldStrategy('time');
|
||||
|
||||
// 10+ counts should not trigger a setTimeout if they happen fast enough
|
||||
jasmine.clock().tick(24);
|
||||
for (let i = 0; i < 11; i++) {
|
||||
stackClearer.clearStack(function() {});
|
||||
}
|
||||
|
||||
expect(queueMicrotask).toHaveBeenCalled();
|
||||
expect(setTimeout).not.toHaveBeenCalled();
|
||||
|
||||
queueMicrotask.calls.reset();
|
||||
jasmine.clock().tick(1);
|
||||
stackClearer.clearStack(function() {});
|
||||
expect(queueMicrotask).not.toHaveBeenCalled();
|
||||
expect(setTimeout).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -215,7 +256,7 @@ describe('ClearStack', function() {
|
||||
fn();
|
||||
}
|
||||
};
|
||||
const clearStack = privateUnderTest.getClearStack(global);
|
||||
const { clearStack } = privateUnderTest.getStackClearer(global);
|
||||
let called = false;
|
||||
|
||||
clearStack(function() {
|
||||
@@ -233,7 +274,7 @@ describe('ClearStack', function() {
|
||||
queueMicrotask,
|
||||
setTimeout
|
||||
};
|
||||
const clearStack = privateUnderTest.getClearStack(global);
|
||||
const { clearStack } = privateUnderTest.getStackClearer(global);
|
||||
|
||||
clearStack(function() {});
|
||||
clearStack(function() {});
|
||||
@@ -311,10 +311,11 @@ describe('SuiteBuilder', function() {
|
||||
suiteBuilder.topSuite.handleException(new Error('nope'));
|
||||
suiteBuilder.parallelReset();
|
||||
|
||||
expect(suiteBuilder.topSuite.result).toEqual({
|
||||
expect(suiteBuilder.topSuite.doneEvent()).toEqual({
|
||||
id: suiteBuilder.topSuite.id,
|
||||
description: 'Jasmine__TopLevel__Suite',
|
||||
fullName: '',
|
||||
status: 'passed',
|
||||
failedExpectations: [],
|
||||
deprecationWarnings: [],
|
||||
duration: null,
|
||||
|
||||
@@ -115,20 +115,20 @@ describe('Suite', function() {
|
||||
const suite = new privateUnderTest.Suite({});
|
||||
|
||||
suite.addExpectationResult(false, {});
|
||||
expect(suite.getResult().status).toBe('failed');
|
||||
expect(suite.doneEvent().status).toBe('failed');
|
||||
});
|
||||
|
||||
it('retrieves a result with updated status', function() {
|
||||
const suite = new privateUnderTest.Suite({});
|
||||
|
||||
expect(suite.getResult().status).toBe('passed');
|
||||
expect(suite.doneEvent().status).toBe('passed');
|
||||
});
|
||||
|
||||
it('retrieves a result with pending status', function() {
|
||||
const suite = new privateUnderTest.Suite({});
|
||||
suite.pend();
|
||||
|
||||
expect(suite.getResult().status).toBe('pending');
|
||||
expect(suite.doneEvent().status).toBe('pending');
|
||||
});
|
||||
|
||||
it('throws an ExpectationFailed when receiving a failed expectation when throwOnExpectationFailure is set', function() {
|
||||
@@ -138,10 +138,10 @@ describe('Suite', function() {
|
||||
|
||||
expect(function() {
|
||||
suite.addExpectationResult(false, { message: 'failed' });
|
||||
}).toThrowError(jasmineUnderTest.private.errors.ExpectationFailed);
|
||||
}).toThrowError(privateUnderTest.errors.ExpectationFailed);
|
||||
|
||||
expect(suite.getResult().status).toBe('failed');
|
||||
expect(suite.result.failedExpectations).toEqual([
|
||||
expect(suite.doneEvent().status).toBe('failed');
|
||||
expect(suite.doneEvent().failedExpectations).toEqual([
|
||||
jasmine.objectContaining({ message: 'failed' })
|
||||
]);
|
||||
});
|
||||
@@ -149,11 +149,9 @@ describe('Suite', function() {
|
||||
it('does not add an additional failure when an expectation fails', function() {
|
||||
const suite = new privateUnderTest.Suite({});
|
||||
|
||||
suite.handleException(
|
||||
new jasmineUnderTest.private.errors.ExpectationFailed()
|
||||
);
|
||||
suite.handleException(new privateUnderTest.errors.ExpectationFailed());
|
||||
|
||||
expect(suite.getResult().failedExpectations).toEqual([]);
|
||||
expect(suite.doneEvent().failedExpectations).toEqual([]);
|
||||
});
|
||||
|
||||
it('forwards late expectation failures to onLateError', function() {
|
||||
@@ -175,7 +173,7 @@ describe('Suite', function() {
|
||||
message: jasmine.stringMatching(/^Error: nope/)
|
||||
})
|
||||
);
|
||||
expect(suite.result.failedExpectations).toEqual([]);
|
||||
expect(suite.doneEvent().failedExpectations).toEqual([]);
|
||||
});
|
||||
|
||||
it('does not forward non-late expectation failures to onLateError', function() {
|
||||
@@ -194,7 +192,7 @@ describe('Suite', function() {
|
||||
suite.addExpectationResult(false, data, true);
|
||||
|
||||
expect(onLateError).not.toHaveBeenCalled();
|
||||
expect(suite.result.failedExpectations.length).toEqual(1);
|
||||
expect(suite.doneEvent().failedExpectations.length).toEqual(1);
|
||||
});
|
||||
|
||||
it('forwards late handleException calls to onLateError', function() {
|
||||
@@ -212,7 +210,7 @@ describe('Suite', function() {
|
||||
message: jasmine.stringMatching(/^Error: oops/)
|
||||
})
|
||||
);
|
||||
expect(suite.result.failedExpectations).toEqual([]);
|
||||
expect(suite.doneEvent().failedExpectations).toEqual([]);
|
||||
});
|
||||
|
||||
it('does not forward non-late handleException calls to onLateError', function() {
|
||||
@@ -225,7 +223,7 @@ describe('Suite', function() {
|
||||
suite.handleException(error);
|
||||
|
||||
expect(onLateError).not.toHaveBeenCalled();
|
||||
expect(suite.result.failedExpectations.length).toEqual(1);
|
||||
expect(suite.doneEvent().failedExpectations.length).toEqual(1);
|
||||
});
|
||||
|
||||
it('clears the reportedDone flag when reset', function() {
|
||||
@@ -248,7 +246,7 @@ describe('Suite', function() {
|
||||
});
|
||||
suite.startTimer();
|
||||
suite.endTimer();
|
||||
expect(suite.getResult().duration).toEqual(77000);
|
||||
expect(suite.doneEvent().duration).toEqual(77000);
|
||||
});
|
||||
|
||||
describe('#sharedUserContext', function() {
|
||||
@@ -306,14 +304,14 @@ describe('Suite', function() {
|
||||
const suite = new privateUnderTest.Suite({});
|
||||
suite.pend();
|
||||
suite.reset();
|
||||
expect(suite.getResult().status).toBe('passed');
|
||||
expect(suite.doneEvent().status).toBe('passed');
|
||||
});
|
||||
|
||||
it('should not reset the "pending" status when the suite was excluded', function() {
|
||||
const suite = new privateUnderTest.Suite({});
|
||||
suite.exclude();
|
||||
suite.reset();
|
||||
expect(suite.getResult().status).toBe('pending');
|
||||
expect(suite.doneEvent().status).toBe('pending');
|
||||
});
|
||||
|
||||
it('should also reset the children', function() {
|
||||
@@ -335,7 +333,7 @@ describe('Suite', function() {
|
||||
|
||||
suite.reset();
|
||||
|
||||
const result = suite.getResult();
|
||||
const result = suite.doneEvent();
|
||||
expect(result.status).toBe('passed');
|
||||
expect(result.failedExpectations).toHaveSize(0);
|
||||
});
|
||||
@@ -409,12 +407,12 @@ describe('Suite', function() {
|
||||
});
|
||||
|
||||
describe('#setSuiteProperty', function() {
|
||||
it('throws if the key is not structured-cloneable', function() {
|
||||
it('throws if the key is not a string', function() {
|
||||
const suite = new privateUnderTest.Suite({});
|
||||
|
||||
expect(function() {
|
||||
suite.setSuiteProperty(new Promise(() => {}), '');
|
||||
}).toThrowError("Key can't be cloned");
|
||||
suite.setSuiteProperty({}, '');
|
||||
}).toThrowError('Key must be a string');
|
||||
});
|
||||
|
||||
it('throws if the value is not structured-cloneable', function() {
|
||||
@@ -424,5 +422,45 @@ describe('Suite', function() {
|
||||
suite.setSuiteProperty('k', new Promise(() => {}));
|
||||
}).toThrowError("Value can't be cloned");
|
||||
});
|
||||
|
||||
it('throws if the value is not JSON-serializable', function() {
|
||||
const suite = new privateUnderTest.Suite({});
|
||||
|
||||
expect(function() {
|
||||
const v = {};
|
||||
v.self = v;
|
||||
suite.setSuiteProperty('k', v);
|
||||
}).toThrowError("Value can't be cloned");
|
||||
});
|
||||
});
|
||||
|
||||
describe('#startedEvent', function() {
|
||||
it('includes only properties that are known before execution', function() {
|
||||
const topSuite = new privateUnderTest.Suite({});
|
||||
const parentSuite = new privateUnderTest.Suite({
|
||||
id: 'suite1',
|
||||
parentSuite: topSuite,
|
||||
description: 'a parent suite'
|
||||
});
|
||||
const suite = new privateUnderTest.Suite({
|
||||
id: 'suite2',
|
||||
parentSuite,
|
||||
reportedParentSuiteId: parentSuite.id,
|
||||
description: 'a suite',
|
||||
filename: 'somefile.js',
|
||||
getPath() {
|
||||
return ['a parent suite', 'a spec'];
|
||||
},
|
||||
queueableFn: { fn: () => {} }
|
||||
});
|
||||
|
||||
expect(suite.startedEvent()).toEqual({
|
||||
id: 'suite2',
|
||||
parentSuiteId: 'suite1',
|
||||
description: 'a suite',
|
||||
fullName: 'a parent suite a suite',
|
||||
filename: 'somefile.js'
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -30,4 +30,8 @@ describe('Timer', function() {
|
||||
expect(timer.elapsed()).toEqual(jasmine.any(Number));
|
||||
});
|
||||
});
|
||||
|
||||
isNonMonkeyPatchableClass(jasmineUnderTest.Timer, function() {
|
||||
return new jasmineUnderTest.Timer();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -6,9 +6,6 @@ describe('TreeProcessor', function() {
|
||||
attrs = attrs || {};
|
||||
this.id = 'node' + nodeNumber++;
|
||||
this.children = attrs.children || [];
|
||||
this.canBeReentered = function() {
|
||||
return !attrs.noReenter;
|
||||
};
|
||||
this.markedPending = attrs.markedPending || false;
|
||||
this.sharedUserContext = function() {
|
||||
return attrs.userContext || {};
|
||||
@@ -195,47 +192,6 @@ describe('TreeProcessor', function() {
|
||||
expect(result.isExcluded(childOfPending)).toEqual(false);
|
||||
});
|
||||
|
||||
it('throws if the specified order would re-enter a node', function() {
|
||||
const leaf1 = new Leaf(),
|
||||
leaf2 = new Leaf(),
|
||||
leaf3 = new Leaf(),
|
||||
reentered = new Node({ noReenter: true, children: [leaf1, leaf2] }),
|
||||
root = new Node({ children: [reentered, leaf3] }),
|
||||
processor = new privateUnderTest.TreeProcessor({
|
||||
tree: root,
|
||||
runnableIds: [leaf1.id, leaf3.id, leaf2.id]
|
||||
});
|
||||
|
||||
expect(function() {
|
||||
processor.processTree();
|
||||
}).toThrowError('Invalid order: would split up a suite');
|
||||
});
|
||||
|
||||
it("does not throw if a node which can't be re-entered is only entered once", function() {
|
||||
const leaf1 = new Leaf(),
|
||||
leaf2 = new Leaf(),
|
||||
leaf3 = new Leaf(),
|
||||
noReentry = new Node({ noReenter: true }),
|
||||
root = new Node({ children: [noReentry] }),
|
||||
processor = new privateUnderTest.TreeProcessor({
|
||||
tree: root,
|
||||
runnableIds: [leaf2.id, leaf1.id, leaf3.id]
|
||||
});
|
||||
|
||||
processor.processTree();
|
||||
});
|
||||
|
||||
it("does not throw if a node which can't be re-entered is run directly", function() {
|
||||
const noReentry = new Node({ noReenter: true }),
|
||||
root = new Node({ children: [noReentry] }),
|
||||
processor = new privateUnderTest.TreeProcessor({
|
||||
tree: root,
|
||||
runnableIds: [root.id]
|
||||
});
|
||||
|
||||
processor.processTree();
|
||||
});
|
||||
|
||||
it('orders children according to orderChildren when specified', function() {
|
||||
const leaf1 = new Leaf();
|
||||
const leaf2 = new Leaf();
|
||||
@@ -290,4 +246,53 @@ describe('TreeProcessor', function() {
|
||||
{ spec: leaf1 }
|
||||
]);
|
||||
});
|
||||
|
||||
describe("The returned ExecutionTree's numExcludedSpecs method", function() {
|
||||
it('counts filtered-out specs', function() {
|
||||
const included = new Leaf();
|
||||
const excluded1 = new Leaf();
|
||||
const excluded2 = new Leaf();
|
||||
const excluded3 = new Leaf();
|
||||
const topSuite = new Node({
|
||||
children: [
|
||||
excluded1,
|
||||
new Node({
|
||||
children: [included, excluded2, new Node({ children: [excluded3] })]
|
||||
})
|
||||
]
|
||||
});
|
||||
const processor = new privateUnderTest.TreeProcessor({
|
||||
tree: topSuite,
|
||||
runnableIds: [topSuite.id],
|
||||
excludeNode(node) {
|
||||
return node.id !== included.id;
|
||||
}
|
||||
});
|
||||
|
||||
const executionTree = processor.processTree();
|
||||
expect(executionTree.numExcludedSpecs()).toEqual(3);
|
||||
});
|
||||
|
||||
it("counts specs that aren't in or descendants of runnableIds", function() {
|
||||
const includedSuite = new Node({
|
||||
children: [new Node({ children: [new Leaf()] }), new Leaf()]
|
||||
});
|
||||
const directlyIncludedSpec = new Leaf();
|
||||
const topSuite = new Node({
|
||||
children: [
|
||||
includedSuite,
|
||||
new Node({
|
||||
children: [new Leaf(), directlyIncludedSpec]
|
||||
})
|
||||
]
|
||||
});
|
||||
const processor = new privateUnderTest.TreeProcessor({
|
||||
tree: topSuite,
|
||||
runnableIds: [includedSuite.id, directlyIncludedSpec.id]
|
||||
});
|
||||
|
||||
const executionTree = processor.processTree();
|
||||
expect(executionTree.numExcludedSpecs()).toEqual(1);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -64,7 +64,7 @@ describe('TreeRunner', function() {
|
||||
expect(currentRunableTracker.currentSpec()).toBeFalsy();
|
||||
expect(runableResources.clearForRunable).toHaveBeenCalledWith(spec.id);
|
||||
expect(reportDispatcher.specDone).toHaveBeenCalledWith(spec.doneEvent());
|
||||
expect(spec.result.duration).toEqual('the elapsed time');
|
||||
expect(spec.doneEvent().duration).toEqual('the elapsed time');
|
||||
expect(spec.reportedDone).toEqual(true);
|
||||
await Promise.resolve();
|
||||
await Promise.resolve();
|
||||
@@ -116,8 +116,8 @@ describe('TreeRunner', function() {
|
||||
expect(specRunQueueArgs.queueableFns[1]).toEqual(queueableFn);
|
||||
queueableFn.fn();
|
||||
|
||||
expect(spec.getResult().status).toEqual('pending');
|
||||
expect(spec.getResult().pendingReason).toEqual('');
|
||||
expect(spec.doneEvent().status).toEqual('pending');
|
||||
expect(spec.doneEvent().pendingReason).toEqual('');
|
||||
});
|
||||
|
||||
it('marks specs pending at runtime with a message', function() {
|
||||
@@ -137,8 +137,8 @@ describe('TreeRunner', function() {
|
||||
expect(specRunQueueArgs.queueableFns[1]).toEqual(queueableFn);
|
||||
queueableFn.fn();
|
||||
|
||||
expect(spec.getResult().status).toEqual('pending');
|
||||
expect(spec.getResult().pendingReason).toEqual('some reason');
|
||||
expect(spec.doneEvent().status).toEqual('pending');
|
||||
expect(spec.doneEvent().pendingReason).toEqual('some reason');
|
||||
});
|
||||
|
||||
it('passes failSpecWithNoExp to Spec#executionFinished', async function() {
|
||||
@@ -218,7 +218,7 @@ describe('TreeRunner', function() {
|
||||
timer.elapsed.and.returnValue('the duration');
|
||||
suiteRunQueueOpts.onComplete();
|
||||
expect(timer.elapsed).toHaveBeenCalled();
|
||||
const result = suite.getResult();
|
||||
const result = suite.doneEvent();
|
||||
expect(result.duration).toEqual('the duration');
|
||||
expect(reportDispatcher.suiteDone).toHaveBeenCalledWith(result);
|
||||
|
||||
|
||||
@@ -1,20 +1,4 @@
|
||||
describe('util', function() {
|
||||
describe('isArray', function() {
|
||||
it('should return true if the argument is an array', function() {
|
||||
expect(privateUnderTest.isArray([])).toBe(true);
|
||||
expect(privateUnderTest.isArray(['a'])).toBe(true);
|
||||
});
|
||||
|
||||
it('should return false if the argument is not an array', function() {
|
||||
expect(privateUnderTest.isArray(undefined)).toBe(false);
|
||||
expect(privateUnderTest.isArray({})).toBe(false);
|
||||
expect(privateUnderTest.isArray(function() {})).toBe(false);
|
||||
expect(privateUnderTest.isArray('foo')).toBe(false);
|
||||
expect(privateUnderTest.isArray(5)).toBe(false);
|
||||
expect(privateUnderTest.isArray(null)).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe('isObject', function() {
|
||||
it('should return true if the argument is an object', function() {
|
||||
expect(privateUnderTest.isObject({})).toBe(true);
|
||||
@@ -179,7 +163,6 @@ describe('util', function() {
|
||||
// Chrome sometimes reports foo.js as foo.js/, so tolerate
|
||||
// a trailing slash if present.
|
||||
expect(privateUnderTest.util.jasmineFile()).toMatch(/util.js\/?$/);
|
||||
expect(jasmine.private.util.jasmineFile()).toMatch(/jasmine.js\/?$/);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
63
spec/core/asymmetric_equality/AllOfSpec.js
Normal file
63
spec/core/asymmetric_equality/AllOfSpec.js
Normal file
@@ -0,0 +1,63 @@
|
||||
describe('AllOf', function() {
|
||||
it('matches a single value', function() {
|
||||
const matchersUtil = new privateUnderTest.MatchersUtil();
|
||||
const allOf = new privateUnderTest.AllOf('foo');
|
||||
|
||||
expect(allOf.asymmetricMatch('foo', matchersUtil)).toBeTrue();
|
||||
});
|
||||
|
||||
it('matches a single matcher', function() {
|
||||
const matchersUtil = new privateUnderTest.MatchersUtil();
|
||||
const allOf = new privateUnderTest.AllOf(
|
||||
new privateUnderTest.StringContaining('oo')
|
||||
);
|
||||
|
||||
expect(allOf.asymmetricMatch('foo', matchersUtil)).toBeTrue();
|
||||
});
|
||||
|
||||
it('matches multiple matchers', function() {
|
||||
const matchersUtil = new privateUnderTest.MatchersUtil();
|
||||
const allOf = new privateUnderTest.AllOf(
|
||||
new privateUnderTest.StringContaining('o'),
|
||||
new privateUnderTest.StringContaining('f')
|
||||
);
|
||||
|
||||
expect(allOf.asymmetricMatch('foo', matchersUtil)).toBeTrue();
|
||||
});
|
||||
|
||||
it('does not match when value does not match', function() {
|
||||
const matchersUtil = new privateUnderTest.MatchersUtil();
|
||||
const allOf = new privateUnderTest.AllOf('bar');
|
||||
|
||||
expect(allOf.asymmetricMatch('foo', matchersUtil)).toBeFalse();
|
||||
});
|
||||
|
||||
it('does not match when any matchers fail', function() {
|
||||
const matchersUtil = new privateUnderTest.MatchersUtil();
|
||||
const allOf = new privateUnderTest.AllOf(
|
||||
new privateUnderTest.StringContaining('o'),
|
||||
new privateUnderTest.StringContaining('x')
|
||||
);
|
||||
|
||||
expect(allOf.asymmetricMatch('foo', matchersUtil)).toBeFalse();
|
||||
});
|
||||
|
||||
it('jasmineToStrings itself', function() {
|
||||
const matcher = new privateUnderTest.AllOf('o');
|
||||
const pp = jasmine.createSpy('pp').and.returnValue('sample');
|
||||
|
||||
expect(matcher.jasmineToString(pp)).toEqual('<jasmine.allOf(sample)>');
|
||||
expect(pp).toHaveBeenCalledWith(['o']);
|
||||
});
|
||||
|
||||
describe('when called without an argument', function() {
|
||||
it('tells the user to pass a constructor argument', function() {
|
||||
expect(function() {
|
||||
new privateUnderTest.AllOf();
|
||||
}).toThrowError(
|
||||
TypeError,
|
||||
'jasmine.allOf() expects at least one argument to be passed.'
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -1,34 +1,5 @@
|
||||
describe('base helpers', function() {
|
||||
describe('isError', function() {
|
||||
it('correctly handles WebSocket events', function(done) {
|
||||
if (typeof jasmine.getGlobal().WebSocket === 'undefined') {
|
||||
pending('Environment does not provide WebSocket');
|
||||
}
|
||||
|
||||
const obj = (function() {
|
||||
const sock = new WebSocket('ws://localhost');
|
||||
let event;
|
||||
sock.onerror = function(e) {
|
||||
event = e;
|
||||
};
|
||||
return function() {
|
||||
return event;
|
||||
};
|
||||
})();
|
||||
let left = 20;
|
||||
|
||||
const int = setInterval(function() {
|
||||
if (obj() || left === 0) {
|
||||
const result = privateUnderTest.isError(obj());
|
||||
expect(result).toBe(false);
|
||||
clearInterval(int);
|
||||
done();
|
||||
} else {
|
||||
left--;
|
||||
}
|
||||
}, 100);
|
||||
});
|
||||
|
||||
it('returns true for an Error subclass', function() {
|
||||
function MyError() {}
|
||||
MyError.prototype = new Error();
|
||||
@@ -199,8 +170,15 @@ describe('base helpers', function() {
|
||||
});
|
||||
|
||||
describe('debugLog', function() {
|
||||
beforeEach(function() {
|
||||
privateUnderTest.currentEnv_ = jasmine.createSpyObj('env', ['debugLog']);
|
||||
});
|
||||
|
||||
afterEach(function() {
|
||||
privateUnderTest.currentEnv_ = null;
|
||||
});
|
||||
|
||||
it("forwards to the current env's debugLog function", function() {
|
||||
spyOn(jasmineUnderTest.getEnv(), 'debugLog');
|
||||
jasmineUnderTest.debugLog('a message');
|
||||
expect(jasmineUnderTest.getEnv().debugLog).toHaveBeenCalledWith(
|
||||
'a message'
|
||||
|
||||
@@ -1114,8 +1114,17 @@ describe('Env integration', function() {
|
||||
global: {
|
||||
setTimeout: globalSetTimeout,
|
||||
clearTimeout: clearTimeout,
|
||||
addEventListener() {},
|
||||
removeEventListener() {},
|
||||
queueMicrotask: function(fn) {
|
||||
queueMicrotask(fn);
|
||||
},
|
||||
// Enough Node globals to make getStackClearer() return the microtask
|
||||
// implementation, which is the easiest to mock
|
||||
process: {
|
||||
versions: {
|
||||
node: ''
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -1179,7 +1188,7 @@ describe('Env integration', function() {
|
||||
global: {
|
||||
setTimeout: function(cb, t) {
|
||||
const stack = new Error().stack;
|
||||
if (stack.indexOf('ClearStack') >= 0) {
|
||||
if (stack.indexOf('clearStack') >= 0) {
|
||||
return realSetTimeout(cb, t);
|
||||
} else {
|
||||
return setTimeout(cb, t);
|
||||
@@ -1188,8 +1197,17 @@ describe('Env integration', function() {
|
||||
clearTimeout: clearTimeout,
|
||||
setInterval: setInterval,
|
||||
clearInterval: clearInterval,
|
||||
addEventListener() {},
|
||||
removeEventListener() {},
|
||||
queueMicrotask: function(fn) {
|
||||
queueMicrotask(fn);
|
||||
},
|
||||
// Enough Node globals to make getStackClearer() return the microtask
|
||||
// implementation, which is the easiest to mock
|
||||
process: {
|
||||
versions: {
|
||||
node: ''
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -1271,9 +1289,7 @@ describe('Env integration', function() {
|
||||
await env.execute();
|
||||
expect(reporter.specDone).toHaveBeenCalledTimes(1);
|
||||
const event = reporter.specDone.calls.argsFor(0)[0];
|
||||
jasmine.debugLog(
|
||||
'Spec result: ' + jasmine.private.basicPrettyPrinter(event)
|
||||
);
|
||||
jasmine.debugLog('Spec result: ' + jasmine.pp(event));
|
||||
expect(event).toEqual(jasmine.objectContaining({ status: 'passed' }));
|
||||
jasmine.clock().tick(1);
|
||||
|
||||
@@ -1539,6 +1555,7 @@ describe('Env integration', function() {
|
||||
|
||||
expect(reporter.jasmineStarted).toHaveBeenCalledWith({
|
||||
totalSpecsDefined: 1,
|
||||
numExcludedSpecs: 0,
|
||||
order: { random: true, seed: jasmine.any(String) },
|
||||
parallel: false
|
||||
});
|
||||
@@ -1574,6 +1591,7 @@ describe('Env integration', function() {
|
||||
|
||||
expect(reporter.jasmineStarted).toHaveBeenCalledWith({
|
||||
totalSpecsDefined: 1,
|
||||
numExcludedSpecs: 0,
|
||||
order: { random: true, seed: jasmine.any(String) },
|
||||
parallel: false
|
||||
});
|
||||
@@ -1630,6 +1648,7 @@ describe('Env integration', function() {
|
||||
|
||||
expect(reporter.jasmineStarted).toHaveBeenCalledWith({
|
||||
totalSpecsDefined: 6,
|
||||
numExcludedSpecs: 3,
|
||||
order: { random: false },
|
||||
parallel: false
|
||||
});
|
||||
@@ -1765,10 +1784,12 @@ describe('Env integration', function() {
|
||||
|
||||
const baseSuiteEvent = {
|
||||
id: jasmine.any(String),
|
||||
filename: jasmine.any(String),
|
||||
filename: jasmine.any(String)
|
||||
};
|
||||
const baseSuiteDoneEvent = {
|
||||
...baseSuiteEvent,
|
||||
failedExpectations: [],
|
||||
deprecationWarnings: [],
|
||||
duration: null,
|
||||
properties: null
|
||||
};
|
||||
|
||||
@@ -1779,7 +1800,7 @@ describe('Env integration', function() {
|
||||
parentSuiteId: null
|
||||
});
|
||||
expect(reporter.suiteDone.calls.argsFor(2)[0]).toEqual({
|
||||
...baseSuiteEvent,
|
||||
...baseSuiteDoneEvent,
|
||||
description: 'A Suite',
|
||||
fullName: 'A Suite',
|
||||
status: 'passed',
|
||||
@@ -1794,7 +1815,7 @@ describe('Env integration', function() {
|
||||
parentSuiteId: suiteFullNameToId['A Suite']
|
||||
});
|
||||
expect(reporter.suiteDone.calls.argsFor(0)[0]).toEqual({
|
||||
...baseSuiteEvent,
|
||||
...baseSuiteDoneEvent,
|
||||
description: 'with a nested suite',
|
||||
status: 'passed',
|
||||
fullName: 'A Suite with a nested suite',
|
||||
@@ -1809,7 +1830,7 @@ describe('Env integration', function() {
|
||||
parentSuiteId: suiteFullNameToId['A Suite']
|
||||
});
|
||||
expect(reporter.suiteDone.calls.argsFor(1)[0]).toEqual({
|
||||
...baseSuiteEvent,
|
||||
...baseSuiteDoneEvent,
|
||||
description: 'with only non-executable specs',
|
||||
status: 'passed',
|
||||
fullName: 'A Suite with only non-executable specs',
|
||||
@@ -2041,6 +2062,7 @@ describe('Env integration', function() {
|
||||
|
||||
expect(reporter.jasmineStarted).toHaveBeenCalledWith({
|
||||
totalSpecsDefined: 1,
|
||||
numExcludedSpecs: 1,
|
||||
order: { random: true, seed: jasmine.any(String) },
|
||||
parallel: false
|
||||
});
|
||||
@@ -2272,6 +2294,34 @@ describe('Env integration', function() {
|
||||
await env.execute();
|
||||
});
|
||||
|
||||
it('Custom matchers set in top-level beforeAll should be available to all specs and suites', async function() {
|
||||
const matchers = {
|
||||
toFoo: function() {}
|
||||
};
|
||||
|
||||
env.beforeAll(function() {
|
||||
env.addMatchers(matchers);
|
||||
});
|
||||
|
||||
env.describe('suite - top-level', function() {
|
||||
env.it('has access to the custom matcher', function() {
|
||||
expect(env.expect().toFoo).toBeDefined();
|
||||
});
|
||||
|
||||
env.describe('suite - nested', function() {
|
||||
env.it('has access to the custom matcher', function() {
|
||||
expect(env.expect().toFoo).toBeDefined();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
env.it('spec - top-level - has access to the custom matcher', function() {
|
||||
expect(env.expect().toFoo).toBeDefined();
|
||||
});
|
||||
|
||||
await env.execute();
|
||||
});
|
||||
|
||||
it('throws an exception if you try to create a spy outside of a runnable', async function() {
|
||||
const obj = { fn: function() {} };
|
||||
let exception;
|
||||
@@ -2773,12 +2823,18 @@ describe('Env integration', function() {
|
||||
},
|
||||
queueMicrotask: function(fn) {
|
||||
queueMicrotask(fn);
|
||||
},
|
||||
// Enough Node globals to make getStackClearer() return the microtask
|
||||
// implementation, which is the easiest to mock
|
||||
process: {
|
||||
versions: {
|
||||
node: ''
|
||||
}
|
||||
}
|
||||
};
|
||||
spyOn(jasmineUnderTest, 'getGlobal').and.returnValue(global);
|
||||
|
||||
env.cleanup_();
|
||||
env = new privateUnderTest.Env();
|
||||
env = new privateUnderTest.Env({ global });
|
||||
const reporter = jasmine.createSpyObj('reporter', [
|
||||
'jasmineDone',
|
||||
'suiteDone',
|
||||
@@ -3226,13 +3282,11 @@ describe('Env integration', function() {
|
||||
});
|
||||
|
||||
it('is resolved after the stack is cleared', function(done) {
|
||||
const realClearStack = privateUnderTest.getClearStack(
|
||||
jasmineUnderTest.getGlobal()
|
||||
),
|
||||
clearStackSpy = jasmine
|
||||
.createSpy('clearStack')
|
||||
.and.callFake(realClearStack);
|
||||
spyOn(privateUnderTest, 'getClearStack').and.returnValue(clearStackSpy);
|
||||
const stackClearer = privateUnderTest.getStackClearer(
|
||||
jasmineUnderTest.getGlobal()
|
||||
);
|
||||
spyOn(stackClearer, 'clearStack').and.callThrough();
|
||||
spyOn(privateUnderTest, 'getStackClearer').and.returnValue(stackClearer);
|
||||
|
||||
// Create a new env that has the clearStack defined above
|
||||
env.cleanup_();
|
||||
@@ -3243,10 +3297,10 @@ describe('Env integration', function() {
|
||||
});
|
||||
|
||||
env.execute(null).then(function() {
|
||||
expect(clearStackSpy).toHaveBeenCalled(); // (many times)
|
||||
clearStackSpy.calls.reset();
|
||||
expect(stackClearer.clearStack).toHaveBeenCalled(); // (many times)
|
||||
stackClearer.clearStack.calls.reset();
|
||||
setTimeout(function() {
|
||||
expect(clearStackSpy).not.toHaveBeenCalled();
|
||||
expect(stackClearer.clearStack).not.toHaveBeenCalled();
|
||||
done();
|
||||
});
|
||||
});
|
||||
@@ -3335,13 +3389,11 @@ describe('Env integration', function() {
|
||||
});
|
||||
|
||||
it('is called after the stack is cleared', async function() {
|
||||
const realClearStack = privateUnderTest.getClearStack(
|
||||
jasmineUnderTest.getGlobal()
|
||||
),
|
||||
clearStackSpy = jasmine
|
||||
.createSpy('clearStack')
|
||||
.and.callFake(realClearStack);
|
||||
spyOn(privateUnderTest, 'getClearStack').and.returnValue(clearStackSpy);
|
||||
const stackClearer = privateUnderTest.getStackClearer(
|
||||
jasmineUnderTest.getGlobal()
|
||||
);
|
||||
spyOn(stackClearer, 'clearStack').and.callThrough();
|
||||
spyOn(privateUnderTest, 'getStackClearer').and.returnValue(stackClearer);
|
||||
|
||||
// Create a new env that has the clearStack defined above
|
||||
env.cleanup_();
|
||||
@@ -3353,12 +3405,12 @@ describe('Env integration', function() {
|
||||
|
||||
await env.execute();
|
||||
|
||||
expect(clearStackSpy).toHaveBeenCalled(); // (many times)
|
||||
clearStackSpy.calls.reset();
|
||||
expect(stackClearer.clearStack).toHaveBeenCalled(); // (many times)
|
||||
stackClearer.clearStack.calls.reset();
|
||||
|
||||
await new Promise(resolve => setTimeout(resolve));
|
||||
|
||||
expect(clearStackSpy).not.toHaveBeenCalled();
|
||||
expect(stackClearer.clearStack).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('is called after QueueRunner timeouts are cleared', async function() {
|
||||
@@ -3792,6 +3844,34 @@ describe('Env integration', function() {
|
||||
});
|
||||
});
|
||||
|
||||
describe('pp', function() {
|
||||
it("pretty-prints using the current runable's custom object formatters", async function() {
|
||||
env.it('a spec', function() {
|
||||
env.addCustomObjectFormatter(function(x) {
|
||||
if (x === 1) {
|
||||
return 'hi!';
|
||||
}
|
||||
});
|
||||
env.expect(env.pp(1)).toEqual('hi!');
|
||||
});
|
||||
|
||||
const reporter = jasmine.createSpyObj('reporter', ['specDone']);
|
||||
env.addReporter(reporter);
|
||||
|
||||
await env.execute();
|
||||
|
||||
expect(reporter.specDone).toHaveBeenCalledWith(
|
||||
jasmine.objectContaining({
|
||||
failedExpectations: []
|
||||
})
|
||||
);
|
||||
});
|
||||
|
||||
it('works when there is no current runable', function() {
|
||||
expect(env.pp({ some: 'thing' })).toEqual("Object({ some: 'thing' })");
|
||||
});
|
||||
});
|
||||
|
||||
it('forbids duplicates when forbidDuplicateNames is true', function() {
|
||||
env.configure({ forbidDuplicateNames: true });
|
||||
env.it('a spec');
|
||||
|
||||
@@ -11,8 +11,8 @@ describe('Global error handling (integration)', function() {
|
||||
env.cleanup_();
|
||||
});
|
||||
|
||||
it('reports errors that occur during loading', async function() {
|
||||
const global = {
|
||||
function mockGlobal() {
|
||||
return {
|
||||
...browserEventMethods(),
|
||||
setTimeout: function(fn, delay) {
|
||||
return setTimeout(fn, delay);
|
||||
@@ -23,12 +23,21 @@ describe('Global error handling (integration)', function() {
|
||||
queueMicrotask: function(fn) {
|
||||
queueMicrotask(fn);
|
||||
},
|
||||
onerror: function() {}
|
||||
onerror: function() {},
|
||||
// Enough Node globals to make getStackClearer() return the microtask
|
||||
// implementation, which is the easiest to mock
|
||||
process: {
|
||||
versions: {
|
||||
node: ''
|
||||
}
|
||||
}
|
||||
};
|
||||
spyOn(jasmineUnderTest, 'getGlobal').and.returnValue(global);
|
||||
}
|
||||
|
||||
it('reports errors that occur during loading', async function() {
|
||||
const global = mockGlobal();
|
||||
env.cleanup_();
|
||||
env = new privateUnderTest.Env();
|
||||
env = new privateUnderTest.Env({ global });
|
||||
const reporter = jasmine.createSpyObj('reporter', [
|
||||
'jasmineDone',
|
||||
'suiteDone',
|
||||
@@ -53,38 +62,26 @@ describe('Global error handling (integration)', function() {
|
||||
passed: false,
|
||||
globalErrorType: 'load',
|
||||
message: 'Uncaught SyntaxError: Unexpected end of input',
|
||||
stack: undefined,
|
||||
filename: 'borkenSpec.js',
|
||||
lineno: 42
|
||||
lineno: 42,
|
||||
matcherName: undefined,
|
||||
stack: jasmine.any(String)
|
||||
},
|
||||
{
|
||||
passed: false,
|
||||
globalErrorType: 'load',
|
||||
message: 'ENOCHEESE',
|
||||
stack: error.stack,
|
||||
filename: undefined,
|
||||
lineno: undefined
|
||||
matcherName: undefined,
|
||||
stack: jasmine.any(String)
|
||||
}
|
||||
]);
|
||||
});
|
||||
|
||||
describe('If suppressLoadErrors: true was passed', function() {
|
||||
it('does not install a global error handler during loading', async function() {
|
||||
const global = mockGlobal();
|
||||
const originalOnerror = jasmine.createSpy('original onerror');
|
||||
const global = {
|
||||
...browserEventMethods(),
|
||||
setTimeout: function(fn, delay) {
|
||||
return setTimeout(fn, delay);
|
||||
},
|
||||
clearTimeout: function(fn, delay) {
|
||||
clearTimeout(fn, delay);
|
||||
},
|
||||
queueMicrotask: function(fn) {
|
||||
queueMicrotask(fn);
|
||||
},
|
||||
onerror: originalOnerror
|
||||
};
|
||||
spyOn(jasmineUnderTest, 'getGlobal').and.returnValue(global);
|
||||
global.onerror = originalOnerror;
|
||||
const globalErrors = new privateUnderTest.GlobalErrors(global);
|
||||
const onerror = jasmine.createSpy('onerror');
|
||||
globalErrors.pushListener(onerror);
|
||||
@@ -92,6 +89,7 @@ describe('Global error handling (integration)', function() {
|
||||
env.cleanup_();
|
||||
env = new privateUnderTest.Env({
|
||||
suppressLoadErrors: true,
|
||||
global,
|
||||
GlobalErrors: function() {
|
||||
return globalErrors;
|
||||
}
|
||||
@@ -115,21 +113,9 @@ describe('Global error handling (integration)', function() {
|
||||
|
||||
describe('Handling unhandled exceptions', function() {
|
||||
it('routes unhandled exceptions to the running spec', async function() {
|
||||
const global = {
|
||||
...browserEventMethods(),
|
||||
setTimeout: function(fn, delay) {
|
||||
return setTimeout(fn, delay);
|
||||
},
|
||||
clearTimeout: function(fn, delay) {
|
||||
clearTimeout(fn, delay);
|
||||
},
|
||||
queueMicrotask: function(fn) {
|
||||
queueMicrotask(fn);
|
||||
}
|
||||
};
|
||||
spyOn(jasmineUnderTest, 'getGlobal').and.returnValue(global);
|
||||
const global = mockGlobal();
|
||||
env.cleanup_();
|
||||
env = new privateUnderTest.Env();
|
||||
env = new privateUnderTest.Env({ global });
|
||||
const reporter = jasmine.createSpyObj('fakeReporter', [
|
||||
'specDone',
|
||||
'suiteDone'
|
||||
@@ -156,24 +142,12 @@ describe('Global error handling (integration)', function() {
|
||||
|
||||
describe('When the most recently running spec has reported specDone', function() {
|
||||
it('routes unhandled exceptions to an ancestor suite', async function() {
|
||||
const global = {
|
||||
...browserEventMethods(),
|
||||
setTimeout: function(fn, delay) {
|
||||
return setTimeout(fn, delay);
|
||||
},
|
||||
clearTimeout: function(fn) {
|
||||
clearTimeout(fn);
|
||||
},
|
||||
queueMicrotask: function(fn) {
|
||||
queueMicrotask(fn);
|
||||
}
|
||||
};
|
||||
spyOn(jasmineUnderTest, 'getGlobal').and.returnValue(global);
|
||||
|
||||
const realClearStack = privateUnderTest.getClearStack(global);
|
||||
const global = mockGlobal();
|
||||
const stackClearer = privateUnderTest.getStackClearer(global);
|
||||
const realClearStack = stackClearer.clearStack;
|
||||
const clearStackCallbacks = {};
|
||||
let clearStackCallCount = 0;
|
||||
spyOn(privateUnderTest, 'getClearStack').and.returnValue(function(fn) {
|
||||
spyOn(stackClearer, 'clearStack').and.callFake(function(fn) {
|
||||
clearStackCallCount++;
|
||||
|
||||
if (clearStackCallbacks[clearStackCallCount]) {
|
||||
@@ -182,9 +156,12 @@ describe('Global error handling (integration)', function() {
|
||||
|
||||
realClearStack(fn);
|
||||
});
|
||||
spyOn(privateUnderTest, 'getStackClearer').and.returnValue(
|
||||
stackClearer
|
||||
);
|
||||
|
||||
env.cleanup_();
|
||||
env = new privateUnderTest.Env();
|
||||
env = new privateUnderTest.Env({ global });
|
||||
|
||||
let suiteErrors = [];
|
||||
env.addReporter({
|
||||
@@ -220,21 +197,9 @@ describe('Global error handling (integration)', function() {
|
||||
});
|
||||
|
||||
it('routes unhandled exceptions to the running suite', async function() {
|
||||
const global = {
|
||||
...browserEventMethods(),
|
||||
setTimeout: function(fn, delay) {
|
||||
return setTimeout(fn, delay);
|
||||
},
|
||||
clearTimeout: function(fn, delay) {
|
||||
clearTimeout(fn, delay);
|
||||
},
|
||||
queueMicrotask: function(fn) {
|
||||
queueMicrotask(fn);
|
||||
}
|
||||
};
|
||||
spyOn(jasmineUnderTest, 'getGlobal').and.returnValue(global);
|
||||
const global = mockGlobal();
|
||||
env.cleanup_();
|
||||
env = new privateUnderTest.Env();
|
||||
env = new privateUnderTest.Env({ global });
|
||||
const reporter = jasmine.createSpyObj('fakeReporter', [
|
||||
'specDone',
|
||||
'suiteDone'
|
||||
@@ -273,24 +238,12 @@ describe('Global error handling (integration)', function() {
|
||||
|
||||
describe('When the most recently suite has reported suiteDone', function() {
|
||||
it('routes unhandled exceptions to an ancestor suite', async function() {
|
||||
const global = {
|
||||
...browserEventMethods(),
|
||||
setTimeout: function(fn, delay) {
|
||||
return setTimeout(fn, delay);
|
||||
},
|
||||
clearTimeout: function(fn, delay) {
|
||||
clearTimeout(fn, delay);
|
||||
},
|
||||
queueMicrotask: function(fn) {
|
||||
queueMicrotask(fn);
|
||||
}
|
||||
};
|
||||
spyOn(jasmineUnderTest, 'getGlobal').and.returnValue(global);
|
||||
|
||||
const realClearStack = privateUnderTest.getClearStack(global);
|
||||
const global = mockGlobal();
|
||||
const stackClearer = privateUnderTest.getStackClearer(global);
|
||||
const realClearStack = stackClearer.clearStack;
|
||||
const clearStackCallbacks = {};
|
||||
let clearStackCallCount = 0;
|
||||
spyOn(privateUnderTest, 'getClearStack').and.returnValue(function(fn) {
|
||||
spyOn(stackClearer, 'clearStack').and.callFake(function(fn) {
|
||||
clearStackCallCount++;
|
||||
|
||||
if (clearStackCallbacks[clearStackCallCount]) {
|
||||
@@ -299,9 +252,12 @@ describe('Global error handling (integration)', function() {
|
||||
|
||||
realClearStack(fn);
|
||||
});
|
||||
spyOn(privateUnderTest, 'getStackClearer').and.returnValue(
|
||||
stackClearer
|
||||
);
|
||||
|
||||
env.cleanup_();
|
||||
env = new privateUnderTest.Env();
|
||||
env = new privateUnderTest.Env({ global });
|
||||
|
||||
let suiteErrors = [];
|
||||
env.addReporter({
|
||||
@@ -341,21 +297,9 @@ describe('Global error handling (integration)', function() {
|
||||
|
||||
describe('When the env has started reporting jasmineDone', function() {
|
||||
it('logs the error to the console', async function() {
|
||||
const global = {
|
||||
...browserEventMethods(),
|
||||
setTimeout: function(fn, delay) {
|
||||
return setTimeout(fn, delay);
|
||||
},
|
||||
clearTimeout: function(fn, delay) {
|
||||
clearTimeout(fn, delay);
|
||||
},
|
||||
queueMicrotask: function(fn) {
|
||||
queueMicrotask(fn);
|
||||
}
|
||||
};
|
||||
spyOn(jasmineUnderTest, 'getGlobal').and.returnValue(global);
|
||||
const global = mockGlobal();
|
||||
env.cleanup_();
|
||||
env = new privateUnderTest.Env();
|
||||
env = new privateUnderTest.Env({ global });
|
||||
|
||||
spyOn(console, 'error');
|
||||
|
||||
@@ -384,26 +328,14 @@ describe('Global error handling (integration)', function() {
|
||||
});
|
||||
|
||||
it('routes all errors that occur during stack clearing somewhere', async function() {
|
||||
const global = {
|
||||
...browserEventMethods(),
|
||||
setTimeout: function(fn, delay) {
|
||||
return setTimeout(fn, delay);
|
||||
},
|
||||
clearTimeout: function(fn) {
|
||||
clearTimeout(fn);
|
||||
},
|
||||
queueMicrotask: function(fn) {
|
||||
queueMicrotask(fn);
|
||||
}
|
||||
};
|
||||
spyOn(jasmineUnderTest, 'getGlobal').and.returnValue(global);
|
||||
|
||||
const realClearStack = privateUnderTest.getClearStack(global);
|
||||
const global = mockGlobal();
|
||||
const stackClearer = privateUnderTest.getStackClearer(global);
|
||||
const realClearStack = stackClearer.clearStack;
|
||||
let clearStackCallCount = 0;
|
||||
let jasmineDone = false;
|
||||
const expectedErrors = [];
|
||||
const expectedErrorsAfterJasmineDone = [];
|
||||
spyOn(privateUnderTest, 'getClearStack').and.returnValue(function(fn) {
|
||||
spyOn(stackClearer, 'clearStack').and.callFake(function(fn) {
|
||||
clearStackCallCount++;
|
||||
const msg = `Error in clearStack #${clearStackCallCount}`;
|
||||
|
||||
@@ -416,10 +348,11 @@ describe('Global error handling (integration)', function() {
|
||||
dispatchErrorEvent(global, 'error', { error: msg });
|
||||
realClearStack(fn);
|
||||
});
|
||||
spyOn(privateUnderTest, 'getStackClearer').and.returnValue(stackClearer);
|
||||
spyOn(console, 'error');
|
||||
|
||||
env.cleanup_();
|
||||
env = new privateUnderTest.Env();
|
||||
env = new privateUnderTest.Env({ global });
|
||||
|
||||
const receivedErrors = [];
|
||||
function logErrors(event) {
|
||||
@@ -459,21 +392,9 @@ describe('Global error handling (integration)', function() {
|
||||
|
||||
describe('Handling unhandled promise rejections', function() {
|
||||
it('routes unhandled promise rejections to the running spec', async function() {
|
||||
const global = {
|
||||
...browserEventMethods(),
|
||||
setTimeout: function(fn, delay) {
|
||||
return setTimeout(fn, delay);
|
||||
},
|
||||
clearTimeout: function(fn, delay) {
|
||||
clearTimeout(fn, delay);
|
||||
},
|
||||
queueMicrotask: function(fn) {
|
||||
queueMicrotask(fn);
|
||||
}
|
||||
};
|
||||
spyOn(jasmineUnderTest, 'getGlobal').and.returnValue(global);
|
||||
const global = mockGlobal();
|
||||
env.cleanup_();
|
||||
env = new privateUnderTest.Env();
|
||||
env = new privateUnderTest.Env({ global });
|
||||
const reporter = jasmine.createSpyObj('fakeReporter', [
|
||||
'specDone',
|
||||
'suiteDone'
|
||||
@@ -502,24 +423,12 @@ describe('Global error handling (integration)', function() {
|
||||
|
||||
describe('When the most recently running spec has reported specDone', function() {
|
||||
it('routes unhandled promise rejections to an ancestor suite', async function() {
|
||||
const global = {
|
||||
...browserEventMethods(),
|
||||
setTimeout: function(fn, delay) {
|
||||
return setTimeout(fn, delay);
|
||||
},
|
||||
clearTimeout: function(fn) {
|
||||
clearTimeout(fn);
|
||||
},
|
||||
queueMicrotask: function(fn) {
|
||||
queueMicrotask(fn);
|
||||
}
|
||||
};
|
||||
spyOn(jasmineUnderTest, 'getGlobal').and.returnValue(global);
|
||||
|
||||
const realClearStack = privateUnderTest.getClearStack(global);
|
||||
const global = mockGlobal();
|
||||
const stackClearer = privateUnderTest.getStackClearer(global);
|
||||
const realClearStack = stackClearer.clearStack;
|
||||
const clearStackCallbacks = {};
|
||||
let clearStackCallCount = 0;
|
||||
spyOn(privateUnderTest, 'getClearStack').and.returnValue(function(fn) {
|
||||
spyOn(stackClearer, 'clearStack').and.callFake(function(fn) {
|
||||
clearStackCallCount++;
|
||||
|
||||
if (clearStackCallbacks[clearStackCallCount]) {
|
||||
@@ -528,9 +437,12 @@ describe('Global error handling (integration)', function() {
|
||||
|
||||
realClearStack(fn);
|
||||
});
|
||||
spyOn(privateUnderTest, 'getStackClearer').and.returnValue(
|
||||
stackClearer
|
||||
);
|
||||
|
||||
env.cleanup_();
|
||||
env = new privateUnderTest.Env();
|
||||
env = new privateUnderTest.Env({ global });
|
||||
|
||||
let suiteErrors = [];
|
||||
env.addReporter({
|
||||
@@ -566,21 +478,9 @@ describe('Global error handling (integration)', function() {
|
||||
});
|
||||
|
||||
it('routes unhandled promise rejections to the running suite', async function() {
|
||||
const global = {
|
||||
...browserEventMethods(),
|
||||
setTimeout: function(fn, delay) {
|
||||
return setTimeout(fn, delay);
|
||||
},
|
||||
clearTimeout: function(fn, delay) {
|
||||
clearTimeout(fn, delay);
|
||||
},
|
||||
queueMicrotask: function(fn) {
|
||||
queueMicrotask(fn);
|
||||
}
|
||||
};
|
||||
spyOn(jasmineUnderTest, 'getGlobal').and.returnValue(global);
|
||||
const global = mockGlobal();
|
||||
env.cleanup_();
|
||||
env = new privateUnderTest.Env();
|
||||
env = new privateUnderTest.Env({ global });
|
||||
const reporter = jasmine.createSpyObj('fakeReporter', [
|
||||
'specDone',
|
||||
'suiteDone'
|
||||
@@ -621,24 +521,12 @@ describe('Global error handling (integration)', function() {
|
||||
|
||||
describe('When the most recently suite has reported suiteDone', function() {
|
||||
it('routes unhandled promise rejections to an ancestor suite', async function() {
|
||||
const global = {
|
||||
...browserEventMethods(),
|
||||
setTimeout: function(fn, delay) {
|
||||
return setTimeout(fn, delay);
|
||||
},
|
||||
clearTimeout: function(fn, delay) {
|
||||
clearTimeout(fn, delay);
|
||||
},
|
||||
queueMicrotask: function(fn) {
|
||||
queueMicrotask(fn);
|
||||
}
|
||||
};
|
||||
spyOn(jasmineUnderTest, 'getGlobal').and.returnValue(global);
|
||||
|
||||
const realClearStack = privateUnderTest.getClearStack(global);
|
||||
const global = mockGlobal();
|
||||
const stackClearer = privateUnderTest.getStackClearer(global);
|
||||
const realClearStack = stackClearer.clearStack;
|
||||
const clearStackCallbacks = {};
|
||||
let clearStackCallCount = 0;
|
||||
spyOn(privateUnderTest, 'getClearStack').and.returnValue(function(fn) {
|
||||
spyOn(stackClearer, 'clearStack').and.callFake(function(fn) {
|
||||
clearStackCallCount++;
|
||||
|
||||
if (clearStackCallbacks[clearStackCallCount]) {
|
||||
@@ -647,9 +535,12 @@ describe('Global error handling (integration)', function() {
|
||||
|
||||
realClearStack(fn);
|
||||
});
|
||||
spyOn(privateUnderTest, 'getStackClearer').and.returnValue(
|
||||
stackClearer
|
||||
);
|
||||
|
||||
env.cleanup_();
|
||||
env = new privateUnderTest.Env();
|
||||
env = new privateUnderTest.Env({ global });
|
||||
|
||||
let suiteErrors = [];
|
||||
env.addReporter({
|
||||
@@ -689,21 +580,9 @@ describe('Global error handling (integration)', function() {
|
||||
|
||||
describe('When the env has started reporting jasmineDone', function() {
|
||||
it('logs the rejection to the console', async function() {
|
||||
const global = {
|
||||
...browserEventMethods(),
|
||||
setTimeout: function(fn, delay) {
|
||||
return setTimeout(fn, delay);
|
||||
},
|
||||
clearTimeout: function(fn, delay) {
|
||||
clearTimeout(fn, delay);
|
||||
},
|
||||
queueMicrotask: function(fn) {
|
||||
queueMicrotask(fn);
|
||||
}
|
||||
};
|
||||
spyOn(jasmineUnderTest, 'getGlobal').and.returnValue(global);
|
||||
const global = mockGlobal();
|
||||
env.cleanup_();
|
||||
env = new privateUnderTest.Env();
|
||||
env = new privateUnderTest.Env({ global });
|
||||
|
||||
spyOn(console, 'error');
|
||||
|
||||
@@ -734,26 +613,14 @@ describe('Global error handling (integration)', function() {
|
||||
});
|
||||
|
||||
it('routes all unhandled promise rejections that occur during stack clearing somewhere', async function() {
|
||||
const global = {
|
||||
...browserEventMethods(),
|
||||
setTimeout: function(fn, delay) {
|
||||
return setTimeout(fn, delay);
|
||||
},
|
||||
clearTimeout: function(fn) {
|
||||
clearTimeout(fn);
|
||||
},
|
||||
queueMicrotask: function(fn) {
|
||||
queueMicrotask(fn);
|
||||
}
|
||||
};
|
||||
spyOn(jasmineUnderTest, 'getGlobal').and.returnValue(global);
|
||||
|
||||
const realClearStack = privateUnderTest.getClearStack(global);
|
||||
const global = mockGlobal();
|
||||
const stackClearer = privateUnderTest.getStackClearer(global);
|
||||
const realClearStack = stackClearer.clearStack;
|
||||
let clearStackCallCount = 0;
|
||||
let jasmineDone = false;
|
||||
const expectedErrors = [];
|
||||
const expectedErrorsAfterJasmineDone = [];
|
||||
spyOn(privateUnderTest, 'getClearStack').and.returnValue(function(fn) {
|
||||
spyOn(stackClearer, 'clearStack').and.callFake(function(fn) {
|
||||
clearStackCallCount++;
|
||||
const reason = `Error in clearStack #${clearStackCallCount}`;
|
||||
const expectedMsg = `Unhandled promise rejection: ${reason} thrown`;
|
||||
@@ -767,10 +634,11 @@ describe('Global error handling (integration)', function() {
|
||||
dispatchErrorEvent(global, 'unhandledrejection', { reason });
|
||||
realClearStack(fn);
|
||||
});
|
||||
spyOn(privateUnderTest, 'getStackClearer').and.returnValue(stackClearer);
|
||||
spyOn(console, 'error');
|
||||
|
||||
env.cleanup_();
|
||||
env = new privateUnderTest.Env();
|
||||
env = new privateUnderTest.Env({ global });
|
||||
|
||||
const receivedErrors = [];
|
||||
function logErrors(event) {
|
||||
@@ -819,21 +687,9 @@ describe('Global error handling (integration)', function() {
|
||||
let global, reporter;
|
||||
|
||||
beforeEach(function() {
|
||||
global = {
|
||||
...browserEventMethods(),
|
||||
setTimeout: function(fn, delay) {
|
||||
return setTimeout(fn, delay);
|
||||
},
|
||||
clearTimeout: function(fn, delay) {
|
||||
clearTimeout(fn, delay);
|
||||
},
|
||||
queueMicrotask: function(fn) {
|
||||
queueMicrotask(fn);
|
||||
}
|
||||
};
|
||||
spyOn(jasmineUnderTest, 'getGlobal').and.returnValue(global);
|
||||
global = mockGlobal();
|
||||
env.cleanup_();
|
||||
env = new privateUnderTest.Env();
|
||||
env = new privateUnderTest.Env({ global });
|
||||
env.configure({ detectLateRejectionHandling: true });
|
||||
|
||||
reporter = jasmine.createSpyObj('fakeReporter', [
|
||||
@@ -966,21 +822,8 @@ describe('Global error handling (integration)', function() {
|
||||
|
||||
describe("When the unhandled rejection event doesn't have a promise", function() {
|
||||
it('reports the rejection', async function() {
|
||||
const global = {
|
||||
...browserEventMethods(),
|
||||
setTimeout: function(fn, delay) {
|
||||
return setTimeout(fn, delay);
|
||||
},
|
||||
clearTimeout: function(fn, delay) {
|
||||
clearTimeout(fn, delay);
|
||||
},
|
||||
queueMicrotask: function(fn) {
|
||||
queueMicrotask(fn);
|
||||
}
|
||||
};
|
||||
spyOn(jasmineUnderTest, 'getGlobal').and.returnValue(global);
|
||||
env.cleanup_();
|
||||
env = new privateUnderTest.Env();
|
||||
const global = mockGlobal();
|
||||
env = new privateUnderTest.Env({ global });
|
||||
env.configure({ detectLateRejectionHandling: true });
|
||||
const reporter = jasmine.createSpyObj('fakeReporter', [
|
||||
'specDone',
|
||||
@@ -1012,21 +855,9 @@ describe('Global error handling (integration)', function() {
|
||||
});
|
||||
|
||||
it('works when the suite is run multiple times', async function() {
|
||||
const global = {
|
||||
...browserEventMethods(),
|
||||
setTimeout: function(fn, delay) {
|
||||
return setTimeout(fn, delay);
|
||||
},
|
||||
clearTimeout: function(fn, delay) {
|
||||
clearTimeout(fn, delay);
|
||||
},
|
||||
queueMicrotask: function(fn) {
|
||||
queueMicrotask(fn);
|
||||
}
|
||||
};
|
||||
spyOn(jasmineUnderTest, 'getGlobal').and.returnValue(global);
|
||||
const global = mockGlobal();
|
||||
env.cleanup_();
|
||||
env = new privateUnderTest.Env();
|
||||
env = new privateUnderTest.Env({ global });
|
||||
env.configure({ autoCleanClosures: false });
|
||||
const reporter = jasmine.createSpyObj('fakeReporter', ['specDone']);
|
||||
|
||||
|
||||
@@ -13,23 +13,71 @@ describe('The jasmine namespace', function() {
|
||||
expect(setDifference(actualKeys, expectedKeys())).toEqual(new Set());
|
||||
});
|
||||
|
||||
describe('Preventing monkey patching', function() {
|
||||
const mutable = mutableKeys();
|
||||
|
||||
for (const key of expectedKeys()) {
|
||||
if (mutable.includes(key)) {
|
||||
it(`allows overwriting of jasmine.${key}`, function() {
|
||||
const existingVal = jasmineUnderTest[key];
|
||||
|
||||
try {
|
||||
jasmineUnderTest[key] = 'new value';
|
||||
expect(jasmineUnderTest[key]).toEqual('new value');
|
||||
} finally {
|
||||
jasmineUnderTest[key] = existingVal;
|
||||
}
|
||||
});
|
||||
} else {
|
||||
it(`prevents overwriting of jasmine.${key}`, function() {
|
||||
const existingVal = jasmineUnderTest[key];
|
||||
|
||||
try {
|
||||
jasmineUnderTest[key] = 'monkey patch';
|
||||
expect(jasmineUnderTest[key]).toBe(existingVal);
|
||||
} finally {
|
||||
// This will be a no-op if the test passed, but will prevent state
|
||||
// leakage if it failed.
|
||||
jasmineUnderTest[key] = existingVal;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
it('allows additions', function() {
|
||||
try {
|
||||
jasmineUnderTest.Ajax = 'it worked';
|
||||
expect(jasmineUnderTest.Ajax).toEqual('it worked');
|
||||
} finally {
|
||||
delete jasmineUnderTest.Ajax;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
function mutableKeys() {
|
||||
return [
|
||||
'MAX_PRETTY_PRINT_ARRAY_LENGTH',
|
||||
'MAX_PRETTY_PRINT_CHARS',
|
||||
'MAX_PRETTY_PRINT_DEPTH',
|
||||
'DEFAULT_TIMEOUT_INTERVAL'
|
||||
];
|
||||
}
|
||||
|
||||
function expectedKeys() {
|
||||
// Does not include properties added by requireInterface(), since that isn't
|
||||
// called by defineJasmineUnderTest.js/nodeDefineJasmineUnderTest.js.
|
||||
const result = new Set([
|
||||
'MAX_PRETTY_PRINT_ARRAY_LENGTH',
|
||||
'MAX_PRETTY_PRINT_CHARS',
|
||||
'MAX_PRETTY_PRINT_DEPTH',
|
||||
...mutableKeys(),
|
||||
'debugLog',
|
||||
'getEnv',
|
||||
'isSpy',
|
||||
'ParallelReportDispatcher',
|
||||
'private',
|
||||
'spyOnGlobalErrorsAsync',
|
||||
'Timer',
|
||||
'version',
|
||||
|
||||
// Asymmetric equality testers
|
||||
'allOf',
|
||||
'any',
|
||||
'anything',
|
||||
'arrayContaining',
|
||||
@@ -52,9 +100,8 @@ describe('The jasmine namespace', function() {
|
||||
|
||||
if (typeof window !== 'undefined') {
|
||||
// jasmine-html.js
|
||||
result.add('HtmlReporter');
|
||||
result.add('HtmlSpecFilter');
|
||||
result.add('HtmlExactSpecFilter');
|
||||
result.add('HtmlReporterV2');
|
||||
result.add('HtmlReporterV2Urls');
|
||||
result.add('QueryString');
|
||||
}
|
||||
|
||||
|
||||
@@ -768,7 +768,16 @@ describe('matchersUtil', function() {
|
||||
a2[0] = 1;
|
||||
const diffBuilder = new privateUnderTest.DiffBuilder();
|
||||
expect(matchersUtil.equals(a1, a2, diffBuilder)).toBe(false);
|
||||
jasmine.debugLog('Diff: ' + diffBuilder.getMessage());
|
||||
jasmine.debugLog(
|
||||
'a1 keys: ' + jasmine.pp(privateUnderTest.MatchersUtil.keys(a1))
|
||||
);
|
||||
jasmine.debugLog(
|
||||
'a2 keys: ' + jasmine.pp(privateUnderTest.MatchersUtil.keys(a2))
|
||||
);
|
||||
jasmine.debugLog('a1 length:' + a1.length);
|
||||
jasmine.debugLog('a2 length:' + a2.length);
|
||||
jasmine.debugLog('a1[0]: ' + a1[0]);
|
||||
jasmine.debugLog('a2[0]: ' + a2[0]);
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
5
spec/helpers/callerFilenameShim.js
Normal file
5
spec/helpers/callerFilenameShim.js
Normal file
@@ -0,0 +1,5 @@
|
||||
(function() {
|
||||
specHelpers.callerFilenameShim = function(fn) {
|
||||
return fn();
|
||||
};
|
||||
})();
|
||||
@@ -1,9 +1,11 @@
|
||||
(function() {
|
||||
// By the time onload is called, jasmineRequire will be redefined to point
|
||||
// to the Jasmine source files (and not jasmine.js). So re-require
|
||||
window.jasmineUnderTest = jasmineRequire.core(jasmineRequire);
|
||||
jasmineRequire.html(jasmineUnderTest);
|
||||
// By the time onload is called, getJasmineRequireObj() and
|
||||
// getJasmineHtmlRequireObj() will be redefined to point
|
||||
// to the Jasmine source files (and not jasmine.js). So re-require.
|
||||
const jasmineRequire = getJasmineRequireObj();
|
||||
const coreUnderTest = jasmineRequire.core(jasmineRequire);
|
||||
window.jasmineUnderTest = coreUnderTest.jasmine;
|
||||
window.privateUnderTest = coreUnderTest.private;
|
||||
|
||||
// Alias the private namespace so tests can be less verbose
|
||||
window.privateUnderTest = window.jasmineUnderTest.private;
|
||||
getJasmineHtmlRequireObj().html(jasmineUnderTest, privateUnderTest);
|
||||
})();
|
||||
|
||||
@@ -42,9 +42,9 @@
|
||||
: 'Expected runnable "' +
|
||||
fullName +
|
||||
'" to have failures ' +
|
||||
jasmine.private.basicPrettyPrinter(expectedFailures) +
|
||||
jasmine.pp(expectedFailures) +
|
||||
' but it had ' +
|
||||
jasmine.private.basicPrettyPrinter(foundFailures)
|
||||
jasmine.pp(foundFailures)
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
67
spec/helpers/monkeyPatchingSpecs.js
Normal file
67
spec/helpers/monkeyPatchingSpecs.js
Normal file
@@ -0,0 +1,67 @@
|
||||
globalThis.isNonMonkeyPatchableClass = function(ctor, makeInstance) {
|
||||
describe('Monkey patching prevention', function() {
|
||||
it(`prevents overwriting ${ctor.name}.prototype`, function() {
|
||||
const existing = ctor.prototype;
|
||||
|
||||
try {
|
||||
ctor.prototype = {};
|
||||
expect(ctor.prototype).toBe(existing);
|
||||
} finally {
|
||||
// This will be a no-op if the test passed, but will prevent state
|
||||
// leakage if it failed.
|
||||
ctor.prototype = existing;
|
||||
}
|
||||
});
|
||||
|
||||
it("prevents overwriting an instance's prototype", function() {
|
||||
const instance = makeInstance();
|
||||
let thrown;
|
||||
|
||||
// The message varies from browser to browser, so we can't rely on it
|
||||
try {
|
||||
instance.__proto__ = {};
|
||||
} catch (e) {
|
||||
thrown = e;
|
||||
}
|
||||
|
||||
expect(thrown).toBeInstanceOf(TypeError);
|
||||
});
|
||||
|
||||
it('prevents overwriting prototype properties', function() {
|
||||
let any = false;
|
||||
|
||||
for (const k of Object.getOwnPropertyNames(ctor.prototype)) {
|
||||
any = true;
|
||||
const existingValue = ctor.prototype[k];
|
||||
|
||||
try {
|
||||
ctor.prototype[k] = {};
|
||||
expect(ctor.prototype[k])
|
||||
.withContext(k)
|
||||
.toBe(existingValue);
|
||||
} finally {
|
||||
// This will be a no-op if the test passed, but will prevent state
|
||||
// leakage if it failed.
|
||||
ctor.prototype[k] = existingValue;
|
||||
}
|
||||
}
|
||||
|
||||
expect(any).toBe(true);
|
||||
});
|
||||
|
||||
it('prevents overriding prototype properties', function() {
|
||||
const instance = makeInstance();
|
||||
let any = false;
|
||||
|
||||
for (const k of Object.getOwnPropertyNames(ctor.prototype)) {
|
||||
any = true;
|
||||
instance[k] = {};
|
||||
expect(instance[k])
|
||||
.withContext(k)
|
||||
.toBe(ctor.prototype[k]);
|
||||
}
|
||||
|
||||
expect(any).toBe(true);
|
||||
});
|
||||
});
|
||||
};
|
||||
@@ -7,24 +7,29 @@
|
||||
'../../src/core/requireCore.js'
|
||||
));
|
||||
|
||||
// Individual source files call getJasmineRequireObj. It's normally defined
|
||||
// by requireCore.js which is concatenated into jasmine.js before other source
|
||||
// files. Since we're bypassing that mechanism, we need to provide our own.
|
||||
global.getJasmineRequireObj = function() {
|
||||
return jasmineUnderTestRequire;
|
||||
};
|
||||
|
||||
function getSourceFiles() {
|
||||
const globs = ['../../src/core/**/*.js', '../../src/version.js'];
|
||||
const srcFiles = globs.flatMap(g => glob.sync(g, { cwd: __dirname }));
|
||||
const srcFiles = [
|
||||
...glob.sync('../../src/core/**/*.js', {
|
||||
ignore: '../../src/core/requireSuffix.js',
|
||||
cwd: __dirname
|
||||
}),
|
||||
'../../src/version.js',
|
||||
'../../src/core/requireCore.js'
|
||||
];
|
||||
|
||||
for (const file of srcFiles) {
|
||||
require(file);
|
||||
}
|
||||
for (const file of srcFiles) {
|
||||
require(file);
|
||||
}
|
||||
|
||||
getSourceFiles();
|
||||
global.jasmineUnderTest = jasmineUnderTestRequire.core(
|
||||
jasmineUnderTestRequire
|
||||
);
|
||||
delete global.getJasmineRequireObj;
|
||||
|
||||
// Alias the private namespace so tests can be less verbose
|
||||
global.privateUnderTest = global.jasmineUnderTest.private;
|
||||
const built = jasmineUnderTestRequire.core(jasmineUnderTestRequire);
|
||||
global.jasmineUnderTest = built.jasmine;
|
||||
global.privateUnderTest = built.private;
|
||||
})();
|
||||
|
||||
@@ -1,63 +0,0 @@
|
||||
describe('HtmlExactSpecFilter', function() {
|
||||
it('matches everything when no string is provided', function() {
|
||||
const specFilter = new jasmineUnderTest.HtmlExactSpecFilter({
|
||||
queryString: {
|
||||
getParam(name) {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
expect(specFilter.matches({})).toBeTrue();
|
||||
});
|
||||
|
||||
it('matches a spec with the exact same path', function() {
|
||||
const specFilter = new jasmineUnderTest.HtmlExactSpecFilter({
|
||||
queryString: {
|
||||
getParam(name) {
|
||||
if (name === 'spec') {
|
||||
return '["a","b","c"]';
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
expect(specFilter.matches(stubSpec(['a', 'b', 'c']))).toBeTrue();
|
||||
});
|
||||
|
||||
it('matches a spec whose path has the filter path as a prefix', function() {
|
||||
const specFilter = new jasmineUnderTest.HtmlExactSpecFilter({
|
||||
queryString: {
|
||||
getParam(name) {
|
||||
if (name === 'spec') {
|
||||
return '["a","b"]';
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
expect(specFilter.matches(stubSpec(['a', 'b', 'c']))).toBeTrue();
|
||||
});
|
||||
|
||||
it('does not match a spec with a different path', function() {
|
||||
const specFilter = new jasmineUnderTest.HtmlExactSpecFilter({
|
||||
queryString: {
|
||||
getParam(name) {
|
||||
if (name === 'spec') {
|
||||
return '["a","b","c"]';
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
expect(specFilter.matches(stubSpec(['a', 'd', 'c']))).toBeFalse();
|
||||
});
|
||||
|
||||
function stubSpec(path) {
|
||||
return {
|
||||
getPath() {
|
||||
return path;
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
File diff suppressed because it is too large
Load Diff
1401
spec/html/HtmlReporterV2Spec.js
Normal file
1401
spec/html/HtmlReporterV2Spec.js
Normal file
File diff suppressed because it is too large
Load Diff
70
spec/html/HtmlReporterV2UrlsSpec.js
Normal file
70
spec/html/HtmlReporterV2UrlsSpec.js
Normal file
@@ -0,0 +1,70 @@
|
||||
describe('HtmlReporterV2Urls', function() {
|
||||
describe('#configFromCurrentUrl', function() {
|
||||
passesThroughQueryParam('stopOnSpecFailure');
|
||||
passesThroughQueryParam('stopSpecOnExpectationFailure');
|
||||
passesThroughQueryParam('random');
|
||||
ignoresEmpty('random');
|
||||
passesThroughQueryParam('seed');
|
||||
ignoresEmpty('seed');
|
||||
|
||||
it('configures a matching spec filter', function() {
|
||||
const queryString = mockQueryString();
|
||||
queryString.getParam.withArgs('path').and.returnValue('["foo","bar"]');
|
||||
const subject = new jasmineUnderTest.HtmlReporterV2Urls({ queryString });
|
||||
const config = subject.configFromCurrentUrl();
|
||||
const matching = {
|
||||
getPath() {
|
||||
return ['foo', 'bar'];
|
||||
}
|
||||
};
|
||||
const nonMatching = {
|
||||
getPath() {
|
||||
return ['foobar'];
|
||||
}
|
||||
};
|
||||
expect(config.specFilter(matching)).toEqual(true);
|
||||
expect(config.specFilter(nonMatching)).toEqual(false);
|
||||
});
|
||||
|
||||
function passesThroughQueryParam(k) {
|
||||
it(`sets config.${k} to undefined when ${k} is not in the query string`, function() {
|
||||
const queryString = mockQueryString();
|
||||
queryString.getParam.withArgs(k).and.returnValue(undefined);
|
||||
const subject = new jasmineUnderTest.HtmlReporterV2Urls({
|
||||
queryString
|
||||
});
|
||||
expect(subject.configFromCurrentUrl()[k]).toBeUndefined();
|
||||
});
|
||||
|
||||
it(`sets config.${k} to the ${k} query param`, function() {
|
||||
const queryString = mockQueryString();
|
||||
queryString.getParam.withArgs(k).and.returnValue('someval');
|
||||
const subject = new jasmineUnderTest.HtmlReporterV2Urls({
|
||||
queryString
|
||||
});
|
||||
expect(subject.configFromCurrentUrl()[k]).toEqual('someval');
|
||||
});
|
||||
}
|
||||
|
||||
function ignoresEmpty(k) {
|
||||
it(`sets config.${k} to undefined when the ${k} query param is empty`, function() {
|
||||
const queryString = mockQueryString();
|
||||
queryString.getParam.withArgs(k).and.returnValue(undefined);
|
||||
const subject = new jasmineUnderTest.HtmlReporterV2Urls({
|
||||
queryString
|
||||
});
|
||||
expect(subject.configFromCurrentUrl()[k]).toBeUndefined();
|
||||
});
|
||||
}
|
||||
|
||||
function mockQueryString() {
|
||||
const qs = jasmine.createSpyObj('queryString', ['getParam']);
|
||||
qs.getParam.and.returnValue('NOT STUBBED');
|
||||
return qs;
|
||||
}
|
||||
});
|
||||
|
||||
isNonMonkeyPatchableClass(jasmineUnderTest.HtmlReporterV2Urls, function() {
|
||||
return new jasmineUnderTest.HtmlReporterV2Urls({});
|
||||
});
|
||||
});
|
||||
@@ -1,32 +0,0 @@
|
||||
describe('HtmlSpecFilter', function() {
|
||||
it('should match when no string is provided', function() {
|
||||
const specFilter = new jasmineUnderTest.HtmlSpecFilter();
|
||||
|
||||
expect(specFilter.matches('foo')).toBe(true);
|
||||
expect(specFilter.matches('*bar')).toBe(true);
|
||||
});
|
||||
|
||||
it('should only match the provided string', function() {
|
||||
const specFilter = new jasmineUnderTest.HtmlSpecFilter({
|
||||
filterString: function() {
|
||||
return 'foo';
|
||||
}
|
||||
});
|
||||
|
||||
expect(specFilter.matches('foo')).toBe(true);
|
||||
expect(specFilter.matches('bar')).toBe(false);
|
||||
});
|
||||
|
||||
it('copes with HtmlExactSpecFilterV2 filter strings', function() {
|
||||
const specFilter = new jasmineUnderTest.HtmlSpecFilter({
|
||||
filterString: function() {
|
||||
return '["foo","bar"]';
|
||||
}
|
||||
});
|
||||
|
||||
expect(specFilter.matches('foo bar')).toBe(true);
|
||||
expect(specFilter.matches('baz foo bar qux')).toBe(true);
|
||||
expect(specFilter.matches('foo')).toBe(false);
|
||||
expect(specFilter.matches('bar')).toBe(false);
|
||||
});
|
||||
});
|
||||
70
spec/html/HtmlSpecFilterV2Spec.js
Normal file
70
spec/html/HtmlSpecFilterV2Spec.js
Normal file
@@ -0,0 +1,70 @@
|
||||
describe('HtmlSpecFilterV2', function() {
|
||||
describe('When both query parameters are falsy', function() {
|
||||
it('matches everything', function() {
|
||||
const specFilter = new privateUnderTest.HtmlSpecFilterV2({
|
||||
filterParams() {
|
||||
return { path: '', spec: '' };
|
||||
}
|
||||
});
|
||||
|
||||
expect(specFilter.matches({})).toBeTrue();
|
||||
});
|
||||
});
|
||||
|
||||
describe('When the path parameter is truthy', function() {
|
||||
it('matches a spec with the exact same path', function() {
|
||||
const specFilter = new privateUnderTest.HtmlSpecFilterV2({
|
||||
filterParams() {
|
||||
return { path: '["a","b","c"]', spec: '' };
|
||||
}
|
||||
});
|
||||
|
||||
expect(specFilter.matches(stubSpec(['a', 'b', 'c']))).toBeTrue();
|
||||
});
|
||||
|
||||
it('matches a spec whose path has the filter path as a prefix', function() {
|
||||
const specFilter = new privateUnderTest.HtmlSpecFilterV2({
|
||||
filterParams() {
|
||||
return { path: '["a","b"]', spec: '' };
|
||||
}
|
||||
});
|
||||
|
||||
expect(specFilter.matches(stubSpec(['a', 'b', 'c']))).toBeTrue();
|
||||
});
|
||||
|
||||
it('does not match a spec with a different path', function() {
|
||||
const specFilter = new privateUnderTest.HtmlSpecFilterV2({
|
||||
filterParams() {
|
||||
return { path: '["a","b","c"]', spec: '' };
|
||||
}
|
||||
});
|
||||
|
||||
expect(specFilter.matches(stubSpec(['a', 'd', 'c']))).toBeFalse();
|
||||
});
|
||||
});
|
||||
|
||||
describe('When the path parameter is falsy and the spec parameter is truthy', function() {
|
||||
it('matches specs with full names containing the parameter value', function() {
|
||||
const specFilter = new privateUnderTest.HtmlSpecFilterV2({
|
||||
filterParams() {
|
||||
return { path: '', spec: 'bar' };
|
||||
}
|
||||
});
|
||||
|
||||
expect(specFilter.matches(stubSpec('', 'foo bar baz'))).toBeTrue();
|
||||
expect(specFilter.matches(stubSpec('', 'foo baz'))).toBeFalse();
|
||||
expect(specFilter.matches(stubSpec('', 'sandbars'))).toBeTrue();
|
||||
});
|
||||
});
|
||||
|
||||
function stubSpec(path, fullName) {
|
||||
return {
|
||||
getPath() {
|
||||
return path;
|
||||
},
|
||||
getFullName() {
|
||||
return fullName;
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
107
spec/html/PerformanceViewSpec.js
Normal file
107
spec/html/PerformanceViewSpec.js
Normal file
@@ -0,0 +1,107 @@
|
||||
'use strict';
|
||||
|
||||
describe('PerformanceView', function() {
|
||||
it('shows specs ordered by execution time', function() {
|
||||
const stateBuilder = new privateUnderTest.ResultsStateBuilder();
|
||||
stateBuilder.suiteStarted({});
|
||||
stateBuilder.specDone({
|
||||
fullName: 'spec A',
|
||||
duration: 2
|
||||
});
|
||||
stateBuilder.suiteDone({});
|
||||
stateBuilder.specDone({
|
||||
fullName: 'spec B',
|
||||
duration: 1
|
||||
});
|
||||
stateBuilder.specDone({
|
||||
fullName: 'spec C',
|
||||
duration: 3
|
||||
});
|
||||
const subject = new privateUnderTest.PerformanceView();
|
||||
subject.addResults(stateBuilder.topResults);
|
||||
|
||||
const rows = Array.from(subject.rootEl.querySelectorAll('tbody tr'));
|
||||
const durations = rows.map(r => r.querySelectorAll('td')[0].textContent);
|
||||
const names = rows.map(r => r.querySelectorAll('td')[1].textContent);
|
||||
expect(names).toEqual(['spec C', 'spec A', 'spec B']);
|
||||
expect(durations).toEqual(['3ms', '2ms', '1ms']);
|
||||
});
|
||||
|
||||
it('shows at most 20 specs', function() {
|
||||
const stateBuilder = new privateUnderTest.ResultsStateBuilder();
|
||||
const subject = new privateUnderTest.PerformanceView();
|
||||
|
||||
for (let i = 0; i < 21; i++) {
|
||||
stateBuilder.specDone({
|
||||
fullName: `spec ${i}`,
|
||||
duration: i
|
||||
});
|
||||
}
|
||||
|
||||
subject.addResults(stateBuilder.topResults);
|
||||
|
||||
expect(subject.rootEl.querySelectorAll('tbody tr').length).toEqual(20);
|
||||
expect(subject.textContent).not.toContain('spec 0');
|
||||
});
|
||||
|
||||
it('shows mean and median run times for an odd number of specs', function() {
|
||||
const stateBuilder = new privateUnderTest.ResultsStateBuilder();
|
||||
const subject = new privateUnderTest.PerformanceView();
|
||||
|
||||
stateBuilder.specDone({ duration: 1 });
|
||||
stateBuilder.specDone({ duration: 2 });
|
||||
stateBuilder.specDone({ duration: 5 });
|
||||
subject.addResults(stateBuilder.topResults);
|
||||
|
||||
expect(subject.rootEl.textContent).toContain('Mean spec run time: 3ms');
|
||||
expect(subject.rootEl.textContent).toContain('Median spec run time: 2ms');
|
||||
});
|
||||
|
||||
it('shows mean and median run times for an even number of specs', function() {
|
||||
const stateBuilder = new privateUnderTest.ResultsStateBuilder();
|
||||
const subject = new privateUnderTest.PerformanceView();
|
||||
|
||||
stateBuilder.specDone({ duration: 1 });
|
||||
stateBuilder.specDone({ duration: 3 });
|
||||
stateBuilder.specDone({ duration: 10 });
|
||||
stateBuilder.specDone({ duration: 2 });
|
||||
subject.addResults(stateBuilder.topResults);
|
||||
|
||||
expect(subject.rootEl.textContent).toContain('Mean spec run time: 4ms');
|
||||
expect(subject.rootEl.textContent).toContain('Median spec run time: 2ms');
|
||||
});
|
||||
|
||||
it('copes with 0 specs', function() {
|
||||
const stateBuilder = new privateUnderTest.ResultsStateBuilder();
|
||||
const subject = new privateUnderTest.PerformanceView();
|
||||
|
||||
expect(function() {
|
||||
subject.addResults(stateBuilder.topResults);
|
||||
}).not.toThrow();
|
||||
});
|
||||
|
||||
it('filters out excluded specs', function() {
|
||||
const stateBuilder = new privateUnderTest.ResultsStateBuilder();
|
||||
stateBuilder.specDone({
|
||||
fullName: 'spec A',
|
||||
duration: 2
|
||||
});
|
||||
stateBuilder.specDone({
|
||||
fullName: 'spec B',
|
||||
duration: 1,
|
||||
status: 'excluded'
|
||||
});
|
||||
stateBuilder.specDone({
|
||||
fullName: 'spec C',
|
||||
duration: 3
|
||||
});
|
||||
const subject = new privateUnderTest.PerformanceView();
|
||||
subject.addResults(stateBuilder.topResults);
|
||||
|
||||
const rows = Array.from(subject.rootEl.querySelectorAll('tbody tr'));
|
||||
const names = rows.map(r => r.querySelectorAll('td')[1].textContent);
|
||||
expect(names).toEqual(['spec C', 'spec A']);
|
||||
expect(subject.rootEl.textContent).toContain('Mean spec run time: 3ms');
|
||||
expect(subject.rootEl.textContent).toContain('Median spec run time: 2ms');
|
||||
});
|
||||
});
|
||||
@@ -77,4 +77,12 @@ describe('QueryString', function() {
|
||||
expect(queryString.getParam('baz')).toBeFalsy();
|
||||
});
|
||||
});
|
||||
|
||||
isNonMonkeyPatchableClass(jasmineUnderTest.QueryString, function() {
|
||||
return new jasmineUnderTest.QueryString({
|
||||
getWindowLocation: function() {
|
||||
return { search: '' };
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
97
spec/html/TabBarSpec.js
Normal file
97
spec/html/TabBarSpec.js
Normal file
@@ -0,0 +1,97 @@
|
||||
describe('TabBar', function() {
|
||||
it('initially renders but hides the tabs', function() {
|
||||
const subject = new privateUnderTest.TabBar([
|
||||
{ id: 'tab1', label: 'tab 1' }
|
||||
]);
|
||||
const tabs = subject.rootEl.querySelectorAll('.jasmine-tab');
|
||||
expect(tabs.length).toEqual(1);
|
||||
expect(tabs[0].id).toEqual('tab1');
|
||||
expect(tabs[0]).toHaveClass('jasmine-hidden');
|
||||
const link = tabs[0].querySelector('a');
|
||||
expect(link).toBeTruthy();
|
||||
expect(link.textContent).toEqual('tab 1');
|
||||
});
|
||||
|
||||
it('does not initially call the onSelect callback', function() {
|
||||
const onSelect = jasmine.createSpy('onSelect');
|
||||
new privateUnderTest.TabBar([{ id: 'tab1', label: '' }], onSelect);
|
||||
expect(onSelect).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
describe('#showTab', function() {
|
||||
it('shows the specified tab', function() {
|
||||
const subject = new privateUnderTest.TabBar([
|
||||
{ id: 'tab1' },
|
||||
{ id: 'tab2' }
|
||||
]);
|
||||
|
||||
subject.showTab('tab2');
|
||||
|
||||
const tabs = subject.rootEl.querySelectorAll('.jasmine-tab');
|
||||
expect(tabs[0]).toHaveClass('jasmine-hidden');
|
||||
expect(tabs[1]).not.toHaveClass('jasmine-hidden');
|
||||
});
|
||||
|
||||
it('does not hide previously shown tabs', function() {
|
||||
const subject = new privateUnderTest.TabBar([
|
||||
{ id: 'tab1' },
|
||||
{ id: 'tab2' }
|
||||
]);
|
||||
|
||||
subject.showTab('tab1');
|
||||
subject.showTab('tab2');
|
||||
|
||||
const tabs = subject.rootEl.querySelectorAll('.jasmine-tab');
|
||||
expect(tabs[0]).not.toHaveClass('jasmine-hidden');
|
||||
});
|
||||
});
|
||||
|
||||
describe("When a tab's link is clicked", function() {
|
||||
it("calls the onSelect callback with the tab's id", function() {
|
||||
const onSelect = jasmine.createSpy('onSelect');
|
||||
const subject = new privateUnderTest.TabBar(
|
||||
[{ id: 'tab1', label: '' }],
|
||||
onSelect
|
||||
);
|
||||
|
||||
subject.rootEl.querySelector('.jasmine-tab a').click();
|
||||
|
||||
expect(onSelect).toHaveBeenCalledWith('tab1');
|
||||
});
|
||||
|
||||
it('shows links on all non-selected tabs only', function() {
|
||||
const subject = new privateUnderTest.TabBar(
|
||||
[
|
||||
{ id: 'tab1', label: 'tab 1' },
|
||||
{ id: 'tab2', label: 'tab 2' },
|
||||
{ id: 'tab3', label: 'tab 3' }
|
||||
],
|
||||
() => {}
|
||||
);
|
||||
|
||||
subject.rootEl.querySelectorAll('.jasmine-tab a')[1].click();
|
||||
let tabs = subject.rootEl.querySelectorAll('.jasmine-tab');
|
||||
expect(tabs[0].querySelector('a'))
|
||||
.withContext('tab 1')
|
||||
.toBeTruthy();
|
||||
expect(tabs[1].querySelector('a'))
|
||||
.withContext('tab 1')
|
||||
.toBeFalsy();
|
||||
expect(tabs[2].querySelector('a'))
|
||||
.withContext('tab 1')
|
||||
.toBeTruthy();
|
||||
|
||||
subject.rootEl.querySelectorAll('.jasmine-tab a')[0].click();
|
||||
tabs = subject.rootEl.querySelectorAll('.jasmine-tab');
|
||||
expect(tabs[0].querySelector('a'))
|
||||
.withContext('tab 1')
|
||||
.toBeFalsy();
|
||||
expect(tabs[1].querySelector('a'))
|
||||
.withContext('tab 1')
|
||||
.toBeTruthy();
|
||||
expect(tabs[2].querySelector('a'))
|
||||
.withContext('tab 1')
|
||||
.toBeTruthy();
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -77,7 +77,7 @@ describe('npm package', function() {
|
||||
});
|
||||
|
||||
it('has bootFiles', function() {
|
||||
expect(this.packagedCore.files.bootFiles).toEqual(['boot0.js', 'boot1.js']);
|
||||
expect(this.packagedCore.files.bootFiles).toEqual(['boot.js']);
|
||||
|
||||
for (const fileName of this.packagedCore.files.bootFiles) {
|
||||
expect(fileName).toExistInPath(this.packagedCore.files.bootDir);
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
/* eslint-env node, es6 */
|
||||
const path = require('path'),
|
||||
jasmineBrowser = require('jasmine-browser-runner'),
|
||||
jasmineCore = require('../../lib/jasmine-core');
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
/* eslint-env node, es6 */
|
||||
module.exports = {
|
||||
srcDir: 'src',
|
||||
srcFiles: [
|
||||
@@ -7,13 +6,14 @@ module.exports = {
|
||||
'core/util.js',
|
||||
'core/Spec.js',
|
||||
'core/Env.js',
|
||||
'core/JsApiReporter.js',
|
||||
'core/PrettyPrinter.js',
|
||||
'core/Suite.js',
|
||||
'core/**/*.js',
|
||||
'html/**/*.js',
|
||||
'**/*.js',
|
||||
'!boot/**.js'
|
||||
'!boot/**.js',
|
||||
'!core/requireSuffix.js',
|
||||
'!html/requireSuffix.js'
|
||||
],
|
||||
specDir: 'spec',
|
||||
specFiles: ['**/*[Ss]pec.js', '!npmPackage/**/*'],
|
||||
@@ -23,11 +23,14 @@ module.exports = {
|
||||
'helpers/BrowserFlags.js',
|
||||
'helpers/domHelpers.js',
|
||||
'helpers/integrationMatchers.js',
|
||||
'helpers/callerFilenameShim.js',
|
||||
'helpers/monkeyPatchingSpecs.js',
|
||||
'helpers/defineJasmineUnderTest.js',
|
||||
'helpers/resetEnv.js'
|
||||
],
|
||||
env: {
|
||||
forbidDuplicateNames: true
|
||||
forbidDuplicateNames: true,
|
||||
safariYieldStrategy: 'time'
|
||||
},
|
||||
random: true,
|
||||
browser: {
|
||||
|
||||
@@ -8,7 +8,9 @@
|
||||
"helpers/init.js",
|
||||
"helpers/domHelpers.js",
|
||||
"helpers/integrationMatchers.js",
|
||||
"helpers/callerFilenameShim.js",
|
||||
"helpers/overrideConsoleLogForCircleCi.js",
|
||||
"helpers/monkeyPatchingSpecs.js",
|
||||
"helpers/nodeDefineJasmineUnderTest.js",
|
||||
"helpers/resetEnv.js"
|
||||
],
|
||||
|
||||
@@ -8,10 +8,10 @@
|
||||
<link rel="stylesheet" href="lib/jasmine-<%= jasmineVersion %>/jasmine.css">
|
||||
|
||||
<script src="lib/jasmine-<%= jasmineVersion %>/jasmine.js"></script>
|
||||
<script src="lib/jasmine-<%= jasmineVersion %>/jasmine-html.js"></script>
|
||||
<script src="lib/jasmine-<%= jasmineVersion %>/boot0.js"></script>
|
||||
<script src="lib/jasmine-<%= jasmineVersion %>/jasmine-html.js"></script>
|
||||
<!-- optional: include a file here that configures the Jasmine env -->
|
||||
<script src="lib/jasmine-<%= jasmineVersion %>/boot1.js"></script>
|
||||
<script src="lib/jasmine-<%= jasmineVersion %>/boot.js"></script>
|
||||
|
||||
<!-- include source files here... -->
|
||||
<script src="src/Player.js"></script>
|
||||
|
||||
27
src/boot/boot.js
Normal file
27
src/boot/boot.js
Normal file
@@ -0,0 +1,27 @@
|
||||
'use strict';
|
||||
|
||||
(function() {
|
||||
const env = jasmine.getEnv();
|
||||
const urls = new jasmine.HtmlReporterV2Urls();
|
||||
|
||||
/**
|
||||
* Configures Jasmine based on the current set of query parameters. This
|
||||
* supports all parameters set by the HTML reporter as well as
|
||||
* spec=partialPath, which filters out specs whose paths don't contain the
|
||||
* parameter.
|
||||
*/
|
||||
env.configure(urls.configFromCurrentUrl());
|
||||
|
||||
const currentWindowOnload = window.onload;
|
||||
window.onload = function() {
|
||||
if (currentWindowOnload) {
|
||||
currentWindowOnload();
|
||||
}
|
||||
|
||||
// The HTML reporter needs to be set up here so it can access the DOM. Other
|
||||
// reporters can be added at any time before env.execute() is called.
|
||||
const htmlReporter = new jasmine.HtmlReporterV2({ env, urls });
|
||||
env.addReporter(htmlReporter);
|
||||
env.execute();
|
||||
};
|
||||
})();
|
||||
@@ -1,42 +0,0 @@
|
||||
/**
|
||||
This file starts the process of "booting" Jasmine. It initializes Jasmine,
|
||||
makes its globals available, and creates the env. This file should be loaded
|
||||
after `jasmine.js` and `jasmine_html.js`, but before `boot1.js` or any project
|
||||
source files or spec files are loaded.
|
||||
*/
|
||||
(function() {
|
||||
const jasmineRequire = window.jasmineRequire || require('./jasmine.js');
|
||||
|
||||
/**
|
||||
* ## Require & Instantiate
|
||||
*
|
||||
* Require Jasmine's core files. Specifically, this requires and attaches all of Jasmine's code to the `jasmine` reference.
|
||||
*/
|
||||
const jasmine = jasmineRequire.core(jasmineRequire),
|
||||
global = jasmine.getGlobal();
|
||||
global.jasmine = jasmine;
|
||||
|
||||
/**
|
||||
* Since this is being run in a browser and the results should populate to an HTML page, require the HTML-specific Jasmine code, injecting the same reference.
|
||||
*/
|
||||
jasmineRequire.html(jasmine);
|
||||
|
||||
/**
|
||||
* Create the Jasmine environment. This is used to run all specs in a project.
|
||||
*/
|
||||
const env = jasmine.getEnv();
|
||||
|
||||
/**
|
||||
* ## The Global Interface
|
||||
*
|
||||
* Build up the functions that will be exposed as the Jasmine public interface. A project can customize, rename or alias any of these functions as desired, provided the implementation remains unchanged.
|
||||
*/
|
||||
const jasmineInterface = jasmineRequire.interface(jasmine, env);
|
||||
|
||||
/**
|
||||
* Add all of the Jasmine global/public interface to the global scope, so a project can use the public interface directly. For example, calling `describe` in specs instead of `jasmine.getEnv().describe`.
|
||||
*/
|
||||
for (const property in jasmineInterface) {
|
||||
global[property] = jasmineInterface[property];
|
||||
}
|
||||
})();
|
||||
@@ -1,97 +0,0 @@
|
||||
/**
|
||||
This file finishes 'booting' Jasmine, performing all of the necessary
|
||||
initialization before executing the loaded environment and all of a project's
|
||||
specs. This file should be loaded after `boot0.js` but before any project
|
||||
source files or spec files are loaded. Thus this file can also be used to
|
||||
customize Jasmine for a project.
|
||||
|
||||
If a project is using Jasmine via the standalone distribution, this file can
|
||||
be customized directly. If you only wish to configure the Jasmine env, you
|
||||
can load another file that calls `jasmine.getEnv().configure({...})`
|
||||
after `boot0.js` is loaded and before this file is loaded.
|
||||
*/
|
||||
|
||||
(function() {
|
||||
const env = jasmine.getEnv();
|
||||
|
||||
const queryString = new jasmine.QueryString({
|
||||
getWindowLocation: function() {
|
||||
return window.location;
|
||||
}
|
||||
});
|
||||
|
||||
const config = {
|
||||
stopOnSpecFailure: queryString.getParam('stopOnSpecFailure'),
|
||||
stopSpecOnExpectationFailure: queryString.getParam(
|
||||
'stopSpecOnExpectationFailure'
|
||||
),
|
||||
hideDisabled: queryString.getParam('hideDisabled')
|
||||
};
|
||||
|
||||
const random = queryString.getParam('random');
|
||||
|
||||
if (random !== undefined && random !== '') {
|
||||
config.random = random;
|
||||
}
|
||||
|
||||
const 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).
|
||||
*/
|
||||
const 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(),
|
||||
queryString
|
||||
});
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
const specFilter = new jasmine.HtmlExactSpecFilter({ queryString });
|
||||
config.specFilter = function(spec) {
|
||||
return specFilter.matches(spec);
|
||||
};
|
||||
|
||||
env.configure(config);
|
||||
|
||||
/**
|
||||
* ## Execution
|
||||
*
|
||||
* Replace the browser window's `onload`, ensure it's called, and then run all of the loaded specs. This includes initializing the `HtmlReporter` instance and then executing the loaded Jasmine environment. All of this will happen after all of the specs are loaded.
|
||||
*/
|
||||
const currentWindowOnload = window.onload;
|
||||
|
||||
window.onload = function() {
|
||||
if (currentWindowOnload) {
|
||||
currentWindowOnload();
|
||||
}
|
||||
htmlReporter.initialize();
|
||||
env.execute();
|
||||
};
|
||||
})();
|
||||
@@ -1,67 +1,25 @@
|
||||
/**
|
||||
* Note: Only available on Node.
|
||||
* @module jasmine-core
|
||||
*/
|
||||
'use strict';
|
||||
|
||||
const jasmineRequire = require('./jasmine-core/jasmine.js');
|
||||
module.exports = jasmineRequire;
|
||||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
const {
|
||||
globals,
|
||||
installGlobals,
|
||||
version,
|
||||
private$
|
||||
} = require('./jasmine-core/jasmine.js');
|
||||
|
||||
const bootWithoutGlobals = (function() {
|
||||
let jasmine, jasmineInterface;
|
||||
|
||||
return function bootWithoutGlobals(reinitialize) {
|
||||
if (!jasmineInterface || reinitialize === true) {
|
||||
jasmine = jasmineRequire.core(jasmineRequire);
|
||||
const env = jasmine.getEnv({ suppressLoadErrors: true });
|
||||
jasmineInterface = jasmineRequire.interface(jasmine, env);
|
||||
}
|
||||
|
||||
return { jasmine, jasmineInterface };
|
||||
};
|
||||
})();
|
||||
|
||||
/**
|
||||
* Boots a copy of Jasmine and returns an object as described in {@link jasmine}.
|
||||
* @param {boolean} [reinitialize=true] Whether to create a new copy of Jasmine if one already exists
|
||||
* @type {function}
|
||||
* @return {jasmine}
|
||||
*/
|
||||
module.exports.boot = function(reinitialize) {
|
||||
if (reinitialize === undefined) {
|
||||
reinitialize = true;
|
||||
}
|
||||
|
||||
const { jasmine, jasmineInterface } = bootWithoutGlobals(reinitialize);
|
||||
|
||||
for (const k in jasmineInterface) {
|
||||
global[k] = jasmineInterface[k];
|
||||
}
|
||||
|
||||
return jasmine;
|
||||
};
|
||||
|
||||
/**
|
||||
* Boots a copy of Jasmine and returns an object containing the properties
|
||||
* that would normally be added to the global object. If noGlobals is called
|
||||
* multiple times, the same object is returned every time.
|
||||
*
|
||||
* @example
|
||||
* const {describe, beforeEach, it, expect, jasmine} = require('jasmine-core').noGlobals();
|
||||
*/
|
||||
module.exports.noGlobals = function() {
|
||||
const { jasmineInterface } = bootWithoutGlobals(false);
|
||||
return jasmineInterface;
|
||||
};
|
||||
|
||||
const path = require('path'),
|
||||
fs = require('fs');
|
||||
function reset() {
|
||||
private$.currentEnv_ = null;
|
||||
const env = jasmine.getEnv({ suppressLoadErrors: true });
|
||||
rebindInterface(env);
|
||||
}
|
||||
|
||||
const rootPath = path.join(__dirname, 'jasmine-core'),
|
||||
bootFiles = ['boot0.js', 'boot1.js'],
|
||||
legacyBootFiles = ['boot.js'],
|
||||
bootFiles = ['boot.js'],
|
||||
cssFiles = [],
|
||||
jsFiles = [],
|
||||
jsFilesToSkip = ['jasmine.js'].concat(bootFiles, legacyBootFiles);
|
||||
jsFilesToSkip = ['jasmine.js'].concat(bootFiles);
|
||||
|
||||
fs.readdirSync(rootPath).forEach(function(file) {
|
||||
if (fs.statSync(path.join(rootPath, file)).isFile()) {
|
||||
@@ -78,12 +36,40 @@ fs.readdirSync(rootPath).forEach(function(file) {
|
||||
}
|
||||
});
|
||||
|
||||
module.exports.files = {
|
||||
self: __filename,
|
||||
path: rootPath,
|
||||
bootDir: rootPath,
|
||||
bootFiles: bootFiles,
|
||||
cssFiles: cssFiles,
|
||||
jsFiles: ['jasmine.js'].concat(jsFiles),
|
||||
imagesDir: path.join(__dirname, '../images')
|
||||
/**
|
||||
* Note: Only available on Node.
|
||||
*
|
||||
* In addition to the members documented here, this module's exports include all
|
||||
* {@link globals}.
|
||||
* @module jasmine-core
|
||||
*/
|
||||
module.exports = {
|
||||
...globals,
|
||||
/**
|
||||
* Copies Jasmine globals (jasmine, describe, it, etc) to the specified
|
||||
* object or to globalThis.
|
||||
* @function
|
||||
* @param {object} [dest] - The object to copy globals to.
|
||||
*/
|
||||
installGlobals,
|
||||
/**
|
||||
* Returns the jasmine-core version.
|
||||
* @function
|
||||
*/
|
||||
version,
|
||||
/**
|
||||
* Resets all of jasmine-core's state, including removing specs, suites, and
|
||||
* reporters, and resetting configuration to the default.
|
||||
* @function
|
||||
*/
|
||||
reset,
|
||||
files: {
|
||||
self: __filename,
|
||||
path: rootPath,
|
||||
bootDir: rootPath,
|
||||
bootFiles: bootFiles,
|
||||
cssFiles: cssFiles,
|
||||
jsFiles: ['jasmine.js'].concat(jsFiles),
|
||||
imagesDir: path.join(__dirname, '../images')
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
getJasmineRequireObj().CallTracker = function(j$) {
|
||||
getJasmineRequireObj().CallTracker = function(j$, private$) {
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* @namespace Spy#calls
|
||||
* @since 2.0.0
|
||||
@@ -123,9 +125,7 @@ getJasmineRequireObj().CallTracker = function(j$) {
|
||||
* @param {Function} [argsCloner] A function to use to clone the arguments. Defaults to a shallow cloning function.
|
||||
* @function
|
||||
*/
|
||||
this.saveArgumentsByValue = function(
|
||||
argsCloner = j$.private.util.cloneArgs
|
||||
) {
|
||||
this.saveArgumentsByValue = function(argsCloner = private$.util.cloneArgs) {
|
||||
opts.cloneArgs = true;
|
||||
opts.argsCloner = argsCloner;
|
||||
};
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
getJasmineRequireObj().Clock = function() {
|
||||
getJasmineRequireObj().Clock = function(j$, private$) {
|
||||
'use strict';
|
||||
|
||||
/* global process */
|
||||
const NODE_JS =
|
||||
typeof process !== 'undefined' &&
|
||||
@@ -189,6 +191,9 @@ callbacks to execute _before_ running the next one.
|
||||
clearTimeout[IsMockClockTimingFn] = true;
|
||||
setInterval[IsMockClockTimingFn] = true;
|
||||
clearInterval[IsMockClockTimingFn] = true;
|
||||
|
||||
Object.freeze(this);
|
||||
|
||||
return this;
|
||||
|
||||
// Advances the Clock's time until the mode changes.
|
||||
@@ -342,5 +347,7 @@ callbacks to execute _before_ running the next one.
|
||||
};
|
||||
|
||||
Clock.IsMockClockTimingFn = IsMockClockTimingFn;
|
||||
Object.freeze(Clock);
|
||||
Object.freeze(Clock.prototype);
|
||||
return Clock;
|
||||
};
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
getJasmineRequireObj().CompleteOnFirstErrorSkipPolicy = function(j$) {
|
||||
getJasmineRequireObj().CompleteOnFirstErrorSkipPolicy = function(j$, private$) {
|
||||
'use strict';
|
||||
|
||||
function CompleteOnFirstErrorSkipPolicy(queueableFns) {
|
||||
this.queueableFns_ = queueableFns;
|
||||
this.erroredFnIx_ = null;
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
getJasmineRequireObj().Configuration = function(j$) {
|
||||
getJasmineRequireObj().Configuration = function(j$, private$) {
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* This represents the available options to configure Jasmine.
|
||||
* Options that are not provided will use their default values.
|
||||
@@ -71,6 +73,8 @@ getJasmineRequireObj().Configuration = function(j$) {
|
||||
specFilter: function() {
|
||||
return true;
|
||||
},
|
||||
|
||||
// TODO: remove hideDisabled when HtmlReporter is removed
|
||||
/**
|
||||
* Whether reporters should hide disabled specs from their output.
|
||||
* Currently only supported by Jasmine's HTMLReporter
|
||||
@@ -78,6 +82,7 @@ getJasmineRequireObj().Configuration = function(j$) {
|
||||
* @since 3.3.0
|
||||
* @type Boolean
|
||||
* @default false
|
||||
* @deprecated
|
||||
*/
|
||||
hideDisabled: false,
|
||||
/**
|
||||
@@ -123,7 +128,45 @@ getJasmineRequireObj().Configuration = function(j$) {
|
||||
* @type Boolean
|
||||
* @default false
|
||||
*/
|
||||
detectLateRejectionHandling: false
|
||||
detectLateRejectionHandling: false,
|
||||
|
||||
/**
|
||||
* The number of extra stack frames inserted by a wrapper around {@link it}
|
||||
* or by some other local modification. Jasmine uses this to determine the
|
||||
* filename for {@link SpecStartedEvent} and {@link SpecDoneEvent}.
|
||||
* @name Configuration#extraItStackFrames
|
||||
* @since 5.13.0
|
||||
* @type number
|
||||
* @default 0
|
||||
*/
|
||||
extraItStackFrames: 0,
|
||||
|
||||
/**
|
||||
* The number of extra stack frames inserted by a wrapper around
|
||||
* {@link describe} or by some other local modification. Jasmine uses this
|
||||
* to determine the filename for {@link SpecStartedEvent} and
|
||||
* {@link SpecDoneEvent}.
|
||||
* @name Configuration#extraDescribeStackFrames
|
||||
* @since 5.13.0
|
||||
* @type number
|
||||
* @default 0
|
||||
*/
|
||||
extraDescribeStackFrames: 0,
|
||||
|
||||
/**
|
||||
* The strategy to use in Safari and similar browsers to determine how often
|
||||
* to yield control by calling setTimeout. If set to "count", the default,
|
||||
* the frequency of setTimeout calls is based on the number of relevant
|
||||
* function calls. If set to "time", the frequency of setTimeout calls is
|
||||
* based on elapsed time. Using "time" may provide a significant performance
|
||||
* improvement, but as of 6.0 it hasn't been tested with a wide variety of
|
||||
* workloads and should be considered experimental.
|
||||
* @name Configuration#safariYieldStrategy
|
||||
* @since 6.0.0
|
||||
* @type 'count' | 'time'
|
||||
* @default 'count'
|
||||
*/
|
||||
safariYieldStrategy: 'count'
|
||||
};
|
||||
Object.freeze(defaultConfig);
|
||||
|
||||
@@ -174,6 +217,28 @@ getJasmineRequireObj().Configuration = function(j$) {
|
||||
if (typeof changes.seed !== 'undefined') {
|
||||
this.#values.seed = changes.seed;
|
||||
}
|
||||
|
||||
// 0 is a valid value for both of these, so a truthiness check wouldn't work
|
||||
if (typeof changes.extraItStackFrames !== 'undefined') {
|
||||
this.#values.extraItStackFrames = changes.extraItStackFrames;
|
||||
}
|
||||
|
||||
if (typeof changes.extraDescribeStackFrames !== 'undefined') {
|
||||
this.#values.extraDescribeStackFrames =
|
||||
changes.extraDescribeStackFrames;
|
||||
}
|
||||
|
||||
if (typeof changes.safariYieldStrategy !== 'undefined') {
|
||||
const v = changes.safariYieldStrategy;
|
||||
|
||||
if (v === 'count' || v === 'time') {
|
||||
this.#values.safariYieldStrategy = v;
|
||||
} else {
|
||||
throw new Error(
|
||||
"Invalid safariYieldStrategy value. Valid values are 'count' and 'time'."
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
getJasmineRequireObj().CurrentRunableTracker = function() {
|
||||
'use strict';
|
||||
|
||||
class CurrentRunableTracker {
|
||||
#currentSpec;
|
||||
#currentlyExecutingSuites;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
getJasmineRequireObj().DelayedFunctionScheduler = function(j$) {
|
||||
getJasmineRequireObj().DelayedFunctionScheduler = function(j$, private$) {
|
||||
'use strict';
|
||||
|
||||
function DelayedFunctionScheduler() {
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
getJasmineRequireObj().Deprecator = function(j$) {
|
||||
getJasmineRequireObj().Deprecator = function(j$, private$) {
|
||||
'use strict';
|
||||
|
||||
function Deprecator(topSuite) {
|
||||
this.topSuite_ = topSuite;
|
||||
this.verbose_ = false;
|
||||
@@ -23,7 +25,7 @@ getJasmineRequireObj().Deprecator = function(j$) {
|
||||
) {
|
||||
options = options || {};
|
||||
|
||||
if (!this.verbose_ && !j$.private.isError(deprecation)) {
|
||||
if (!this.verbose_ && !private$.isError(deprecation)) {
|
||||
if (this.toSuppress_.indexOf(deprecation) !== -1) {
|
||||
return;
|
||||
}
|
||||
@@ -35,7 +37,7 @@ getJasmineRequireObj().Deprecator = function(j$) {
|
||||
};
|
||||
|
||||
Deprecator.prototype.log_ = function(runnable, deprecation, options) {
|
||||
if (j$.private.isError(deprecation)) {
|
||||
if (private$.isError(deprecation)) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.error(deprecation);
|
||||
return;
|
||||
@@ -64,7 +66,7 @@ getJasmineRequireObj().Deprecator = function(j$) {
|
||||
};
|
||||
|
||||
Deprecator.prototype.stackTrace_ = function() {
|
||||
const formatter = new j$.private.ExceptionFormatter();
|
||||
const formatter = new private$.ExceptionFormatter();
|
||||
return formatter.stack(new Error()).replace(/^Error\n/m, '');
|
||||
};
|
||||
|
||||
@@ -73,7 +75,7 @@ getJasmineRequireObj().Deprecator = function(j$) {
|
||||
runnable = this.topSuite_;
|
||||
}
|
||||
|
||||
if (j$.private.isError(deprecation)) {
|
||||
if (private$.isError(deprecation)) {
|
||||
runnable.addDeprecationWarning(deprecation);
|
||||
return;
|
||||
}
|
||||
|
||||
137
src/core/Env.js
137
src/core/Env.js
@@ -1,4 +1,8 @@
|
||||
getJasmineRequireObj().Env = function(j$) {
|
||||
getJasmineRequireObj().Env = function(j$, private$) {
|
||||
'use strict';
|
||||
|
||||
const DEFAULT_IT_DESCRIBE_STACK_DEPTH = 3;
|
||||
|
||||
/**
|
||||
* @class Env
|
||||
* @since 2.0.0
|
||||
@@ -11,22 +15,22 @@ getJasmineRequireObj().Env = function(j$) {
|
||||
envOptions = envOptions || {};
|
||||
|
||||
const self = this;
|
||||
const GlobalErrors = envOptions.GlobalErrors || j$.private.GlobalErrors;
|
||||
const GlobalErrors = envOptions.GlobalErrors || private$.GlobalErrors;
|
||||
const global = envOptions.global || j$.getGlobal();
|
||||
|
||||
const realSetTimeout = global.setTimeout;
|
||||
const realClearTimeout = global.clearTimeout;
|
||||
const clearStack = j$.private.getClearStack(global);
|
||||
this.clock = new j$.private.Clock(
|
||||
const stackClearer = private$.getStackClearer(global);
|
||||
this.clock = new private$.Clock(
|
||||
global,
|
||||
function() {
|
||||
return new j$.private.DelayedFunctionScheduler();
|
||||
return new private$.DelayedFunctionScheduler();
|
||||
},
|
||||
new j$.private.MockDate(global)
|
||||
new private$.MockDate(global)
|
||||
);
|
||||
|
||||
const globalErrors = new GlobalErrors(
|
||||
undefined,
|
||||
global,
|
||||
// Configuration is late-bound because GlobalErrors needs to be constructed
|
||||
// before it's set to detect load-time errors in browsers
|
||||
() => this.configuration()
|
||||
@@ -50,7 +54,7 @@ getJasmineRequireObj().Env = function(j$) {
|
||||
};
|
||||
})();
|
||||
|
||||
const runableResources = new j$.private.RunableResources({
|
||||
const runableResources = new private$.RunableResources({
|
||||
getCurrentRunableId: function() {
|
||||
const r = runner.currentRunable();
|
||||
return r ? r.id : null;
|
||||
@@ -63,18 +67,18 @@ getJasmineRequireObj().Env = function(j$) {
|
||||
let runner;
|
||||
let parallelLoadingState = null; // 'specs', 'helpers', or null for non-parallel
|
||||
|
||||
const config = new j$.private.Configuration();
|
||||
const config = new private$.Configuration();
|
||||
|
||||
if (!envOptions.suppressLoadErrors) {
|
||||
installGlobalErrors();
|
||||
globalErrors.pushListener(function loadtimeErrorHandler(error, event) {
|
||||
topSuite.result.failedExpectations.push({
|
||||
globalErrors.pushListener(function loadtimeErrorHandler(error) {
|
||||
topSuite.addExpectationResult(false, {
|
||||
passed: false,
|
||||
globalErrorType: 'load',
|
||||
message: error ? error.message : event.message,
|
||||
stack: error && error.stack,
|
||||
filename: event && event.filename,
|
||||
lineno: event && event.lineno
|
||||
message: error.message,
|
||||
stack: error.stack,
|
||||
filename: error.filename,
|
||||
lineno: error.lineno
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -95,6 +99,7 @@ getJasmineRequireObj().Env = function(j$) {
|
||||
|
||||
config.update(changes);
|
||||
deprecator.verboseDeprecations(config.verboseDeprecations);
|
||||
stackClearer.setSafariYieldStrategy(config.safariYieldStrategy);
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -132,11 +137,11 @@ getJasmineRequireObj().Env = function(j$) {
|
||||
runableResources.customObjectFormatters().push(formatter);
|
||||
};
|
||||
|
||||
j$.private.Expectation.addCoreMatchers(j$.private.matchers);
|
||||
j$.private.Expectation.addAsyncCoreMatchers(j$.private.asyncMatchers);
|
||||
private$.Expectation.addCoreMatchers(private$.matchers);
|
||||
private$.Expectation.addAsyncCoreMatchers(private$.asyncMatchers);
|
||||
|
||||
const expectationFactory = function(actual, spec) {
|
||||
return j$.private.Expectation.factory({
|
||||
return private$.Expectation.factory({
|
||||
matchersUtil: runableResources.makeMatchersUtil(),
|
||||
customMatchers: runableResources.customMatchers(),
|
||||
actual: actual,
|
||||
@@ -169,7 +174,7 @@ getJasmineRequireObj().Env = function(j$) {
|
||||
};
|
||||
|
||||
const throwUnlessFactory = function(actual, spec) {
|
||||
return j$.private.Expectation.factory({
|
||||
return private$.Expectation.factory({
|
||||
matchersUtil: runableResources.makeMatchersUtil(),
|
||||
customMatchers: runableResources.customMatchers(),
|
||||
actual: actual,
|
||||
@@ -178,7 +183,7 @@ getJasmineRequireObj().Env = function(j$) {
|
||||
};
|
||||
|
||||
const throwUnlessAsyncFactory = function(actual, spec) {
|
||||
return j$.private.Expectation.asyncFactory({
|
||||
return private$.Expectation.asyncFactory({
|
||||
matchersUtil: runableResources.makeMatchersUtil(),
|
||||
customAsyncMatchers: runableResources.customAsyncMatchers(),
|
||||
actual: actual,
|
||||
@@ -193,7 +198,7 @@ getJasmineRequireObj().Env = function(j$) {
|
||||
error.matcherName !== undefined && error.passed !== undefined;
|
||||
const result = isExpectationResult
|
||||
? error
|
||||
: j$.private.buildExpectationResult({
|
||||
: private$.buildExpectationResult({
|
||||
error,
|
||||
passed: false,
|
||||
matcherName: '',
|
||||
@@ -240,7 +245,7 @@ getJasmineRequireObj().Env = function(j$) {
|
||||
expectationResult.globalErrorType = 'lateError';
|
||||
}
|
||||
|
||||
r.result.failedExpectations.push(expectationResult);
|
||||
r.addExpectationResult(false, expectationResult);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -254,7 +259,7 @@ getJasmineRequireObj().Env = function(j$) {
|
||||
}
|
||||
|
||||
const asyncExpectationFactory = function(actual, spec, runableType) {
|
||||
return j$.private.Expectation.asyncFactory({
|
||||
return private$.Expectation.asyncFactory({
|
||||
matchersUtil: runableResources.makeMatchersUtil(),
|
||||
customAsyncMatchers: runableResources.customAsyncMatchers(),
|
||||
actual: actual,
|
||||
@@ -291,13 +296,16 @@ getJasmineRequireObj().Env = function(j$) {
|
||||
* @param {String|Error} deprecation The deprecation message
|
||||
* @param {Object} [options] Optional extra options, as described above
|
||||
*/
|
||||
this.deprecated = function(deprecation, options) {
|
||||
const runable = runner.currentRunable() || topSuite;
|
||||
deprecator.addDeprecationWarning(runable, deprecation, options);
|
||||
};
|
||||
Object.defineProperty(this, 'deprecated', {
|
||||
enumerable: true,
|
||||
value: function(deprecation, options) {
|
||||
const runable = runner.currentRunable() || topSuite;
|
||||
deprecator.addDeprecationWarning(runable, deprecation, options);
|
||||
}
|
||||
});
|
||||
|
||||
function runQueue(options) {
|
||||
options.clearStack = options.clearStack || clearStack;
|
||||
options.clearStack = options.clearStack || stackClearer;
|
||||
options.timeout = {
|
||||
setTimeout: realSetTimeout,
|
||||
clearTimeout: realClearTimeout
|
||||
@@ -310,10 +318,10 @@ getJasmineRequireObj().Env = function(j$) {
|
||||
(runner.currentRunable() || topSuite).handleException(e);
|
||||
};
|
||||
|
||||
new j$.private.QueueRunner(options).execute();
|
||||
new private$.QueueRunner(options).execute();
|
||||
}
|
||||
|
||||
const suiteBuilder = new j$.private.SuiteBuilder({
|
||||
const suiteBuilder = new private$.SuiteBuilder({
|
||||
env: this,
|
||||
expectationFactory,
|
||||
asyncExpectationFactory,
|
||||
@@ -321,7 +329,8 @@ getJasmineRequireObj().Env = function(j$) {
|
||||
runQueue
|
||||
});
|
||||
topSuite = suiteBuilder.topSuite;
|
||||
const deprecator = new j$.private.Deprecator(topSuite);
|
||||
const deprecator =
|
||||
envOptions?.deprecator ?? new private$.Deprecator(topSuite);
|
||||
|
||||
/**
|
||||
* Provides the root suite, through which all suites and specs can be
|
||||
@@ -341,23 +350,23 @@ getJasmineRequireObj().Env = function(j$) {
|
||||
* @interface Reporter
|
||||
* @see custom_reporter
|
||||
*/
|
||||
reportDispatcher = new j$.private.ReportDispatcher(
|
||||
j$.private.reporterEvents,
|
||||
reportDispatcher = new private$.ReportDispatcher(
|
||||
private$.reporterEvents,
|
||||
function(options) {
|
||||
options.SkipPolicy = j$.private.NeverSkipPolicy;
|
||||
options.SkipPolicy = private$.NeverSkipPolicy;
|
||||
return runQueue(options);
|
||||
},
|
||||
recordLateError
|
||||
);
|
||||
|
||||
runner = new j$.private.Runner({
|
||||
runner = new private$.Runner({
|
||||
topSuite,
|
||||
totalSpecsDefined: () => suiteBuilder.totalSpecsDefined,
|
||||
focusedRunables: () => suiteBuilder.focusedRunables,
|
||||
runableResources,
|
||||
reportDispatcher,
|
||||
runQueue,
|
||||
TreeProcessor: j$.private.TreeProcessor,
|
||||
TreeProcessor: private$.TreeProcessor,
|
||||
globalErrors,
|
||||
getConfig: () => config
|
||||
});
|
||||
@@ -400,6 +409,14 @@ getJasmineRequireObj().Env = function(j$) {
|
||||
this.execute = async function(runablesToRun) {
|
||||
installGlobalErrors();
|
||||
|
||||
// Karma incorrectly loads jasmine-core as an ES module. It isn't one,
|
||||
// and we don't test that configuration. Warn about it.
|
||||
if (private$.loadedAsBrowserEsm) {
|
||||
this.deprecated(
|
||||
"jasmine-core isn't an ES module but it was loaded as one. This is not a supported configuration."
|
||||
);
|
||||
}
|
||||
|
||||
if (parallelLoadingState) {
|
||||
validateConfigForParallel();
|
||||
}
|
||||
@@ -523,7 +540,7 @@ getJasmineRequireObj().Env = function(j$) {
|
||||
try {
|
||||
const maybePromise = fn(spy);
|
||||
|
||||
if (!j$.private.isPromiseLike(maybePromise)) {
|
||||
if (!private$.isPromiseLike(maybePromise)) {
|
||||
throw new Error(
|
||||
'The callback to spyOnGlobalErrorsAsync must be an async or promise-returning function'
|
||||
);
|
||||
@@ -581,14 +598,14 @@ getJasmineRequireObj().Env = function(j$) {
|
||||
|
||||
this.describe = function(description, definitionFn) {
|
||||
ensureIsNotNested('describe');
|
||||
const filename = callerCallerFilename();
|
||||
const filename = indirectCallerFilename(describeStackDepth());
|
||||
return suiteBuilder.describe(description, definitionFn, filename)
|
||||
.metadata;
|
||||
};
|
||||
|
||||
this.xdescribe = function(description, definitionFn) {
|
||||
ensureIsNotNested('xdescribe');
|
||||
const filename = callerCallerFilename();
|
||||
const filename = indirectCallerFilename(describeStackDepth());
|
||||
return suiteBuilder.xdescribe(description, definitionFn, filename)
|
||||
.metadata;
|
||||
};
|
||||
@@ -596,30 +613,38 @@ getJasmineRequireObj().Env = function(j$) {
|
||||
this.fdescribe = function(description, definitionFn) {
|
||||
ensureIsNotNested('fdescribe');
|
||||
ensureNonParallel('fdescribe');
|
||||
const filename = callerCallerFilename();
|
||||
const filename = indirectCallerFilename(describeStackDepth());
|
||||
return suiteBuilder.fdescribe(description, definitionFn, filename)
|
||||
.metadata;
|
||||
};
|
||||
|
||||
this.it = function(description, fn, timeout) {
|
||||
ensureIsNotNested('it');
|
||||
const filename = callerCallerFilename();
|
||||
const filename = indirectCallerFilename(itStackDepth());
|
||||
return suiteBuilder.it(description, fn, timeout, filename).metadata;
|
||||
};
|
||||
|
||||
this.xit = function(description, fn, timeout) {
|
||||
ensureIsNotNested('xit');
|
||||
const filename = callerCallerFilename();
|
||||
const filename = indirectCallerFilename(itStackDepth());
|
||||
return suiteBuilder.xit(description, fn, timeout, filename).metadata;
|
||||
};
|
||||
|
||||
this.fit = function(description, fn, timeout) {
|
||||
ensureIsNotNested('fit');
|
||||
ensureNonParallel('fit');
|
||||
const filename = callerCallerFilename();
|
||||
const filename = indirectCallerFilename(itStackDepth());
|
||||
return suiteBuilder.fit(description, fn, timeout, filename).metadata;
|
||||
};
|
||||
|
||||
function itStackDepth() {
|
||||
return DEFAULT_IT_DESCRIBE_STACK_DEPTH + config.extraItStackFrames;
|
||||
}
|
||||
|
||||
function describeStackDepth() {
|
||||
return DEFAULT_IT_DESCRIBE_STACK_DEPTH + config.extraDescribeStackFrames;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a user-defined property as part of the properties field of {@link SpecDoneEvent}
|
||||
* @name Env#getSpecProperty
|
||||
@@ -758,7 +783,7 @@ getJasmineRequireObj().Env = function(j$) {
|
||||
};
|
||||
|
||||
this.pending = function(message) {
|
||||
let fullMessage = j$.private.Spec.pendingSpecExceptionMessage;
|
||||
let fullMessage = private$.Spec.pendingSpecExceptionMessage;
|
||||
if (message) {
|
||||
fullMessage += message;
|
||||
}
|
||||
@@ -777,7 +802,7 @@ getJasmineRequireObj().Env = function(j$) {
|
||||
message += ': ';
|
||||
if (error.message) {
|
||||
message += error.message;
|
||||
} else if (j$.private.isString(error)) {
|
||||
} else if (private$.isString(error)) {
|
||||
message += error;
|
||||
} else {
|
||||
// pretty print all kind of objects. This includes arrays.
|
||||
@@ -800,17 +825,29 @@ getJasmineRequireObj().Env = function(j$) {
|
||||
}
|
||||
};
|
||||
|
||||
this.pp = function(value) {
|
||||
const pp = runner.currentRunable()
|
||||
? runableResources.makePrettyPrinter()
|
||||
: private$.basicPrettyPrinter;
|
||||
return pp(value);
|
||||
};
|
||||
|
||||
this.cleanup_ = function() {
|
||||
uninstallGlobalErrors();
|
||||
};
|
||||
|
||||
Object.freeze(this);
|
||||
}
|
||||
|
||||
function callerCallerFilename() {
|
||||
const frames = new j$.private.StackTrace(new Error()).frames;
|
||||
// frames[3] should always exist except in Jasmine's own tests, which bypass
|
||||
// the global it/describe layer, but don't crash if it doesn't.
|
||||
return frames[3] && frames[3].file;
|
||||
function indirectCallerFilename(depth) {
|
||||
const frames = new private$.StackTrace(new Error()).frames;
|
||||
// The specified frame should always exist except in Jasmine's own tests,
|
||||
// which bypass the global it/describe layer, but could be absent in case
|
||||
// of misconfiguration. Don't crash if it's absent.
|
||||
return frames[depth] && frames[depth].file;
|
||||
}
|
||||
|
||||
Object.freeze(Env);
|
||||
Object.freeze(Env.prototype);
|
||||
return Env;
|
||||
};
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
getJasmineRequireObj().ExceptionFormatter = function(j$) {
|
||||
getJasmineRequireObj().ExceptionFormatter = function(j$, private$) {
|
||||
'use strict';
|
||||
|
||||
const ignoredProperties = [
|
||||
'name',
|
||||
'message',
|
||||
@@ -9,12 +11,13 @@ getJasmineRequireObj().ExceptionFormatter = function(j$) {
|
||||
'lineNumber',
|
||||
'column',
|
||||
'description',
|
||||
'jasmineMessage'
|
||||
'jasmineMessage',
|
||||
'errors'
|
||||
];
|
||||
|
||||
function ExceptionFormatter(options) {
|
||||
const jasmineFile =
|
||||
(options && options.jasmineFile) || j$.private.util.jasmineFile();
|
||||
(options && options.jasmineFile) || private$.util.jasmineFile();
|
||||
this.message = function(error) {
|
||||
let message = '';
|
||||
|
||||
@@ -58,7 +61,7 @@ getJasmineRequireObj().ExceptionFormatter = function(j$) {
|
||||
lines.pop();
|
||||
}
|
||||
|
||||
const stackTrace = new j$.private.StackTrace(error);
|
||||
const stackTrace = new private$.StackTrace(error);
|
||||
lines = lines.concat(filterJasmine(stackTrace));
|
||||
|
||||
if (messageHandling === 'require') {
|
||||
@@ -75,6 +78,19 @@ getJasmineRequireObj().ExceptionFormatter = function(j$) {
|
||||
lines = lines.concat(substack);
|
||||
}
|
||||
|
||||
if (Array.isArray(error.errors)) {
|
||||
for (let i = 0; i < error.errors.length; i++) {
|
||||
if (error.errors[i] instanceof Error) {
|
||||
lines.push('');
|
||||
const substack = this.stack_(error.errors[i], {
|
||||
messageHandling: 'require'
|
||||
});
|
||||
substack[0] = 'Error ' + (i + 1) + ': ' + substack[0];
|
||||
lines = lines.concat(substack.map(x => ' ' + x));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return lines;
|
||||
};
|
||||
|
||||
@@ -112,7 +128,7 @@ getJasmineRequireObj().ExceptionFormatter = function(j$) {
|
||||
|
||||
if (!empty) {
|
||||
return (
|
||||
'error properties: ' + j$.private.basicPrettyPrinter(result) + '\n'
|
||||
'error properties: ' + private$.basicPrettyPrinter(result) + '\n'
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
getJasmineRequireObj().Expectation = function(j$) {
|
||||
getJasmineRequireObj().Expectation = function(j$, private$) {
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* Matchers that come with Jasmine out of the box.
|
||||
* @namespace matchers
|
||||
*/
|
||||
function Expectation(options) {
|
||||
this.expector = new j$.private.Expector(options);
|
||||
this.expector = new private$.Expector(options);
|
||||
|
||||
const customMatchers = options.customMatchers || {};
|
||||
for (const matcherName in customMatchers) {
|
||||
@@ -80,7 +82,7 @@ getJasmineRequireObj().Expectation = function(j$) {
|
||||
* @namespace async-matchers
|
||||
*/
|
||||
function AsyncExpectation(options) {
|
||||
this.expector = new j$.private.Expector(options);
|
||||
this.expector = new private$.Expector(options);
|
||||
|
||||
const customAsyncMatchers = options.customAsyncMatchers || {};
|
||||
for (const matcherName in customAsyncMatchers) {
|
||||
@@ -173,7 +175,7 @@ getJasmineRequireObj().Expectation = function(j$) {
|
||||
|
||||
function negatedFailureMessage(result, matcherName, args, matchersUtil) {
|
||||
if (result.message) {
|
||||
if (j$.private.isFunction(result.message)) {
|
||||
if (private$.isFunction(result.message)) {
|
||||
return result.message();
|
||||
} else {
|
||||
return result.message;
|
||||
@@ -218,7 +220,7 @@ getJasmineRequireObj().Expectation = function(j$) {
|
||||
return function(actual) {
|
||||
const matcherArgs = arguments;
|
||||
|
||||
return j$.private.isPending(actual).then(function(isPending) {
|
||||
return private$.isPending(actual).then(function(isPending) {
|
||||
if (isPending) {
|
||||
return {
|
||||
pass: false,
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
getJasmineRequireObj().ExpectationFilterChain = function() {
|
||||
'use strict';
|
||||
|
||||
function ExpectationFilterChain(maybeFilter, prev) {
|
||||
this.filter_ = maybeFilter;
|
||||
this.prev_ = prev;
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
getJasmineRequireObj().Expector = function(j$) {
|
||||
getJasmineRequireObj().Expector = function(j$, private$) {
|
||||
'use strict';
|
||||
|
||||
function Expector(options) {
|
||||
this.matchersUtil = options.matchersUtil || {
|
||||
buildFailureMessage: function() {}
|
||||
};
|
||||
this.actual = options.actual;
|
||||
this.addExpectationResult = options.addExpectationResult || function() {};
|
||||
this.filters = new j$.private.ExpectationFilterChain();
|
||||
this.filters = new private$.ExpectationFilterChain();
|
||||
}
|
||||
|
||||
Expector.prototype.instantiateMatcher = function(
|
||||
@@ -39,7 +41,7 @@ getJasmineRequireObj().Expector = function(j$) {
|
||||
this.matchersUtil,
|
||||
args
|
||||
);
|
||||
} else if (j$.private.isFunction(result.message)) {
|
||||
} else if (private$.isFunction(result.message)) {
|
||||
return result.message();
|
||||
} else {
|
||||
return result.message;
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
getJasmineRequireObj().GlobalErrors = function(j$) {
|
||||
getJasmineRequireObj().GlobalErrors = function(j$, private$) {
|
||||
'use strict';
|
||||
|
||||
class GlobalErrors {
|
||||
#getConfig;
|
||||
#adapter;
|
||||
@@ -24,7 +26,7 @@ getJasmineRequireObj().GlobalErrors = function(j$) {
|
||||
if (
|
||||
global.process &&
|
||||
global.process.listeners &&
|
||||
j$.private.isFunction(global.process.on)
|
||||
private$.isFunction(global.process.on)
|
||||
) {
|
||||
this.#adapter = new NodeAdapter(global, dispatch);
|
||||
} else {
|
||||
@@ -40,13 +42,6 @@ getJasmineRequireObj().GlobalErrors = function(j$) {
|
||||
this.#adapter.uninstall();
|
||||
}
|
||||
|
||||
// The listener at the top of the stack will be called with two arguments:
|
||||
// the error and the event. Either of them may be falsy.
|
||||
// The error will normally be provided, but will be falsy in the case of
|
||||
// some browser load-time errors. The event will normally be provided in
|
||||
// browsers but will be falsy in Node.
|
||||
// Listeners that are pushed after spec files have been loaded should be
|
||||
// able to just use the error parameter.
|
||||
pushListener(listener) {
|
||||
this.#handlers.push(listener);
|
||||
}
|
||||
@@ -78,29 +73,23 @@ getJasmineRequireObj().GlobalErrors = function(j$) {
|
||||
}
|
||||
|
||||
reportUnhandledRejections() {
|
||||
for (const {
|
||||
reason,
|
||||
event
|
||||
} of this.#pendingUnhandledRejections.values()) {
|
||||
this.#dispatchError(reason, event);
|
||||
for (const { reason } of this.#pendingUnhandledRejections.values()) {
|
||||
this.#dispatchError(reason);
|
||||
}
|
||||
|
||||
this.#pendingUnhandledRejections.clear();
|
||||
}
|
||||
|
||||
// Either error or event may be undefined
|
||||
#onUncaughtException(error, event) {
|
||||
this.#dispatchError(error, event);
|
||||
#onUncaughtException(error) {
|
||||
this.#dispatchError(error);
|
||||
}
|
||||
|
||||
// event or promise may be undefined
|
||||
// event is passed through for backwards compatibility reasons. It's probably
|
||||
// unnecessary, but user code could depend on it.
|
||||
#onUnhandledRejection(reason, promise, event) {
|
||||
// promise may be undefined
|
||||
#onUnhandledRejection(reason, promise) {
|
||||
if (this.#detectLateRejectionHandling() && promise) {
|
||||
this.#pendingUnhandledRejections.set(promise, { reason, event });
|
||||
this.#pendingUnhandledRejections.set(promise, { reason });
|
||||
} else {
|
||||
this.#dispatchError(reason, event);
|
||||
this.#dispatchError(reason);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -112,8 +101,7 @@ getJasmineRequireObj().GlobalErrors = function(j$) {
|
||||
this.#pendingUnhandledRejections.delete(promise);
|
||||
}
|
||||
|
||||
// Either error or event may be undefined
|
||||
#dispatchError(error, event) {
|
||||
#dispatchError(error) {
|
||||
if (this.#overrideHandler) {
|
||||
// See discussion of spyOnGlobalErrorsAsync in base.js
|
||||
this.#overrideHandler(error);
|
||||
@@ -123,7 +111,7 @@ getJasmineRequireObj().GlobalErrors = function(j$) {
|
||||
const handler = this.#handlers[this.#handlers.length - 1];
|
||||
|
||||
if (handler) {
|
||||
handler(error, event);
|
||||
handler(error);
|
||||
} else {
|
||||
throw error;
|
||||
}
|
||||
@@ -140,7 +128,7 @@ getJasmineRequireObj().GlobalErrors = function(j$) {
|
||||
constructor(global, dispatch) {
|
||||
this.#global = global;
|
||||
this.#dispatch = dispatch;
|
||||
this.#onError = event => dispatch.onUncaughtException(event.error, event);
|
||||
this.#onError = this.#errorHandler.bind(this);
|
||||
this.#onUnhandledRejection = this.#unhandledRejectionHandler.bind(this);
|
||||
this.#onRejectionHandled = this.#rejectionHandledHandler.bind(this);
|
||||
}
|
||||
@@ -169,18 +157,40 @@ getJasmineRequireObj().GlobalErrors = function(j$) {
|
||||
);
|
||||
}
|
||||
|
||||
#errorHandler(event) {
|
||||
let error = event.error;
|
||||
|
||||
// event.error isn't guaranteed to be present in all browser load-time
|
||||
// error events.
|
||||
if (!error) {
|
||||
error = {
|
||||
message: event.message,
|
||||
stack: `@${event.filename}:${event.lineno}`
|
||||
};
|
||||
}
|
||||
|
||||
if (event.filename) {
|
||||
// filename and lineno can be more convenient than stack when reporting
|
||||
// things like syntax errors. Pass them along.
|
||||
error.filename = event.filename;
|
||||
error.lineno = event.lineno;
|
||||
}
|
||||
|
||||
this.#dispatch.onUncaughtException(error);
|
||||
}
|
||||
|
||||
#unhandledRejectionHandler(event) {
|
||||
const jasmineMessage = 'Unhandled promise rejection: ' + event.reason;
|
||||
let reason;
|
||||
|
||||
if (j$.private.isError(event.reason)) {
|
||||
if (private$.isError(event.reason)) {
|
||||
reason = event.reason;
|
||||
reason.jasmineMessage = jasmineMessage;
|
||||
} else {
|
||||
reason = jasmineMessage;
|
||||
}
|
||||
|
||||
this.#dispatch.onUnhandledRejection(reason, event.promise, event);
|
||||
this.#dispatch.onUnhandledRejection(reason, event.promise);
|
||||
}
|
||||
|
||||
#rejectionHandledHandler(event) {
|
||||
@@ -252,7 +262,7 @@ getJasmineRequireObj().GlobalErrors = function(j$) {
|
||||
jasmineMessagePrefix = 'Uncaught exception';
|
||||
}
|
||||
|
||||
if (j$.private.isError(error)) {
|
||||
if (private$.isError(error)) {
|
||||
error.jasmineMessage = jasmineMessagePrefix + ': ' + error;
|
||||
return error;
|
||||
} else {
|
||||
|
||||
@@ -1,129 +0,0 @@
|
||||
getJasmineRequireObj().JsApiReporter = function(j$) {
|
||||
/**
|
||||
* @name jsApiReporter
|
||||
* @classdesc {@link Reporter} added by default in `boot.js` to record results for retrieval in javascript code. An instance is made available as `jsApiReporter` on the global object.
|
||||
* @class
|
||||
* @hideconstructor
|
||||
*/
|
||||
function JsApiReporter(options) {
|
||||
const timer = options.timer || new j$.Timer();
|
||||
let status = 'loaded';
|
||||
|
||||
this.started = false;
|
||||
this.finished = false;
|
||||
this.runDetails = {};
|
||||
|
||||
this.jasmineStarted = function() {
|
||||
this.started = true;
|
||||
status = 'started';
|
||||
timer.start();
|
||||
};
|
||||
|
||||
let executionTime;
|
||||
|
||||
this.jasmineDone = function(runDetails) {
|
||||
this.finished = true;
|
||||
this.runDetails = runDetails;
|
||||
executionTime = timer.elapsed();
|
||||
status = 'done';
|
||||
};
|
||||
|
||||
/**
|
||||
* Get the current status for the Jasmine environment.
|
||||
* @name jsApiReporter#status
|
||||
* @since 2.0.0
|
||||
* @function
|
||||
* @return {String} - One of `loaded`, `started`, or `done`
|
||||
*/
|
||||
this.status = function() {
|
||||
return status;
|
||||
};
|
||||
|
||||
const suites = [],
|
||||
suites_hash = {};
|
||||
|
||||
this.suiteStarted = function(result) {
|
||||
suites_hash[result.id] = result;
|
||||
};
|
||||
|
||||
this.suiteDone = function(result) {
|
||||
storeSuite(result);
|
||||
};
|
||||
|
||||
/**
|
||||
* Get the results for a set of suites.
|
||||
*
|
||||
* Retrievable in slices for easier serialization.
|
||||
* @name jsApiReporter#suiteResults
|
||||
* @since 2.1.0
|
||||
* @function
|
||||
* @param {Number} index - The position in the suites list to start from.
|
||||
* @param {Number} length - Maximum number of suite results to return.
|
||||
* @return {SuiteResult[]}
|
||||
*/
|
||||
this.suiteResults = function(index, length) {
|
||||
return suites.slice(index, index + length);
|
||||
};
|
||||
|
||||
function storeSuite(result) {
|
||||
suites.push(result);
|
||||
suites_hash[result.id] = result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all of the suites in a single object, with their `id` as the key.
|
||||
* @name jsApiReporter#suites
|
||||
* @since 2.0.0
|
||||
* @function
|
||||
* @return {Object} - Map of suite id to {@link SuiteResult}
|
||||
*/
|
||||
this.suites = function() {
|
||||
return suites_hash;
|
||||
};
|
||||
|
||||
const specs = [];
|
||||
|
||||
this.specDone = function(result) {
|
||||
specs.push(result);
|
||||
};
|
||||
|
||||
/**
|
||||
* Get the results for a set of specs.
|
||||
*
|
||||
* Retrievable in slices for easier serialization.
|
||||
* @name jsApiReporter#specResults
|
||||
* @since 2.0.0
|
||||
* @function
|
||||
* @param {Number} index - The position in the specs list to start from.
|
||||
* @param {Number} length - Maximum number of specs results to return.
|
||||
* @return {SpecDoneEvent[]}
|
||||
*/
|
||||
this.specResults = function(index, length) {
|
||||
return specs.slice(index, index + length);
|
||||
};
|
||||
|
||||
/**
|
||||
* Get all spec results.
|
||||
* @name jsApiReporter#specs
|
||||
* @since 2.0.0
|
||||
* @function
|
||||
* @return {SpecDoneEvent[]}
|
||||
*/
|
||||
this.specs = function() {
|
||||
return specs;
|
||||
};
|
||||
|
||||
/**
|
||||
* Get the number of milliseconds it took for the full Jasmine suite to run.
|
||||
* @name jsApiReporter#executionTime
|
||||
* @since 2.0.0
|
||||
* @function
|
||||
* @return {Number}
|
||||
*/
|
||||
this.executionTime = function() {
|
||||
return executionTime;
|
||||
};
|
||||
}
|
||||
|
||||
return JsApiReporter;
|
||||
};
|
||||
@@ -1,4 +1,6 @@
|
||||
getJasmineRequireObj().MockDate = function(j$) {
|
||||
getJasmineRequireObj().MockDate = function(j$, private$) {
|
||||
'use strict';
|
||||
|
||||
function MockDate(global) {
|
||||
let currentTime = 0;
|
||||
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
getJasmineRequireObj().NeverSkipPolicy = function(j$) {
|
||||
getJasmineRequireObj().NeverSkipPolicy = function(j$, private$) {
|
||||
'use strict';
|
||||
|
||||
function NeverSkipPolicy(queueableFns) {}
|
||||
|
||||
NeverSkipPolicy.prototype.skipTo = function(lastRanFnIx) {
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
getJasmineRequireObj().Order = function() {
|
||||
'use strict';
|
||||
|
||||
function Order(options) {
|
||||
this.random = 'random' in options ? options.random : true;
|
||||
const seed = (this.seed = options.seed || generateSeed());
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
getJasmineRequireObj().ParallelReportDispatcher = function(j$) {
|
||||
getJasmineRequireObj().ParallelReportDispatcher = function(j$, private$) {
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
@@ -15,43 +15,43 @@ getJasmineRequireObj().ParallelReportDispatcher = function(j$) {
|
||||
* Jasmine specs run in. Doing so will break Jasmine's error handling.
|
||||
* @param onError {function} Function called when an unhandled exception, unhandled promise rejection, or explicit reporter failure occurs
|
||||
*/
|
||||
function ParallelReportDispatcher(onError, deps = {}) {
|
||||
const ReportDispatcher =
|
||||
deps.ReportDispatcher || j$.private.ReportDispatcher;
|
||||
const QueueRunner = deps.QueueRunner || j$.private.QueueRunner;
|
||||
const globalErrors = deps.globalErrors || new j$.private.GlobalErrors();
|
||||
const dispatcher = new ReportDispatcher(
|
||||
j$.private.reporterEvents,
|
||||
function(queueRunnerOptions) {
|
||||
queueRunnerOptions = {
|
||||
...queueRunnerOptions,
|
||||
globalErrors,
|
||||
timeout: { setTimeout, clearTimeout },
|
||||
fail: function(error) {
|
||||
// A callback-style async reporter called either done.fail()
|
||||
// or done(anError).
|
||||
if (!error) {
|
||||
error = new Error('A reporter called done.fail()');
|
||||
class ParallelReportDispatcher {
|
||||
constructor(onError, deps = {}) {
|
||||
const ReportDispatcher =
|
||||
deps.ReportDispatcher || private$.ReportDispatcher;
|
||||
const QueueRunner = deps.QueueRunner || private$.QueueRunner;
|
||||
const globalErrors = deps.globalErrors || new private$.GlobalErrors();
|
||||
const dispatcher = new ReportDispatcher(
|
||||
private$.reporterEvents,
|
||||
function(queueRunnerOptions) {
|
||||
queueRunnerOptions = {
|
||||
...queueRunnerOptions,
|
||||
globalErrors,
|
||||
timeout: { setTimeout, clearTimeout },
|
||||
fail: function(error) {
|
||||
// A callback-style async reporter called either done.fail()
|
||||
// or done(anError).
|
||||
if (!error) {
|
||||
error = new Error('A reporter called done.fail()');
|
||||
}
|
||||
|
||||
onError(error);
|
||||
},
|
||||
onException: function(error) {
|
||||
// A reporter method threw an exception or returned a rejected
|
||||
// promise, or there was an unhandled exception or unhandled promise
|
||||
// rejection while an asynchronous reporter method was running.
|
||||
onError(error);
|
||||
}
|
||||
};
|
||||
new QueueRunner(queueRunnerOptions).execute();
|
||||
},
|
||||
function(error) {
|
||||
// A reporter called done() more than once.
|
||||
onError(error);
|
||||
}
|
||||
);
|
||||
|
||||
onError(error);
|
||||
},
|
||||
onException: function(error) {
|
||||
// A reporter method threw an exception or returned a rejected
|
||||
// promise, or there was an unhandled exception or unhandled promise
|
||||
// rejection while an asynchronous reporter method was running.
|
||||
onError(error);
|
||||
}
|
||||
};
|
||||
new QueueRunner(queueRunnerOptions).execute();
|
||||
},
|
||||
function(error) {
|
||||
// A reporter called done() more than once.
|
||||
onError(error);
|
||||
}
|
||||
);
|
||||
|
||||
const self = {
|
||||
/**
|
||||
* Adds a reporter to the list of reporters that events will be dispatched to.
|
||||
* @function
|
||||
@@ -59,13 +59,13 @@ getJasmineRequireObj().ParallelReportDispatcher = function(j$) {
|
||||
* @param {Reporter} reporterToAdd The reporter to be added.
|
||||
* @see custom_reporter
|
||||
*/
|
||||
addReporter: dispatcher.addReporter.bind(dispatcher),
|
||||
this.addReporter = dispatcher.addReporter.bind(dispatcher);
|
||||
/**
|
||||
* Clears all registered reporters.
|
||||
* @function
|
||||
* @name ParallelReportDispatcher#clearReporters
|
||||
*/
|
||||
clearReporters: dispatcher.clearReporters.bind(dispatcher),
|
||||
this.clearReporters = dispatcher.clearReporters.bind(dispatcher);
|
||||
/**
|
||||
* Installs a global error handler. After this method is called, any
|
||||
* unhandled exceptions or unhandled promise rejections will be passed to
|
||||
@@ -73,24 +73,25 @@ getJasmineRequireObj().ParallelReportDispatcher = function(j$) {
|
||||
* @function
|
||||
* @name ParallelReportDispatcher#installGlobalErrors
|
||||
*/
|
||||
installGlobalErrors: globalErrors.install.bind(globalErrors),
|
||||
this.installGlobalErrors = globalErrors.install.bind(globalErrors);
|
||||
/**
|
||||
* Uninstalls the global error handler.
|
||||
* @function
|
||||
* @name ParallelReportDispatcher#uninstallGlobalErrors
|
||||
*/
|
||||
uninstallGlobalErrors: function() {
|
||||
this.uninstallGlobalErrors = function() {
|
||||
// late-bind uninstall because it doesn't exist until install is called
|
||||
globalErrors.uninstall(globalErrors);
|
||||
};
|
||||
|
||||
for (const eventName of private$.reporterEvents) {
|
||||
this[eventName] = dispatcher[eventName].bind(dispatcher);
|
||||
}
|
||||
};
|
||||
|
||||
for (const eventName of j$.private.reporterEvents) {
|
||||
self[eventName] = dispatcher[eventName].bind(dispatcher);
|
||||
Object.freeze(this);
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
Object.freeze(ParallelReportDispatcher.prototype);
|
||||
return ParallelReportDispatcher;
|
||||
};
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
getJasmineRequireObj().makePrettyPrinter = function(j$) {
|
||||
getJasmineRequireObj().makePrettyPrinter = function(j$, private$) {
|
||||
'use strict';
|
||||
|
||||
class SinglePrettyPrintRun {
|
||||
constructor(customObjectFormatters, pp) {
|
||||
this.customObjectFormatters_ = customObjectFormatters;
|
||||
@@ -26,7 +28,7 @@ getJasmineRequireObj().makePrettyPrinter = function(j$) {
|
||||
this.emitScalar('<global>');
|
||||
} else if (value.jasmineToString) {
|
||||
this.emitScalar(value.jasmineToString(this.pp_));
|
||||
} else if (j$.private.isString(value)) {
|
||||
} else if (private$.isString(value)) {
|
||||
this.emitString(value);
|
||||
} else if (j$.isSpy(value)) {
|
||||
this.emitScalar('spy on ' + value.and.identity);
|
||||
@@ -40,7 +42,7 @@ getJasmineRequireObj().makePrettyPrinter = function(j$) {
|
||||
} else {
|
||||
this.emitScalar('Function');
|
||||
}
|
||||
} else if (j$.private.isDomNode(value)) {
|
||||
} else if (private$.isDomNode(value)) {
|
||||
if (value.tagName) {
|
||||
this.emitDomElement(value);
|
||||
} else {
|
||||
@@ -48,16 +50,16 @@ getJasmineRequireObj().makePrettyPrinter = function(j$) {
|
||||
}
|
||||
} else if (value instanceof Date) {
|
||||
this.emitScalar('Date(' + value + ')');
|
||||
} else if (j$.private.isSet(value)) {
|
||||
} else if (private$.isSet(value)) {
|
||||
this.emitSet(value);
|
||||
} else if (j$.private.isMap(value)) {
|
||||
} else if (private$.isMap(value)) {
|
||||
this.emitMap(value);
|
||||
} else if (j$.private.isTypedArray(value)) {
|
||||
} else if (private$.isTypedArray(value)) {
|
||||
this.emitTypedArray(value);
|
||||
} else if (
|
||||
value.toString &&
|
||||
typeof value === 'object' &&
|
||||
!j$.private.isArray(value) &&
|
||||
!Array.isArray(value) &&
|
||||
hasCustomToString(value)
|
||||
) {
|
||||
try {
|
||||
@@ -69,15 +71,12 @@ getJasmineRequireObj().makePrettyPrinter = function(j$) {
|
||||
} else if (this.seen.includes(value)) {
|
||||
this.emitScalar(
|
||||
'<circular reference: ' +
|
||||
(j$.private.isArray(value) ? 'Array' : 'Object') +
|
||||
(Array.isArray(value) ? 'Array' : 'Object') +
|
||||
'>'
|
||||
);
|
||||
} else if (
|
||||
j$.private.isArray(value) ||
|
||||
j$.private.isA('Object', value)
|
||||
) {
|
||||
} else if (Array.isArray(value) || private$.isA('Object', value)) {
|
||||
this.seen.push(value);
|
||||
if (j$.private.isArray(value)) {
|
||||
if (Array.isArray(value)) {
|
||||
this.emitArray(value);
|
||||
} else {
|
||||
this.emitObject(value);
|
||||
@@ -100,10 +99,7 @@ getJasmineRequireObj().makePrettyPrinter = function(j$) {
|
||||
}
|
||||
|
||||
iterateObject(obj, fn) {
|
||||
const objKeys = j$.private.MatchersUtil.keys(
|
||||
obj,
|
||||
j$.private.isArray(obj)
|
||||
);
|
||||
const objKeys = private$.MatchersUtil.keys(obj, Array.isArray(obj));
|
||||
const length = Math.min(objKeys.length, j$.MAX_PRETTY_PRINT_ARRAY_LENGTH);
|
||||
|
||||
for (let i = 0; i < length; i++) {
|
||||
@@ -212,7 +208,7 @@ getJasmineRequireObj().makePrettyPrinter = function(j$) {
|
||||
const ctor = obj.constructor;
|
||||
const constructorName =
|
||||
typeof ctor === 'function' && obj instanceof ctor
|
||||
? j$.private.fnNameFor(obj.constructor)
|
||||
? private$.fnNameFor(obj.constructor)
|
||||
: 'null';
|
||||
|
||||
this.append(constructorName);
|
||||
@@ -242,7 +238,7 @@ getJasmineRequireObj().makePrettyPrinter = function(j$) {
|
||||
}
|
||||
|
||||
emitTypedArray(arr) {
|
||||
const constructorName = j$.private.fnNameFor(arr.constructor);
|
||||
const constructorName = private$.fnNameFor(arr.constructor);
|
||||
const limitedArray = Array.prototype.slice.call(
|
||||
arr,
|
||||
0,
|
||||
@@ -311,7 +307,7 @@ getJasmineRequireObj().makePrettyPrinter = function(j$) {
|
||||
// iframe, web worker)
|
||||
try {
|
||||
return (
|
||||
j$.private.isFunction(value.toString) &&
|
||||
private$.isFunction(value.toString) &&
|
||||
value.toString !== Object.prototype.toString &&
|
||||
value.toString() !== Object.prototype.toString.call(value)
|
||||
);
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
getJasmineRequireObj().QueueRunner = function(j$) {
|
||||
getJasmineRequireObj().QueueRunner = function(j$, private$) {
|
||||
'use strict';
|
||||
|
||||
let nextid = 1;
|
||||
|
||||
function StopExecutionError() {}
|
||||
StopExecutionError.prototype = new Error();
|
||||
j$.private.StopExecutionError = StopExecutionError;
|
||||
private$.StopExecutionError = StopExecutionError;
|
||||
|
||||
function once(fn, onTwice) {
|
||||
let called = false;
|
||||
@@ -49,14 +51,14 @@ getJasmineRequireObj().QueueRunner = function(j$) {
|
||||
}
|
||||
|
||||
this.onComplete = attrs.onComplete || emptyFn;
|
||||
this.clearStack =
|
||||
attrs.clearStack ||
|
||||
function(fn) {
|
||||
this.clearStack = attrs.clearStack || {
|
||||
clearStack(fn) {
|
||||
fn();
|
||||
};
|
||||
}
|
||||
};
|
||||
this.onException = attrs.onException || emptyFn;
|
||||
this.onMultipleDone = attrs.onMultipleDone || fallbackOnMultipleDone;
|
||||
this.userContext = attrs.userContext || new j$.private.UserContext();
|
||||
this.userContext = attrs.userContext || new private$.UserContext();
|
||||
this.timeout = attrs.timeout || {
|
||||
setTimeout: setTimeout,
|
||||
clearTimeout: clearTimeout
|
||||
@@ -67,7 +69,7 @@ getJasmineRequireObj().QueueRunner = function(j$) {
|
||||
popListener: emptyFn
|
||||
};
|
||||
|
||||
const SkipPolicy = attrs.SkipPolicy || j$.private.NeverSkipPolicy;
|
||||
const SkipPolicy = attrs.SkipPolicy || private$.NeverSkipPolicy;
|
||||
this.skipPolicy_ = new SkipPolicy(this.queueableFns);
|
||||
this.errored_ = false;
|
||||
|
||||
@@ -77,8 +79,8 @@ getJasmineRequireObj().QueueRunner = function(j$) {
|
||||
}
|
||||
|
||||
QueueRunner.prototype.execute = function() {
|
||||
this.handleFinalError = (error, event) => {
|
||||
this.onException(errorOrMsgForGlobalError(error, event));
|
||||
this.handleFinalError = error => {
|
||||
this.onException(error);
|
||||
};
|
||||
this.globalErrors.pushListener(this.handleFinalError);
|
||||
this.run(0);
|
||||
@@ -108,8 +110,8 @@ getJasmineRequireObj().QueueRunner = function(j$) {
|
||||
this.recordError_(iterativeIndex);
|
||||
};
|
||||
|
||||
function handleError(error, event) {
|
||||
onException(errorOrMsgForGlobalError(error, event));
|
||||
function handleError(error) {
|
||||
onException(error);
|
||||
}
|
||||
const cleanup = once(() => {
|
||||
if (timeoutId !== void 0) {
|
||||
@@ -190,7 +192,7 @@ getJasmineRequireObj().QueueRunner = function(j$) {
|
||||
if (queueableFn.fn.length === 0) {
|
||||
maybeThenable = queueableFn.fn.call(this.userContext);
|
||||
|
||||
if (maybeThenable && j$.private.isFunction(maybeThenable.then)) {
|
||||
if (maybeThenable && private$.isFunction(maybeThenable.then)) {
|
||||
maybeThenable.then(
|
||||
wrapInPromiseResolutionHandler(next),
|
||||
onPromiseRejection
|
||||
@@ -233,7 +235,7 @@ getJasmineRequireObj().QueueRunner = function(j$) {
|
||||
}
|
||||
}
|
||||
|
||||
this.clearStack(() => {
|
||||
this.clearStack.clearStack(() => {
|
||||
this.globalErrors.popListener(this.handleFinalError);
|
||||
|
||||
if (this.errored_) {
|
||||
@@ -260,11 +262,11 @@ getJasmineRequireObj().QueueRunner = function(j$) {
|
||||
};
|
||||
|
||||
QueueRunner.prototype.diagnoseConflictingAsync_ = function(fn, retval) {
|
||||
if (retval && j$.private.isFunction(retval.then)) {
|
||||
if (retval && private$.isFunction(retval.then)) {
|
||||
// Issue a warning that matches the user's code.
|
||||
// Omit the stack trace because there's almost certainly no user code
|
||||
// on the stack at this point.
|
||||
if (j$.private.isAsyncFunction(fn)) {
|
||||
if (private$.isAsyncFunction(fn)) {
|
||||
this.onException(
|
||||
new Error(
|
||||
'An asynchronous before/it/after ' +
|
||||
@@ -288,7 +290,7 @@ getJasmineRequireObj().QueueRunner = function(j$) {
|
||||
|
||||
function wrapInPromiseResolutionHandler(fn) {
|
||||
return function(maybeArg) {
|
||||
if (j$.private.isError(maybeArg)) {
|
||||
if (private$.isError(maybeArg)) {
|
||||
fn(maybeArg);
|
||||
} else {
|
||||
fn();
|
||||
@@ -296,16 +298,5 @@ getJasmineRequireObj().QueueRunner = function(j$) {
|
||||
};
|
||||
}
|
||||
|
||||
function errorOrMsgForGlobalError(error, event) {
|
||||
// TODO: In cases where error is a string or undefined, the error message
|
||||
// that gets sent to reporters will be `${message} thrown`, which could
|
||||
// be improved to not say "thrown" when the cause wasn't necessarily
|
||||
// an exception or to provide hints about throwing Errors rather than
|
||||
// strings.
|
||||
return (
|
||||
error || (event && event.message) || 'Global error event with no message'
|
||||
);
|
||||
}
|
||||
|
||||
return QueueRunner;
|
||||
};
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
getJasmineRequireObj().ReportDispatcher = function(j$) {
|
||||
getJasmineRequireObj().ReportDispatcher = function(j$, private$) {
|
||||
'use strict';
|
||||
|
||||
function ReportDispatcher(methods, runQueue, onLateError) {
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
getJasmineRequireObj().RunableResources = function(j$) {
|
||||
getJasmineRequireObj().RunableResources = function(j$, private$) {
|
||||
'use strict';
|
||||
|
||||
class RunableResources {
|
||||
constructor(options) {
|
||||
this.byRunableId_ = {};
|
||||
this.getCurrentRunableId_ = options.getCurrentRunableId;
|
||||
this.globalErrors_ = options.globalErrors;
|
||||
|
||||
this.spyFactory = new j$.private.SpyFactory(
|
||||
this.spyFactory = new private$.SpyFactory(
|
||||
() => {
|
||||
if (this.getCurrentRunableId_()) {
|
||||
return this.customSpyStrategies();
|
||||
@@ -17,7 +19,7 @@ getJasmineRequireObj().RunableResources = function(j$) {
|
||||
() => this.makeMatchersUtil()
|
||||
);
|
||||
|
||||
this.spyRegistry = new j$.private.SpyRegistry({
|
||||
this.spyRegistry = new private$.SpyRegistry({
|
||||
currentSpies: () => this.spies(),
|
||||
createSpy: (name, originalFn) =>
|
||||
this.spyFactory.createSpy(name, originalFn)
|
||||
@@ -48,7 +50,7 @@ getJasmineRequireObj().RunableResources = function(j$) {
|
||||
];
|
||||
|
||||
for (const k of toClone) {
|
||||
newRes[k] = j$.private.util.clone(parentRes[k]);
|
||||
newRes[k] = private$.util.clone(parentRes[k]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -126,18 +128,18 @@ getJasmineRequireObj().RunableResources = function(j$) {
|
||||
}
|
||||
|
||||
makePrettyPrinter() {
|
||||
return j$.private.makePrettyPrinter(this.customObjectFormatters());
|
||||
return private$.makePrettyPrinter(this.customObjectFormatters());
|
||||
}
|
||||
|
||||
makeMatchersUtil() {
|
||||
if (this.getCurrentRunableId_()) {
|
||||
return new j$.private.MatchersUtil({
|
||||
return new private$.MatchersUtil({
|
||||
customTesters: this.customEqualityTesters(),
|
||||
pp: this.makePrettyPrinter()
|
||||
});
|
||||
} else {
|
||||
return new j$.private.MatchersUtil({
|
||||
pp: j$.private.basicPrettyPrinter
|
||||
return new private$.MatchersUtil({
|
||||
pp: private$.basicPrettyPrinter
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
getJasmineRequireObj().Runner = function(j$) {
|
||||
getJasmineRequireObj().Runner = function(j$, private$) {
|
||||
'use strict';
|
||||
|
||||
class Runner {
|
||||
#topSuite;
|
||||
#getTotalSpecsDefined;
|
||||
@@ -24,7 +26,7 @@ getJasmineRequireObj().Runner = function(j$) {
|
||||
this.#reportDispatcher = options.reportDispatcher;
|
||||
this.#getConfig = options.getConfig;
|
||||
this.#executedBefore = false;
|
||||
this.#currentRunableTracker = new j$.private.CurrentRunableTracker();
|
||||
this.#currentRunableTracker = new private$.CurrentRunableTracker();
|
||||
}
|
||||
|
||||
currentSpec() {
|
||||
@@ -64,9 +66,9 @@ getJasmineRequireObj().Runner = function(j$) {
|
||||
}
|
||||
}
|
||||
|
||||
const order = new j$.private.Order({
|
||||
const order = new private$.Order({
|
||||
random: config.random,
|
||||
seed: j$.private.isNumber(config.seed) ? config.seed + '' : config.seed
|
||||
seed: private$.isNumber(config.seed) ? config.seed + '' : config.seed
|
||||
});
|
||||
|
||||
const treeProcessor = new this.#TreeProcessor({
|
||||
@@ -94,7 +96,8 @@ getJasmineRequireObj().Runner = function(j$) {
|
||||
/**
|
||||
* Information passed to the {@link Reporter#jasmineStarted} event.
|
||||
* @typedef JasmineStartedInfo
|
||||
* @property {Int} totalSpecsDefined - The total number of specs defined in this suite. Note that this property is not present when Jasmine is run in parallel mode.
|
||||
* @property {int} totalSpecsDefined - The total number of specs defined in this suite. Note that this property is not present when Jasmine is run in parallel mode.
|
||||
* @property {int} numExcludedSpecs - The number of specs that will be excluded from execution. Note that this property is not present when Jasmine is run in parallel mode.
|
||||
* @property {Order} order - Information about the ordering (random or not) of this execution of the suite. Note that this property is not present when Jasmine is run in parallel mode.
|
||||
* @property {Boolean} parallel - Whether Jasmine is being run in parallel mode.
|
||||
* @since 2.0.0
|
||||
@@ -103,12 +106,13 @@ getJasmineRequireObj().Runner = function(j$) {
|
||||
// In parallel mode, the jasmineStarted event is separately dispatched
|
||||
// by jasmine-npm. This event only reaches reporters in non-parallel.
|
||||
totalSpecsDefined,
|
||||
numExcludedSpecs: this.#executionTree.numExcludedSpecs(),
|
||||
order: orderForReporting(order),
|
||||
parallel: false
|
||||
});
|
||||
|
||||
this.#currentRunableTracker.pushSuite(this.#topSuite);
|
||||
const treeRunner = new j$.private.TreeRunner({
|
||||
const treeRunner = new private$.TreeRunner({
|
||||
executionTree: this.#executionTree,
|
||||
globalErrors: this.#globalErrors,
|
||||
runableResources: this.#runableResources,
|
||||
@@ -123,7 +127,7 @@ getJasmineRequireObj().Runner = function(j$) {
|
||||
this.#currentRunableTracker.popSuite();
|
||||
let overallStatus, incompleteReason, incompleteCode;
|
||||
|
||||
if (hasFailures || this.#topSuite.result.failedExpectations.length > 0) {
|
||||
if (hasFailures || this.#topSuite.hasOwnFailedExpectations()) {
|
||||
overallStatus = 'failed';
|
||||
} else if (this.#getFocusedRunables().length > 0) {
|
||||
overallStatus = 'incomplete';
|
||||
@@ -137,6 +141,7 @@ getJasmineRequireObj().Runner = function(j$) {
|
||||
overallStatus = 'passed';
|
||||
}
|
||||
|
||||
const topSuiteResult = this.#topSuite.doneEvent();
|
||||
/**
|
||||
* Information passed to the {@link Reporter#jasmineDone} event.
|
||||
* @typedef JasmineDoneInfo
|
||||
@@ -156,8 +161,8 @@ getJasmineRequireObj().Runner = function(j$) {
|
||||
incompleteReason: incompleteReason,
|
||||
incompleteCode: incompleteCode,
|
||||
order: orderForReporting(order),
|
||||
failedExpectations: this.#topSuite.result.failedExpectations,
|
||||
deprecationWarnings: this.#topSuite.result.deprecationWarnings
|
||||
failedExpectations: topSuiteResult.failedExpectations,
|
||||
deprecationWarnings: topSuiteResult.deprecationWarnings
|
||||
};
|
||||
this.#topSuite.reportedDone = true;
|
||||
await this.#reportDispatcher.jasmineDone(jasmineDoneInfo);
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
getJasmineRequireObj().SkipAfterBeforeAllErrorPolicy = function(j$) {
|
||||
getJasmineRequireObj().SkipAfterBeforeAllErrorPolicy = function(j$, private$) {
|
||||
'use strict';
|
||||
|
||||
function SkipAfterBeforeAllErrorPolicy(queueableFns) {
|
||||
this.queueableFns_ = queueableFns;
|
||||
this.skipping_ = false;
|
||||
|
||||
148
src/core/Spec.js
148
src/core/Spec.js
@@ -1,9 +1,12 @@
|
||||
getJasmineRequireObj().Spec = function(j$) {
|
||||
getJasmineRequireObj().Spec = function(j$, private$) {
|
||||
'use strict';
|
||||
|
||||
class Spec {
|
||||
#autoCleanClosures;
|
||||
#throwOnExpectationFailure;
|
||||
#timer;
|
||||
#metadata;
|
||||
#executionState;
|
||||
|
||||
constructor(attrs) {
|
||||
this.expectationFactory = attrs.expectationFactory;
|
||||
@@ -35,49 +38,47 @@ getJasmineRequireObj().Spec = function(j$) {
|
||||
this.#throwOnExpectationFailure = !!attrs.throwOnExpectationFailure;
|
||||
this.#timer = attrs.timer || new j$.Timer();
|
||||
|
||||
this.reset();
|
||||
|
||||
if (!this.queueableFn.fn) {
|
||||
this.exclude();
|
||||
}
|
||||
|
||||
this.reset();
|
||||
}
|
||||
|
||||
addExpectationResult(passed, data, isError) {
|
||||
const expectationResult = j$.private.buildExpectationResult(data);
|
||||
const expectationResult = private$.buildExpectationResult(data);
|
||||
|
||||
if (passed) {
|
||||
this.result.passedExpectations.push(expectationResult);
|
||||
this.#executionState.passedExpectations.push(expectationResult);
|
||||
} else {
|
||||
if (this.reportedDone) {
|
||||
this.onLateError(expectationResult);
|
||||
} else {
|
||||
this.result.failedExpectations.push(expectationResult);
|
||||
|
||||
// TODO: refactor so that we don't need to override cached status
|
||||
if (this.result.status) {
|
||||
this.result.status = 'failed';
|
||||
}
|
||||
this.#executionState.failedExpectations.push(expectationResult);
|
||||
}
|
||||
|
||||
if (this.#throwOnExpectationFailure && !isError) {
|
||||
throw new j$.private.errors.ExpectationFailed();
|
||||
throw new private$.errors.ExpectationFailed();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
getSpecProperty(key) {
|
||||
this.result.properties = this.result.properties || {};
|
||||
return this.result.properties[key];
|
||||
this.#executionState.properties = this.#executionState.properties || {};
|
||||
return this.#executionState.properties[key];
|
||||
}
|
||||
|
||||
setSpecProperty(key, value) {
|
||||
// Key and value will eventually be cloned during reporting. The error
|
||||
// thrown at that point if they aren't cloneable isn't very helpful.
|
||||
// Throw a better one now.
|
||||
j$.private.util.assertReporterCloneable(key, 'Key');
|
||||
j$.private.util.assertReporterCloneable(value, 'Value');
|
||||
this.result.properties = this.result.properties || {};
|
||||
this.result.properties[key] = value;
|
||||
if (!private$.isString(key)) {
|
||||
throw new Error('Key must be a string');
|
||||
}
|
||||
private$.util.assertReporterCloneable(value, 'Value');
|
||||
|
||||
this.#executionState.properties = this.#executionState.properties || {};
|
||||
this.#executionState.properties[key] = value;
|
||||
}
|
||||
|
||||
executionStarted() {
|
||||
@@ -85,34 +86,48 @@ getJasmineRequireObj().Spec = function(j$) {
|
||||
}
|
||||
|
||||
executionFinished(excluded, failSpecWithNoExp) {
|
||||
this.#executionState.dynamicallyExcluded = excluded;
|
||||
this.#executionState.requireExpectations = failSpecWithNoExp;
|
||||
|
||||
if (this.#autoCleanClosures) {
|
||||
this.queueableFn.fn = null;
|
||||
}
|
||||
|
||||
this.result.status = this.#status(excluded, failSpecWithNoExp);
|
||||
this.result.duration = this.#timer.elapsed();
|
||||
this.#executionState.duration = this.#timer.elapsed();
|
||||
|
||||
if (this.result.status !== 'failed') {
|
||||
this.result.debugLogs = null;
|
||||
if (this.status() !== 'failed') {
|
||||
this.#executionState.debugLogs = null;
|
||||
}
|
||||
}
|
||||
|
||||
hadBeforeAllFailure() {
|
||||
this.addExpectationResult(
|
||||
false,
|
||||
{
|
||||
passed: false,
|
||||
message:
|
||||
'Not run because a beforeAll function failed. The ' +
|
||||
'beforeAll failure will be reported on the suite that ' +
|
||||
'caused it.'
|
||||
},
|
||||
true
|
||||
);
|
||||
}
|
||||
|
||||
reset() {
|
||||
this.result = {
|
||||
id: this.id,
|
||||
description: this.description,
|
||||
fullName: this.getFullName(),
|
||||
parentSuiteId: this.parentSuiteId,
|
||||
filename: this.filename,
|
||||
this.#executionState = {
|
||||
failedExpectations: [],
|
||||
passedExpectations: [],
|
||||
deprecationWarnings: [],
|
||||
pendingReason: this.excludeMessage || '',
|
||||
duration: null,
|
||||
properties: null,
|
||||
debugLogs: null
|
||||
debugLogs: null,
|
||||
// TODO: better naming. Don't make 'excluded' mean two things.
|
||||
dynamicallyExcluded: false,
|
||||
requireExpectations: false,
|
||||
markedPending: this.markedExcluding
|
||||
};
|
||||
this.markedPending = this.markedExcluding;
|
||||
this.reportedDone = false;
|
||||
}
|
||||
|
||||
@@ -129,7 +144,7 @@ getJasmineRequireObj().Spec = function(j$) {
|
||||
* same call stack height as the originals. This property may be removed in
|
||||
* a future version unless there is enough user interest in keeping it.
|
||||
* See {@link https://github.com/jasmine/jasmine/issues/2065}.
|
||||
* @since 6.0.0
|
||||
* @since 2.0.0
|
||||
*/
|
||||
return this.#commonEventFields();
|
||||
}
|
||||
@@ -141,38 +156,37 @@ getJasmineRequireObj().Spec = function(j$) {
|
||||
* @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 {String|null} parentSuiteId - The ID of the suite containing this spec, or null if this spec is not in a describe().
|
||||
* @property {String} filename - Deprecated. The name of the file the spec was defined in.
|
||||
* @property {String} filename - The name of the file the spec was defined in.
|
||||
* Note: The value may be incorrect if zone.js is installed or
|
||||
* `it`/`fit`/`xit` have been replaced with versions that don't maintain the
|
||||
* same call stack height as the originals. This property may be removed in
|
||||
* a future version unless there is enough user interest in keeping it.
|
||||
* See {@link https://github.com/jasmine/jasmine/issues/2065}.
|
||||
* same call stack height as the originals. You can fix that by setting
|
||||
* {@link Configuration#extraItStackFrames}.
|
||||
* @property {ExpectationResult[]} failedExpectations - The list of expectations that failed during execution of this spec.
|
||||
* @property {ExpectationResult[]} passedExpectations - The list of expectations that passed during execution of this spec.
|
||||
* @property {ExpectationResult[]} deprecationWarnings - The list of deprecation warnings that occurred during execution this spec.
|
||||
* @property {String} pendingReason - If the spec is {@link pending}, this will be the reason.
|
||||
* @property {String} status - Once the spec has completed, this string represents the pass/fail status of this spec.
|
||||
* @property {String} status - The result of this spec. May be 'passed', 'failed', 'pending', or 'excluded'.
|
||||
* @property {number} duration - The time in ms used by the spec execution, including any before/afterEach.
|
||||
* @property {Object} properties - User-supplied properties, if any, that were set using {@link Env#setSpecProperty}
|
||||
* @property {DebugLogEntry[]|null} debugLogs - Messages, if any, that were logged using {@link jasmine.debugLog} during a failing spec.
|
||||
* @since 6.0.0
|
||||
* @since 2.0.0
|
||||
*/
|
||||
const event = {
|
||||
...this.#commonEventFields()
|
||||
...this.#commonEventFields(),
|
||||
status: this.status()
|
||||
};
|
||||
const toCopy = [
|
||||
'failedExpectations',
|
||||
'passedExpectations',
|
||||
'deprecationWarnings',
|
||||
'pendingReason',
|
||||
'status',
|
||||
'duration',
|
||||
'properties',
|
||||
'debugLogs'
|
||||
];
|
||||
|
||||
for (const k of toCopy) {
|
||||
event[k] = this.result[k];
|
||||
event[k] = this.#executionState[k];
|
||||
}
|
||||
|
||||
return event;
|
||||
@@ -194,7 +208,7 @@ getJasmineRequireObj().Spec = function(j$) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (e instanceof j$.private.errors.ExpectationFailed) {
|
||||
if (e instanceof private$.errors.ExpectationFailed) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -210,12 +224,16 @@ getJasmineRequireObj().Spec = function(j$) {
|
||||
}
|
||||
|
||||
pend(message) {
|
||||
this.markedPending = true;
|
||||
this.#executionState.markedPending = true;
|
||||
if (message) {
|
||||
this.result.pendingReason = message;
|
||||
this.#executionState.pendingReason = message;
|
||||
}
|
||||
}
|
||||
|
||||
get markedPending() {
|
||||
return this.#executionState.markedPending;
|
||||
}
|
||||
|
||||
// Like pend(), but pending state will survive reset().
|
||||
// Useful for fit, xit, where pending state remains.
|
||||
exclude(message) {
|
||||
@@ -226,15 +244,8 @@ getJasmineRequireObj().Spec = function(j$) {
|
||||
this.pend(message);
|
||||
}
|
||||
|
||||
// TODO: ensure that all access to result goes through .getResult()
|
||||
// so that the status is correct.
|
||||
getResult() {
|
||||
this.result.status = this.#status();
|
||||
return this.result;
|
||||
}
|
||||
|
||||
#status(excluded, failSpecWithNoExpectations) {
|
||||
if (excluded === true) {
|
||||
status() {
|
||||
if (this.#executionState.dynamicallyExcluded) {
|
||||
return 'excluded';
|
||||
}
|
||||
|
||||
@@ -243,10 +254,10 @@ getJasmineRequireObj().Spec = function(j$) {
|
||||
}
|
||||
|
||||
if (
|
||||
this.result.failedExpectations.length > 0 ||
|
||||
(failSpecWithNoExpectations &&
|
||||
this.result.failedExpectations.length +
|
||||
this.result.passedExpectations.length ===
|
||||
this.#executionState.failedExpectations.length > 0 ||
|
||||
(this.#executionState.requireExpectations &&
|
||||
this.#executionState.failedExpectations.length +
|
||||
this.#executionState.passedExpectations.length ===
|
||||
0)
|
||||
) {
|
||||
return 'failed';
|
||||
@@ -263,14 +274,14 @@ getJasmineRequireObj().Spec = function(j$) {
|
||||
if (typeof deprecation === 'string') {
|
||||
deprecation = { message: deprecation };
|
||||
}
|
||||
this.result.deprecationWarnings.push(
|
||||
j$.private.buildExpectationResult(deprecation)
|
||||
this.#executionState.deprecationWarnings.push(
|
||||
private$.buildExpectationResult(deprecation)
|
||||
);
|
||||
}
|
||||
|
||||
debugLog(msg) {
|
||||
if (!this.result.debugLogs) {
|
||||
this.result.debugLogs = [];
|
||||
if (!this.#executionState.debugLogs) {
|
||||
this.#executionState.debugLogs = [];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -279,7 +290,7 @@ getJasmineRequireObj().Spec = function(j$) {
|
||||
* @property {number} timestamp - The time when the entry was added, in
|
||||
* milliseconds from the spec's start time
|
||||
*/
|
||||
this.result.debugLogs.push({
|
||||
this.#executionState.debugLogs.push({
|
||||
message: msg,
|
||||
timestamp: this.#timer.elapsed()
|
||||
});
|
||||
@@ -331,7 +342,20 @@ getJasmineRequireObj().Spec = function(j$) {
|
||||
* @returns {Array.<string>}
|
||||
* @since 5.7.0
|
||||
*/
|
||||
getPath: this.getPath.bind(this)
|
||||
getPath: this.getPath.bind(this),
|
||||
|
||||
/**
|
||||
* The name of the file the spec was defined in.
|
||||
* Note: The value may be incorrect if zone.js is installed or
|
||||
* `it`/`fit`/`xit` have been replaced with versions that don't maintain the
|
||||
* same call stack height as the originals. You can fix that by setting
|
||||
* {@link Configuration#extraItStackFrames}.
|
||||
* @name Spec#filename
|
||||
* @readonly
|
||||
* @type {string}
|
||||
* @since 5.13.0
|
||||
*/
|
||||
filename: this.filename
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user