Merge branch 'master' into expect-context
This commit is contained in:
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
[](https://travis-ci.org/jasmine/jasmine)
|
[](https://travis-ci.org/jasmine/jasmine)
|
||||||
[](https://www.codetriage.com/jasmine/jasmine)
|
[](https://www.codetriage.com/jasmine/jasmine)
|
||||||
|
[](https://app.fossa.io/projects/git%2Bgithub.com%2Fjasmine%2Fjasmine?ref=badge_shield)
|
||||||
|
|
||||||
# A JavaScript Testing Framework
|
# A JavaScript Testing Framework
|
||||||
|
|
||||||
@@ -75,3 +76,7 @@ Jasmine tests itself across many browsers (Safari, Chrome, Firefox, PhantomJS, M
|
|||||||
* Sheel Choksi
|
* Sheel Choksi
|
||||||
|
|
||||||
Copyright (c) 2008-2018 Pivotal Labs. This software is licensed under the MIT License.
|
Copyright (c) 2008-2018 Pivotal Labs. This software is licensed under the MIT License.
|
||||||
|
|
||||||
|
|
||||||
|
## License
|
||||||
|
[](https://app.fossa.io/projects/git%2Bgithub.com%2Fjasmine%2Fjasmine?ref=badge_large)
|
||||||
@@ -73,21 +73,21 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|||||||
|
|
||||||
var filterSpecs = !!queryString.getParam("spec");
|
var filterSpecs = !!queryString.getParam("spec");
|
||||||
|
|
||||||
var stoppingOnSpecFailure = queryString.getParam("failFast");
|
var config = {
|
||||||
env.stopOnSpecFailure(stoppingOnSpecFailure);
|
failFast: queryString.getParam("failFast"),
|
||||||
|
oneFailurePerSpec: queryString.getParam("oneFailurePerSpec"),
|
||||||
var throwingExpectationFailures = queryString.getParam("throwFailures");
|
hideDisabled: queryString.getParam("hideDisabled")
|
||||||
env.throwOnExpectationFailure(throwingExpectationFailures);
|
};
|
||||||
|
|
||||||
var random = queryString.getParam("random");
|
var random = queryString.getParam("random");
|
||||||
|
|
||||||
if (random !== undefined && random !== "") {
|
if (random !== undefined && random !== "") {
|
||||||
env.randomizeTests(random);
|
config.random = random;
|
||||||
}
|
}
|
||||||
|
|
||||||
var seed = queryString.getParam("seed");
|
var seed = queryString.getParam("seed");
|
||||||
if (seed) {
|
if (seed) {
|
||||||
env.seed(seed);
|
config.seed = seed;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -118,10 +118,12 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|||||||
filterString: function() { return queryString.getParam("spec"); }
|
filterString: function() { return queryString.getParam("spec"); }
|
||||||
});
|
});
|
||||||
|
|
||||||
env.specFilter = function(spec) {
|
config.specFilter = function(spec) {
|
||||||
return specFilter.matches(spec.getFullName());
|
return specFilter.matches(spec.getFullName());
|
||||||
};
|
};
|
||||||
|
|
||||||
|
env.configure(config);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Setting up timing functions to be able to be overridden. Certain browsers (Safari, IE 8, phantomjs) require this hack.
|
* Setting up timing functions to be able to be overridden. Certain browsers (Safari, IE 8, phantomjs) require this hack.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -51,21 +51,21 @@
|
|||||||
|
|
||||||
var filterSpecs = !!queryString.getParam("spec");
|
var filterSpecs = !!queryString.getParam("spec");
|
||||||
|
|
||||||
var stoppingOnSpecFailure = queryString.getParam("failFast");
|
var config = {
|
||||||
env.stopOnSpecFailure(stoppingOnSpecFailure);
|
failFast: queryString.getParam("failFast"),
|
||||||
|
oneFailurePerSpec: queryString.getParam("oneFailurePerSpec"),
|
||||||
var throwingExpectationFailures = queryString.getParam("throwFailures");
|
hideDisabled: queryString.getParam("hideDisabled")
|
||||||
env.throwOnExpectationFailure(throwingExpectationFailures);
|
};
|
||||||
|
|
||||||
var random = queryString.getParam("random");
|
var random = queryString.getParam("random");
|
||||||
|
|
||||||
if (random !== undefined && random !== "") {
|
if (random !== undefined && random !== "") {
|
||||||
env.randomizeTests(random);
|
config.random = random;
|
||||||
}
|
}
|
||||||
|
|
||||||
var seed = queryString.getParam("seed");
|
var seed = queryString.getParam("seed");
|
||||||
if (seed) {
|
if (seed) {
|
||||||
env.seed(seed);
|
config.seed = seed;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -96,10 +96,12 @@
|
|||||||
filterString: function() { return queryString.getParam("spec"); }
|
filterString: function() { return queryString.getParam("spec"); }
|
||||||
});
|
});
|
||||||
|
|
||||||
env.specFilter = function(spec) {
|
config.specFilter = function(spec) {
|
||||||
return specFilter.matches(spec.getFullName());
|
return specFilter.matches(spec.getFullName());
|
||||||
};
|
};
|
||||||
|
|
||||||
|
env.configure(config);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Setting up timing functions to be able to be overridden. Certain browsers (Safari, IE 8, phantomjs) require this hack.
|
* Setting up timing functions to be able to be overridden. Certain browsers (Safari, IE 8, phantomjs) require this hack.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ jasmineRequire.HtmlReporter = function(j$) {
|
|||||||
|
|
||||||
|
|
||||||
function HtmlReporter(options) {
|
function HtmlReporter(options) {
|
||||||
var env = options.env || {},
|
var config = function() { return (options.env && options.env.configuration()) || {}; },
|
||||||
getContainer = options.getContainer,
|
getContainer = options.getContainer,
|
||||||
createElement = options.createElement,
|
createElement = options.createElement,
|
||||||
createTextNode = options.createTextNode,
|
createTextNode = options.createTextNode,
|
||||||
@@ -148,7 +148,7 @@ jasmineRequire.HtmlReporter = function(j$) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
symbols.appendChild(createDom('li', {
|
symbols.appendChild(createDom('li', {
|
||||||
className: noExpectations(result) ? 'jasmine-empty' : 'jasmine-' + result.status,
|
className: this.displaySpecInCorrectFormat(result),
|
||||||
id: 'spec_' + result.id,
|
id: 'spec_' + result.id,
|
||||||
title: result.fullName
|
title: result.fullName
|
||||||
}
|
}
|
||||||
@@ -161,6 +161,17 @@ jasmineRequire.HtmlReporter = function(j$) {
|
|||||||
addDeprecationWarnings(result);
|
addDeprecationWarnings(result);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
this.displaySpecInCorrectFormat = function(result) {
|
||||||
|
return noExpectations(result) ? 'jasmine-empty' : this.resultStatus(result.status);
|
||||||
|
};
|
||||||
|
|
||||||
|
this.resultStatus = function(status) {
|
||||||
|
if(status === 'excluded') {
|
||||||
|
return config().hideDisabled ? 'jasmine-excluded-no-display' : 'jasmine-excluded';
|
||||||
|
}
|
||||||
|
return 'jasmine-' + status;
|
||||||
|
};
|
||||||
|
|
||||||
this.jasmineDone = function(doneResult) {
|
this.jasmineDone = function(doneResult) {
|
||||||
var banner = find('.jasmine-banner');
|
var banner = find('.jasmine-banner');
|
||||||
var alert = find('.jasmine-alert');
|
var alert = find('.jasmine-alert');
|
||||||
@@ -168,7 +179,7 @@ jasmineRequire.HtmlReporter = function(j$) {
|
|||||||
var i;
|
var i;
|
||||||
alert.appendChild(createDom('span', {className: 'jasmine-duration'}, 'finished in ' + timer.elapsed() / 1000 + 's'));
|
alert.appendChild(createDom('span', {className: 'jasmine-duration'}, 'finished in ' + timer.elapsed() / 1000 + 's'));
|
||||||
|
|
||||||
banner.appendChild(optionsMenu(env));
|
banner.appendChild(optionsMenu(config()));
|
||||||
|
|
||||||
if (stateBuilder.specsExecuted < totalSpecsDefined) {
|
if (stateBuilder.specsExecuted < totalSpecsDefined) {
|
||||||
var skippedMessage = 'Ran ' + stateBuilder.specsExecuted + ' of ' + totalSpecsDefined + ' specs - run all';
|
var skippedMessage = 'Ran ' + stateBuilder.specsExecuted + ' of ' + totalSpecsDefined + ' specs - run all';
|
||||||
@@ -328,7 +339,7 @@ jasmineRequire.HtmlReporter = function(j$) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function optionsMenu(env) {
|
function optionsMenu(config) {
|
||||||
var optionsMenuDom = createDom('div', { className: 'jasmine-run-options' },
|
var optionsMenuDom = createDom('div', { className: 'jasmine-run-options' },
|
||||||
createDom('span', { className: 'jasmine-trigger' }, 'Options'),
|
createDom('span', { className: 'jasmine-trigger' }, 'Options'),
|
||||||
createDom('div', { className: 'jasmine-payload' },
|
createDom('div', { className: 'jasmine-payload' },
|
||||||
@@ -352,26 +363,39 @@ jasmineRequire.HtmlReporter = function(j$) {
|
|||||||
id: 'jasmine-random-order',
|
id: 'jasmine-random-order',
|
||||||
type: 'checkbox'
|
type: 'checkbox'
|
||||||
}),
|
}),
|
||||||
createDom('label', { className: 'jasmine-label', 'for': 'jasmine-random-order' }, 'run tests in random order'))
|
createDom('label', { className: 'jasmine-label', 'for': 'jasmine-random-order' }, 'run tests in random order')),
|
||||||
|
createDom('div', { className: 'jasmine-hide-disabled' },
|
||||||
|
createDom('input', {
|
||||||
|
className: 'jasmine-disabled',
|
||||||
|
id: 'jasmine-hide-disabled',
|
||||||
|
type: 'checkbox'
|
||||||
|
}),
|
||||||
|
createDom('label', { className: 'jasmine-label', 'for': 'jasmine-hide-disabled' }, 'hide disabled tests'))
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
var failFastCheckbox = optionsMenuDom.querySelector('#jasmine-fail-fast');
|
var failFastCheckbox = optionsMenuDom.querySelector('#jasmine-fail-fast');
|
||||||
failFastCheckbox.checked = env.stoppingOnSpecFailure();
|
failFastCheckbox.checked = config.failFast;
|
||||||
failFastCheckbox.onclick = function() {
|
failFastCheckbox.onclick = function() {
|
||||||
navigateWithNewParam('failFast', !env.stoppingOnSpecFailure());
|
navigateWithNewParam('failFast', !config.failFast);
|
||||||
};
|
};
|
||||||
|
|
||||||
var throwCheckbox = optionsMenuDom.querySelector('#jasmine-throw-failures');
|
var throwCheckbox = optionsMenuDom.querySelector('#jasmine-throw-failures');
|
||||||
throwCheckbox.checked = env.throwingExpectationFailures();
|
throwCheckbox.checked = config.oneFailurePerSpec;
|
||||||
throwCheckbox.onclick = function() {
|
throwCheckbox.onclick = function() {
|
||||||
navigateWithNewParam('throwFailures', !env.throwingExpectationFailures());
|
navigateWithNewParam('throwFailures', !config.oneFailurePerSpec);
|
||||||
};
|
};
|
||||||
|
|
||||||
var randomCheckbox = optionsMenuDom.querySelector('#jasmine-random-order');
|
var randomCheckbox = optionsMenuDom.querySelector('#jasmine-random-order');
|
||||||
randomCheckbox.checked = env.randomTests();
|
randomCheckbox.checked = config.random;
|
||||||
randomCheckbox.onclick = function() {
|
randomCheckbox.onclick = function() {
|
||||||
navigateWithNewParam('random', !env.randomTests());
|
navigateWithNewParam('random', !config.random);
|
||||||
|
};
|
||||||
|
|
||||||
|
var hideDisabled = optionsMenuDom.querySelector('#jasmine-hide-disabled');
|
||||||
|
hideDisabled.checked = config.hideDisabled;
|
||||||
|
hideDisabled.onclick = function() {
|
||||||
|
navigateWithNewParam('hideDisabled', !config.hideDisabled);
|
||||||
};
|
};
|
||||||
|
|
||||||
var optionsTrigger = optionsMenuDom.querySelector('.jasmine-trigger'),
|
var optionsTrigger = optionsMenuDom.querySelector('.jasmine-trigger'),
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
@charset "UTF-8";
|
||||||
body { overflow-y: scroll; }
|
body { overflow-y: scroll; }
|
||||||
|
|
||||||
.jasmine_html-reporter { background-color: #eee; padding: 5px; margin: -8px; font-size: 11px; font-family: Monaco, "Lucida Console", monospace; line-height: 14px; color: #333; }
|
.jasmine_html-reporter { background-color: #eee; padding: 5px; margin: -8px; font-size: 11px; font-family: Monaco, "Lucida Console", monospace; line-height: 14px; color: #333; }
|
||||||
@@ -15,15 +16,16 @@ body { overflow-y: scroll; }
|
|||||||
.jasmine_html-reporter .jasmine-symbol-summary { overflow: hidden; *zoom: 1; margin: 14px 0; }
|
.jasmine_html-reporter .jasmine-symbol-summary { overflow: hidden; *zoom: 1; margin: 14px 0; }
|
||||||
.jasmine_html-reporter .jasmine-symbol-summary li { display: inline-block; height: 10px; width: 14px; font-size: 16px; }
|
.jasmine_html-reporter .jasmine-symbol-summary li { display: inline-block; height: 10px; width: 14px; font-size: 16px; }
|
||||||
.jasmine_html-reporter .jasmine-symbol-summary li.jasmine-passed { font-size: 14px; }
|
.jasmine_html-reporter .jasmine-symbol-summary li.jasmine-passed { font-size: 14px; }
|
||||||
.jasmine_html-reporter .jasmine-symbol-summary li.jasmine-passed:before { color: #007069; content: "\02022"; }
|
.jasmine_html-reporter .jasmine-symbol-summary li.jasmine-passed:before { color: #007069; content: "•"; }
|
||||||
.jasmine_html-reporter .jasmine-symbol-summary li.jasmine-failed { line-height: 9px; }
|
.jasmine_html-reporter .jasmine-symbol-summary li.jasmine-failed { line-height: 9px; }
|
||||||
.jasmine_html-reporter .jasmine-symbol-summary li.jasmine-failed:before { color: #ca3a11; content: "\d7"; font-weight: bold; margin-left: -1px; }
|
.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 { font-size: 14px; }
|
||||||
.jasmine_html-reporter .jasmine-symbol-summary li.jasmine-excluded:before { color: #bababa; content: "\02022"; }
|
.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 { line-height: 17px; }
|
||||||
.jasmine_html-reporter .jasmine-symbol-summary li.jasmine-pending:before { color: #ba9d37; content: "*"; }
|
.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 { font-size: 14px; }
|
||||||
.jasmine_html-reporter .jasmine-symbol-summary li.jasmine-empty:before { color: #ba9d37; content: "\02022"; }
|
.jasmine_html-reporter .jasmine-symbol-summary li.jasmine-empty:before { color: #ba9d37; content: "•"; }
|
||||||
.jasmine_html-reporter .jasmine-run-options { float: right; margin-right: 5px; border: 1px solid #8a4182; color: #8a4182; position: relative; line-height: 20px; }
|
.jasmine_html-reporter .jasmine-run-options { float: right; margin-right: 5px; border: 1px solid #8a4182; color: #8a4182; position: relative; line-height: 20px; }
|
||||||
.jasmine_html-reporter .jasmine-run-options .jasmine-trigger { cursor: pointer; padding: 8px 16px; }
|
.jasmine_html-reporter .jasmine-run-options .jasmine-trigger { cursor: pointer; padding: 8px 16px; }
|
||||||
.jasmine_html-reporter .jasmine-run-options .jasmine-payload { position: absolute; display: none; right: -1px; border: 1px solid #8a4182; background-color: #eee; white-space: nowrap; padding: 4px 8px; }
|
.jasmine_html-reporter .jasmine-run-options .jasmine-payload { position: absolute; display: none; right: -1px; border: 1px solid #8a4182; background-color: #eee; white-space: nowrap; padding: 4px 8px; }
|
||||||
@@ -48,6 +50,11 @@ body { overflow-y: scroll; }
|
|||||||
.jasmine_html-reporter .jasmine-summary li.jasmine-empty a { color: #ba9d37; }
|
.jasmine_html-reporter .jasmine-summary li.jasmine-empty a { color: #ba9d37; }
|
||||||
.jasmine_html-reporter .jasmine-summary li.jasmine-pending a { color: #ba9d37; }
|
.jasmine_html-reporter .jasmine-summary li.jasmine-pending a { color: #ba9d37; }
|
||||||
.jasmine_html-reporter .jasmine-summary li.jasmine-excluded a { color: #bababa; }
|
.jasmine_html-reporter .jasmine-summary li.jasmine-excluded a { color: #bababa; }
|
||||||
|
.jasmine_html-reporter .jasmine-specs li.jasmine-passed a:before { content: "• "; }
|
||||||
|
.jasmine_html-reporter .jasmine-specs li.jasmine-failed a:before { content: "× "; }
|
||||||
|
.jasmine_html-reporter .jasmine-specs li.jasmine-empty a:before { content: "* "; }
|
||||||
|
.jasmine_html-reporter .jasmine-specs li.jasmine-pending a:before { content: "• "; }
|
||||||
|
.jasmine_html-reporter .jasmine-specs li.jasmine-excluded a:before { content: "• "; }
|
||||||
.jasmine_html-reporter .jasmine-description + .jasmine-suite { margin-top: 0; }
|
.jasmine_html-reporter .jasmine-description + .jasmine-suite { margin-top: 0; }
|
||||||
.jasmine_html-reporter .jasmine-suite { margin-top: 14px; }
|
.jasmine_html-reporter .jasmine-suite { margin-top: 14px; }
|
||||||
.jasmine_html-reporter .jasmine-suite a { color: #333; }
|
.jasmine_html-reporter .jasmine-suite a { color: #333; }
|
||||||
|
|||||||
+655
-77
File diff suppressed because it is too large
Load Diff
@@ -4,6 +4,6 @@
|
|||||||
#
|
#
|
||||||
module Jasmine
|
module Jasmine
|
||||||
module Core
|
module Core
|
||||||
VERSION = "3.1.0"
|
VERSION = "3.2.1"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
+2
-2
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "jasmine-core",
|
"name": "jasmine-core",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"version": "3.1.0",
|
"version": "3.2.1",
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/jasmine/jasmine.git"
|
"url": "https://github.com/jasmine/jasmine.git"
|
||||||
@@ -16,7 +16,7 @@
|
|||||||
"test": "grunt jshint execSpecsInNode"
|
"test": "grunt jshint execSpecsInNode"
|
||||||
},
|
},
|
||||||
"description": "Official packaging of Jasmine's core files for use by Node.js projects.",
|
"description": "Official packaging of Jasmine's core files for use by Node.js projects.",
|
||||||
"homepage": "http://jasmine.github.io",
|
"homepage": "https://jasmine.github.io",
|
||||||
"main": "./lib/jasmine-core.js",
|
"main": "./lib/jasmine-core.js",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"glob": "~7.1.2",
|
"glob": "~7.1.2",
|
||||||
|
|||||||
@@ -0,0 +1,83 @@
|
|||||||
|
# Jasmine-Core 3.2 Release Notes
|
||||||
|
|
||||||
|
## Summary
|
||||||
|
|
||||||
|
This release contains a number of fixes and pull requests
|
||||||
|
|
||||||
|
## Changes
|
||||||
|
|
||||||
|
* Add spyOnAllFunctions function
|
||||||
|
- Merges [#1581](https://github.com/jasmine/jasmine/issues/1581) from @aeisenberg
|
||||||
|
- Fixes [#1421](https://github.com/jasmine/jasmine/issues/1421)
|
||||||
|
|
||||||
|
|
||||||
|
* Improve timeout error message
|
||||||
|
- Merges [#1567](https://github.com/jasmine/jasmine/issues/1567) from @ikonst
|
||||||
|
|
||||||
|
|
||||||
|
* Fix JSDoc naming for Env functions
|
||||||
|
- See [#1565](https://github.com/jasmine/jasmine/issues/1565)
|
||||||
|
|
||||||
|
|
||||||
|
* Add documentation for more public functions on Env
|
||||||
|
- Fixes [#1565](https://github.com/jasmine/jasmine/issues/1565)
|
||||||
|
|
||||||
|
|
||||||
|
* Added a basic set of async matchers
|
||||||
|
- Fixes [#1447](https://github.com/jasmine/jasmine/issues/1447)
|
||||||
|
- Fixes [#1547](https://github.com/jasmine/jasmine/issues/1547)
|
||||||
|
|
||||||
|
|
||||||
|
* Properly cascade StopExecutionError's up the tree
|
||||||
|
- Fixes [#1563](https://github.com/jasmine/jasmine/issues/1563)
|
||||||
|
|
||||||
|
|
||||||
|
* Implemented hiding of disabled specs
|
||||||
|
- Merges [#1561](https://github.com/jasmine/jasmine/issues/1561) from @SamFare
|
||||||
|
|
||||||
|
|
||||||
|
* Line-break long expectation failure messages
|
||||||
|
- See [#296](https://github.com/jasmine/jasmine/issues/296)
|
||||||
|
|
||||||
|
|
||||||
|
* Better detection of DOM Nodes for equality
|
||||||
|
- Fixes [#1172](https://github.com/jasmine/jasmine/issues/1172)
|
||||||
|
|
||||||
|
|
||||||
|
* Fix typo from `incimplete` to `incomplete`
|
||||||
|
- Merges [#1555](https://github.com/jasmine/jasmine/issues/1555) from @yinm
|
||||||
|
|
||||||
|
|
||||||
|
* Allow omitting the name argument: `createSpy(func)`
|
||||||
|
- Merges [#1551](https://github.com/jasmine/jasmine/issues/1551) from @riophae
|
||||||
|
|
||||||
|
|
||||||
|
* name new global status stuff correctly in API docs
|
||||||
|
|
||||||
|
|
||||||
|
* Check for accidental global variable creation
|
||||||
|
|
||||||
|
|
||||||
|
* Fixed global variable leak
|
||||||
|
- Fixes [#1534](https://github.com/jasmine/jasmine/issues/1534)
|
||||||
|
|
||||||
|
|
||||||
|
* Correctly format stack traces for errors with multiline messages
|
||||||
|
- Fixes [#1526](https://github.com/jasmine/jasmine/issues/1526)
|
||||||
|
|
||||||
|
|
||||||
|
* Change message for extra elements at end of actual array
|
||||||
|
- Merges [#1527](https://github.com/jasmine/jasmine/issues/1527) from @majidmade
|
||||||
|
- Fixes [#1485](https://github.com/jasmine/jasmine/issues/1485)
|
||||||
|
|
||||||
|
|
||||||
|
* Report unhandled rejections as globalErrors.
|
||||||
|
- Merges [#1521](https://github.com/jasmine/jasmine/issues/1521) from @johnjbarton
|
||||||
|
|
||||||
|
|
||||||
|
* add some links to more tutorials from the api docs
|
||||||
|
|
||||||
|
|
||||||
|
------
|
||||||
|
|
||||||
|
_Release Notes generated with _[Anchorman](http://github.com/infews/anchorman)_
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
# Jasmine-Core 3.2.1 Release Notes
|
||||||
|
|
||||||
|
## Changes
|
||||||
|
|
||||||
|
* Correctly expose `spyOnAllFunctions`
|
||||||
|
- See [#1581](https://github.com/jasmine/jasmine/issues/1581)
|
||||||
|
|
||||||
|
|
||||||
|
------
|
||||||
|
|
||||||
|
_Release Notes generated with _[Anchorman](http://github.com/infews/anchorman)_
|
||||||
@@ -0,0 +1,397 @@
|
|||||||
|
describe('AsyncExpectation', function() {
|
||||||
|
describe('Factory', function() {
|
||||||
|
it('throws an Error if promises are not available', function() {
|
||||||
|
var thenable = {then: function() {}},
|
||||||
|
options = {global: {}, actual: thenable}
|
||||||
|
function f() { jasmineUnderTest.AsyncExpectation.factory(options); }
|
||||||
|
expect(f).toThrowError('expectAsync is unavailable because the environment does not support promises.');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('throws an Error if the argument is not a promise', function() {
|
||||||
|
jasmine.getEnv().requirePromises();
|
||||||
|
function f() {
|
||||||
|
jasmineUnderTest.AsyncExpectation.factory({actual: 'not a promise'});
|
||||||
|
}
|
||||||
|
expect(f).toThrowError('Expected expectAsync to be called with a promise.');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('#toBeResolved', function() {
|
||||||
|
it('passes if the actual is resolved', function() {
|
||||||
|
jasmine.getEnv().requirePromises();
|
||||||
|
var addExpectationResult = jasmine.createSpy('addExpectationResult'),
|
||||||
|
actual = Promise.resolve(),
|
||||||
|
expectation = new jasmineUnderTest.AsyncExpectation({
|
||||||
|
util: jasmineUnderTest.matchersUtil,
|
||||||
|
actual: actual,
|
||||||
|
addExpectationResult: addExpectationResult
|
||||||
|
});
|
||||||
|
|
||||||
|
return expectation.toBeResolved().then(function() {
|
||||||
|
expect(addExpectationResult).toHaveBeenCalledWith(true, {
|
||||||
|
matcherName: 'toBeResolved',
|
||||||
|
passed: true,
|
||||||
|
message: '',
|
||||||
|
error: undefined,
|
||||||
|
errorForStack: jasmine.any(Error),
|
||||||
|
actual: actual
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('fails if the actual is rejected', function() {
|
||||||
|
jasmine.getEnv().requirePromises();
|
||||||
|
var addExpectationResult = jasmine.createSpy('addExpectationResult'),
|
||||||
|
actual = Promise.reject('AsyncExpectationSpec rejection'),
|
||||||
|
expectation = new jasmineUnderTest.AsyncExpectation({
|
||||||
|
util: jasmineUnderTest.matchersUtil,
|
||||||
|
actual: actual,
|
||||||
|
addExpectationResult: addExpectationResult
|
||||||
|
});
|
||||||
|
|
||||||
|
return expectation.toBeResolved().then(function() {
|
||||||
|
expect(addExpectationResult).toHaveBeenCalledWith(false, {
|
||||||
|
matcherName: 'toBeResolved',
|
||||||
|
passed: false,
|
||||||
|
message: 'Expected a promise to be resolved.',
|
||||||
|
error: undefined,
|
||||||
|
errorForStack: jasmine.any(Error),
|
||||||
|
actual: actual
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('#toBeRejected', function() {
|
||||||
|
it('passes if the actual is rejected', function() {
|
||||||
|
jasmine.getEnv().requirePromises();
|
||||||
|
var addExpectationResult = jasmine.createSpy('addExpectationResult'),
|
||||||
|
actual = Promise.reject('AsyncExpectationSpec rejection'),
|
||||||
|
expectation = new jasmineUnderTest.AsyncExpectation({
|
||||||
|
util: jasmineUnderTest.matchersUtil,
|
||||||
|
actual: actual,
|
||||||
|
addExpectationResult: addExpectationResult
|
||||||
|
});
|
||||||
|
|
||||||
|
return expectation.toBeRejected().then(function() {
|
||||||
|
expect(addExpectationResult).toHaveBeenCalledWith(true, {
|
||||||
|
matcherName: 'toBeRejected',
|
||||||
|
passed: true,
|
||||||
|
message: '',
|
||||||
|
error: undefined,
|
||||||
|
errorForStack: jasmine.any(Error),
|
||||||
|
actual: actual
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('fails if the actual is resolved', function() {
|
||||||
|
jasmine.getEnv().requirePromises();
|
||||||
|
var addExpectationResult = jasmine.createSpy('addExpectationResult'),
|
||||||
|
actual = Promise.resolve(),
|
||||||
|
expectation = new jasmineUnderTest.AsyncExpectation({
|
||||||
|
util: jasmineUnderTest.matchersUtil,
|
||||||
|
actual: actual,
|
||||||
|
addExpectationResult: addExpectationResult
|
||||||
|
});
|
||||||
|
|
||||||
|
return expectation.toBeRejected().then(function() {
|
||||||
|
expect(addExpectationResult).toHaveBeenCalledWith(false, {
|
||||||
|
matcherName: 'toBeRejected',
|
||||||
|
passed: false,
|
||||||
|
message: 'Expected a promise to be rejected.',
|
||||||
|
error: undefined,
|
||||||
|
errorForStack: jasmine.any(Error),
|
||||||
|
actual: actual
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('#toBeRejectedWith', function () {
|
||||||
|
it('should return true if the promise is rejected with the expected value', function () {
|
||||||
|
jasmine.getEnv().requirePromises();
|
||||||
|
|
||||||
|
var actual = Promise.reject({error: 'PEBCAK'});
|
||||||
|
var addExpectationResult = jasmine.createSpy('addExpectationResult'),
|
||||||
|
expectation = new jasmineUnderTest.AsyncExpectation({
|
||||||
|
util: jasmineUnderTest.matchersUtil,
|
||||||
|
actual: actual,
|
||||||
|
addExpectationResult: addExpectationResult
|
||||||
|
});
|
||||||
|
|
||||||
|
return expectation.toBeRejectedWith({error: 'PEBCAK'}).then(function () {
|
||||||
|
expect(addExpectationResult).toHaveBeenCalledWith(true, {
|
||||||
|
matcherName: 'toBeRejectedWith',
|
||||||
|
passed: true,
|
||||||
|
message: '',
|
||||||
|
error: undefined,
|
||||||
|
errorForStack: jasmine.any(Error),
|
||||||
|
actual: actual
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should fail if the promise resolves', function () {
|
||||||
|
jasmine.getEnv().requirePromises();
|
||||||
|
|
||||||
|
var actual = Promise.resolve('AsyncExpectation error');
|
||||||
|
var addExpectationResult = jasmine.createSpy('addExpectationResult'),
|
||||||
|
expectation = new jasmineUnderTest.AsyncExpectation({
|
||||||
|
util: jasmineUnderTest.matchersUtil,
|
||||||
|
actual: actual,
|
||||||
|
addExpectationResult: addExpectationResult
|
||||||
|
});
|
||||||
|
|
||||||
|
return expectation.toBeRejectedWith('').then(function () {
|
||||||
|
expect(addExpectationResult).toHaveBeenCalledWith(false, {
|
||||||
|
matcherName: 'toBeRejectedWith',
|
||||||
|
passed: false,
|
||||||
|
message: "Expected a promise to be rejected with '' but it was resolved.",
|
||||||
|
error: undefined,
|
||||||
|
errorForStack: jasmine.any(Error),
|
||||||
|
actual: actual
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should fail if the promise is rejected with a different value', function () {
|
||||||
|
jasmine.getEnv().requirePromises();
|
||||||
|
|
||||||
|
var actual = Promise.reject('A Bad Apple');
|
||||||
|
var addExpectationResult = jasmine.createSpy('addExpectationResult'),
|
||||||
|
expectation = new jasmineUnderTest.AsyncExpectation({
|
||||||
|
util: jasmineUnderTest.matchersUtil,
|
||||||
|
actual: actual,
|
||||||
|
addExpectationResult: addExpectationResult
|
||||||
|
});
|
||||||
|
|
||||||
|
return expectation.toBeRejectedWith('Some Cool Thing').then(function () {
|
||||||
|
expect(addExpectationResult).toHaveBeenCalledWith(false, {
|
||||||
|
matcherName: 'toBeRejectedWith',
|
||||||
|
passed: false,
|
||||||
|
message: "Expected a promise to be rejected with 'Some Cool Thing' but it was rejected with 'A Bad Apple'.",
|
||||||
|
error: undefined,
|
||||||
|
errorForStack: jasmine.any(Error),
|
||||||
|
actual: actual
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should build its error correctly when negated', function () {
|
||||||
|
jasmine.getEnv().requirePromises();
|
||||||
|
|
||||||
|
var addExpectationResult = jasmine.createSpy('addExpectationResult'),
|
||||||
|
expectation = jasmineUnderTest.AsyncExpectation.factory({
|
||||||
|
util: jasmineUnderTest.matchersUtil,
|
||||||
|
actual: Promise.reject(true),
|
||||||
|
addExpectationResult: addExpectationResult
|
||||||
|
});
|
||||||
|
|
||||||
|
return expectation.not.toBeRejectedWith(true).then(function () {
|
||||||
|
expect(addExpectationResult).toHaveBeenCalledWith(false,
|
||||||
|
jasmine.objectContaining({
|
||||||
|
passed: false,
|
||||||
|
message: 'Expected a promise not to be rejected with true.'
|
||||||
|
})
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should support custom equality testers', function () {
|
||||||
|
jasmine.getEnv().requirePromises();
|
||||||
|
|
||||||
|
var addExpectationResult = jasmine.createSpy('addExpectationResult'),
|
||||||
|
expectation = new jasmineUnderTest.AsyncExpectation({
|
||||||
|
util: jasmineUnderTest.matchersUtil,
|
||||||
|
customEqualityTesters: [function() { return true; }],
|
||||||
|
actual: Promise.reject('actual'),
|
||||||
|
addExpectationResult: addExpectationResult
|
||||||
|
});
|
||||||
|
|
||||||
|
return expectation.toBeRejectedWith('expected').then(function() {
|
||||||
|
expect(addExpectationResult).toHaveBeenCalledWith(true,
|
||||||
|
jasmine.objectContaining({passed: true}));
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('#toBeResolvedTo', function() {
|
||||||
|
it('passes if the promise is resolved to the expected value', function() {
|
||||||
|
jasmine.getEnv().requirePromises();
|
||||||
|
|
||||||
|
var actual = Promise.resolve({foo: 42});
|
||||||
|
var addExpectationResult = jasmine.createSpy('addExpectationResult'),
|
||||||
|
expectation = new jasmineUnderTest.AsyncExpectation({
|
||||||
|
util: jasmineUnderTest.matchersUtil,
|
||||||
|
actual: actual,
|
||||||
|
addExpectationResult: addExpectationResult
|
||||||
|
});
|
||||||
|
|
||||||
|
return expectation.toBeResolvedTo({foo: 42}).then(function() {
|
||||||
|
expect(addExpectationResult).toHaveBeenCalledWith(true, {
|
||||||
|
matcherName: 'toBeResolvedTo',
|
||||||
|
passed: true,
|
||||||
|
message: '',
|
||||||
|
error: undefined,
|
||||||
|
errorForStack: jasmine.any(Error),
|
||||||
|
actual: actual
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('fails if the promise is rejected', function() {
|
||||||
|
jasmine.getEnv().requirePromises();
|
||||||
|
|
||||||
|
var actual = Promise.reject('AsyncExpectationSpec error');
|
||||||
|
var addExpectationResult = jasmine.createSpy('addExpectationResult'),
|
||||||
|
expectation = new jasmineUnderTest.AsyncExpectation({
|
||||||
|
util: jasmineUnderTest.matchersUtil,
|
||||||
|
actual: actual,
|
||||||
|
addExpectationResult: addExpectationResult
|
||||||
|
});
|
||||||
|
|
||||||
|
return expectation.toBeResolvedTo('').then(function() {
|
||||||
|
expect(addExpectationResult).toHaveBeenCalledWith(false, {
|
||||||
|
matcherName: 'toBeResolvedTo',
|
||||||
|
passed: false,
|
||||||
|
message: "Expected a promise to be resolved to '' but it was rejected.",
|
||||||
|
error: undefined,
|
||||||
|
errorForStack: jasmine.any(Error),
|
||||||
|
actual: actual
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('fails if the promise is resolved to a different value', function() {
|
||||||
|
jasmine.getEnv().requirePromises();
|
||||||
|
|
||||||
|
var actual = Promise.resolve({foo: 17});
|
||||||
|
var addExpectationResult = jasmine.createSpy('addExpectationResult'),
|
||||||
|
expectation = new jasmineUnderTest.AsyncExpectation({
|
||||||
|
util: jasmineUnderTest.matchersUtil,
|
||||||
|
actual: actual,
|
||||||
|
addExpectationResult: addExpectationResult
|
||||||
|
});
|
||||||
|
|
||||||
|
return expectation.toBeResolvedTo({foo: 42}).then(function() {
|
||||||
|
expect(addExpectationResult).toHaveBeenCalledWith(false, {
|
||||||
|
matcherName: 'toBeResolvedTo',
|
||||||
|
passed: false,
|
||||||
|
message: 'Expected a promise to be resolved to Object({ foo: 42 }) but it was resolved to Object({ foo: 17 }).',
|
||||||
|
error: undefined,
|
||||||
|
errorForStack: jasmine.any(Error),
|
||||||
|
actual: actual
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('builds its message correctly when negated', function() {
|
||||||
|
jasmine.getEnv().requirePromises();
|
||||||
|
|
||||||
|
var addExpectationResult = jasmine.createSpy('addExpectationResult'),
|
||||||
|
expectation = jasmineUnderTest.AsyncExpectation.factory({
|
||||||
|
util: jasmineUnderTest.matchersUtil,
|
||||||
|
actual: Promise.resolve(true),
|
||||||
|
addExpectationResult: addExpectationResult
|
||||||
|
});
|
||||||
|
|
||||||
|
return expectation.not.toBeResolvedTo(true).then(function() {
|
||||||
|
expect(addExpectationResult).toHaveBeenCalledWith(false,
|
||||||
|
jasmine.objectContaining({
|
||||||
|
passed: false,
|
||||||
|
message: 'Expected a promise not to be resolved to true.'
|
||||||
|
})
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('supports custom equality testers', function() {
|
||||||
|
jasmine.getEnv().requirePromises();
|
||||||
|
|
||||||
|
var addExpectationResult = jasmine.createSpy('addExpectationResult'),
|
||||||
|
expectation = new jasmineUnderTest.AsyncExpectation({
|
||||||
|
util: jasmineUnderTest.matchersUtil,
|
||||||
|
customEqualityTesters: [function() { return true; }],
|
||||||
|
actual: Promise.resolve('actual'),
|
||||||
|
addExpectationResult: addExpectationResult
|
||||||
|
});
|
||||||
|
|
||||||
|
return expectation.toBeResolvedTo('expected').then(function() {
|
||||||
|
expect(addExpectationResult).toHaveBeenCalledWith(true,
|
||||||
|
jasmine.objectContaining({passed: true}));
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('#not', function() {
|
||||||
|
it('converts a pass to a fail', function() {
|
||||||
|
jasmine.getEnv().requirePromises();
|
||||||
|
|
||||||
|
var addExpectationResult = jasmine.createSpy('addExpectationResult'),
|
||||||
|
actual = Promise.resolve(),
|
||||||
|
expectation = jasmineUnderTest.AsyncExpectation.factory({
|
||||||
|
util: jasmineUnderTest.matchersUtil,
|
||||||
|
actual: actual,
|
||||||
|
addExpectationResult: addExpectationResult
|
||||||
|
});
|
||||||
|
|
||||||
|
return expectation.not.toBeResolved().then(function() {
|
||||||
|
expect(addExpectationResult).toHaveBeenCalledWith(false,
|
||||||
|
jasmine.objectContaining({
|
||||||
|
passed: false,
|
||||||
|
message: 'Expected a promise not to be resolved.'
|
||||||
|
})
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('converts a fail to a pass', function() {
|
||||||
|
jasmine.getEnv().requirePromises();
|
||||||
|
|
||||||
|
var addExpectationResult = jasmine.createSpy('addExpectationResult'),
|
||||||
|
actual = Promise.reject(),
|
||||||
|
expectation = jasmineUnderTest.AsyncExpectation.factory({
|
||||||
|
util: jasmineUnderTest.matchersUtil,
|
||||||
|
actual: actual,
|
||||||
|
addExpectationResult: addExpectationResult
|
||||||
|
});
|
||||||
|
|
||||||
|
return expectation.not.toBeResolved().then(function() {
|
||||||
|
expect(addExpectationResult).toHaveBeenCalledWith(true,
|
||||||
|
jasmine.objectContaining({
|
||||||
|
passed: true,
|
||||||
|
message: ''
|
||||||
|
})
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('propagates rejections from the comparison function', function() {
|
||||||
|
jasmine.getEnv().requirePromises();
|
||||||
|
var error = new Error('AsyncExpectationSpec failure');
|
||||||
|
|
||||||
|
spyOn(jasmineUnderTest.AsyncExpectation.prototype, 'toBeResolved')
|
||||||
|
.and.returnValue(Promise.reject(error));
|
||||||
|
|
||||||
|
var addExpectationResult = jasmine.createSpy('addExpectationResult'),
|
||||||
|
actual = dummyPromise(),
|
||||||
|
expectation = new jasmineUnderTest.AsyncExpectation({
|
||||||
|
actual: actual,
|
||||||
|
addExpectationResult: addExpectationResult
|
||||||
|
});
|
||||||
|
|
||||||
|
return expectation.toBeResolved()
|
||||||
|
.then(
|
||||||
|
function() { fail('Expected a rejection'); },
|
||||||
|
function(e) { expect(e).toBe(error); }
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
function dummyPromise() {
|
||||||
|
return new Promise(function(resolve, reject) {
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
+18
-2
@@ -27,7 +27,7 @@ describe("Env", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('can configure specs to throw errors on expectation failures', function() {
|
it('can configure specs to throw errors on expectation failures', function() {
|
||||||
env.throwOnExpectationFailure(true);
|
env.configure({oneFailurePerSpec: true});
|
||||||
|
|
||||||
spyOn(jasmineUnderTest, 'Spec');
|
spyOn(jasmineUnderTest, 'Spec');
|
||||||
env.it('foo', function() {});
|
env.it('foo', function() {});
|
||||||
@@ -37,7 +37,7 @@ describe("Env", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('can configure suites to throw errors on expectation failures', function() {
|
it('can configure suites to throw errors on expectation failures', function() {
|
||||||
env.throwOnExpectationFailure(true);
|
env.configure({oneFailurePerSpec: true});
|
||||||
|
|
||||||
spyOn(jasmineUnderTest, 'Suite');
|
spyOn(jasmineUnderTest, 'Suite');
|
||||||
env.describe('foo', function() {});
|
env.describe('foo', function() {});
|
||||||
@@ -46,6 +46,22 @@ describe("Env", function() {
|
|||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('defaults to multiple failures for specs', function() {
|
||||||
|
spyOn(jasmineUnderTest, 'Spec');
|
||||||
|
env.it('bar', function() {});
|
||||||
|
expect(jasmineUnderTest.Spec).toHaveBeenCalledWith(jasmine.objectContaining({
|
||||||
|
throwOnExpectationFailure: false
|
||||||
|
}));
|
||||||
|
});
|
||||||
|
|
||||||
|
it('defaults to multiple failures for suites', function() {
|
||||||
|
spyOn(jasmineUnderTest, 'Suite');
|
||||||
|
env.describe('foo', function() {});
|
||||||
|
expect(jasmineUnderTest.Suite).toHaveBeenCalledWith(jasmine.objectContaining({
|
||||||
|
throwOnExpectationFailure: false
|
||||||
|
}));
|
||||||
|
});
|
||||||
|
|
||||||
describe('#describe', function () {
|
describe('#describe', function () {
|
||||||
it("throws an error when given arguments", function() {
|
it("throws an error when given arguments", function() {
|
||||||
expect(function() {
|
expect(function() {
|
||||||
|
|||||||
@@ -37,6 +37,28 @@ describe("ExceptionFormatter", function() {
|
|||||||
expect(message).toEqual('A Classic Mistake: you got your foo in my bar');
|
expect(message).toEqual('A Classic Mistake: you got your foo in my bar');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('formats unnamed exceptions with message', function() {
|
||||||
|
var unnamedError = {message: 'This is an unnamed error message.'};
|
||||||
|
|
||||||
|
var exceptionFormatter = new jasmineUnderTest.ExceptionFormatter(),
|
||||||
|
message = exceptionFormatter.message(unnamedError);
|
||||||
|
|
||||||
|
expect(message).toEqual('This is an unnamed error message.');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('formats empty exceptions with toString format', function() {
|
||||||
|
var EmptyError = function() {};
|
||||||
|
EmptyError.prototype.toString = function() {
|
||||||
|
return '[EmptyError]';
|
||||||
|
};
|
||||||
|
var emptyError = new EmptyError();
|
||||||
|
|
||||||
|
var exceptionFormatter = new jasmineUnderTest.ExceptionFormatter(),
|
||||||
|
message = exceptionFormatter.message(emptyError);
|
||||||
|
|
||||||
|
expect(message).toEqual('[EmptyError] thrown');
|
||||||
|
});
|
||||||
|
|
||||||
it("formats thrown exceptions that aren't errors", function() {
|
it("formats thrown exceptions that aren't errors", function() {
|
||||||
var thrown = "crazy error",
|
var thrown = "crazy error",
|
||||||
exceptionFormatter = new jasmineUnderTest.ExceptionFormatter(),
|
exceptionFormatter = new jasmineUnderTest.ExceptionFormatter(),
|
||||||
|
|||||||
@@ -44,6 +44,21 @@ describe("buildExpectationResult", function() {
|
|||||||
expect(result.stack).toEqual('foo');
|
expect(result.stack).toEqual('foo');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("delegates stack formatting to the provided formatter if there was a provided errorForStack", function() {
|
||||||
|
var fakeError = {stack: 'foo'},
|
||||||
|
stackFormatter = jasmine.createSpy("stack formatter").and.returnValue(fakeError.stack);
|
||||||
|
|
||||||
|
var result = jasmineUnderTest.buildExpectationResult(
|
||||||
|
{
|
||||||
|
passed: false,
|
||||||
|
errorForStack: fakeError,
|
||||||
|
stackFormatter: stackFormatter
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(stackFormatter).toHaveBeenCalledWith(fakeError);
|
||||||
|
expect(result.stack).toEqual('foo');
|
||||||
|
});
|
||||||
|
|
||||||
it("matcherName returns passed matcherName", function() {
|
it("matcherName returns passed matcherName", function() {
|
||||||
var result = jasmineUnderTest.buildExpectationResult({matcherName: 'some-value'});
|
var result = jasmineUnderTest.buildExpectationResult({matcherName: 'some-value'});
|
||||||
expect(result.matcherName).toBe('some-value');
|
expect(result.matcherName).toBe('some-value');
|
||||||
|
|||||||
@@ -33,7 +33,9 @@ describe("Expectation", function() {
|
|||||||
matchers = {
|
matchers = {
|
||||||
toFoo: matcherFactory
|
toFoo: matcherFactory
|
||||||
},
|
},
|
||||||
util = {},
|
util = {
|
||||||
|
buildFailureMessage: jasmine.createSpy('buildFailureMessage')
|
||||||
|
},
|
||||||
customEqualityTesters = ['a'],
|
customEqualityTesters = ['a'],
|
||||||
addExpectationResult = jasmine.createSpy("addExpectationResult"),
|
addExpectationResult = jasmine.createSpy("addExpectationResult"),
|
||||||
expectation;
|
expectation;
|
||||||
|
|||||||
@@ -183,7 +183,7 @@ describe("QueueRunner", function() {
|
|||||||
|
|
||||||
it("sets a timeout if requested for asynchronous functions so they don't go on forever", function() {
|
it("sets a timeout if requested for asynchronous functions so they don't go on forever", function() {
|
||||||
var timeout = 3,
|
var timeout = 3,
|
||||||
beforeFn = { fn: function(done) { }, type: 'before', timeout: function() { return timeout; } },
|
beforeFn = { fn: function(done) { }, type: 'before', timeout: timeout },
|
||||||
queueableFn = { fn: jasmine.createSpy('fn'), type: 'queueable' },
|
queueableFn = { fn: jasmine.createSpy('fn'), type: 'queueable' },
|
||||||
onComplete = jasmine.createSpy('onComplete'),
|
onComplete = jasmine.createSpy('onComplete'),
|
||||||
onException = jasmine.createSpy('onException'),
|
onException = jasmine.createSpy('onException'),
|
||||||
@@ -304,7 +304,7 @@ describe("QueueRunner", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("continues running functions when an exception is thrown in async code without timing out", function() {
|
it("continues running functions when an exception is thrown in async code without timing out", function() {
|
||||||
var queueableFn = { fn: function(done) { throwAsync(); }, timeout: function() { return 1; } },
|
var queueableFn = { fn: function(done) { throwAsync(); }, timeout: 1 },
|
||||||
nextQueueableFn = { fn: jasmine.createSpy("nextFunction") },
|
nextQueueableFn = { fn: jasmine.createSpy("nextFunction") },
|
||||||
onException = jasmine.createSpy('onException'),
|
onException = jasmine.createSpy('onException'),
|
||||||
globalErrors = { pushListener: jasmine.createSpy('pushListener'), popListener: jasmine.createSpy('popListener') },
|
globalErrors = { pushListener: jasmine.createSpy('pushListener'), popListener: jasmine.createSpy('popListener') },
|
||||||
@@ -481,15 +481,18 @@ describe("QueueRunner", function() {
|
|||||||
var queueableFn = { fn: function() { throw new Error("error"); } },
|
var queueableFn = { fn: function() { throw new Error("error"); } },
|
||||||
nextQueueableFn = { fn: jasmine.createSpy("nextFunction") },
|
nextQueueableFn = { fn: jasmine.createSpy("nextFunction") },
|
||||||
cleanupFn = { fn: jasmine.createSpy("cleanup") },
|
cleanupFn = { fn: jasmine.createSpy("cleanup") },
|
||||||
|
onComplete = jasmine.createSpy("onComplete"),
|
||||||
queueRunner = new jasmineUnderTest.QueueRunner({
|
queueRunner = new jasmineUnderTest.QueueRunner({
|
||||||
queueableFns: [queueableFn, nextQueueableFn],
|
queueableFns: [queueableFn, nextQueueableFn],
|
||||||
cleanupFns: [cleanupFn],
|
cleanupFns: [cleanupFn],
|
||||||
|
onComplete: onComplete,
|
||||||
completeOnFirstError: true
|
completeOnFirstError: true
|
||||||
});
|
});
|
||||||
|
|
||||||
queueRunner.execute();
|
queueRunner.execute();
|
||||||
expect(nextQueueableFn.fn).not.toHaveBeenCalled();
|
expect(nextQueueableFn.fn).not.toHaveBeenCalled();
|
||||||
expect(cleanupFn.fn).toHaveBeenCalled();
|
expect(cleanupFn.fn).toHaveBeenCalled();
|
||||||
|
expect(onComplete).toHaveBeenCalledWith(jasmine.any(jasmineUnderTest.StopExecutionError));
|
||||||
});
|
});
|
||||||
|
|
||||||
it("does not skip when a cleanup function throws", function() {
|
it("does not skip when a cleanup function throws", function() {
|
||||||
|
|||||||
@@ -214,6 +214,97 @@ describe("SpyRegistry", function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe("#spyOnAllFunctions", function() {
|
||||||
|
it("checks for the existence of the object", function() {
|
||||||
|
var spyRegistry = new jasmineUnderTest.SpyRegistry();
|
||||||
|
expect(function() {
|
||||||
|
spyRegistry.spyOnAllFunctions(void 0);
|
||||||
|
}).toThrowError(/spyOnAllFunctions could not find an object to spy upon/);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("overrides all writable and configurable functions of the object", function() {
|
||||||
|
var spyRegistry = new jasmineUnderTest.SpyRegistry({createSpy: function() {
|
||||||
|
return 'I am a spy';
|
||||||
|
}});
|
||||||
|
var createNoop = function() { return function() { /**/}; };
|
||||||
|
var noop1 = createNoop();
|
||||||
|
var noop2 = createNoop();
|
||||||
|
var noop3 = createNoop();
|
||||||
|
var noop4 = createNoop();
|
||||||
|
var noop5 = createNoop();
|
||||||
|
|
||||||
|
var parent = {
|
||||||
|
notSpied1: noop1
|
||||||
|
};
|
||||||
|
var subject = Object.create(parent);
|
||||||
|
Object.defineProperty(subject, 'spied1', {
|
||||||
|
value: noop1,
|
||||||
|
writable: true,
|
||||||
|
configurable: true,
|
||||||
|
enumerable: true
|
||||||
|
});
|
||||||
|
Object.defineProperty(subject, 'spied2', {
|
||||||
|
value: noop2,
|
||||||
|
writable: true,
|
||||||
|
configurable: true,
|
||||||
|
enumerable: true
|
||||||
|
});
|
||||||
|
var _spied3 = noop3;
|
||||||
|
Object.defineProperty(subject, 'spied3', {
|
||||||
|
configurable: true,
|
||||||
|
set: function (val) {
|
||||||
|
_spied3 = val;
|
||||||
|
},
|
||||||
|
get: function() {
|
||||||
|
return _spied3;
|
||||||
|
},
|
||||||
|
enumerable: true
|
||||||
|
});
|
||||||
|
subject.spied4 = noop4;
|
||||||
|
Object.defineProperty(subject, 'notSpied2', {
|
||||||
|
value: noop2,
|
||||||
|
writable: false,
|
||||||
|
configurable: true,
|
||||||
|
enumerable: true
|
||||||
|
});
|
||||||
|
Object.defineProperty(subject, 'notSpied3', {
|
||||||
|
value: noop3,
|
||||||
|
writable: true,
|
||||||
|
configurable: false,
|
||||||
|
enumerable: true
|
||||||
|
});
|
||||||
|
Object.defineProperty(subject, 'notSpied4', {
|
||||||
|
configurable: false,
|
||||||
|
set: function(val) { /**/ },
|
||||||
|
get: function() {
|
||||||
|
return noop4;
|
||||||
|
},
|
||||||
|
enumerable: true
|
||||||
|
});
|
||||||
|
Object.defineProperty(subject, 'notSpied5', {
|
||||||
|
value: noop5,
|
||||||
|
writable: true,
|
||||||
|
configurable: true,
|
||||||
|
enumerable: false
|
||||||
|
});
|
||||||
|
subject.notSpied6 = 6;
|
||||||
|
|
||||||
|
var spiedObject = spyRegistry.spyOnAllFunctions(subject);
|
||||||
|
|
||||||
|
expect(subject.notSpied1).toBe(noop1);
|
||||||
|
expect(subject.notSpied2).toBe(noop2);
|
||||||
|
expect(subject.notSpied3).toBe(noop3);
|
||||||
|
expect(subject.notSpied4).toBe(noop4);
|
||||||
|
expect(subject.notSpied5).toBe(noop5);
|
||||||
|
expect(subject.notSpied6).toBe(6);
|
||||||
|
expect(subject.spied1).toBe('I am a spy');
|
||||||
|
expect(subject.spied2).toBe('I am a spy');
|
||||||
|
expect(subject.spied3).toBe('I am a spy');
|
||||||
|
expect(subject.spied4).toBe('I am a spy');
|
||||||
|
expect(spiedObject).toBe(subject);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describe("#clearSpies", function() {
|
describe("#clearSpies", function() {
|
||||||
it("restores the original functions on the spied-upon objects", function() {
|
it("restores the original functions on the spied-upon objects", function() {
|
||||||
var spies = [],
|
var spies = [],
|
||||||
|
|||||||
@@ -297,7 +297,7 @@ describe("TreeProcessor", function() {
|
|||||||
node.getResult.and.returnValue({ my: 'result' });
|
node.getResult.and.returnValue({ my: 'result' });
|
||||||
|
|
||||||
queueRunner.calls.mostRecent().args[0].onComplete();
|
queueRunner.calls.mostRecent().args[0].onComplete();
|
||||||
expect(nodeComplete).toHaveBeenCalledWith(node, { my: 'result' }, nodeDone);
|
expect(nodeComplete).toHaveBeenCalledWith(node, { my: 'result' }, jasmine.any(Function));
|
||||||
});
|
});
|
||||||
|
|
||||||
it("runs a node with children", function() {
|
it("runs a node with children", function() {
|
||||||
@@ -328,6 +328,37 @@ describe("TreeProcessor", function() {
|
|||||||
expect(leaf2.execute).toHaveBeenCalledWith('bar', false);
|
expect(leaf2.execute).toHaveBeenCalledWith('bar', false);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("cascades errors up the tree", function() {
|
||||||
|
var leaf = new Leaf(),
|
||||||
|
node = new Node({ children: [leaf] }),
|
||||||
|
root = new Node({ children: [node] }),
|
||||||
|
queueRunner = jasmine.createSpy('queueRunner'),
|
||||||
|
nodeComplete = jasmine.createSpy('nodeComplete'),
|
||||||
|
processor = new jasmineUnderTest.TreeProcessor({
|
||||||
|
tree: root,
|
||||||
|
runnableIds: [node.id],
|
||||||
|
nodeComplete: nodeComplete,
|
||||||
|
queueRunnerFactory: queueRunner
|
||||||
|
}),
|
||||||
|
treeComplete = jasmine.createSpy('treeComplete'),
|
||||||
|
nodeDone = jasmine.createSpy('nodeDone');
|
||||||
|
|
||||||
|
processor.execute(treeComplete);
|
||||||
|
var queueableFns = queueRunner.calls.mostRecent().args[0].queueableFns;
|
||||||
|
queueableFns[0].fn(nodeDone);
|
||||||
|
|
||||||
|
queueableFns = queueRunner.calls.mostRecent().args[0].queueableFns;
|
||||||
|
expect(queueableFns.length).toBe(2);
|
||||||
|
|
||||||
|
queueableFns[1].fn('foo');
|
||||||
|
expect(leaf.execute).toHaveBeenCalledWith('foo', false);
|
||||||
|
|
||||||
|
queueRunner.calls.mostRecent().args[0].onComplete('things');
|
||||||
|
expect(nodeComplete).toHaveBeenCalled();
|
||||||
|
nodeComplete.calls.mostRecent().args[2]();
|
||||||
|
expect(nodeDone).toHaveBeenCalledWith('things');
|
||||||
|
});
|
||||||
|
|
||||||
it("runs an excluded node with leaf", function() {
|
it("runs an excluded node with leaf", function() {
|
||||||
var leaf1 = new Leaf(),
|
var leaf1 = new Leaf(),
|
||||||
node = new Node({ children: [leaf1] }),
|
node = new Node({ children: [leaf1] }),
|
||||||
@@ -361,7 +392,7 @@ describe("TreeProcessor", function() {
|
|||||||
node.getResult.and.returnValue({ im: 'disabled' });
|
node.getResult.and.returnValue({ im: 'disabled' });
|
||||||
|
|
||||||
queueRunner.calls.mostRecent().args[0].onComplete();
|
queueRunner.calls.mostRecent().args[0].onComplete();
|
||||||
expect(nodeComplete).toHaveBeenCalledWith(node, { im: 'disabled' }, nodeDone);
|
expect(nodeComplete).toHaveBeenCalledWith(node, { im: 'disabled' }, jasmine.any(Function));
|
||||||
});
|
});
|
||||||
|
|
||||||
it("runs beforeAlls for a node with children", function() {
|
it("runs beforeAlls for a node with children", function() {
|
||||||
|
|||||||
@@ -31,6 +31,105 @@ describe("jasmineUnderTest.util", function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe("promise utils", function () {
|
||||||
|
|
||||||
|
var mockNativePromise,
|
||||||
|
mockPromiseLikeObject;
|
||||||
|
|
||||||
|
var mockPromiseLike = function () {this.then = function () {};};
|
||||||
|
|
||||||
|
beforeEach(function () {
|
||||||
|
jasmine.getEnv().requirePromises();
|
||||||
|
mockNativePromise = new Promise(function (res, rej) {});
|
||||||
|
mockPromiseLikeObject = new mockPromiseLike();
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("isPromise", function () {
|
||||||
|
|
||||||
|
it("should return true when passed a native promise", function () {
|
||||||
|
expect(jasmineUnderTest.isPromise(mockNativePromise)).toBe(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should return false for promise like objects", function () {
|
||||||
|
expect(jasmineUnderTest.isPromise(mockPromiseLikeObject)).toBe(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should return false for strings", function () {
|
||||||
|
expect(jasmineUnderTest.isPromise("hello")).toBe(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should return false for numbers", function () {
|
||||||
|
expect(jasmineUnderTest.isPromise(3)).toBe(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should return false for null", function () {
|
||||||
|
expect(jasmineUnderTest.isPromise(null)).toBe(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should return false for undefined", function () {
|
||||||
|
expect(jasmineUnderTest.isPromise(undefined)).toBe(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should return false for arrays", function () {
|
||||||
|
expect(jasmineUnderTest.isPromise([])).toBe(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should return false for objects", function () {
|
||||||
|
expect(jasmineUnderTest.isPromise({})).toBe(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should return false for boolean values", function () {
|
||||||
|
expect(jasmineUnderTest.isPromise(true)).toBe(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("isPromiseLike", function () {
|
||||||
|
|
||||||
|
it("should return true when passed a native promise", function () {
|
||||||
|
expect(jasmineUnderTest.isPromiseLike(mockNativePromise)).toBe(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should return true for promise like objects", function () {
|
||||||
|
expect(jasmineUnderTest.isPromiseLike(mockPromiseLikeObject)).toBe(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should return false if then is not a function", function () {
|
||||||
|
expect(jasmineUnderTest.isPromiseLike({then:{its:"Not a function :O"}})).toBe(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should return false for strings", function () {
|
||||||
|
expect(jasmineUnderTest.isPromiseLike("hello")).toBe(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should return false for numbers", function () {
|
||||||
|
expect(jasmineUnderTest.isPromiseLike(3)).toBe(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should return false for null", function () {
|
||||||
|
expect(jasmineUnderTest.isPromiseLike(null)).toBe(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should return false for undefined", function () {
|
||||||
|
expect(jasmineUnderTest.isPromiseLike(undefined)).toBe(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should return false for arrays", function () {
|
||||||
|
expect(jasmineUnderTest.isPromiseLike([])).toBe(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should return false for objects", function () {
|
||||||
|
expect(jasmineUnderTest.isPromiseLike({})).toBe(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should return false for boolean values", function () {
|
||||||
|
expect(jasmineUnderTest.isPromiseLike(true)).toBe(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
describe("isUndefined", function() {
|
describe("isUndefined", function() {
|
||||||
it("reports if a variable is defined", function() {
|
it("reports if a variable is defined", function() {
|
||||||
var a;
|
var a;
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ describe("Custom Matchers (Integration)", function() {
|
|||||||
|
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
env = new jasmineUnderTest.Env();
|
env = new jasmineUnderTest.Env();
|
||||||
env.randomizeTests(false);
|
env.configure({random: false});
|
||||||
});
|
});
|
||||||
|
|
||||||
it("allows adding more matchers local to a spec", function(done) {
|
it("allows adding more matchers local to a spec", function(done) {
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ describe('Custom Spy Strategies (Integration)', function() {
|
|||||||
|
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
env = new jasmineUnderTest.Env();
|
env = new jasmineUnderTest.Env();
|
||||||
env.randomizeTests(false);
|
env.configure({random: false});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('allows adding more strategies local to a suite', function(done) {
|
it('allows adding more strategies local to a suite', function(done) {
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ describe("Env integration", function() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
env.addReporter({ jasmineDone: assertions});
|
env.addReporter({ jasmineDone: assertions});
|
||||||
env.randomizeTests(false);
|
env.configure({random: false});
|
||||||
|
|
||||||
env.describe("A Suite", function() {
|
env.describe("A Suite", function() {
|
||||||
env.it("with a spec", function() {
|
env.it("with a spec", function() {
|
||||||
@@ -46,7 +46,7 @@ describe("Env integration", function() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
env.addReporter({ jasmineDone: assertions });
|
env.addReporter({ jasmineDone: assertions });
|
||||||
env.randomizeTests(false);
|
env.configure({random: false});
|
||||||
|
|
||||||
env.describe("Outer suite", function() {
|
env.describe("Outer suite", function() {
|
||||||
env.it("an outer spec", function() {
|
env.it("an outer spec", function() {
|
||||||
@@ -81,7 +81,7 @@ describe("Env integration", function() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
env.addReporter({ jasmineDone: assertions });
|
env.addReporter({ jasmineDone: assertions });
|
||||||
env.randomizeTests(false);
|
env.configure({random: false});
|
||||||
|
|
||||||
|
|
||||||
env.describe("Outer suite", function() {
|
env.describe("Outer suite", function() {
|
||||||
@@ -200,7 +200,7 @@ describe("Env integration", function() {
|
|||||||
var env = new jasmineUnderTest.Env();
|
var env = new jasmineUnderTest.Env();
|
||||||
|
|
||||||
env.addReporter({jasmineDone: done});
|
env.addReporter({jasmineDone: done});
|
||||||
env.randomizeTests(false);
|
env.configure({random: false});
|
||||||
env.describe("tests", function() {
|
env.describe("tests", function() {
|
||||||
var firstTimeThrough = true, firstSpecContext, secondSpecContext;
|
var firstTimeThrough = true, firstSpecContext, secondSpecContext;
|
||||||
|
|
||||||
@@ -783,9 +783,11 @@ describe("Env integration", function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
env.specFilter = function(spec) {
|
env.configure({
|
||||||
return /^first suite/.test(spec.getFullName());
|
specFilter: function(spec) {
|
||||||
};
|
return /^first suite/.test(spec.getFullName());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
env.execute();
|
env.execute();
|
||||||
});
|
});
|
||||||
@@ -953,7 +955,7 @@ describe("Env integration", function() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
env.addReporter({ jasmineDone: assertions });
|
env.addReporter({ jasmineDone: assertions });
|
||||||
env.randomizeTests(false);
|
env.configure({random: false});
|
||||||
|
|
||||||
env.describe("tests", function() {
|
env.describe("tests", function() {
|
||||||
env.it("test with mock clock", function() {
|
env.it("test with mock clock", function() {
|
||||||
@@ -1106,17 +1108,15 @@ describe("Env integration", function() {
|
|||||||
|
|
||||||
it('should wait a custom interval before reporting async functions that fail to call done', function(done) {
|
it('should wait a custom interval before reporting async functions that fail to call done', function(done) {
|
||||||
var env = createMockedEnv(),
|
var env = createMockedEnv(),
|
||||||
reporter = jasmine.createSpyObj('fakeReport', ['jasmineDone', 'suiteDone', 'specDone']),
|
reporter = jasmine.createSpyObj('fakeReport', ['jasmineDone', 'suiteDone', 'specDone']);
|
||||||
timeoutFailure = (/^Error: Timeout - Async callback was not invoked within timeout specified by jasmine\.DEFAULT_TIMEOUT_INTERVAL\./);
|
|
||||||
|
|
||||||
|
|
||||||
reporter.jasmineDone.and.callFake(function(r) {
|
reporter.jasmineDone.and.callFake(function(r) {
|
||||||
expect(r.failedExpectations).toEqual([]);
|
expect(r.failedExpectations).toEqual([]);
|
||||||
expect(reporter.suiteDone).toHaveFailedExpectationsForRunnable('suite beforeAll', [ timeoutFailure ]);
|
expect(reporter.suiteDone).toHaveFailedExpectationsForRunnable('suite beforeAll', [ /^Error: Timeout - Async callback was not invoked within 5000ms \(custom timeout\)/ ]);
|
||||||
expect(reporter.suiteDone).toHaveFailedExpectationsForRunnable('suite afterAll', [ timeoutFailure ]);
|
expect(reporter.suiteDone).toHaveFailedExpectationsForRunnable('suite afterAll', [ /^Error: Timeout - Async callback was not invoked within 2000ms \(custom timeout\)/ ]);
|
||||||
expect(reporter.specDone).toHaveFailedExpectationsForRunnable('suite beforeEach times out', [ timeoutFailure ]);
|
expect(reporter.specDone).toHaveFailedExpectationsForRunnable('suite beforeEach times out', [/^Error: Timeout - Async callback was not invoked within 1000ms \(custom timeout\)/]);
|
||||||
expect(reporter.specDone).toHaveFailedExpectationsForRunnable('suite afterEach times out', [ timeoutFailure ]);
|
expect(reporter.specDone).toHaveFailedExpectationsForRunnable('suite afterEach times out', [ /^Error: Timeout - Async callback was not invoked within 4000ms \(custom timeout\)/ ]);
|
||||||
expect(reporter.specDone).toHaveFailedExpectationsForRunnable('suite it times out', [ timeoutFailure ]);
|
expect(reporter.specDone).toHaveFailedExpectationsForRunnable('suite it times out', [ /^Error: Timeout - Async callback was not invoked within 6000ms \(custom timeout\)/ ]);
|
||||||
|
|
||||||
jasmine.clock().tick(1);
|
jasmine.clock().tick(1);
|
||||||
realSetTimeout(done);
|
realSetTimeout(done);
|
||||||
@@ -1478,8 +1478,7 @@ describe("Env integration", function() {
|
|||||||
"specStarted",
|
"specStarted",
|
||||||
"specDone"
|
"specDone"
|
||||||
]);
|
]);
|
||||||
env.randomizeTests(true);
|
env.configure({random: true, seed: '123456'});
|
||||||
env.seed('123456');
|
|
||||||
|
|
||||||
reporter.jasmineDone.and.callFake(function(doneArg) {
|
reporter.jasmineDone.and.callFake(function(doneArg) {
|
||||||
expect(reporter.jasmineStarted).toHaveBeenCalled();
|
expect(reporter.jasmineStarted).toHaveBeenCalled();
|
||||||
@@ -1493,7 +1492,7 @@ describe("Env integration", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
env.addReporter(reporter);
|
env.addReporter(reporter);
|
||||||
env.randomizeTests(true);
|
env.configure({random: true});
|
||||||
env.execute();
|
env.execute();
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -1664,7 +1663,7 @@ describe("Env integration", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
env.addReporter(reporter);
|
env.addReporter(reporter);
|
||||||
env.randomizeTests(false);
|
env.configure({random: false});
|
||||||
|
|
||||||
env.describe("testing custom equality testers", function() {
|
env.describe("testing custom equality testers", function() {
|
||||||
env.it("with a custom tester", function() {
|
env.it("with a custom tester", function() {
|
||||||
@@ -1700,7 +1699,7 @@ describe("Env integration", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
env.addReporter(reporter);
|
env.addReporter(reporter);
|
||||||
env.randomizeTests(false);
|
env.configure({random: false});
|
||||||
|
|
||||||
env.describe("testing custom equality testers", function() {
|
env.describe("testing custom equality testers", function() {
|
||||||
env.beforeAll(function() { env.addCustomEqualityTester(function(a, b) { return true; }); });
|
env.beforeAll(function() { env.addCustomEqualityTester(function(a, b) { return true; }); });
|
||||||
@@ -1741,7 +1740,7 @@ describe("Env integration", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
env.addReporter(reporter);
|
env.addReporter(reporter);
|
||||||
env.randomizeTests(false);
|
env.configure({random: false});
|
||||||
|
|
||||||
env.describe("testing custom equality testers", function() {
|
env.describe("testing custom equality testers", function() {
|
||||||
env.it("with a custom tester", function() {
|
env.it("with a custom tester", function() {
|
||||||
@@ -1794,7 +1793,7 @@ describe("Env integration", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
env.addReporter(reporter);
|
env.addReporter(reporter);
|
||||||
env.randomizeTests(false);
|
env.configure({random: false});
|
||||||
|
|
||||||
env.describe("testing custom equality testers", function() {
|
env.describe("testing custom equality testers", function() {
|
||||||
env.beforeAll(function() { env.addCustomEqualityTester(function(a, b) { return true; })});
|
env.beforeAll(function() { env.addCustomEqualityTester(function(a, b) { return true; })});
|
||||||
@@ -2415,4 +2414,106 @@ describe("Env integration", function() {
|
|||||||
|
|
||||||
env.execute();
|
env.execute();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('supports async matchers', function(done) {
|
||||||
|
jasmine.getEnv().requirePromises();
|
||||||
|
|
||||||
|
var env = new jasmineUnderTest.Env(),
|
||||||
|
specDone = jasmine.createSpy('specDone'),
|
||||||
|
suiteDone = jasmine.createSpy('suiteDone');
|
||||||
|
|
||||||
|
env.addReporter({
|
||||||
|
specDone: specDone,
|
||||||
|
suiteDone: suiteDone,
|
||||||
|
jasmineDone: function(result) {
|
||||||
|
expect(result.failedExpectations).toEqual([jasmine.objectContaining({
|
||||||
|
message: 'Expected a promise to be rejected.'
|
||||||
|
})]);
|
||||||
|
|
||||||
|
expect(specDone).toHaveBeenCalledWith(jasmine.objectContaining({
|
||||||
|
description: 'has an async failure',
|
||||||
|
failedExpectations: [jasmine.objectContaining({
|
||||||
|
message: 'Expected a promise to be rejected.'
|
||||||
|
})]
|
||||||
|
}));
|
||||||
|
|
||||||
|
expect(suiteDone).toHaveBeenCalledWith(jasmine.objectContaining({
|
||||||
|
description: 'a suite',
|
||||||
|
failedExpectations: [jasmine.objectContaining({
|
||||||
|
message: 'Expected a promise to be rejected.'
|
||||||
|
})]
|
||||||
|
}));
|
||||||
|
|
||||||
|
done();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
function fail(innerDone) {
|
||||||
|
var resolve;
|
||||||
|
var p = new Promise(function(res, rej) { resolve = res });
|
||||||
|
env.expectAsync(p).toBeRejected().then(innerDone);
|
||||||
|
resolve();
|
||||||
|
}
|
||||||
|
|
||||||
|
env.afterAll(fail);
|
||||||
|
env.describe('a suite', function() {
|
||||||
|
env.afterAll(fail);
|
||||||
|
env.it('has an async failure', fail);
|
||||||
|
});
|
||||||
|
|
||||||
|
env.execute();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('provides custom equality testers to async matchers', function(done) {
|
||||||
|
jasmine.getEnv().requirePromises();
|
||||||
|
|
||||||
|
var env = new jasmineUnderTest.Env(),
|
||||||
|
specDone = jasmine.createSpy('specDone');
|
||||||
|
|
||||||
|
env.addReporter({
|
||||||
|
specDone: specDone,
|
||||||
|
jasmineDone: function() {
|
||||||
|
expect(specDone).toHaveBeenCalledWith(jasmine.objectContaining({
|
||||||
|
description: 'has an async failure',
|
||||||
|
failedExpectations: []
|
||||||
|
}));
|
||||||
|
done();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
env.it('has an async failure', function() {
|
||||||
|
env.addCustomEqualityTester(function() { return true; });
|
||||||
|
var p = Promise.resolve('something');
|
||||||
|
return env.expectAsync(p).toBeResolvedTo('something else');
|
||||||
|
});
|
||||||
|
|
||||||
|
env.execute();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('includes useful stack frames in async matcher failures', function(done) {
|
||||||
|
jasmine.getEnv().requirePromises();
|
||||||
|
|
||||||
|
var env = new jasmineUnderTest.Env(),
|
||||||
|
specDone = jasmine.createSpy('specDone');
|
||||||
|
|
||||||
|
env.addReporter({
|
||||||
|
specDone: specDone,
|
||||||
|
jasmineDone: function() {
|
||||||
|
expect(specDone).toHaveBeenCalledWith(jasmine.objectContaining({
|
||||||
|
failedExpectations: [jasmine.objectContaining({
|
||||||
|
stack: jasmine.stringMatching('EnvSpec.js')
|
||||||
|
})]
|
||||||
|
}));
|
||||||
|
done();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
env.it('has an async failure', function() {
|
||||||
|
env.addCustomEqualityTester(function() { return true; });
|
||||||
|
var p = Promise.resolve();
|
||||||
|
return env.expectAsync(p).toBeRejected();
|
||||||
|
});
|
||||||
|
|
||||||
|
env.execute();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ describe("spec running", function () {
|
|||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
jasmine.getEnv().registerIntegrationMatchers();
|
jasmine.getEnv().registerIntegrationMatchers();
|
||||||
env = new jasmineUnderTest.Env();
|
env = new jasmineUnderTest.Env();
|
||||||
env.randomizeTests(false);
|
env.configure({random: false});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should assign spec ids sequentially', function() {
|
it('should assign spec ids sequentially', function() {
|
||||||
@@ -740,8 +740,7 @@ describe("spec running", function () {
|
|||||||
|
|
||||||
it("should run the tests in a consistent order when a seed is supplied", function(done) {
|
it("should run the tests in a consistent order when a seed is supplied", function(done) {
|
||||||
var actions = [];
|
var actions = [];
|
||||||
env.seed('123456');
|
env.configure({random: true, seed: '123456'});
|
||||||
env.randomizeTests(true);
|
|
||||||
|
|
||||||
env.beforeEach(function () {
|
env.beforeEach(function () {
|
||||||
actions.push('topSuite beforeEach');
|
actions.push('topSuite beforeEach');
|
||||||
@@ -865,7 +864,7 @@ describe("spec running", function () {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
env.throwOnExpectationFailure(true);
|
env.configure({oneFailurePerSpec: true});
|
||||||
|
|
||||||
var assertions = function() {
|
var assertions = function() {
|
||||||
expect(actions).toEqual([
|
expect(actions).toEqual([
|
||||||
@@ -900,7 +899,7 @@ describe("spec running", function () {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
env.throwOnExpectationFailure(true);
|
env.configure({oneFailurePerSpec: true});
|
||||||
|
|
||||||
var assertions = function() {
|
var assertions = function() {
|
||||||
expect(actions).toEqual([
|
expect(actions).toEqual([
|
||||||
@@ -932,7 +931,7 @@ describe("spec running", function () {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
env.throwOnExpectationFailure(true);
|
env.configure({oneFailurePerSpec: true});
|
||||||
|
|
||||||
var assertions = function() {
|
var assertions = function() {
|
||||||
expect(actions).toEqual([
|
expect(actions).toEqual([
|
||||||
@@ -946,23 +945,145 @@ describe("spec running", function () {
|
|||||||
|
|
||||||
env.execute();
|
env.execute();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("skips to cleanup functions after an error with deprecations", function(done) {
|
||||||
|
var actions = [];
|
||||||
|
|
||||||
|
spyOn(env, 'deprecated');
|
||||||
|
|
||||||
|
env.describe('Something', function() {
|
||||||
|
env.beforeEach(function() {
|
||||||
|
actions.push('outer beforeEach');
|
||||||
|
throw new Error("error");
|
||||||
|
});
|
||||||
|
|
||||||
|
env.afterEach(function() {
|
||||||
|
actions.push('outer afterEach');
|
||||||
|
});
|
||||||
|
|
||||||
|
env.describe('Inner', function() {
|
||||||
|
env.beforeEach(function() {
|
||||||
|
actions.push('inner beforeEach');
|
||||||
|
});
|
||||||
|
|
||||||
|
env.afterEach(function() {
|
||||||
|
actions.push('inner afterEach');
|
||||||
|
});
|
||||||
|
|
||||||
|
env.it('does it' , function() {
|
||||||
|
actions.push('inner it');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
env.throwOnExpectationFailure(true);
|
||||||
|
|
||||||
|
var assertions = function() {
|
||||||
|
expect(actions).toEqual([
|
||||||
|
'outer beforeEach',
|
||||||
|
'inner afterEach',
|
||||||
|
'outer afterEach'
|
||||||
|
]);
|
||||||
|
expect(env.deprecated).toHaveBeenCalled();
|
||||||
|
done();
|
||||||
|
};
|
||||||
|
|
||||||
|
env.addReporter({jasmineDone: assertions});
|
||||||
|
|
||||||
|
env.execute();
|
||||||
|
});
|
||||||
|
|
||||||
|
it("skips to cleanup functions after done.fail is called with deprecations", function(done) {
|
||||||
|
var actions = [];
|
||||||
|
|
||||||
|
spyOn(env, 'deprecated');
|
||||||
|
|
||||||
|
env.describe('Something', function() {
|
||||||
|
env.beforeEach(function(done) {
|
||||||
|
actions.push('beforeEach');
|
||||||
|
done.fail('error');
|
||||||
|
actions.push('after done.fail');
|
||||||
|
});
|
||||||
|
|
||||||
|
env.afterEach(function() {
|
||||||
|
actions.push('afterEach');
|
||||||
|
});
|
||||||
|
|
||||||
|
env.it('does it' , function() {
|
||||||
|
actions.push('it');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
env.throwOnExpectationFailure(true);
|
||||||
|
|
||||||
|
var assertions = function() {
|
||||||
|
expect(actions).toEqual([
|
||||||
|
'beforeEach',
|
||||||
|
'afterEach'
|
||||||
|
]);
|
||||||
|
expect(env.deprecated).toHaveBeenCalled();
|
||||||
|
done();
|
||||||
|
};
|
||||||
|
|
||||||
|
env.addReporter({jasmineDone: assertions});
|
||||||
|
|
||||||
|
env.execute();
|
||||||
|
});
|
||||||
|
|
||||||
|
it("skips to cleanup functions when an async function times out with deprecations", function(done) {
|
||||||
|
var actions = [];
|
||||||
|
|
||||||
|
spyOn(env, 'deprecated');
|
||||||
|
|
||||||
|
env.describe('Something', function() {
|
||||||
|
env.beforeEach(function(innerDone) {
|
||||||
|
actions.push('beforeEach');
|
||||||
|
}, 1);
|
||||||
|
|
||||||
|
env.afterEach(function() {
|
||||||
|
actions.push('afterEach');
|
||||||
|
});
|
||||||
|
|
||||||
|
env.it('does it' , function() {
|
||||||
|
actions.push('it');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
env.throwOnExpectationFailure(true);
|
||||||
|
|
||||||
|
var assertions = function() {
|
||||||
|
expect(actions).toEqual([
|
||||||
|
'beforeEach',
|
||||||
|
'afterEach'
|
||||||
|
]);
|
||||||
|
expect(env.deprecated).toHaveBeenCalled();
|
||||||
|
done();
|
||||||
|
};
|
||||||
|
|
||||||
|
env.addReporter({jasmineDone: assertions});
|
||||||
|
|
||||||
|
env.execute();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("when stopOnSpecFailure is on", function() {
|
describe("when stopOnSpecFailure is on", function() {
|
||||||
it("does not run further specs when one fails", function(done) {
|
it("does not run further specs when one fails", function(done) {
|
||||||
var actions = [];
|
var actions = [];
|
||||||
|
|
||||||
env.it('fails', function() {
|
env.describe('wrapper', function() {
|
||||||
actions.push('fails');
|
env.it('fails', function() {
|
||||||
env.expect(1).toBe(2);
|
actions.push('fails');
|
||||||
|
env.expect(1).toBe(2);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
env.it('does not run', function() {
|
env.describe('holder', function() {
|
||||||
actions.push('does not run');
|
env.it('does not run', function() {
|
||||||
|
actions.push('does not run');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
env.randomizeTests(false);
|
env.configure({random: false, failFast: true});
|
||||||
env.stopOnSpecFailure(true);
|
|
||||||
|
|
||||||
var assertions = function() {
|
var assertions = function() {
|
||||||
expect(actions).toEqual(['fails']);
|
expect(actions).toEqual(['fails']);
|
||||||
@@ -972,5 +1093,36 @@ describe("spec running", function () {
|
|||||||
env.addReporter({ jasmineDone: assertions });
|
env.addReporter({ jasmineDone: assertions });
|
||||||
env.execute();
|
env.execute();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("does not run further specs when one fails when configured with deprecated option", function(done) {
|
||||||
|
var actions = [];
|
||||||
|
|
||||||
|
spyOn(env, 'deprecated');
|
||||||
|
|
||||||
|
env.describe('wrapper', function() {
|
||||||
|
env.it('fails', function() {
|
||||||
|
actions.push('fails');
|
||||||
|
env.expect(1).toBe(2);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
env.describe('holder', function() {
|
||||||
|
env.it('does not run', function() {
|
||||||
|
actions.push('does not run');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
env.configure({random: false});
|
||||||
|
env.stopOnSpecFailure(true);
|
||||||
|
|
||||||
|
var assertions = function() {
|
||||||
|
expect(actions).toEqual(['fails']);
|
||||||
|
expect(env.deprecated).toHaveBeenCalled();
|
||||||
|
done();
|
||||||
|
};
|
||||||
|
|
||||||
|
env.addReporter({ jasmineDone: assertions });
|
||||||
|
env.execute();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,17 +1,56 @@
|
|||||||
describe("toBe", function() {
|
describe("toBe", function() {
|
||||||
it("passes when actual === expected", function() {
|
it("passes with no message when actual === expected", function() {
|
||||||
var matcher = jasmineUnderTest.matchers.toBe(),
|
var matcher = jasmineUnderTest.matchers.toBe(jasmineUnderTest.matchersUtil),
|
||||||
result;
|
result;
|
||||||
|
|
||||||
result = matcher.compare(1, 1);
|
result = matcher.compare(1, 1);
|
||||||
expect(result.pass).toBe(true);
|
expect(result.pass).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("fails when actual !== expected", function() {
|
it("passes with a custom message when expected is an array", function() {
|
||||||
var matcher = jasmineUnderTest.matchers.toBe(),
|
var matcher = jasmineUnderTest.matchers.toBe(jasmineUnderTest.matchersUtil),
|
||||||
|
result,
|
||||||
|
array = [1];
|
||||||
|
|
||||||
|
result = matcher.compare(array, array);
|
||||||
|
expect(result.pass).toBe(true);
|
||||||
|
expect(result.message).toBe("Expected [ 1 ] not to be [ 1 ]. Tip: To check for deep equality, use .toEqual() instead of .toBe().")
|
||||||
|
});
|
||||||
|
|
||||||
|
it("passes with a custom message when expected is an object", function() {
|
||||||
|
var matcher = jasmineUnderTest.matchers.toBe(jasmineUnderTest.matchersUtil),
|
||||||
|
result,
|
||||||
|
obj = {foo: "bar"};
|
||||||
|
|
||||||
|
result = matcher.compare(obj, obj);
|
||||||
|
expect(result.pass).toBe(true);
|
||||||
|
expect(result.message).toBe("Expected Object({ foo: 'bar' }) not to be Object({ foo: 'bar' }). Tip: To check for deep equality, use .toEqual() instead of .toBe().")
|
||||||
|
});
|
||||||
|
|
||||||
|
it("fails with no message when actual !== expected", function() {
|
||||||
|
var matcher = jasmineUnderTest.matchers.toBe(jasmineUnderTest.matchersUtil),
|
||||||
result;
|
result;
|
||||||
|
|
||||||
result = matcher.compare(1, 2);
|
result = matcher.compare(1, 2);
|
||||||
expect(result.pass).toBe(false);
|
expect(result.pass).toBe(false);
|
||||||
|
expect(result.message).toBeUndefined();
|
||||||
|
});
|
||||||
|
|
||||||
|
it("fails with a custom message when expected is an array", function() {
|
||||||
|
var matcher = jasmineUnderTest.matchers.toBe(jasmineUnderTest.matchersUtil),
|
||||||
|
result;
|
||||||
|
|
||||||
|
result = matcher.compare([1], [1]);
|
||||||
|
expect(result.pass).toBe(false);
|
||||||
|
expect(result.message).toBe("Expected [ 1 ] to be [ 1 ]. Tip: To check for deep equality, use .toEqual() instead of .toBe().")
|
||||||
|
});
|
||||||
|
|
||||||
|
it("fails with a custom message when expected is an object", function() {
|
||||||
|
var matcher = jasmineUnderTest.matchers.toBe(jasmineUnderTest.matchersUtil),
|
||||||
|
result;
|
||||||
|
|
||||||
|
result = matcher.compare({foo: "bar"}, {foo: "bar"});
|
||||||
|
expect(result.pass).toBe(false);
|
||||||
|
expect(result.message).toBe("Expected Object({ foo: 'bar' }) to be Object({ foo: 'bar' }). Tip: To check for deep equality, use .toEqual() instead of .toBe().")
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -0,0 +1,8 @@
|
|||||||
|
(function(env) {
|
||||||
|
env.requirePromises = function() {
|
||||||
|
if (typeof Promise !== 'function') {
|
||||||
|
env.pending("Environment does not support promises");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
})(jasmine.getEnv());
|
||||||
|
|
||||||
@@ -103,7 +103,6 @@ describe("HtmlReporter", function() {
|
|||||||
createTextNode: function() { return document.createTextNode.apply(document, arguments); }
|
createTextNode: function() { return document.createTextNode.apply(document, arguments); }
|
||||||
});
|
});
|
||||||
reporter.initialize();
|
reporter.initialize();
|
||||||
|
|
||||||
reporter.specDone({id: 789, status: "excluded", fullName: "symbols should have titles", passedExpectations: [], failedExpectations: []});
|
reporter.specDone({id: 789, status: "excluded", fullName: "symbols should have titles", passedExpectations: [], failedExpectations: []});
|
||||||
|
|
||||||
var specEl = container.querySelector('.jasmine-symbol-summary li');
|
var specEl = container.querySelector('.jasmine-symbol-summary li');
|
||||||
@@ -519,7 +518,7 @@ describe("HtmlReporter", function() {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
env.stopOnSpecFailure(true);
|
env.configure({failFast: true});
|
||||||
|
|
||||||
reporter.initialize();
|
reporter.initialize();
|
||||||
reporter.jasmineDone({});
|
reporter.jasmineDone({});
|
||||||
@@ -575,7 +574,7 @@ describe("HtmlReporter", function() {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
env.stopOnSpecFailure(true);
|
env.configure({failFast: true});
|
||||||
|
|
||||||
reporter.initialize();
|
reporter.initialize();
|
||||||
reporter.jasmineDone({});
|
reporter.jasmineDone({});
|
||||||
@@ -629,7 +628,7 @@ describe("HtmlReporter", function() {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
env.throwOnExpectationFailure(true);
|
env.configure({oneFailurePerSpec: true});
|
||||||
|
|
||||||
reporter.initialize();
|
reporter.initialize();
|
||||||
reporter.jasmineDone({});
|
reporter.jasmineDone({});
|
||||||
@@ -685,7 +684,7 @@ describe("HtmlReporter", function() {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
env.throwOnExpectationFailure(true);
|
env.configure({oneFailurePerSpec: true});
|
||||||
|
|
||||||
reporter.initialize();
|
reporter.initialize();
|
||||||
reporter.jasmineDone({});
|
reporter.jasmineDone({});
|
||||||
@@ -696,7 +695,82 @@ describe("HtmlReporter", function() {
|
|||||||
expect(navigateHandler).toHaveBeenCalledWith('throwFailures', false);
|
expect(navigateHandler).toHaveBeenCalledWith('throwFailures', false);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
describe("UI for hiding disabled specs", function() {
|
||||||
|
it("should be unchecked if not hiding disabled specs", function() {
|
||||||
|
var env = new jasmineUnderTest.Env(),
|
||||||
|
container = document.createElement("div"),
|
||||||
|
getContainer = function() {
|
||||||
|
return container;
|
||||||
|
},
|
||||||
|
reporter = new jasmineUnderTest.HtmlReporter({
|
||||||
|
env: env,
|
||||||
|
getContainer: getContainer,
|
||||||
|
createElement: function() {
|
||||||
|
return document.createElement.apply(document, arguments);
|
||||||
|
},
|
||||||
|
createTextNode: function() {
|
||||||
|
return document.createTextNode.apply(document, arguments);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
env.configure({hideDisabled: false});
|
||||||
|
reporter.initialize();
|
||||||
|
reporter.jasmineDone({});
|
||||||
|
|
||||||
|
var disabledUI = container.querySelector(".jasmine-disabled");
|
||||||
|
expect(disabledUI.checked).toBe(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should be checked if hiding disabled", function() {
|
||||||
|
var env = new jasmineUnderTest.Env(),
|
||||||
|
container = document.createElement("div"),
|
||||||
|
getContainer = function() {
|
||||||
|
return container;
|
||||||
|
},
|
||||||
|
reporter = new jasmineUnderTest.HtmlReporter({
|
||||||
|
env: env,
|
||||||
|
getContainer: getContainer,
|
||||||
|
createElement: function() {
|
||||||
|
return document.createElement.apply(document, arguments);
|
||||||
|
},
|
||||||
|
createTextNode: function() {
|
||||||
|
return document.createTextNode.apply(document, arguments);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
env.configure({hideDisabled: true});
|
||||||
|
reporter.initialize();
|
||||||
|
reporter.jasmineDone({});
|
||||||
|
|
||||||
|
var disabledUI = container.querySelector(".jasmine-disabled");
|
||||||
|
expect(disabledUI.checked).toBe(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should not display specs that have been disabled", function() {
|
||||||
|
var env = new jasmineUnderTest.Env(),
|
||||||
|
container = document.createElement('div'),
|
||||||
|
getContainer = function() {return container;},
|
||||||
|
reporter = new jasmineUnderTest.HtmlReporter({
|
||||||
|
env: env,
|
||||||
|
getContainer: getContainer,
|
||||||
|
createElement: function() { return document.createElement.apply(document, arguments); },
|
||||||
|
createTextNode: function() { return document.createTextNode.apply(document, arguments); }
|
||||||
|
});
|
||||||
|
|
||||||
|
env.configure({hideDisabled: true});
|
||||||
|
reporter.initialize();
|
||||||
|
reporter.specDone({
|
||||||
|
id: 789,
|
||||||
|
status: "excluded",
|
||||||
|
fullName: "symbols should have titles",
|
||||||
|
passedExpectations: [],
|
||||||
|
failedExpectations: []
|
||||||
|
});
|
||||||
|
|
||||||
|
var specEl = container.querySelector('.jasmine-symbol-summary li');
|
||||||
|
expect(specEl.getAttribute("class")).toEqual("jasmine-excluded-no-display");
|
||||||
|
});
|
||||||
|
});
|
||||||
describe("UI for running tests in random order", function() {
|
describe("UI for running tests in random order", function() {
|
||||||
it("should be unchecked if not randomizing", function() {
|
it("should be unchecked if not randomizing", function() {
|
||||||
var env = new jasmineUnderTest.Env(),
|
var env = new jasmineUnderTest.Env(),
|
||||||
@@ -715,7 +789,7 @@ describe("HtmlReporter", function() {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
env.randomizeTests(false);
|
env.configure({random: false});
|
||||||
reporter.initialize();
|
reporter.initialize();
|
||||||
reporter.jasmineDone({});
|
reporter.jasmineDone({});
|
||||||
|
|
||||||
@@ -740,7 +814,7 @@ describe("HtmlReporter", function() {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
env.randomizeTests(true);
|
env.configure({random: true});
|
||||||
reporter.initialize();
|
reporter.initialize();
|
||||||
reporter.jasmineDone({});
|
reporter.jasmineDone({});
|
||||||
|
|
||||||
@@ -767,7 +841,7 @@ describe("HtmlReporter", function() {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
env.randomizeTests(false);
|
env.configure({random: false});
|
||||||
reporter.initialize();
|
reporter.initialize();
|
||||||
reporter.jasmineDone({});
|
reporter.jasmineDone({});
|
||||||
|
|
||||||
@@ -796,7 +870,7 @@ describe("HtmlReporter", function() {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
env.randomizeTests(true);
|
env.configure({random: true});
|
||||||
reporter.initialize();
|
reporter.initialize();
|
||||||
reporter.jasmineDone({});
|
reporter.jasmineDone({});
|
||||||
|
|
||||||
|
|||||||
@@ -11,6 +11,7 @@
|
|||||||
"helpers/checkForSymbol.js",
|
"helpers/checkForSymbol.js",
|
||||||
"helpers/checkForTypedArrays.js",
|
"helpers/checkForTypedArrays.js",
|
||||||
"helpers/integrationMatchers.js",
|
"helpers/integrationMatchers.js",
|
||||||
|
"helpers/promises.js",
|
||||||
"helpers/nodeDefineJasmineUnderTest.js"
|
"helpers/nodeDefineJasmineUnderTest.js"
|
||||||
],
|
],
|
||||||
"random": true
|
"random": true
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ helpers:
|
|||||||
- 'helpers/checkForSymbol.js'
|
- 'helpers/checkForSymbol.js'
|
||||||
- 'helpers/checkForTypedArrays.js'
|
- 'helpers/checkForTypedArrays.js'
|
||||||
- 'helpers/integrationMatchers.js'
|
- 'helpers/integrationMatchers.js'
|
||||||
|
- 'helpers/promises.js'
|
||||||
- 'helpers/defineJasmineUnderTest.js'
|
- 'helpers/defineJasmineUnderTest.js'
|
||||||
spec_files:
|
spec_files:
|
||||||
- '**/*[Ss]pec.js'
|
- '**/*[Ss]pec.js'
|
||||||
|
|||||||
@@ -0,0 +1,228 @@
|
|||||||
|
getJasmineRequireObj().AsyncExpectation = function(j$) {
|
||||||
|
var promiseForMessage = {
|
||||||
|
jasmineToString: function() { return 'a promise'; }
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Asynchronous matchers.
|
||||||
|
* @namespace async-matchers
|
||||||
|
*/
|
||||||
|
function AsyncExpectation(options) {
|
||||||
|
var global = options.global || j$.getGlobal();
|
||||||
|
this.util = options.util || { buildFailureMessage: function() {} };
|
||||||
|
this.customEqualityTesters = options.customEqualityTesters || [];
|
||||||
|
this.addExpectationResult = options.addExpectationResult || function(){};
|
||||||
|
this.actual = options.actual;
|
||||||
|
this.filters = new j$.ExpectationFilterChain();
|
||||||
|
|
||||||
|
if (!global.Promise) {
|
||||||
|
throw new Error('expectAsync is unavailable because the environment does not support promises.');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!j$.isPromiseLike(this.actual)) {
|
||||||
|
throw new Error('Expected expectAsync to be called with a promise.');
|
||||||
|
}
|
||||||
|
|
||||||
|
['toBeResolved', 'toBeRejected', 'toBeResolvedTo', 'toBeRejectedWith'].forEach(wrapCompare.bind(this));
|
||||||
|
}
|
||||||
|
|
||||||
|
function wrapCompare(name) {
|
||||||
|
var matcher = this[name];
|
||||||
|
this[name] = function() {
|
||||||
|
var self = this;
|
||||||
|
var args = Array.prototype.slice.call(arguments);
|
||||||
|
args.unshift(this.actual);
|
||||||
|
|
||||||
|
// Capture the call stack here, before we go async, so that it will
|
||||||
|
// contain frames that are relevant to the user instead of just parts
|
||||||
|
// of Jasmine.
|
||||||
|
var errorForStack = j$.util.errorWithStack();
|
||||||
|
|
||||||
|
var matcherCompare = this.instantiateMatcher(matcher);
|
||||||
|
|
||||||
|
return matcherCompare.apply(self, args).then(function(result) {
|
||||||
|
var message;
|
||||||
|
|
||||||
|
args[0] = promiseForMessage;
|
||||||
|
message = j$.Expectation.prototype.buildMessage.call(self, result, name, args);
|
||||||
|
|
||||||
|
self.addExpectationResult(result.pass, {
|
||||||
|
matcherName: name,
|
||||||
|
passed: result.pass,
|
||||||
|
message: message,
|
||||||
|
error: undefined,
|
||||||
|
errorForStack: errorForStack,
|
||||||
|
actual: self.actual
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
AsyncExpectation.prototype.instantiateMatcher = function(matcher) {
|
||||||
|
var comparisonFunc = this.filters.selectComparisonFunc(matcher);
|
||||||
|
return comparisonFunc || matcher;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Expect a promise to be resolved.
|
||||||
|
* @function
|
||||||
|
* @async
|
||||||
|
* @name async-matchers#toBeResolved
|
||||||
|
* @example
|
||||||
|
* await expectAsync(aPromise).toBeResolved();
|
||||||
|
* @example
|
||||||
|
* return expectAsync(aPromise).toBeResolved();
|
||||||
|
*/
|
||||||
|
AsyncExpectation.prototype.toBeResolved = function(actual) {
|
||||||
|
return actual.then(
|
||||||
|
function() { return {pass: true}; },
|
||||||
|
function() { return {pass: false}; }
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Expect a promise to be rejected.
|
||||||
|
* @function
|
||||||
|
* @async
|
||||||
|
* @name async-matchers#toBeRejected
|
||||||
|
* @example
|
||||||
|
* await expectAsync(aPromise).toBeRejected();
|
||||||
|
* @example
|
||||||
|
* return expectAsync(aPromise).toBeRejected();
|
||||||
|
*/
|
||||||
|
AsyncExpectation.prototype.toBeRejected = function(actual) {
|
||||||
|
return actual.then(
|
||||||
|
function() { return {pass: false}; },
|
||||||
|
function() { return {pass: true}; }
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Expect a promise to be resolved to a value equal to the expected, using deep equality comparison.
|
||||||
|
* @function
|
||||||
|
* @async
|
||||||
|
* @name async-matchers#toBeResolvedTo
|
||||||
|
* @param {Object} expected - Value that the promise is expected to resolve to
|
||||||
|
* @example
|
||||||
|
* await expectAsync(aPromise).toBeResolvedTo({prop: 'value'});
|
||||||
|
* @example
|
||||||
|
* return expectAsync(aPromise).toBeResolvedTo({prop: 'value'});
|
||||||
|
*/
|
||||||
|
AsyncExpectation.prototype.toBeResolvedTo = function(actualPromise, expectedValue) {
|
||||||
|
var self = this;
|
||||||
|
|
||||||
|
function prefix(passed) {
|
||||||
|
return 'Expected a promise ' +
|
||||||
|
(passed ? 'not ' : '') +
|
||||||
|
'to be resolved to ' + j$.pp(expectedValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
return actualPromise.then(
|
||||||
|
function(actualValue) {
|
||||||
|
if (self.util.equals(actualValue, expectedValue, self.customEqualityTesters)) {
|
||||||
|
return {
|
||||||
|
pass: true,
|
||||||
|
message: prefix(true) + '.'
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
return {
|
||||||
|
pass: false,
|
||||||
|
message: prefix(false) + ' but it was resolved to ' + j$.pp(actualValue) + '.'
|
||||||
|
};
|
||||||
|
}
|
||||||
|
},
|
||||||
|
function() {
|
||||||
|
return {
|
||||||
|
pass: false,
|
||||||
|
message: prefix(false) + ' but it was rejected.'
|
||||||
|
};
|
||||||
|
}
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Expect a promise to be rejected to a value equal to the expected, using deep equality comparison.
|
||||||
|
* @function
|
||||||
|
* @async
|
||||||
|
* @name async-matchers#toBeRejectedWith
|
||||||
|
* @param {Object} expected - Value that the promise is expected to reject to
|
||||||
|
* @example
|
||||||
|
* await expectAsync(aPromise).toBeRejectedWith({prop: 'value'});
|
||||||
|
* @example
|
||||||
|
* return expectAsync(aPromise).toBeRejectedWith({prop: 'value'});
|
||||||
|
*/
|
||||||
|
AsyncExpectation.prototype.toBeRejectedWith = function(actualPromise, expectedValue) {
|
||||||
|
var self = this;
|
||||||
|
|
||||||
|
function prefix(passed) {
|
||||||
|
return 'Expected a promise ' +
|
||||||
|
(passed ? 'not ' : '') +
|
||||||
|
'to be rejected with ' + j$.pp(expectedValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
return actualPromise.then(
|
||||||
|
function() {
|
||||||
|
return {
|
||||||
|
pass: false,
|
||||||
|
message: prefix(false) + ' but it was resolved.'
|
||||||
|
};
|
||||||
|
},
|
||||||
|
function(actualValue) {
|
||||||
|
if (self.util.equals(actualValue, expectedValue, self.customEqualityTesters)) {
|
||||||
|
return {
|
||||||
|
pass: true,
|
||||||
|
message: prefix(true) + '.'
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
return {
|
||||||
|
pass: false,
|
||||||
|
message: prefix(false) + ' but it was rejected with ' + j$.pp(actualValue) + '.'
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
AsyncExpectation.prototype.addFilter = function(filter) {
|
||||||
|
var result = Object.create(this);
|
||||||
|
result.filters = this.filters.addFilter(filter);
|
||||||
|
return result;
|
||||||
|
};
|
||||||
|
|
||||||
|
AsyncExpectation.factory = function(options) {
|
||||||
|
var expect = new AsyncExpectation(options);
|
||||||
|
expect.not = expect.addFilter(negatingFilter);
|
||||||
|
|
||||||
|
return expect;
|
||||||
|
};
|
||||||
|
|
||||||
|
var negatingFilter = {
|
||||||
|
selectComparisonFunc: function(matcher) {
|
||||||
|
function defaultNegativeCompare() {
|
||||||
|
return matcher.apply(this, arguments).then(function(result) {
|
||||||
|
result.pass = !result.pass;
|
||||||
|
return result;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return defaultNegativeCompare;
|
||||||
|
},
|
||||||
|
buildFailureMessage: function(result, matcherName, args, util) {
|
||||||
|
if (result.message) {
|
||||||
|
if (j$.isFunction_(result.message)) {
|
||||||
|
return result.message();
|
||||||
|
} else {
|
||||||
|
return result.message;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
args = args.slice();
|
||||||
|
args.unshift(true);
|
||||||
|
args.unshift(matcherName);
|
||||||
|
return util.buildFailureMessage.apply(null, args);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
return AsyncExpectation;
|
||||||
|
};
|
||||||
+220
-28
@@ -23,13 +23,62 @@ getJasmineRequireObj().Env = function(j$) {
|
|||||||
var currentSpec = null;
|
var currentSpec = null;
|
||||||
var currentlyExecutingSuites = [];
|
var currentlyExecutingSuites = [];
|
||||||
var currentDeclarationSuite = null;
|
var currentDeclarationSuite = null;
|
||||||
var throwOnExpectationFailure = false;
|
|
||||||
var stopOnSpecFailure = false;
|
|
||||||
var random = true;
|
|
||||||
var seed = null;
|
|
||||||
var handlingLoadErrors = true;
|
|
||||||
var hasFailures = false;
|
var hasFailures = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This represents the available options to configure Jasmine.
|
||||||
|
* Options that are not provided will use their default values
|
||||||
|
* @interface Configuration
|
||||||
|
*/
|
||||||
|
var config = {
|
||||||
|
/**
|
||||||
|
* Whether to randomize spec execution order
|
||||||
|
* @name Configuration#random
|
||||||
|
* @type Boolean
|
||||||
|
* @default true
|
||||||
|
*/
|
||||||
|
random: true,
|
||||||
|
/**
|
||||||
|
* Seed to use as the basis of randomization.
|
||||||
|
* Null causes the seed to be determined randomly at the start of execution.
|
||||||
|
* @name Configuration#seed
|
||||||
|
* @type function
|
||||||
|
* @default null
|
||||||
|
*/
|
||||||
|
seed: null,
|
||||||
|
/**
|
||||||
|
* Whether to stop execution of the suite after the first spec failure
|
||||||
|
* @name Configuration#failFast
|
||||||
|
* @type Boolean
|
||||||
|
* @default false
|
||||||
|
*/
|
||||||
|
failFast: false,
|
||||||
|
/**
|
||||||
|
* Whether to cause specs to only have one expectation failure.
|
||||||
|
* @name Configuration#oneFailurePerSpec
|
||||||
|
* @type Boolean
|
||||||
|
* @default false
|
||||||
|
*/
|
||||||
|
oneFailurePerSpec: false,
|
||||||
|
/**
|
||||||
|
* Function to use to filter specs
|
||||||
|
* @name Configuration#specFilter
|
||||||
|
* @type function
|
||||||
|
* @default true
|
||||||
|
*/
|
||||||
|
specFilter: function() {
|
||||||
|
return true;
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
* Whether or not reporters should hide disabled specs from their output.
|
||||||
|
* Currently only supported by Jasmine's HTMLReporter
|
||||||
|
* @name Configuration#hideDisabled
|
||||||
|
* @type Boolean
|
||||||
|
* @default false
|
||||||
|
*/
|
||||||
|
hideDisabled: false
|
||||||
|
};
|
||||||
|
|
||||||
var currentSuite = function() {
|
var currentSuite = function() {
|
||||||
return currentlyExecutingSuites[currentlyExecutingSuites.length - 1];
|
return currentlyExecutingSuites[currentlyExecutingSuites.length - 1];
|
||||||
};
|
};
|
||||||
@@ -62,10 +111,63 @@ getJasmineRequireObj().Env = function(j$) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
this.specFilter = function() {
|
/**
|
||||||
return true;
|
* Configure your jasmine environment
|
||||||
|
* @name Env#configure
|
||||||
|
* @argument {Configuration} configuration
|
||||||
|
* @function
|
||||||
|
*/
|
||||||
|
this.configure = function(configuration) {
|
||||||
|
if (configuration.specFilter) {
|
||||||
|
config.specFilter = configuration.specFilter;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (configuration.hasOwnProperty('random')) {
|
||||||
|
config.random = !!configuration.random;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (configuration.hasOwnProperty('seed')) {
|
||||||
|
config.seed = configuration.seed;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (configuration.hasOwnProperty('failFast')) {
|
||||||
|
config.failFast = configuration.failFast;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (configuration.hasOwnProperty('oneFailurePerSpec')) {
|
||||||
|
config.oneFailurePerSpec = configuration.oneFailurePerSpec;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (configuration.hasOwnProperty('hideDisabled')) {
|
||||||
|
config.hideDisabled = configuration.hideDisabled;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the current configuration for your jasmine environment
|
||||||
|
* @name Env#configuration
|
||||||
|
* @function
|
||||||
|
* @returns {Configuration}
|
||||||
|
*/
|
||||||
|
this.configuration = function() {
|
||||||
|
var result = {};
|
||||||
|
for (var property in config) {
|
||||||
|
result[property] = config[property];
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
};
|
||||||
|
|
||||||
|
Object.defineProperty(this, 'specFilter', {
|
||||||
|
get: function() {
|
||||||
|
self.deprecated('Getting specFilter directly from Env is deprecated, please check the specFilter option from `configuration`');
|
||||||
|
return config.specFilter;
|
||||||
|
},
|
||||||
|
set: function(val) {
|
||||||
|
self.deprecated('Setting specFilter directly on Env is deprecated, please use the specFilter option in `configure`');
|
||||||
|
config.specFilter = val;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
this.addSpyStrategy = function(name, fn) {
|
this.addSpyStrategy = function(name, fn) {
|
||||||
if(!currentRunnable()) {
|
if(!currentRunnable()) {
|
||||||
throw new Error('Custom spy strategies must be added in a before function or a spec');
|
throw new Error('Custom spy strategies must be added in a before function or a spec');
|
||||||
@@ -116,6 +218,19 @@ getJasmineRequireObj().Env = function(j$) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var asyncExpectationFactory = function(actual, spec) {
|
||||||
|
return j$.AsyncExpectation.factory({
|
||||||
|
util: j$.matchersUtil,
|
||||||
|
customEqualityTesters: runnableResources[spec.id].customEqualityTesters,
|
||||||
|
actual: actual,
|
||||||
|
addExpectationResult: addExpectationResult
|
||||||
|
});
|
||||||
|
|
||||||
|
function addExpectationResult(passed, result) {
|
||||||
|
return spec.addExpectationResult(passed, result);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
var defaultResourcesForRunnable = function(id, parentRunnableId) {
|
var defaultResourcesForRunnable = function(id, parentRunnableId) {
|
||||||
var resources = {spies: [], customEqualityTesters: [], customMatchers: {}, customSpyStrategies: {}};
|
var resources = {spies: [], customEqualityTesters: [], customMatchers: {}, customSpyStrategies: {}};
|
||||||
|
|
||||||
@@ -174,35 +289,85 @@ getJasmineRequireObj().Env = function(j$) {
|
|||||||
var maximumSpecCallbackDepth = 20;
|
var maximumSpecCallbackDepth = 20;
|
||||||
var currentSpecCallbackDepth = 0;
|
var currentSpecCallbackDepth = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets whether Jasmine should throw an Error when an expectation fails.
|
||||||
|
* This causes a spec to only have one expectation failure.
|
||||||
|
* @name Env#throwOnExpectationFailure
|
||||||
|
* @function
|
||||||
|
* @param {Boolean} value Whether to throw when a expectation fails
|
||||||
|
* @deprecated Use the `oneFailurePerSpec` option with {@link Env#configure}
|
||||||
|
*/
|
||||||
this.throwOnExpectationFailure = function(value) {
|
this.throwOnExpectationFailure = function(value) {
|
||||||
throwOnExpectationFailure = !!value;
|
this.deprecated('Setting throwOnExpectationFailure directly on Env is deprecated, please use the oneFailurePerSpec option in `configure`');
|
||||||
|
this.configure({oneFailurePerSpec: !!value});
|
||||||
};
|
};
|
||||||
|
|
||||||
this.throwingExpectationFailures = function() {
|
this.throwingExpectationFailures = function() {
|
||||||
return throwOnExpectationFailure;
|
this.deprecated('Getting throwingExpectationFailures directly from Env is deprecated, please check the oneFailurePerSpec option from `configuration`');
|
||||||
|
return config.oneFailurePerSpec;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set whether to stop suite execution when a spec fails
|
||||||
|
* @name Env#stopOnSpecFailure
|
||||||
|
* @function
|
||||||
|
* @param {Boolean} value Whether to stop suite execution when a spec fails
|
||||||
|
* @deprecated Use the `failFast` option with {@link Env#configure}
|
||||||
|
*/
|
||||||
this.stopOnSpecFailure = function(value) {
|
this.stopOnSpecFailure = function(value) {
|
||||||
stopOnSpecFailure = !!value;
|
this.deprecated('Setting stopOnSpecFailure directly is deprecated, please use the failFast option in `configure`');
|
||||||
|
this.configure({failFast: !!value});
|
||||||
};
|
};
|
||||||
|
|
||||||
this.stoppingOnSpecFailure = function() {
|
this.stoppingOnSpecFailure = function() {
|
||||||
return stopOnSpecFailure;
|
this.deprecated('Getting stoppingOnSpecFailure directly from Env is deprecated, please check the failFast option from `configuration`');
|
||||||
|
return config.failFast;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set whether to randomize test execution order
|
||||||
|
* @name Env#randomizeTests
|
||||||
|
* @function
|
||||||
|
* @param {Boolean} value Whether to randomize execution order
|
||||||
|
* @deprecated Use the `random` option with {@link Env#configure}
|
||||||
|
*/
|
||||||
this.randomizeTests = function(value) {
|
this.randomizeTests = function(value) {
|
||||||
random = !!value;
|
this.deprecated('Setting randomizeTests directly is deprecated, please use the random option in `configure`');
|
||||||
|
config.random = !!value;
|
||||||
};
|
};
|
||||||
|
|
||||||
this.randomTests = function() {
|
this.randomTests = function() {
|
||||||
return random;
|
this.deprecated('Getting randomTests directly from Env is deprecated, please check the random option from `configuration`');
|
||||||
|
return config.random;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the random number seed for spec randomization
|
||||||
|
* @name Env#seed
|
||||||
|
* @function
|
||||||
|
* @param {Number} value The seed value
|
||||||
|
* @deprecated Use the `seed` option with {@link Env#configure}
|
||||||
|
*/
|
||||||
this.seed = function(value) {
|
this.seed = function(value) {
|
||||||
|
this.deprecated('Setting seed directly is deprecated, please use the seed option in `configure`');
|
||||||
if (value) {
|
if (value) {
|
||||||
seed = value;
|
config.seed = value;
|
||||||
}
|
}
|
||||||
return seed;
|
return config.seed;
|
||||||
|
};
|
||||||
|
|
||||||
|
this.hidingDisabled = function(value) {
|
||||||
|
this.deprecated('Getting hidingDisabled directly from Env is deprecated, please check the hideDisabled option from `configuration`');
|
||||||
|
return config.hideDisabled;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @name Env#hideDisabled
|
||||||
|
* @function
|
||||||
|
*/
|
||||||
|
this.hideDisabled = function(value) {
|
||||||
|
this.deprecated('Setting hideDisabled directly is deprecated, please use the hideDisabled option in `configure`');
|
||||||
|
config.hideDisabled = !!value;
|
||||||
};
|
};
|
||||||
|
|
||||||
this.deprecated = function(deprecation) {
|
this.deprecated = function(deprecation) {
|
||||||
@@ -216,9 +381,9 @@ getJasmineRequireObj().Env = function(j$) {
|
|||||||
var queueRunnerFactory = function(options, args) {
|
var queueRunnerFactory = function(options, args) {
|
||||||
var failFast = false;
|
var failFast = false;
|
||||||
if (options.isLeaf) {
|
if (options.isLeaf) {
|
||||||
failFast = throwOnExpectationFailure;
|
failFast = config.oneFailurePerSpec;
|
||||||
} else if (!options.isReporter) {
|
} else if (!options.isReporter) {
|
||||||
failFast = stopOnSpecFailure;
|
failFast = config.failFast;
|
||||||
}
|
}
|
||||||
options.clearStack = options.clearStack || clearStack;
|
options.clearStack = options.clearStack || clearStack;
|
||||||
options.timeout = {setTimeout: realSetTimeout, clearTimeout: realClearTimeout};
|
options.timeout = {setTimeout: realSetTimeout, clearTimeout: realClearTimeout};
|
||||||
@@ -238,6 +403,7 @@ getJasmineRequireObj().Env = function(j$) {
|
|||||||
id: getNextSuiteId(),
|
id: getNextSuiteId(),
|
||||||
description: 'Jasmine__TopLevel__Suite',
|
description: 'Jasmine__TopLevel__Suite',
|
||||||
expectationFactory: expectationFactory,
|
expectationFactory: expectationFactory,
|
||||||
|
asyncExpectationFactory: asyncExpectationFactory,
|
||||||
expectationResultFactory: expectationResultFactory
|
expectationResultFactory: expectationResultFactory
|
||||||
});
|
});
|
||||||
defaultResourcesForRunnable(topSuite.id);
|
defaultResourcesForRunnable(topSuite.id);
|
||||||
@@ -332,8 +498,8 @@ getJasmineRequireObj().Env = function(j$) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var order = new j$.Order({
|
var order = new j$.Order({
|
||||||
random: random,
|
random: config.random,
|
||||||
seed: seed
|
seed: config.seed
|
||||||
});
|
});
|
||||||
|
|
||||||
var processor = new j$.TreeProcessor({
|
var processor = new j$.TreeProcessor({
|
||||||
@@ -363,7 +529,7 @@ getJasmineRequireObj().Env = function(j$) {
|
|||||||
return order.sort(node.children);
|
return order.sort(node.children);
|
||||||
},
|
},
|
||||||
excludeNode: function(spec) {
|
excludeNode: function(spec) {
|
||||||
return !self.specFilter(spec);
|
return !config.specFilter(spec);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -431,10 +597,22 @@ getJasmineRequireObj().Env = function(j$) {
|
|||||||
reporter.addReporter(reporterToAdd);
|
reporter.addReporter(reporterToAdd);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provide a fallback reporter if no other reporters have been specified.
|
||||||
|
* @name Env#provideFallbackReporter
|
||||||
|
* @function
|
||||||
|
* @param {Reporter} reporterToAdd The reporter
|
||||||
|
* @see custom_reporter
|
||||||
|
*/
|
||||||
this.provideFallbackReporter = function(reporterToAdd) {
|
this.provideFallbackReporter = function(reporterToAdd) {
|
||||||
reporter.provideFallbackReporter(reporterToAdd);
|
reporter.provideFallbackReporter(reporterToAdd);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clear all registered reporters
|
||||||
|
* @name Env#clearReporters
|
||||||
|
* @function
|
||||||
|
*/
|
||||||
this.clearReporters = function() {
|
this.clearReporters = function() {
|
||||||
reporter.clearReporters();
|
reporter.clearReporters();
|
||||||
};
|
};
|
||||||
@@ -473,6 +651,10 @@ getJasmineRequireObj().Env = function(j$) {
|
|||||||
return spyRegistry.spyOnProperty.apply(spyRegistry, arguments);
|
return spyRegistry.spyOnProperty.apply(spyRegistry, arguments);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
this.spyOnAllFunctions = function() {
|
||||||
|
return spyRegistry.spyOnAllFunctions.apply(spyRegistry, arguments);
|
||||||
|
};
|
||||||
|
|
||||||
this.createSpy = function(name, originalFn) {
|
this.createSpy = function(name, originalFn) {
|
||||||
if (arguments.length === 1 && j$.isFunction_(name)) {
|
if (arguments.length === 1 && j$.isFunction_(name)) {
|
||||||
originalFn = name;
|
originalFn = name;
|
||||||
@@ -512,8 +694,9 @@ getJasmineRequireObj().Env = function(j$) {
|
|||||||
description: description,
|
description: description,
|
||||||
parentSuite: currentDeclarationSuite,
|
parentSuite: currentDeclarationSuite,
|
||||||
expectationFactory: expectationFactory,
|
expectationFactory: expectationFactory,
|
||||||
|
asyncExpectationFactory: asyncExpectationFactory,
|
||||||
expectationResultFactory: expectationResultFactory,
|
expectationResultFactory: expectationResultFactory,
|
||||||
throwOnExpectationFailure: throwOnExpectationFailure
|
throwOnExpectationFailure: config.oneFailurePerSpec
|
||||||
});
|
});
|
||||||
|
|
||||||
return suite;
|
return suite;
|
||||||
@@ -605,6 +788,7 @@ getJasmineRequireObj().Env = function(j$) {
|
|||||||
id: getNextSpecId(),
|
id: getNextSpecId(),
|
||||||
beforeAndAfterFns: beforeAndAfterFns(suite),
|
beforeAndAfterFns: beforeAndAfterFns(suite),
|
||||||
expectationFactory: expectationFactory,
|
expectationFactory: expectationFactory,
|
||||||
|
asyncExpectationFactory: asyncExpectationFactory,
|
||||||
resultCallback: specResultCallback,
|
resultCallback: specResultCallback,
|
||||||
getSpecName: function(spec) {
|
getSpecName: function(spec) {
|
||||||
return getSpecName(spec, suite);
|
return getSpecName(spec, suite);
|
||||||
@@ -616,9 +800,9 @@ getJasmineRequireObj().Env = function(j$) {
|
|||||||
userContext: function() { return suite.clonedSharedUserContext(); },
|
userContext: function() { return suite.clonedSharedUserContext(); },
|
||||||
queueableFn: {
|
queueableFn: {
|
||||||
fn: fn,
|
fn: fn,
|
||||||
timeout: function() { return timeout || j$.DEFAULT_TIMEOUT_INTERVAL; }
|
timeout: timeout || 0
|
||||||
},
|
},
|
||||||
throwOnExpectationFailure: throwOnExpectationFailure
|
throwOnExpectationFailure: config.oneFailurePerSpec
|
||||||
});
|
});
|
||||||
|
|
||||||
return spec;
|
return spec;
|
||||||
@@ -686,12 +870,20 @@ getJasmineRequireObj().Env = function(j$) {
|
|||||||
return currentRunnable().expect(actual);
|
return currentRunnable().expect(actual);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
this.expectAsync = function(actual) {
|
||||||
|
if (!currentRunnable()) {
|
||||||
|
throw new Error('\'expectAsync\' was used when there was no current spec, this could be because an asynchronous test timed out');
|
||||||
|
}
|
||||||
|
|
||||||
|
return currentRunnable().expectAsync(actual);
|
||||||
|
};
|
||||||
|
|
||||||
this.beforeEach = function(beforeEachFunction, timeout) {
|
this.beforeEach = function(beforeEachFunction, timeout) {
|
||||||
ensureIsNotNested('beforeEach');
|
ensureIsNotNested('beforeEach');
|
||||||
ensureIsFunctionOrAsync(beforeEachFunction, 'beforeEach');
|
ensureIsFunctionOrAsync(beforeEachFunction, 'beforeEach');
|
||||||
currentDeclarationSuite.beforeEach({
|
currentDeclarationSuite.beforeEach({
|
||||||
fn: beforeEachFunction,
|
fn: beforeEachFunction,
|
||||||
timeout: function() { return timeout || j$.DEFAULT_TIMEOUT_INTERVAL; }
|
timeout: timeout || 0
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -700,7 +892,7 @@ getJasmineRequireObj().Env = function(j$) {
|
|||||||
ensureIsFunctionOrAsync(beforeAllFunction, 'beforeAll');
|
ensureIsFunctionOrAsync(beforeAllFunction, 'beforeAll');
|
||||||
currentDeclarationSuite.beforeAll({
|
currentDeclarationSuite.beforeAll({
|
||||||
fn: beforeAllFunction,
|
fn: beforeAllFunction,
|
||||||
timeout: function() { return timeout || j$.DEFAULT_TIMEOUT_INTERVAL; }
|
timeout: timeout || 0
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -710,7 +902,7 @@ getJasmineRequireObj().Env = function(j$) {
|
|||||||
afterEachFunction.isCleanup = true;
|
afterEachFunction.isCleanup = true;
|
||||||
currentDeclarationSuite.afterEach({
|
currentDeclarationSuite.afterEach({
|
||||||
fn: afterEachFunction,
|
fn: afterEachFunction,
|
||||||
timeout: function() { return timeout || j$.DEFAULT_TIMEOUT_INTERVAL; }
|
timeout: timeout || 0
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -719,7 +911,7 @@ getJasmineRequireObj().Env = function(j$) {
|
|||||||
ensureIsFunctionOrAsync(afterAllFunction, 'afterAll');
|
ensureIsFunctionOrAsync(afterAllFunction, 'afterAll');
|
||||||
currentDeclarationSuite.afterAll({
|
currentDeclarationSuite.afterAll({
|
||||||
fn: afterAllFunction,
|
fn: afterAllFunction,
|
||||||
timeout: function() { return timeout || j$.DEFAULT_TIMEOUT_INTERVAL; }
|
timeout: timeout || 0
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -758,7 +950,7 @@ getJasmineRequireObj().Env = function(j$) {
|
|||||||
error: error && error.message ? error : null
|
error: error && error.message ? error : null
|
||||||
});
|
});
|
||||||
|
|
||||||
if (self.throwingExpectationFailures()) {
|
if (config.oneFailurePerSpec) {
|
||||||
throw new Error(message);
|
throw new Error(message);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -7,6 +7,8 @@ getJasmineRequireObj().ExceptionFormatter = function(j$) {
|
|||||||
|
|
||||||
if (error.name && error.message) {
|
if (error.name && error.message) {
|
||||||
message += error.name + ': ' + error.message;
|
message += error.name + ': ' + error.message;
|
||||||
|
} else if (error.message) {
|
||||||
|
message += error.message;
|
||||||
} else {
|
} else {
|
||||||
message += error.toString() + ' thrown';
|
message += error.toString() + ' thrown';
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ getJasmineRequireObj().Expectation = function(j$) {
|
|||||||
Expectation.prototype.processResult = function(result, name, expected, args) {
|
Expectation.prototype.processResult = function(result, name, expected, args) {
|
||||||
var message = this.buildMessage(result, name, args);
|
var message = this.buildMessage(result, name, args);
|
||||||
|
|
||||||
if (expected.length == 1) {
|
if (expected.length === 1) {
|
||||||
expected = expected[0];
|
expected = expected[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -58,14 +58,13 @@ getJasmineRequireObj().Expectation = function(j$) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
Expectation.prototype.buildMessage = function(result, name, args) {
|
Expectation.prototype.buildMessage = function(result, name, args) {
|
||||||
var util = this.util,
|
var util = this.util;
|
||||||
msg;
|
|
||||||
|
|
||||||
if (result.pass) {
|
if (result.pass) {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
msg = this.filters.buildFailureMessage(result, name, args, util, defaultMessage);
|
var msg = this.filters.buildFailureMessage(result, name, args, util, defaultMessage);
|
||||||
return this.filters.modifyFailureMessage(msg || defaultMessage());
|
return this.filters.modifyFailureMessage(msg || defaultMessage());
|
||||||
|
|
||||||
function defaultMessage() {
|
function defaultMessage() {
|
||||||
|
|||||||
@@ -45,7 +45,9 @@ getJasmineRequireObj().buildExpectationResult = function() {
|
|||||||
|
|
||||||
var error = options.error;
|
var error = options.error;
|
||||||
if (!error) {
|
if (!error) {
|
||||||
if (options.stack) {
|
if (options.errorForStack) {
|
||||||
|
error = options.errorForStack;
|
||||||
|
} else if (options.stack) {
|
||||||
error = options;
|
error = options;
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
|
|||||||
+20
-11
@@ -5,26 +5,29 @@ getJasmineRequireObj().QueueRunner = function(j$) {
|
|||||||
|
|
||||||
function once(fn) {
|
function once(fn) {
|
||||||
var called = false;
|
var called = false;
|
||||||
return function() {
|
return function(arg) {
|
||||||
if (!called) {
|
if (!called) {
|
||||||
called = true;
|
called = true;
|
||||||
fn.apply(null, arguments);
|
// Direct call using single parameter, because cleanup/next does not need more
|
||||||
|
fn(arg);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function emptyFn() {}
|
||||||
|
|
||||||
function QueueRunner(attrs) {
|
function QueueRunner(attrs) {
|
||||||
var queueableFns = attrs.queueableFns || [];
|
var queueableFns = attrs.queueableFns || [];
|
||||||
this.queueableFns = queueableFns.concat(attrs.cleanupFns || []);
|
this.queueableFns = queueableFns.concat(attrs.cleanupFns || []);
|
||||||
this.firstCleanupIx = queueableFns.length;
|
this.firstCleanupIx = queueableFns.length;
|
||||||
this.onComplete = attrs.onComplete || function() {};
|
this.onComplete = attrs.onComplete || emptyFn;
|
||||||
this.clearStack = attrs.clearStack || function(fn) {fn();};
|
this.clearStack = attrs.clearStack || function(fn) {fn();};
|
||||||
this.onException = attrs.onException || function() {};
|
this.onException = attrs.onException || emptyFn;
|
||||||
this.userContext = attrs.userContext || new j$.UserContext();
|
this.userContext = attrs.userContext || new j$.UserContext();
|
||||||
this.timeout = attrs.timeout || {setTimeout: setTimeout, clearTimeout: clearTimeout};
|
this.timeout = attrs.timeout || {setTimeout: setTimeout, clearTimeout: clearTimeout};
|
||||||
this.fail = attrs.fail || function() {};
|
this.fail = attrs.fail || emptyFn;
|
||||||
this.globalErrors = attrs.globalErrors || { pushListener: function() {}, popListener: function() {} };
|
this.globalErrors = attrs.globalErrors || { pushListener: emptyFn, popListener: emptyFn };
|
||||||
this.completeOnFirstError = !!attrs.completeOnFirstError;
|
this.completeOnFirstError = !!attrs.completeOnFirstError;
|
||||||
this.errored = false;
|
this.errored = false;
|
||||||
|
|
||||||
@@ -66,7 +69,9 @@ getJasmineRequireObj().QueueRunner = function(j$) {
|
|||||||
next(error);
|
next(error);
|
||||||
},
|
},
|
||||||
cleanup = once(function cleanup() {
|
cleanup = once(function cleanup() {
|
||||||
self.clearTimeout(timeoutId);
|
if (timeoutId !== void 0) {
|
||||||
|
self.clearTimeout(timeoutId);
|
||||||
|
}
|
||||||
self.globalErrors.popListener(handleError);
|
self.globalErrors.popListener(handleError);
|
||||||
}),
|
}),
|
||||||
next = once(function next(err) {
|
next = once(function next(err) {
|
||||||
@@ -105,12 +110,16 @@ getJasmineRequireObj().QueueRunner = function(j$) {
|
|||||||
|
|
||||||
self.globalErrors.pushListener(handleError);
|
self.globalErrors.pushListener(handleError);
|
||||||
|
|
||||||
if (queueableFn.timeout) {
|
if (queueableFn.timeout !== undefined) {
|
||||||
|
var timeoutInterval = queueableFn.timeout || j$.DEFAULT_TIMEOUT_INTERVAL;
|
||||||
timeoutId = self.setTimeout(function() {
|
timeoutId = self.setTimeout(function() {
|
||||||
var error = new Error('Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL.');
|
var error = new Error(
|
||||||
|
'Timeout - Async callback was not invoked within ' + timeoutInterval + 'ms ' +
|
||||||
|
(queueableFn.timeout ? '(custom timeout)' : '(set by jasmine.DEFAULT_TIMEOUT_INTERVAL)')
|
||||||
|
);
|
||||||
onException(error);
|
onException(error);
|
||||||
next();
|
next();
|
||||||
}, queueableFn.timeout());
|
}, timeoutInterval);
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -159,7 +168,7 @@ getJasmineRequireObj().QueueRunner = function(j$) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
self.errored = result.errored;
|
self.errored = self.errored || result.errored;
|
||||||
|
|
||||||
if (this.completeOnFirstError && result.errored) {
|
if (this.completeOnFirstError && result.errored) {
|
||||||
this.skipToCleanup(iterativeIndex);
|
this.skipToCleanup(iterativeIndex);
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
getJasmineRequireObj().Spec = function(j$) {
|
getJasmineRequireObj().Spec = function(j$) {
|
||||||
function Spec(attrs) {
|
function Spec(attrs) {
|
||||||
this.expectationFactory = attrs.expectationFactory;
|
this.expectationFactory = attrs.expectationFactory;
|
||||||
|
this.asyncExpectationFactory = attrs.asyncExpectationFactory;
|
||||||
this.resultCallback = attrs.resultCallback || function() {};
|
this.resultCallback = attrs.resultCallback || function() {};
|
||||||
this.id = attrs.id;
|
this.id = attrs.id;
|
||||||
this.description = attrs.description || '';
|
this.description = attrs.description || '';
|
||||||
@@ -57,6 +58,10 @@ getJasmineRequireObj().Spec = function(j$) {
|
|||||||
return this.expectationFactory(actual, this);
|
return this.expectationFactory(actual, this);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Spec.prototype.expectAsync = function(actual) {
|
||||||
|
return this.asyncExpectationFactory(actual, this);
|
||||||
|
};
|
||||||
|
|
||||||
Spec.prototype.execute = function(onComplete, excluded) {
|
Spec.prototype.execute = function(onComplete, excluded) {
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
|
|||||||
@@ -120,6 +120,23 @@ getJasmineRequireObj().SpyRegistry = function(j$) {
|
|||||||
return spy;
|
return spy;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
this.spyOnAllFunctions = function(obj) {
|
||||||
|
if (j$.util.isUndefined(obj)) {
|
||||||
|
throw new Error('spyOnAllFunctions could not find an object to spy upon');
|
||||||
|
}
|
||||||
|
|
||||||
|
for (var prop in obj) {
|
||||||
|
if (Object.prototype.hasOwnProperty.call(obj, prop) && obj[prop] instanceof Function) {
|
||||||
|
var descriptor = Object.getOwnPropertyDescriptor(obj, prop);
|
||||||
|
if ((descriptor.writable || descriptor.set) && descriptor.configurable) {
|
||||||
|
this.spyOn(obj, prop);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return obj;
|
||||||
|
};
|
||||||
|
|
||||||
this.clearSpies = function() {
|
this.clearSpies = function() {
|
||||||
var spies = currentSpies();
|
var spies = currentSpies();
|
||||||
for (var i = spies.length - 1; i >= 0; i--) {
|
for (var i = spies.length - 1; i >= 0; i--) {
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ getJasmineRequireObj().Suite = function(j$) {
|
|||||||
this.parentSuite = attrs.parentSuite;
|
this.parentSuite = attrs.parentSuite;
|
||||||
this.description = attrs.description;
|
this.description = attrs.description;
|
||||||
this.expectationFactory = attrs.expectationFactory;
|
this.expectationFactory = attrs.expectationFactory;
|
||||||
|
this.asyncExpectationFactory = attrs.asyncExpectationFactory;
|
||||||
this.expectationResultFactory = attrs.expectationResultFactory;
|
this.expectationResultFactory = attrs.expectationResultFactory;
|
||||||
this.throwOnExpectationFailure = !!attrs.throwOnExpectationFailure;
|
this.throwOnExpectationFailure = !!attrs.throwOnExpectationFailure;
|
||||||
|
|
||||||
@@ -37,6 +38,10 @@ getJasmineRequireObj().Suite = function(j$) {
|
|||||||
return this.expectationFactory(actual, this);
|
return this.expectationFactory(actual, this);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Suite.prototype.expectAsync = function(actual) {
|
||||||
|
return this.asyncExpectationFactory(actual, this);
|
||||||
|
};
|
||||||
|
|
||||||
Suite.prototype.getFullName = function() {
|
Suite.prototype.getFullName = function() {
|
||||||
var fullName = [];
|
var fullName = [];
|
||||||
for (var parentSuite = this; parentSuite; parentSuite = parentSuite.parentSuite) {
|
for (var parentSuite = this; parentSuite; parentSuite = parentSuite.parentSuite) {
|
||||||
|
|||||||
@@ -174,8 +174,11 @@ getJasmineRequireObj().TreeProcessor = function() {
|
|||||||
|
|
||||||
queueRunnerFactory({
|
queueRunnerFactory({
|
||||||
onComplete: function () {
|
onComplete: function () {
|
||||||
|
var args = Array.prototype.slice.call(arguments, [0]);
|
||||||
node.cleanupBeforeAfter();
|
node.cleanupBeforeAfter();
|
||||||
nodeComplete(node, node.getResult(), done);
|
nodeComplete(node, node.getResult(), function() {
|
||||||
|
done.apply(undefined, args);
|
||||||
|
});
|
||||||
},
|
},
|
||||||
queueableFns: [onStart].concat(wrapChildren(node, segmentNumber)),
|
queueableFns: [onStart].concat(wrapChildren(node, segmentNumber)),
|
||||||
userContext: node.sharedUserContext(),
|
userContext: node.sharedUserContext(),
|
||||||
|
|||||||
+5
-1
@@ -120,7 +120,11 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
j$.isPromise = function(obj) {
|
j$.isPromise = function(obj) {
|
||||||
return typeof jasmineGlobal.Promise !== 'undefined' && obj.constructor === jasmineGlobal.Promise;
|
return typeof jasmineGlobal.Promise !== 'undefined' && !!obj && obj.constructor === jasmineGlobal.Promise;
|
||||||
|
};
|
||||||
|
|
||||||
|
j$.isPromiseLike = function(obj) {
|
||||||
|
return !!obj && j$.isFunction_(obj.then);
|
||||||
};
|
};
|
||||||
|
|
||||||
j$.fnNameFor = function(func) {
|
j$.fnNameFor = function(func) {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
getJasmineRequireObj().toBe = function() {
|
getJasmineRequireObj().toBe = function(j$) {
|
||||||
/**
|
/**
|
||||||
* {@link expect} the actual value to be `===` to the expected value.
|
* {@link expect} the actual value to be `===` to the expected value.
|
||||||
* @function
|
* @function
|
||||||
@@ -7,12 +7,20 @@ getJasmineRequireObj().toBe = function() {
|
|||||||
* @example
|
* @example
|
||||||
* expect(thing).toBe(realThing);
|
* expect(thing).toBe(realThing);
|
||||||
*/
|
*/
|
||||||
function toBe() {
|
function toBe(util) {
|
||||||
|
var tip = ' Tip: To check for deep equality, use .toEqual() instead of .toBe().';
|
||||||
|
|
||||||
return {
|
return {
|
||||||
compare: function(actual, expected) {
|
compare: function(actual, expected) {
|
||||||
return {
|
var result = {
|
||||||
pass: actual === expected
|
pass: actual === expected,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (typeof expected === 'object') {
|
||||||
|
result.message = util.buildFailureMessage('toBe', result.pass, actual, expected) + tip;
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ var getJasmineRequireObj = (function (jasmineGlobal) {
|
|||||||
j$.ExceptionFormatter = jRequire.ExceptionFormatter(j$);
|
j$.ExceptionFormatter = jRequire.ExceptionFormatter(j$);
|
||||||
j$.ExpectationFilterChain = jRequire.ExpectationFilterChain();
|
j$.ExpectationFilterChain = jRequire.ExpectationFilterChain();
|
||||||
j$.Expectation = jRequire.Expectation(j$);
|
j$.Expectation = jRequire.Expectation(j$);
|
||||||
|
j$.AsyncExpectation = jRequire.AsyncExpectation(j$);
|
||||||
j$.buildExpectationResult = jRequire.buildExpectationResult();
|
j$.buildExpectationResult = jRequire.buildExpectationResult();
|
||||||
j$.JsApiReporter = jRequire.JsApiReporter();
|
j$.JsApiReporter = jRequire.JsApiReporter();
|
||||||
j$.matchersUtil = jRequire.matchersUtil(j$);
|
j$.matchersUtil = jRequire.matchersUtil(j$);
|
||||||
|
|||||||
@@ -167,6 +167,25 @@ getJasmineRequireObj().interface = function(jasmine, env) {
|
|||||||
return env.expect(actual);
|
return env.expect(actual);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create an asynchronous expectation for a spec. Note that the matchers
|
||||||
|
* that are provided by an asynchronous expectation all return promises
|
||||||
|
* which must be either returned from the spec or waited for using `await`
|
||||||
|
* in order for Jasmine to associate them with the correct spec.
|
||||||
|
* @name expectAsync
|
||||||
|
* @function
|
||||||
|
* @global
|
||||||
|
* @param {Object} actual - Actual computed value to test expectations against.
|
||||||
|
* @return {async-matchers}
|
||||||
|
* @example
|
||||||
|
* await expectAsync(somePromise).toBeResolved();
|
||||||
|
* @example
|
||||||
|
* return expectAsync(somePromise).toBeResolved();
|
||||||
|
*/
|
||||||
|
expectAsync: function(actual) {
|
||||||
|
return env.expectAsync(actual);
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Mark a spec as pending, expectation results will be ignored.
|
* Mark a spec as pending, expectation results will be ignored.
|
||||||
* @name pending
|
* @name pending
|
||||||
@@ -216,6 +235,18 @@ getJasmineRequireObj().interface = function(jasmine, env) {
|
|||||||
return env.spyOnProperty(obj, methodName, accessType);
|
return env.spyOnProperty(obj, methodName, accessType);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Installs spies on all writable and configurable properties of an object.
|
||||||
|
* @name spyOnAllFunctions
|
||||||
|
* @function
|
||||||
|
* @global
|
||||||
|
* @param {Object} obj - The object upon which to install the {@link Spy}s
|
||||||
|
* @returns {Object} the spied object
|
||||||
|
*/
|
||||||
|
spyOnAllFunctions: function(obj) {
|
||||||
|
return env.spyOnAllFunctions(obj);
|
||||||
|
},
|
||||||
|
|
||||||
jsApiReporter: new jasmine.JsApiReporter({
|
jsApiReporter: new jasmine.JsApiReporter({
|
||||||
timer: new jasmine.Timer()
|
timer: new jasmine.Timer()
|
||||||
}),
|
}),
|
||||||
|
|||||||
+35
-11
@@ -51,7 +51,7 @@ jasmineRequire.HtmlReporter = function(j$) {
|
|||||||
|
|
||||||
|
|
||||||
function HtmlReporter(options) {
|
function HtmlReporter(options) {
|
||||||
var env = options.env || {},
|
var config = function() { return (options.env && options.env.configuration()) || {}; },
|
||||||
getContainer = options.getContainer,
|
getContainer = options.getContainer,
|
||||||
createElement = options.createElement,
|
createElement = options.createElement,
|
||||||
createTextNode = options.createTextNode,
|
createTextNode = options.createTextNode,
|
||||||
@@ -119,7 +119,7 @@ jasmineRequire.HtmlReporter = function(j$) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
symbols.appendChild(createDom('li', {
|
symbols.appendChild(createDom('li', {
|
||||||
className: noExpectations(result) ? 'jasmine-empty' : 'jasmine-' + result.status,
|
className: this.displaySpecInCorrectFormat(result),
|
||||||
id: 'spec_' + result.id,
|
id: 'spec_' + result.id,
|
||||||
title: result.fullName
|
title: result.fullName
|
||||||
}
|
}
|
||||||
@@ -132,6 +132,17 @@ jasmineRequire.HtmlReporter = function(j$) {
|
|||||||
addDeprecationWarnings(result);
|
addDeprecationWarnings(result);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
this.displaySpecInCorrectFormat = function(result) {
|
||||||
|
return noExpectations(result) ? 'jasmine-empty' : this.resultStatus(result.status);
|
||||||
|
};
|
||||||
|
|
||||||
|
this.resultStatus = function(status) {
|
||||||
|
if(status === 'excluded') {
|
||||||
|
return config().hideDisabled ? 'jasmine-excluded-no-display' : 'jasmine-excluded';
|
||||||
|
}
|
||||||
|
return 'jasmine-' + status;
|
||||||
|
};
|
||||||
|
|
||||||
this.jasmineDone = function(doneResult) {
|
this.jasmineDone = function(doneResult) {
|
||||||
var banner = find('.jasmine-banner');
|
var banner = find('.jasmine-banner');
|
||||||
var alert = find('.jasmine-alert');
|
var alert = find('.jasmine-alert');
|
||||||
@@ -139,7 +150,7 @@ jasmineRequire.HtmlReporter = function(j$) {
|
|||||||
var i;
|
var i;
|
||||||
alert.appendChild(createDom('span', {className: 'jasmine-duration'}, 'finished in ' + timer.elapsed() / 1000 + 's'));
|
alert.appendChild(createDom('span', {className: 'jasmine-duration'}, 'finished in ' + timer.elapsed() / 1000 + 's'));
|
||||||
|
|
||||||
banner.appendChild(optionsMenu(env));
|
banner.appendChild(optionsMenu(config()));
|
||||||
|
|
||||||
if (stateBuilder.specsExecuted < totalSpecsDefined) {
|
if (stateBuilder.specsExecuted < totalSpecsDefined) {
|
||||||
var skippedMessage = 'Ran ' + stateBuilder.specsExecuted + ' of ' + totalSpecsDefined + ' specs - run all';
|
var skippedMessage = 'Ran ' + stateBuilder.specsExecuted + ' of ' + totalSpecsDefined + ' specs - run all';
|
||||||
@@ -299,7 +310,7 @@ jasmineRequire.HtmlReporter = function(j$) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function optionsMenu(env) {
|
function optionsMenu(config) {
|
||||||
var optionsMenuDom = createDom('div', { className: 'jasmine-run-options' },
|
var optionsMenuDom = createDom('div', { className: 'jasmine-run-options' },
|
||||||
createDom('span', { className: 'jasmine-trigger' }, 'Options'),
|
createDom('span', { className: 'jasmine-trigger' }, 'Options'),
|
||||||
createDom('div', { className: 'jasmine-payload' },
|
createDom('div', { className: 'jasmine-payload' },
|
||||||
@@ -323,26 +334,39 @@ jasmineRequire.HtmlReporter = function(j$) {
|
|||||||
id: 'jasmine-random-order',
|
id: 'jasmine-random-order',
|
||||||
type: 'checkbox'
|
type: 'checkbox'
|
||||||
}),
|
}),
|
||||||
createDom('label', { className: 'jasmine-label', 'for': 'jasmine-random-order' }, 'run tests in random order'))
|
createDom('label', { className: 'jasmine-label', 'for': 'jasmine-random-order' }, 'run tests in random order')),
|
||||||
|
createDom('div', { className: 'jasmine-hide-disabled' },
|
||||||
|
createDom('input', {
|
||||||
|
className: 'jasmine-disabled',
|
||||||
|
id: 'jasmine-hide-disabled',
|
||||||
|
type: 'checkbox'
|
||||||
|
}),
|
||||||
|
createDom('label', { className: 'jasmine-label', 'for': 'jasmine-hide-disabled' }, 'hide disabled tests'))
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
var failFastCheckbox = optionsMenuDom.querySelector('#jasmine-fail-fast');
|
var failFastCheckbox = optionsMenuDom.querySelector('#jasmine-fail-fast');
|
||||||
failFastCheckbox.checked = env.stoppingOnSpecFailure();
|
failFastCheckbox.checked = config.failFast;
|
||||||
failFastCheckbox.onclick = function() {
|
failFastCheckbox.onclick = function() {
|
||||||
navigateWithNewParam('failFast', !env.stoppingOnSpecFailure());
|
navigateWithNewParam('failFast', !config.failFast);
|
||||||
};
|
};
|
||||||
|
|
||||||
var throwCheckbox = optionsMenuDom.querySelector('#jasmine-throw-failures');
|
var throwCheckbox = optionsMenuDom.querySelector('#jasmine-throw-failures');
|
||||||
throwCheckbox.checked = env.throwingExpectationFailures();
|
throwCheckbox.checked = config.oneFailurePerSpec;
|
||||||
throwCheckbox.onclick = function() {
|
throwCheckbox.onclick = function() {
|
||||||
navigateWithNewParam('throwFailures', !env.throwingExpectationFailures());
|
navigateWithNewParam('throwFailures', !config.oneFailurePerSpec);
|
||||||
};
|
};
|
||||||
|
|
||||||
var randomCheckbox = optionsMenuDom.querySelector('#jasmine-random-order');
|
var randomCheckbox = optionsMenuDom.querySelector('#jasmine-random-order');
|
||||||
randomCheckbox.checked = env.randomTests();
|
randomCheckbox.checked = config.random;
|
||||||
randomCheckbox.onclick = function() {
|
randomCheckbox.onclick = function() {
|
||||||
navigateWithNewParam('random', !env.randomTests());
|
navigateWithNewParam('random', !config.random);
|
||||||
|
};
|
||||||
|
|
||||||
|
var hideDisabled = optionsMenuDom.querySelector('#jasmine-hide-disabled');
|
||||||
|
hideDisabled.checked = config.hideDisabled;
|
||||||
|
hideDisabled.onclick = function() {
|
||||||
|
navigateWithNewParam('hideDisabled', !config.hideDisabled);
|
||||||
};
|
};
|
||||||
|
|
||||||
var optionsTrigger = optionsMenuDom.querySelector('.jasmine-trigger'),
|
var optionsTrigger = optionsMenuDom.querySelector('.jasmine-trigger'),
|
||||||
|
|||||||
@@ -16,6 +16,11 @@ $empty-color: #eff543;
|
|||||||
$neutral-color: #bababa;
|
$neutral-color: #bababa;
|
||||||
$jasmine-color: #8a4182;
|
$jasmine-color: #8a4182;
|
||||||
|
|
||||||
|
$passing-mark: "\02022";
|
||||||
|
$failing-mark: "\d7";
|
||||||
|
$pending-mark: "*";
|
||||||
|
$space: "\0020";
|
||||||
|
|
||||||
$font-size: 11px;
|
$font-size: 11px;
|
||||||
$large-font-size: 14px;
|
$large-font-size: 14px;
|
||||||
|
|
||||||
@@ -120,7 +125,7 @@ body {
|
|||||||
|
|
||||||
&:before {
|
&:before {
|
||||||
color: $passing-color;
|
color: $passing-color;
|
||||||
content: "\02022";
|
content: $passing-mark;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -129,26 +134,31 @@ body {
|
|||||||
|
|
||||||
&:before {
|
&:before {
|
||||||
color: $failing-color;
|
color: $failing-color;
|
||||||
content: "\d7";
|
content: $failing-mark;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
margin-left: -1px;
|
margin-left: -1px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
&.jasmine-excluded {
|
&.jasmine-excluded {
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
|
|
||||||
&:before {
|
&:before {
|
||||||
color: $neutral-color;
|
color: $neutral-color;
|
||||||
content: "\02022";
|
content: $passing-mark;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
&.jasmine-excluded-no-display {
|
||||||
|
font-size: 14px;
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
&.jasmine-pending {
|
&.jasmine-pending {
|
||||||
line-height: 17px;
|
line-height: 17px;
|
||||||
&:before {
|
&:before {
|
||||||
color: $pending-color;
|
color: $pending-color;
|
||||||
content: "*";
|
content: $pending-mark;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -157,7 +167,7 @@ body {
|
|||||||
|
|
||||||
&:before {
|
&:before {
|
||||||
color: $pending-color;
|
color: $pending-color;
|
||||||
content: "\02022";
|
content: $passing-mark;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -298,6 +308,30 @@ body {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.jasmine-specs {
|
||||||
|
li {
|
||||||
|
&.jasmine-passed a:before {
|
||||||
|
content: $passing-mark + $space;
|
||||||
|
}
|
||||||
|
|
||||||
|
&.jasmine-failed a:before {
|
||||||
|
content: $failing-mark + $space;
|
||||||
|
}
|
||||||
|
|
||||||
|
&.jasmine-empty a:before {
|
||||||
|
content: $pending-mark + $space;
|
||||||
|
}
|
||||||
|
|
||||||
|
&.jasmine-pending a:before {
|
||||||
|
content: $passing-mark + $space;
|
||||||
|
}
|
||||||
|
|
||||||
|
&.jasmine-excluded a:before {
|
||||||
|
content: $passing-mark + $space;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.jasmine-description + .jasmine-suite {
|
.jasmine-description + .jasmine-suite {
|
||||||
margin-top: 0;
|
margin-top: 0;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user