Compare commits
43 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
557fb4ed72 | ||
|
|
ee52023b3d | ||
|
|
91296a44f2 | ||
|
|
1923461b09 | ||
|
|
71116d3957 | ||
|
|
63cc7cafc8 | ||
|
|
fdecf02472 | ||
|
|
11f4d894a6 | ||
|
|
1149d4edde | ||
|
|
9ee85c35d2 | ||
|
|
0367ca5294 | ||
|
|
763a83c833 | ||
|
|
7fb53dcdfa | ||
|
|
a9a112e88f | ||
|
|
0184808a86 | ||
|
|
1ac2a6f608 | ||
|
|
785f62c7a0 | ||
|
|
d8c154a2c6 | ||
|
|
c974c4740c | ||
|
|
2b27bd393f | ||
|
|
3b77f38188 | ||
|
|
11827572d3 | ||
|
|
8326ecf919 | ||
|
|
cd6a0de852 | ||
|
|
148d94558d | ||
|
|
83beca6899 | ||
|
|
3c6308f1dc | ||
|
|
6193bc113b | ||
|
|
fa6a80b76e | ||
|
|
c861f6c6c2 | ||
|
|
4fcd4099ad | ||
|
|
1d495587ff | ||
|
|
c859128537 | ||
|
|
a8a5b839ab | ||
|
|
4e5d947faa | ||
|
|
c2603efeb4 | ||
|
|
fbec3cc230 | ||
|
|
1acbd1ef96 | ||
|
|
3d8e379fa6 | ||
|
|
55267e11f6 | ||
|
|
09a6e3714a | ||
|
|
8ec4d54685 | ||
|
|
d90e20eb15 |
10
.travis.yml
10
.travis.yml
@@ -2,7 +2,7 @@ language: ruby
|
||||
cache: bundler
|
||||
sudo: false
|
||||
|
||||
rvm: 2.2.2
|
||||
rvm: 2.5
|
||||
|
||||
script: $TEST_COMMAND
|
||||
|
||||
@@ -43,10 +43,6 @@ matrix:
|
||||
- JASMINE_BROWSER="safari"
|
||||
- SAUCE_OS="OS X 10.10"
|
||||
- SAUCE_BROWSER_VERSION=8
|
||||
- env:
|
||||
- JASMINE_BROWSER="safari"
|
||||
- SAUCE_OS="OS X 10.9"
|
||||
- SAUCE_BROWSER_VERSION=7
|
||||
- env:
|
||||
- JASMINE_BROWSER="MicrosoftEdge"
|
||||
- SAUCE_OS="Windows 10"
|
||||
@@ -66,7 +62,3 @@ matrix:
|
||||
- env:
|
||||
- JASMINE_BROWSER="phantomjs"
|
||||
- USE_SAUCE=false
|
||||
- env:
|
||||
- USE_SAUCE=false
|
||||
- JASMINE_BROWSER="phantomjs"
|
||||
- TEST_COMMAND="bash travis-docs-script.sh"
|
||||
|
||||
@@ -1,15 +1,16 @@
|
||||
<a name="README">[<img src="https://rawgithub.com/jasmine/jasmine/master/images/jasmine-horizontal.svg" width="400px" />](http://jasmine.github.io)</a>
|
||||
|
||||
[](https://travis-ci.org/jasmine/jasmine)
|
||||
[](https://www.codetriage.com/jasmine/jasmine)
|
||||
|
||||
# A JavaScript Testing Framework
|
||||
|
||||
Jasmine is a Behavior Driven Development testing framework for JavaScript. It does not rely on browsers, DOM, or any JavaScript framework. Thus it's suited for websites, [Node.js](http://nodejs.org) projects, or anywhere that JavaScript can run.
|
||||
|
||||
Documentation & guides live here: [http://jasmine.github.io](http://jasmine.github.io/)
|
||||
For a quick start guide of Jasmine 2.x, see the beginning of [http://jasmine.github.io/edge/introduction.html](http://jasmine.github.io/edge/introduction.html)
|
||||
For a quick start guide of Jasmine, see the beginning of [http://jasmine.github.io/edge/introduction.html](http://jasmine.github.io/edge/introduction.html)
|
||||
|
||||
Upgrading from Jasmine 1.x? Check out the [2.0 release notes](https://github.com/jasmine/jasmine/blob/v2.0.0/release_notes/20.md) for a list of what's new (including breaking interface changes). You can also read the [upgrade guide](http://jasmine.github.io/2.0/upgrading.html).
|
||||
Upgrading from Jasmine 2.x? Check out the [3.0 release notes](https://github.com/jasmine/jasmine/blob/v3.0.0/release_notes/3.0.md) for a list of what's new (including breaking changes).
|
||||
|
||||
## Contributing
|
||||
|
||||
@@ -73,4 +74,4 @@ Jasmine tests itself across many browsers (Safari, Chrome, Firefox, PhantomJS, M
|
||||
* [Christian Williams](mailto:antixian666@gmail.com), Cloud Foundry
|
||||
* Sheel Choksi
|
||||
|
||||
Copyright (c) 2008-2017 Pivotal Labs. This software is licensed under the MIT License.
|
||||
Copyright (c) 2008-2018 Pivotal Labs. This software is licensed under the MIT License.
|
||||
|
||||
@@ -14,7 +14,7 @@ Gem::Specification.new do |s|
|
||||
s.rubyforge_project = "jasmine-core"
|
||||
s.license = "MIT"
|
||||
|
||||
s.files = Dir.glob("./lib/**/*") + Dir.glob("./lib/jasmine-core/spec/**/*.js")
|
||||
s.files = Dir.glob("./lib/**/*")
|
||||
s.require_paths = ["lib"]
|
||||
s.add_development_dependency "rake"
|
||||
s.add_development_dependency "sauce-connect"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
module.exports = function(jasmineRequire) {
|
||||
var jasmine = jasmineRequire.core(jasmineRequire);
|
||||
|
||||
var env = jasmine.getEnv();
|
||||
var env = jasmine.getEnv({suppressLoadErrors: true});
|
||||
|
||||
var jasmineInterface = jasmineRequire.interface(jasmine, env);
|
||||
|
||||
|
||||
@@ -25,7 +25,6 @@ jasmineRequire.html = function(j$) {
|
||||
j$.HtmlReporter = jasmineRequire.HtmlReporter(j$);
|
||||
j$.QueryString = jasmineRequire.QueryString();
|
||||
j$.HtmlSpecFilter = jasmineRequire.HtmlSpecFilter();
|
||||
j$.matchers.toHaveClass = jasmineRequire.toHaveClass(j$);
|
||||
};
|
||||
|
||||
jasmineRequire.HtmlReporter = function(j$) {
|
||||
@@ -600,37 +599,3 @@ jasmineRequire.QueryString = function() {
|
||||
|
||||
return QueryString;
|
||||
};
|
||||
|
||||
jasmineRequire.toHaveClass = function(j$) {
|
||||
/**
|
||||
* {@link expect} the actual value to be a DOM element that has the expected class
|
||||
* @function
|
||||
* @name matchers#toHaveClass
|
||||
* @param {Object} expected - The class name to test for
|
||||
* @example
|
||||
* var el = document.createElement('div');
|
||||
* el.className = 'foo bar baz';
|
||||
* expect(el).toHaveClass('bar');
|
||||
*/
|
||||
function toHaveClass(util, customEqualityTesters) {
|
||||
return {
|
||||
compare: function(actual, expected) {
|
||||
if (!isElement(actual)) {
|
||||
throw new Error(j$.pp(actual) + ' is not a DOM element');
|
||||
}
|
||||
|
||||
return {
|
||||
pass: actual.classList.contains(expected)
|
||||
};
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function isElement(maybeEl) {
|
||||
return maybeEl &&
|
||||
maybeEl.classList &&
|
||||
j$.isFunction_(maybeEl.classList.contains);
|
||||
}
|
||||
|
||||
return toHaveClass;
|
||||
};
|
||||
|
||||
@@ -33,13 +33,7 @@ body { overflow-y: scroll; }
|
||||
.jasmine_html-reporter .jasmine-bar.jasmine-passed { background-color: #007069; }
|
||||
.jasmine_html-reporter .jasmine-bar.jasmine-incomplete { background-color: #bababa; }
|
||||
.jasmine_html-reporter .jasmine-bar.jasmine-skipped { background-color: #bababa; }
|
||||
<<<<<<< HEAD
|
||||
||||||| merged common ancestors
|
||||
.jasmine_html-reporter .jasmine-bar.jasmine-errored { background-color: #ca3a11; }
|
||||
=======
|
||||
.jasmine_html-reporter .jasmine-bar.jasmine-errored { background-color: #ca3a11; }
|
||||
.jasmine_html-reporter .jasmine-bar.jasmine-warning { background-color: #ba9d37; color: #333; }
|
||||
>>>>>>> master
|
||||
.jasmine_html-reporter .jasmine-bar.jasmine-menu { background-color: #fff; color: #aaa; }
|
||||
.jasmine_html-reporter .jasmine-bar.jasmine-menu a { color: #333; }
|
||||
.jasmine_html-reporter .jasmine-bar a { color: white; }
|
||||
|
||||
@@ -85,6 +85,11 @@ var getJasmineRequireObj = (function (jasmineGlobal) {
|
||||
j$.ObjectPath = jRequire.ObjectPath(j$);
|
||||
j$.GlobalErrors = jRequire.GlobalErrors(j$);
|
||||
|
||||
j$.Truthy = jRequire.Truthy(j$);
|
||||
j$.Falsy = jRequire.Falsy(j$);
|
||||
j$.Empty = jRequire.Empty(j$);
|
||||
j$.NotEmpty = jRequire.NotEmpty(j$);
|
||||
|
||||
j$.matchers = jRequire.requireMatchers(jRequire, j$);
|
||||
|
||||
return j$;
|
||||
@@ -116,6 +121,7 @@ getJasmineRequireObj().requireMatchers = function(jRequire, j$) {
|
||||
'toHaveBeenCalledBefore',
|
||||
'toHaveBeenCalledTimes',
|
||||
'toHaveBeenCalledWith',
|
||||
'toHaveClass',
|
||||
'toMatch',
|
||||
'toThrow',
|
||||
'toThrowError',
|
||||
@@ -254,8 +260,8 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) {
|
||||
return func.name;
|
||||
}
|
||||
|
||||
var matches = func.toString().match(/^\s*function\s*(\w*)\s*\(/) ||
|
||||
func.toString().match(/^\s*\[object\s*(\w*)Constructor\]/);
|
||||
var matches = func.toString().match(/^\s*function\s*(\w+)\s*\(/) ||
|
||||
func.toString().match(/^\s*\[object\s*(\w+)Constructor\]/);
|
||||
|
||||
return matches ? matches[1] : '<anonymous>';
|
||||
};
|
||||
@@ -281,6 +287,38 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) {
|
||||
return new j$.Anything();
|
||||
};
|
||||
|
||||
/**
|
||||
* Get a matcher, usable in any {@link matchers|matcher} that uses Jasmine's equality (e.g. {@link matchers#toEqual|toEqual}, {@link matchers#toContain|toContain}, or {@link matchers#toHaveBeenCalledWith|toHaveBeenCalledWith}),
|
||||
* that will succeed if the actual value being compared is `true` or anything truthy.
|
||||
* @name jasmine.truthy
|
||||
* @function
|
||||
*/
|
||||
j$.truthy = function() {return new j$.Truthy();};
|
||||
|
||||
/**
|
||||
* Get a matcher, usable in any {@link matchers|matcher} that uses Jasmine's equality (e.g. {@link matchers#toEqual|toEqual}, {@link matchers#toContain|toContain}, or {@link matchers#toHaveBeenCalledWith|toHaveBeenCalledWith}),
|
||||
* that will succeed if the actual value being compared is `null`, `undefined`, `0`, `false` or anything falsey.
|
||||
* @name jasmine.falsy
|
||||
* @function
|
||||
*/
|
||||
j$.falsy = function() {return new j$.Falsy();};
|
||||
|
||||
/**
|
||||
* Get a matcher, usable in any {@link matchers|matcher} that uses Jasmine's equality (e.g. {@link matchers#toEqual|toEqual}, {@link matchers#toContain|toContain}, or {@link matchers#toHaveBeenCalledWith|toHaveBeenCalledWith}),
|
||||
* that will succeed if the actual value being compared is empty.
|
||||
* @name jasmine.empty
|
||||
* @function
|
||||
*/
|
||||
j$.empty = function() {return new j$.Empty();};
|
||||
|
||||
/**
|
||||
* Get a matcher, usable in any {@link matchers|matcher} that uses Jasmine's equality (e.g. {@link matchers#toEqual|toEqual}, {@link matchers#toContain|toContain}, or {@link matchers#toHaveBeenCalledWith|toHaveBeenCalledWith}),
|
||||
* that will succeed if the actual value being compared is not empty.
|
||||
* @name jasmine.notEmpty
|
||||
* @function
|
||||
*/
|
||||
j$.notEmpty = function() {return new j$.NotEmpty();};
|
||||
|
||||
/**
|
||||
* Get a matcher, usable in any {@link matchers|matcher} that uses Jasmine's equality (e.g. {@link matchers#toEqual|toEqual}, {@link matchers#toContain|toContain}, or {@link matchers#toHaveBeenCalledWith|toHaveBeenCalledWith}),
|
||||
* that will succeed if the actual value being compared contains at least the keys and values.
|
||||
@@ -641,8 +679,11 @@ getJasmineRequireObj().Spec = function(j$) {
|
||||
return this.getSpecName(this);
|
||||
};
|
||||
|
||||
Spec.prototype.addDeprecationWarning = function(msg) {
|
||||
this.result.deprecationWarnings.push(this.expectationResultFactory({ message: msg }));
|
||||
Spec.prototype.addDeprecationWarning = function(deprecation) {
|
||||
if (typeof deprecation === 'string') {
|
||||
deprecation = { message: deprecation };
|
||||
}
|
||||
this.result.deprecationWarnings.push(this.expectationResultFactory(deprecation));
|
||||
};
|
||||
|
||||
var extractCustomPendingMessage = function(e) {
|
||||
@@ -753,17 +794,29 @@ getJasmineRequireObj().Env = function(j$) {
|
||||
return currentSpec || currentSuite();
|
||||
};
|
||||
|
||||
var globalErrors = new j$.GlobalErrors();
|
||||
globalErrors.install();
|
||||
globalErrors.pushListener(function(message, filename, lineno) {
|
||||
topSuite.result.failedExpectations.push({
|
||||
passed: false,
|
||||
globalErrorType: 'load',
|
||||
message: message,
|
||||
filename: filename,
|
||||
lineno: lineno
|
||||
var globalErrors = null;
|
||||
|
||||
var installGlobalErrors = function() {
|
||||
if (globalErrors) {
|
||||
return;
|
||||
}
|
||||
|
||||
globalErrors = new j$.GlobalErrors();
|
||||
globalErrors.install();
|
||||
};
|
||||
|
||||
if (!options.suppressLoadErrors) {
|
||||
installGlobalErrors();
|
||||
globalErrors.pushListener(function(message, filename, lineno) {
|
||||
topSuite.result.failedExpectations.push({
|
||||
passed: false,
|
||||
globalErrorType: 'load',
|
||||
message: message,
|
||||
filename: filename,
|
||||
lineno: lineno
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
this.specFilter = function() {
|
||||
return true;
|
||||
@@ -908,18 +961,11 @@ getJasmineRequireObj().Env = function(j$) {
|
||||
return seed;
|
||||
};
|
||||
|
||||
this.suppressLoadErrors = function() {
|
||||
if (handlingLoadErrors) {
|
||||
globalErrors.popListener();
|
||||
}
|
||||
handlingLoadErrors = false;
|
||||
};
|
||||
|
||||
this.deprecated = function(msg) {
|
||||
this.deprecated = function(deprecation) {
|
||||
var runnable = currentRunnable() || topSuite;
|
||||
runnable.addDeprecationWarning(msg);
|
||||
if(typeof console !== 'undefined' && typeof console.warn !== 'undefined') {
|
||||
console.error('DEPRECATION: ' + msg);
|
||||
runnable.addDeprecationWarning(deprecation);
|
||||
if(typeof console !== 'undefined' && typeof console.error === 'function') {
|
||||
console.error('DEPRECATION:', deprecation);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -967,6 +1013,8 @@ getJasmineRequireObj().Env = function(j$) {
|
||||
* @function
|
||||
* @name Reporter#jasmineStarted
|
||||
* @param {JasmineStartedInfo} suiteInfo Information about the full Jasmine suite that is being run
|
||||
* @param {Function} [done] Used to specify to Jasmine that this callback is asynchronous and Jasmine should wait until it has been called before moving on.
|
||||
* @returns {} Optionally return a Promise instead of using `done` to cause Jasmine to wait for completion.
|
||||
*/
|
||||
'jasmineStarted',
|
||||
/**
|
||||
@@ -974,6 +1022,8 @@ getJasmineRequireObj().Env = function(j$) {
|
||||
* @function
|
||||
* @name Reporter#jasmineDone
|
||||
* @param {JasmineDoneInfo} suiteInfo Information about the full Jasmine suite that just finished running.
|
||||
* @param {Function} [done] Used to specify to Jasmine that this callback is asynchronous and Jasmine should wait until it has been called before moving on.
|
||||
* @returns {} Optionally return a Promise instead of using `done` to cause Jasmine to wait for completion.
|
||||
*/
|
||||
'jasmineDone',
|
||||
/**
|
||||
@@ -981,6 +1031,8 @@ getJasmineRequireObj().Env = function(j$) {
|
||||
* @function
|
||||
* @name Reporter#suiteStarted
|
||||
* @param {SuiteResult} result Information about the individual {@link describe} being run
|
||||
* @param {Function} [done] Used to specify to Jasmine that this callback is asynchronous and Jasmine should wait until it has been called before moving on.
|
||||
* @returns {} Optionally return a Promise instead of using `done` to cause Jasmine to wait for completion.
|
||||
*/
|
||||
'suiteStarted',
|
||||
/**
|
||||
@@ -990,6 +1042,8 @@ getJasmineRequireObj().Env = function(j$) {
|
||||
* @function
|
||||
* @name Reporter#suiteDone
|
||||
* @param {SuiteResult} result
|
||||
* @param {Function} [done] Used to specify to Jasmine that this callback is asynchronous and Jasmine should wait until it has been called before moving on.
|
||||
* @returns {} Optionally return a Promise instead of using `done` to cause Jasmine to wait for completion.
|
||||
*/
|
||||
'suiteDone',
|
||||
/**
|
||||
@@ -997,6 +1051,8 @@ getJasmineRequireObj().Env = function(j$) {
|
||||
* @function
|
||||
* @name Reporter#specStarted
|
||||
* @param {SpecResult} result Information about the individual {@link it} being run
|
||||
* @param {Function} [done] Used to specify to Jasmine that this callback is asynchronous and Jasmine should wait until it has been called before moving on.
|
||||
* @returns {} Optionally return a Promise instead of using `done` to cause Jasmine to wait for completion.
|
||||
*/
|
||||
'specStarted',
|
||||
/**
|
||||
@@ -1006,13 +1062,15 @@ getJasmineRequireObj().Env = function(j$) {
|
||||
* @function
|
||||
* @name Reporter#specDone
|
||||
* @param {SpecResult} result
|
||||
* @param {Function} [done] Used to specify to Jasmine that this callback is asynchronous and Jasmine should wait until it has been called before moving on.
|
||||
* @returns {} Optionally return a Promise instead of using `done` to cause Jasmine to wait for completion.
|
||||
*/
|
||||
'specDone'
|
||||
], queueRunnerFactory);
|
||||
|
||||
this.execute = function(runnablesToRun) {
|
||||
var self = this;
|
||||
this.suppressLoadErrors();
|
||||
installGlobalErrors();
|
||||
|
||||
if(!runnablesToRun) {
|
||||
if (focusedRunnables.length) {
|
||||
@@ -1707,6 +1765,74 @@ getJasmineRequireObj().ArrayWithExactContents = function(j$) {
|
||||
return ArrayWithExactContents;
|
||||
};
|
||||
|
||||
getJasmineRequireObj().Empty = function (j$) {
|
||||
|
||||
function Empty() {}
|
||||
|
||||
Empty.prototype.asymmetricMatch = function (other) {
|
||||
if (j$.isString_(other) || j$.isArray_(other) || j$.isTypedArray_(other)) {
|
||||
return other.length === 0;
|
||||
}
|
||||
|
||||
if (j$.isMap(other) || j$.isSet(other)) {
|
||||
return other.size === 0;
|
||||
}
|
||||
|
||||
if (j$.isObject_(other)) {
|
||||
return Object.keys(other).length === 0;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
Empty.prototype.jasmineToString = function () {
|
||||
return '<jasmine.empty>';
|
||||
};
|
||||
|
||||
return Empty;
|
||||
};
|
||||
|
||||
getJasmineRequireObj().Falsy = function(j$) {
|
||||
|
||||
function Falsy() {}
|
||||
|
||||
Falsy.prototype.asymmetricMatch = function(other) {
|
||||
return !other;
|
||||
};
|
||||
|
||||
Falsy.prototype.jasmineToString = function() {
|
||||
return '<jasmine.falsy>';
|
||||
};
|
||||
|
||||
return Falsy;
|
||||
};
|
||||
|
||||
getJasmineRequireObj().NotEmpty = function (j$) {
|
||||
|
||||
function NotEmpty() {}
|
||||
|
||||
NotEmpty.prototype.asymmetricMatch = function (other) {
|
||||
if (j$.isString_(other) || j$.isArray_(other) || j$.isTypedArray_(other)) {
|
||||
return other.length !== 0;
|
||||
}
|
||||
|
||||
if (j$.isMap(other) || j$.isSet(other)) {
|
||||
return other.size !== 0;
|
||||
}
|
||||
|
||||
if (j$.isObject_(other)) {
|
||||
return Object.keys(other).length !== 0;
|
||||
}
|
||||
|
||||
return false;
|
||||
};
|
||||
|
||||
NotEmpty.prototype.jasmineToString = function () {
|
||||
return '<jasmine.notEmpty>';
|
||||
};
|
||||
|
||||
return NotEmpty;
|
||||
};
|
||||
|
||||
getJasmineRequireObj().ObjectContaining = function(j$) {
|
||||
|
||||
function ObjectContaining(sample) {
|
||||
@@ -1778,6 +1904,21 @@ getJasmineRequireObj().StringMatching = function(j$) {
|
||||
return StringMatching;
|
||||
};
|
||||
|
||||
getJasmineRequireObj().Truthy = function(j$) {
|
||||
|
||||
function Truthy() {}
|
||||
|
||||
Truthy.prototype.asymmetricMatch = function(other) {
|
||||
return !!other;
|
||||
};
|
||||
|
||||
Truthy.prototype.jasmineToString = function() {
|
||||
return '<jasmine.truthy>';
|
||||
};
|
||||
|
||||
return Truthy;
|
||||
};
|
||||
|
||||
getJasmineRequireObj().CallTracker = function(j$) {
|
||||
|
||||
/**
|
||||
@@ -2357,18 +2498,22 @@ getJasmineRequireObj().ExceptionFormatter = function(j$) {
|
||||
|
||||
var stackTrace = new j$.StackTrace(error.stack);
|
||||
var lines = filterJasmine(stackTrace);
|
||||
var result = '';
|
||||
|
||||
if (stackTrace.message) {
|
||||
lines.unshift(stackTrace.message);
|
||||
}
|
||||
|
||||
return lines.join('\n');
|
||||
result += formatProperties(error);
|
||||
result += lines.join('\n');
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
function filterJasmine(stackTrace) {
|
||||
var result = [],
|
||||
jasmineMarker = stackTrace.style === 'webkit' ? '<Jasmine>' : ' at <Jasmine>';
|
||||
|
||||
|
||||
stackTrace.frames.forEach(function(frame) {
|
||||
if (frame.file && frame.file !== jasmineFile) {
|
||||
result.push(frame.raw);
|
||||
@@ -2376,9 +2521,33 @@ getJasmineRequireObj().ExceptionFormatter = function(j$) {
|
||||
result.push(jasmineMarker);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
function formatProperties(error) {
|
||||
if (!(error instanceof Object)) {
|
||||
return;
|
||||
}
|
||||
|
||||
var ignored = ['name', 'message', 'stack', 'fileName', 'sourceURL', 'line', 'lineNumber', 'column', 'description'];
|
||||
var result = {};
|
||||
var empty = true;
|
||||
|
||||
for (var prop in error) {
|
||||
if (j$.util.arrayContains(ignored, prop)) {
|
||||
continue;
|
||||
}
|
||||
result[prop] = error[prop];
|
||||
empty = false;
|
||||
}
|
||||
|
||||
if (!empty) {
|
||||
return 'error properties: ' + j$.pp(result) + '\n';
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
return ExceptionFormatter;
|
||||
@@ -2530,10 +2699,14 @@ getJasmineRequireObj().buildExpectationResult = function() {
|
||||
|
||||
var error = options.error;
|
||||
if (!error) {
|
||||
try {
|
||||
throw new Error(message());
|
||||
} catch (e) {
|
||||
error = e;
|
||||
if (options.stack) {
|
||||
error = options;
|
||||
} else {
|
||||
try {
|
||||
throw new Error(message());
|
||||
} catch (e) {
|
||||
error = e;
|
||||
}
|
||||
}
|
||||
}
|
||||
return stackFormatter(error);
|
||||
@@ -3766,6 +3939,40 @@ getJasmineRequireObj().toHaveBeenCalledWith = function(j$) {
|
||||
return toHaveBeenCalledWith;
|
||||
};
|
||||
|
||||
getJasmineRequireObj().toHaveClass = function(j$) {
|
||||
/**
|
||||
* {@link expect} the actual value to be a DOM element that has the expected class
|
||||
* @function
|
||||
* @name matchers#toHaveClass
|
||||
* @param {Object} expected - The class name to test for
|
||||
* @example
|
||||
* var el = document.createElement('div');
|
||||
* el.className = 'foo bar baz';
|
||||
* expect(el).toHaveClass('bar');
|
||||
*/
|
||||
function toHaveClass(util, customEqualityTesters) {
|
||||
return {
|
||||
compare: function(actual, expected) {
|
||||
if (!isElement(actual)) {
|
||||
throw new Error(j$.pp(actual) + ' is not a DOM element');
|
||||
}
|
||||
|
||||
return {
|
||||
pass: actual.classList.contains(expected)
|
||||
};
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function isElement(maybeEl) {
|
||||
return maybeEl &&
|
||||
maybeEl.classList &&
|
||||
j$.isFunction_(maybeEl.classList.contains);
|
||||
}
|
||||
|
||||
return toHaveClass;
|
||||
};
|
||||
|
||||
getJasmineRequireObj().toMatch = function(j$) {
|
||||
|
||||
var getErrorMsg = j$.formatErrorMsg('<toMatch>', 'expect(<expectation>).toMatch(<string> || <regexp>)');
|
||||
@@ -5749,8 +5956,11 @@ getJasmineRequireObj().Suite = function(j$) {
|
||||
}
|
||||
};
|
||||
|
||||
Suite.prototype.addDeprecationWarning = function(msg) {
|
||||
this.result.deprecationWarnings.push(this.expectationResultFactory({ message: msg }));
|
||||
Suite.prototype.addDeprecationWarning = function(deprecation) {
|
||||
if (typeof deprecation === 'string') {
|
||||
deprecation = { message: deprecation };
|
||||
}
|
||||
this.result.deprecationWarnings.push(this.expectationResultFactory(deprecation));
|
||||
};
|
||||
|
||||
function isFailure(args) {
|
||||
@@ -6020,5 +6230,5 @@ getJasmineRequireObj().UserContext = function(j$) {
|
||||
};
|
||||
|
||||
getJasmineRequireObj().version = function() {
|
||||
return '3.0.0';
|
||||
return '3.1.0';
|
||||
};
|
||||
|
||||
@@ -23,7 +23,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
module.exports = function(jasmineRequire) {
|
||||
var jasmine = jasmineRequire.core(jasmineRequire);
|
||||
|
||||
var env = jasmine.getEnv();
|
||||
var env = jasmine.getEnv({suppressLoadErrors: true});
|
||||
|
||||
var jasmineInterface = jasmineRequire.interface(jasmine, env);
|
||||
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
../../spec
|
||||
@@ -4,6 +4,6 @@
|
||||
#
|
||||
module Jasmine
|
||||
module Core
|
||||
VERSION = "3.0.0"
|
||||
VERSION = "3.1.0"
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "jasmine-core",
|
||||
"license": "MIT",
|
||||
"version": "3.0.0",
|
||||
"version": "3.1.0",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/jasmine/jasmine.git"
|
||||
@@ -26,7 +26,8 @@
|
||||
"grunt-contrib-compress": "^1.3.0",
|
||||
"grunt-contrib-concat": "^1.0.1",
|
||||
"grunt-contrib-jshint": "^1.0.0",
|
||||
"jasmine": "^2.5.0",
|
||||
"jasmine": "^3.0.0",
|
||||
"jsdom": "^9.12.0",
|
||||
"load-grunt-tasks": "^0.4.0",
|
||||
"shelljs": "^0.7.0",
|
||||
"temp": "~0.8.1"
|
||||
|
||||
@@ -10,7 +10,7 @@ There is also a 2.99 release of Jasmine that will present deprecation warnings f
|
||||
|
||||
* Replace old "catch exceptions" logic with proper fail fast with error reporting
|
||||
- Fixes [#414](https://github.com/jasmine/jasmine/issues/414)
|
||||
- Fixes [jasmine/jasmine-npm#16](https://github.com/jasmine/jasmine/jasmine-npm/issues/16)
|
||||
- Fixes [jasmine/jasmine-npm#16](https://github.com/jasmine/jasmine-npm/issues/16)
|
||||
|
||||
* Detect an Error passed to `done` and add an expectation failure
|
||||
- Fixes [#567](https://github.com/jasmine/jasmine/issues/567)
|
||||
@@ -29,6 +29,13 @@ There is also a 2.99 release of Jasmine that will present deprecation warnings f
|
||||
|
||||
* Default to running tests in random order
|
||||
|
||||
* Additionally, Jasmine 3.0 drops support for older browsers and environments. Notably:
|
||||
- Internet Explorer 8 and 9
|
||||
- Ruby 1.x (for the Ruby gem)
|
||||
- Rails 3.x (for the Ruby gem)
|
||||
- Python 2.x (for the Python wheel)
|
||||
- Nodejs 0.x (for the NPM package)
|
||||
|
||||
## Changes
|
||||
|
||||
* Remove node modules from python wheel, and update languages
|
||||
|
||||
54
release_notes/3.1.0.md
Normal file
54
release_notes/3.1.0.md
Normal file
@@ -0,0 +1,54 @@
|
||||
# Jasmine-Core 3.1 Release Notes
|
||||
|
||||
## Summary
|
||||
|
||||
This release contains a number of fixes and pull requests
|
||||
|
||||
## Pull Requests and Issues
|
||||
|
||||
* Display error properties for failed specs
|
||||
- Merges [#1516](https://github.com/jasmine/jasmine/issues/1516) from @jbunton-atlassian
|
||||
|
||||
* Allow node to report load time errors
|
||||
- Fixes [#1519](https://github.com/jasmine/jasmine/issues/1519)
|
||||
|
||||
* Fixing missing semi-colons
|
||||
- Merges [#1512](https://github.com/jasmine/jasmine/issues/1512) from @Sylhare
|
||||
|
||||
* Fixed release notes link
|
||||
|
||||
* Added matchers: truthy, falsy, empty and notEmpty
|
||||
- Merges [#1460](https://github.com/jasmine/jasmine/issues/1460) from @sjolicoeur
|
||||
|
||||
* Add API docs for async reporters
|
||||
|
||||
* Return <anonymous> for functions that have no actual words between keyword and (
|
||||
- Also fixes a potential catastrophic backtracking if someone has
|
||||
severely damaged their own `toString` during test execution.
|
||||
|
||||
* Moved toHaveClass matcher into core so that it can be used in Karma
|
||||
- Fixes [#1503](https://github.com/jasmine/jasmine/issues/1503)
|
||||
|
||||
* allow adding a deprecation object
|
||||
- Merges [#1498](https://github.com/jasmine/jasmine/issues/1498) from @UziTech
|
||||
|
||||
* Add CodeTriage badge to jasmine/jasmine
|
||||
- Merges [#1505](https://github.com/jasmine/jasmine/issues/1505) from @codetriage-readme-bot
|
||||
|
||||
* Resolve merge conflict
|
||||
- Merges [#1501](https://github.com/jasmine/jasmine/issues/1501) from @aptx4869
|
||||
- Fixes [#1500](https://github.com/jasmine/jasmine/issues/1500)
|
||||
|
||||
* Fix release note typo
|
||||
- Merges [#1499](https://github.com/jasmine/jasmine/issues/1499) @bcaudan
|
||||
|
||||
* Only show deprecation for catch exceptions if you tell Jasmine not to catch
|
||||
- Fixes [#1497](https://github.com/jasmine/jasmine/issues/1497)
|
||||
|
||||
* Add notes for environments that have lost support
|
||||
- Fixes [#1495](https://github.com/jasmine/jasmine/issues/1495)
|
||||
|
||||
|
||||
------
|
||||
|
||||
_Release Notes generated with _[Anchorman](http://github.com/infews/anchorman)_
|
||||
@@ -669,7 +669,7 @@ describe("Clock (acceptance)", function() {
|
||||
expect(global.Date().getTime()).toEqual(baseTime.getTime() + 5);
|
||||
|
||||
expect(actualTimes).toEqual([baseTime.getTime(), baseTime.getTime() + 1, baseTime.getTime() + 3]);
|
||||
})
|
||||
});
|
||||
|
||||
it('correctly clears a scheduled timeout while the Clock is advancing', function () {
|
||||
var delayedFunctionScheduler = new jasmineUnderTest.DelayedFunctionScheduler(),
|
||||
|
||||
@@ -197,4 +197,24 @@ describe("Env", function() {
|
||||
}).not.toThrow();
|
||||
});
|
||||
});
|
||||
|
||||
describe('when not constructed with suppressLoadErrors: true', function() {
|
||||
it('installs a global error handler on construction', function() {
|
||||
var globalErrors = jasmine.createSpyObj('globalErrors', ['install', 'pushListener', 'popListener']);
|
||||
spyOn(jasmineUnderTest, 'GlobalErrors').and.returnValue(globalErrors);
|
||||
new jasmineUnderTest.Env();
|
||||
expect(globalErrors.install).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
describe('when constructed with suppressLoadErrors: true', function() {
|
||||
it('does not install a global error handler until execute is called', function() {
|
||||
var globalErrors = jasmine.createSpyObj('globalErrors', ['install', 'pushListener', 'popListener']);
|
||||
spyOn(jasmineUnderTest, 'GlobalErrors').and.returnValue(globalErrors);
|
||||
env = new jasmineUnderTest.Env({suppressLoadErrors: true});
|
||||
expect(globalErrors.install).not.toHaveBeenCalled();
|
||||
env.execute();
|
||||
expect(globalErrors.install).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -116,5 +116,16 @@ describe("ExceptionFormatter", function() {
|
||||
it("returns null if no Error provided", function() {
|
||||
expect(new jasmineUnderTest.ExceptionFormatter().stack()).toBeNull();
|
||||
});
|
||||
|
||||
it("includes error properties in stack", function() {
|
||||
var error;
|
||||
try { throw new Error("an error") } catch(e) { error = e; }
|
||||
error.someProperty = 'hello there';
|
||||
|
||||
var result = new jasmineUnderTest.ExceptionFormatter().stack(error);
|
||||
|
||||
expect(result).toMatch(/error properties:.*someProperty.*hello there/);
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
@@ -32,7 +32,7 @@ describe("UserContext", function() {
|
||||
describe('when using a regular object as parameter', function() {
|
||||
beforeEach(function() {
|
||||
this.context = {};
|
||||
this.value = 'value'
|
||||
this.value = 'value';
|
||||
this.context.key = this.value;
|
||||
this.cloned = jasmineUnderTest.UserContext.fromExisting(this.context);
|
||||
});
|
||||
|
||||
51
spec/core/asymmetric_equality/EmptySpec.js
Normal file
51
spec/core/asymmetric_equality/EmptySpec.js
Normal file
@@ -0,0 +1,51 @@
|
||||
describe("Empty", function () {
|
||||
it("matches an empty object", function () {
|
||||
var empty = new jasmineUnderTest.Empty();
|
||||
|
||||
expect(empty.asymmetricMatch({})).toBe(true);
|
||||
expect(empty.asymmetricMatch({undefined: false})).toBe(false);
|
||||
});
|
||||
|
||||
it("matches an empty array", function () {
|
||||
var empty = new jasmineUnderTest.Empty();
|
||||
|
||||
expect(empty.asymmetricMatch([])).toBe(true);
|
||||
expect(empty.asymmetricMatch([1, 12, 3])).toBe(false);
|
||||
});
|
||||
|
||||
it("matches an empty string", function () {
|
||||
var empty = new jasmineUnderTest.Empty();
|
||||
|
||||
expect(empty.asymmetricMatch("")).toBe(true);
|
||||
expect(empty.asymmetricMatch('')).toBe(true);
|
||||
expect(empty.asymmetricMatch('12312')).toBe(false);
|
||||
});
|
||||
|
||||
it("matches an empty map", function () {
|
||||
jasmine.getEnv().requireFunctioningMaps();
|
||||
var empty = new jasmineUnderTest.Empty();
|
||||
var fullMap = new Map();
|
||||
fullMap.set('thing', 2);
|
||||
|
||||
expect(empty.asymmetricMatch(new Map())).toBe(true);
|
||||
expect(empty.asymmetricMatch(fullMap)).toBe(false);
|
||||
});
|
||||
|
||||
it("matches an empty set", function () {
|
||||
jasmine.getEnv().requireFunctioningSets();
|
||||
var empty = new jasmineUnderTest.Empty();
|
||||
var fullSet = new Set();
|
||||
fullSet.add(3);
|
||||
|
||||
expect(empty.asymmetricMatch(new Set())).toBe(true);
|
||||
expect(empty.asymmetricMatch(fullSet)).toBe(false);
|
||||
});
|
||||
|
||||
it("matches an empty typed array", function() {
|
||||
jasmine.getEnv().requireFunctioningTypedArrays();
|
||||
var empty = new jasmineUnderTest.Empty();
|
||||
|
||||
expect(empty.asymmetricMatch(new Int16Array())).toBe(true);
|
||||
expect(empty.asymmetricMatch(new Int16Array([1,2]))).toBe(false);
|
||||
});
|
||||
});
|
||||
38
spec/core/asymmetric_equality/FalsySpec.js
Normal file
38
spec/core/asymmetric_equality/FalsySpec.js
Normal file
@@ -0,0 +1,38 @@
|
||||
describe("Falsy", function() {
|
||||
it("is true for an empty string", function() {
|
||||
var falsy = new jasmineUnderTest.Falsy();
|
||||
|
||||
expect(falsy.asymmetricMatch("")).toBe(true);
|
||||
expect(falsy.asymmetricMatch('')).toBe(true);
|
||||
expect(falsy.asymmetricMatch('asdasdad')).toBe(false);
|
||||
});
|
||||
|
||||
it("is false for a number that is 0", function() {
|
||||
var falsy = new jasmineUnderTest.Falsy(Number);
|
||||
|
||||
expect(falsy.asymmetricMatch(1)).toBe(false);
|
||||
expect(falsy.asymmetricMatch(0)).toBe(true);
|
||||
expect(falsy.asymmetricMatch(-23)).toBe(false);
|
||||
expect(falsy.asymmetricMatch(-3.1)).toBe(false);
|
||||
});
|
||||
|
||||
it("is true for a null or undefined", function() {
|
||||
var falsy = new jasmineUnderTest.Falsy(Function);
|
||||
|
||||
expect(falsy.asymmetricMatch(null)).toBe(true);
|
||||
expect(falsy.asymmetricMatch(undefined )).toBe(true);
|
||||
});
|
||||
|
||||
it("is true for NaN", function() {
|
||||
var falsy = new jasmineUnderTest.Falsy(Object);
|
||||
|
||||
expect(falsy.asymmetricMatch(NaN)).toBe(true);
|
||||
});
|
||||
|
||||
it("is true for a false Boolean", function() {
|
||||
var falsy = new jasmineUnderTest.Falsy(Boolean);
|
||||
|
||||
expect(falsy.asymmetricMatch(false)).toBe(true);
|
||||
expect(falsy.asymmetricMatch(true)).toBe(false);
|
||||
});
|
||||
});
|
||||
53
spec/core/asymmetric_equality/NotEmptySpec.js
Normal file
53
spec/core/asymmetric_equality/NotEmptySpec.js
Normal file
@@ -0,0 +1,53 @@
|
||||
describe("NotEmpty", function () {
|
||||
it("matches a non empty object", function () {
|
||||
var notEmpty = new jasmineUnderTest.NotEmpty();
|
||||
|
||||
expect(notEmpty.asymmetricMatch({undefined: false})).toBe(true);
|
||||
expect(notEmpty.asymmetricMatch({})).toBe(false);
|
||||
});
|
||||
|
||||
it("matches a non empty array", function () {
|
||||
var notEmpty = new jasmineUnderTest.NotEmpty();
|
||||
|
||||
expect(notEmpty.asymmetricMatch([1, 12, 3])).toBe(true);
|
||||
expect(notEmpty.asymmetricMatch([])).toBe(false);
|
||||
});
|
||||
|
||||
it("matches a non empty string", function () {
|
||||
var notEmpty = new jasmineUnderTest.NotEmpty();
|
||||
|
||||
expect(notEmpty.asymmetricMatch('12312')).toBe(true);
|
||||
expect(notEmpty.asymmetricMatch("")).toBe(false);
|
||||
expect(notEmpty.asymmetricMatch('')).toBe(false);
|
||||
});
|
||||
|
||||
it("matches a non empty map", function () {
|
||||
jasmine.getEnv().requireFunctioningMaps();
|
||||
var notEmpty = new jasmineUnderTest.NotEmpty();
|
||||
var fullMap = new Map();
|
||||
fullMap.set('one', 1);
|
||||
var emptyMap = new Map();
|
||||
|
||||
expect(notEmpty.asymmetricMatch(fullMap)).toBe(true);
|
||||
expect(notEmpty.asymmetricMatch(emptyMap)).toBe(false);
|
||||
});
|
||||
|
||||
it("matches a non empty set", function () {
|
||||
jasmine.getEnv().requireFunctioningSets();
|
||||
var notEmpty = new jasmineUnderTest.NotEmpty();
|
||||
var filledSet = new Set();
|
||||
filledSet.add(1);
|
||||
var emptySet = new Set();
|
||||
|
||||
expect(notEmpty.asymmetricMatch(filledSet)).toBe(true);
|
||||
expect(notEmpty.asymmetricMatch(emptySet)).toBe(false);
|
||||
});
|
||||
|
||||
it("matches a non empty typed array", function() {
|
||||
jasmine.getEnv().requireFunctioningTypedArrays();
|
||||
var notEmpty = new jasmineUnderTest.NotEmpty();
|
||||
|
||||
expect(notEmpty.asymmetricMatch(new Int16Array([1,2,3]))).toBe(true);
|
||||
expect(notEmpty.asymmetricMatch(new Int16Array())).toBe(false);
|
||||
});
|
||||
});
|
||||
63
spec/core/asymmetric_equality/TruthySpec.js
Normal file
63
spec/core/asymmetric_equality/TruthySpec.js
Normal file
@@ -0,0 +1,63 @@
|
||||
describe("Truthy", function () {
|
||||
it("is true for a non empty string", function () {
|
||||
var truthy = new jasmineUnderTest.Truthy();
|
||||
|
||||
expect(truthy.asymmetricMatch("foo")).toBe(true);
|
||||
expect(truthy.asymmetricMatch("")).toBe(false);
|
||||
});
|
||||
|
||||
it("is true for a number that is not 0", function () {
|
||||
var truthy = new jasmineUnderTest.Truthy();
|
||||
|
||||
expect(truthy.asymmetricMatch(1)).toBe(true);
|
||||
expect(truthy.asymmetricMatch(0)).toBe(false);
|
||||
expect(truthy.asymmetricMatch(-23)).toBe(true);
|
||||
expect(truthy.asymmetricMatch(-3.1)).toBe(true);
|
||||
});
|
||||
|
||||
it("is true for a function", function () {
|
||||
var truthy = new jasmineUnderTest.Truthy();
|
||||
|
||||
expect(truthy.asymmetricMatch(function () {
|
||||
})).toBe(true);
|
||||
});
|
||||
|
||||
it("is true for an Object", function () {
|
||||
var truthy = new jasmineUnderTest.Truthy();
|
||||
|
||||
expect(truthy.asymmetricMatch({})).toBe(true);
|
||||
});
|
||||
|
||||
it("is true for a truthful Boolean", function () {
|
||||
var truthy = new jasmineUnderTest.Truthy();
|
||||
|
||||
expect(truthy.asymmetricMatch(true)).toBe(true);
|
||||
expect(truthy.asymmetricMatch(false)).toBe(false);
|
||||
});
|
||||
|
||||
it("is true for an empty object", function () {
|
||||
var truthy = new jasmineUnderTest.Truthy();
|
||||
|
||||
expect(truthy.asymmetricMatch({})).toBe(true);
|
||||
});
|
||||
|
||||
it("is true for an empty array", function () {
|
||||
var truthy = new jasmineUnderTest.Truthy();
|
||||
|
||||
expect(truthy.asymmetricMatch([])).toBe(true);
|
||||
});
|
||||
|
||||
it("is true for a date", function () {
|
||||
var truthy = new jasmineUnderTest.Truthy();
|
||||
|
||||
expect(truthy.asymmetricMatch(new Date())).toBe(true);
|
||||
});
|
||||
|
||||
it("is true for a infiniti", function () {
|
||||
var truthy = new jasmineUnderTest.Truthy();
|
||||
|
||||
expect(truthy.asymmetricMatch(Infinity)).toBe(true);
|
||||
expect(truthy.asymmetricMatch(-Infinity)).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -121,7 +121,7 @@ describe("Custom Matchers (Integration)", function() {
|
||||
|
||||
var specExpectations = function(result) {
|
||||
expect(result.status).toEqual('passed');
|
||||
}
|
||||
};
|
||||
|
||||
env.addReporter({ specDone: specExpectations, jasmineDone: done });
|
||||
env.execute();
|
||||
|
||||
@@ -892,7 +892,7 @@ describe("Env integration", function() {
|
||||
};
|
||||
|
||||
env.describe('test suite', function() {
|
||||
env.beforeAll(function() { env.spyOn(testObj, 'foo');})
|
||||
env.beforeAll(function() { env.spyOn(testObj, 'foo');});
|
||||
|
||||
env.it('spec 0', function() {
|
||||
expect(jasmineUnderTest.isSpy(testObj.foo)).toBe(true);
|
||||
@@ -2060,11 +2060,13 @@ describe("Env integration", function() {
|
||||
env.execute();
|
||||
});
|
||||
|
||||
describe('If suppressLoadErrors was called', function() {
|
||||
it('does not report or handle errors that occur during loading', function(done) {
|
||||
describe('If suppressLoadErrors: true was passed', function() {
|
||||
it('does not install a global error handler during loading', function(done) {
|
||||
var originalOnerror = jasmine.createSpy('original onerror')
|
||||
var global = {
|
||||
setTimeout: function(fn, delay) { setTimeout(fn, delay) },
|
||||
clearTimeout: function(fn, delay) { clearTimeout(fn, delay) }
|
||||
clearTimeout: function(fn, delay) { clearTimeout(fn, delay) },
|
||||
onerror: originalOnerror
|
||||
};
|
||||
spyOn(jasmineUnderTest, 'getGlobal').and.returnValue(global);
|
||||
var globalErrors = new jasmineUnderTest.GlobalErrors(global);
|
||||
@@ -2072,17 +2074,16 @@ describe("Env integration", function() {
|
||||
globalErrors.pushListener(onerror);
|
||||
spyOn(jasmineUnderTest, 'GlobalErrors').and.returnValue(globalErrors);
|
||||
|
||||
var env = new jasmineUnderTest.Env(),
|
||||
var env = new jasmineUnderTest.Env({suppressLoadErrors: true});
|
||||
reporter = jasmine.createSpyObj('reporter', ['jasmineDone', 'suiteDone', 'specDone']);
|
||||
|
||||
reporter.jasmineDone.and.callFake(function(e) {
|
||||
expect(e.failedExpectations).toEqual([]);
|
||||
expect(onerror).toHaveBeenCalledWith('Uncaught Error: ENOCHEESE');
|
||||
expect(originalOnerror).toHaveBeenCalledWith('Uncaught Error: ENOCHEESE');
|
||||
done();
|
||||
});
|
||||
|
||||
env.addReporter(reporter);
|
||||
env.suppressLoadErrors(true);
|
||||
global.onerror('Uncaught Error: ENOCHEESE');
|
||||
|
||||
env.execute();
|
||||
@@ -2303,6 +2304,9 @@ describe("Env integration", function() {
|
||||
var env = new jasmineUnderTest.Env(),
|
||||
reporter = jasmine.createSpyObj('reporter', ['jasmineDone', 'suiteDone', 'specDone']);
|
||||
|
||||
// prevent deprecation from being desplayed
|
||||
spyOn(console, "error");
|
||||
|
||||
reporter.jasmineDone.and.callFake(function(result) {
|
||||
expect(result.deprecationWarnings).toEqual([
|
||||
jasmine.objectContaining({ message: 'top level deprecation' })
|
||||
@@ -2341,4 +2345,65 @@ describe("Env integration", function() {
|
||||
|
||||
env.execute();
|
||||
});
|
||||
|
||||
it('should report deprecation stack with an error object', function(done) {
|
||||
var env = new jasmineUnderTest.Env(),
|
||||
exceptionFormatter = new jasmineUnderTest.ExceptionFormatter(),
|
||||
reporter = jasmine.createSpyObj('reporter', ['jasmineDone', 'suiteDone', 'specDone']),
|
||||
topLevelError, suiteLevelError, specLevelError;
|
||||
|
||||
try { throw new Error('top level deprecation') } catch (err) { topLevelError = err; }
|
||||
try { throw new Error('suite level deprecation') } catch (err) { suiteLevelError = err; }
|
||||
try { throw new Error('spec level deprecation') } catch (err) { specLevelError = err; }
|
||||
|
||||
// prevent deprecation from being desplayed
|
||||
spyOn(console, "error");
|
||||
|
||||
reporter.jasmineDone.and.callFake(function(result) {
|
||||
expect(result.deprecationWarnings).toEqual([
|
||||
jasmine.objectContaining({
|
||||
message: topLevelError.message,
|
||||
stack: exceptionFormatter.stack(topLevelError)
|
||||
})
|
||||
]);
|
||||
|
||||
expect(reporter.suiteDone).toHaveBeenCalledWith(jasmine.objectContaining({
|
||||
fullName: 'suite',
|
||||
deprecationWarnings: [
|
||||
jasmine.objectContaining({
|
||||
message: suiteLevelError.message,
|
||||
stack: exceptionFormatter.stack(suiteLevelError)
|
||||
})
|
||||
]
|
||||
}));
|
||||
|
||||
expect(reporter.specDone).toHaveBeenCalledWith(jasmine.objectContaining({
|
||||
fullName: 'suite spec',
|
||||
deprecationWarnings: [
|
||||
jasmine.objectContaining({
|
||||
message: specLevelError.message,
|
||||
stack: exceptionFormatter.stack(specLevelError)
|
||||
})
|
||||
]
|
||||
}));
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
env.addReporter(reporter);
|
||||
|
||||
env.deprecated(topLevelError);
|
||||
|
||||
env.describe('suite', function() {
|
||||
env.beforeAll(function() {
|
||||
env.deprecated(suiteLevelError);
|
||||
});
|
||||
|
||||
env.it('spec', function() {
|
||||
env.deprecated(specLevelError);
|
||||
});
|
||||
});
|
||||
|
||||
env.execute();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -145,7 +145,7 @@ describe("matchersUtil", function() {
|
||||
actual = { b: 1 };
|
||||
|
||||
expect(jasmineUnderTest.matchersUtil.equals(actual, expected)).toBe(false);
|
||||
})
|
||||
});
|
||||
|
||||
it("fails when comparing an empty object to an empty array (issue #114)", function() {
|
||||
var emptyObject = {},
|
||||
@@ -211,11 +211,11 @@ describe("matchersUtil", function() {
|
||||
return;
|
||||
}
|
||||
var a = document.createElement("div");
|
||||
a.setAttribute("test-attr", "attr-value")
|
||||
a.setAttribute("test-attr", "attr-value");
|
||||
a.appendChild(document.createTextNode('test'));
|
||||
|
||||
var b = document.createElement("div");
|
||||
b.setAttribute("test-attr", "attr-value2")
|
||||
b.setAttribute("test-attr", "attr-value2");
|
||||
b.appendChild(document.createTextNode('test'));
|
||||
|
||||
expect(jasmineUnderTest.matchersUtil.equals(a,b)).toBe(false);
|
||||
|
||||
@@ -14,7 +14,7 @@ describe("toBeGreaterThanOrEqual", function() {
|
||||
|
||||
result = matcher.compare(1.0, 1.0);
|
||||
expect(result.pass).toBe(true);
|
||||
})
|
||||
});
|
||||
|
||||
it("fails when actual < expected", function() {
|
||||
var matcher = jasmineUnderTest.matchers.toBeGreaterThanOrEqual(),
|
||||
|
||||
@@ -95,7 +95,7 @@ describe("toEqual", function() {
|
||||
expected = {x: {}},
|
||||
message =
|
||||
"Expected $.x not to have properties\n" +
|
||||
" y: 'foo bar'"
|
||||
" y: 'foo bar'";
|
||||
|
||||
expect(compareEquals(actual, expected).message).toEqual(message);
|
||||
});
|
||||
@@ -594,15 +594,15 @@ describe("toEqual", function() {
|
||||
var nodeA = document.createElement('div'),
|
||||
nodeB = document.createElement('div');
|
||||
|
||||
nodeA.innerText = 'foo'
|
||||
nodeB.innerText = 'bar'
|
||||
nodeA.innerText = 'foo';
|
||||
nodeB.innerText = 'bar';
|
||||
|
||||
var actual = {a: nodeA},
|
||||
expected = {a: nodeB},
|
||||
message = 'Expected $.a = <div>...</div> to equal <div>...</div>.';
|
||||
|
||||
expect(compareEquals(actual, expected).message).toEqual(message);
|
||||
})
|
||||
});
|
||||
|
||||
it("reports mismatches between a DOM node and a bare Object", function() {
|
||||
if(isNotRunningInBrowser()) {
|
||||
@@ -658,7 +658,7 @@ describe("toEqual", function() {
|
||||
boolean: false,
|
||||
notDefined: 0,
|
||||
aNull: void 0
|
||||
}
|
||||
};
|
||||
|
||||
var expected = {
|
||||
foo: [
|
||||
@@ -675,7 +675,7 @@ describe("toEqual", function() {
|
||||
boolean: true,
|
||||
notDefined: void 0,
|
||||
aNull: null
|
||||
}
|
||||
};
|
||||
|
||||
var message =
|
||||
'Expected $.foo[0].bar = 1 to equal 2.\n' +
|
||||
@@ -690,10 +690,10 @@ describe("toEqual", function() {
|
||||
'Expected $.inf = -Infinity to equal Infinity.\n' +
|
||||
'Expected $.boolean = false to equal true.\n' +
|
||||
'Expected $.notDefined = 0 to equal undefined.\n' +
|
||||
'Expected $.aNull = undefined to equal null.'
|
||||
'Expected $.aNull = undefined to equal null.';
|
||||
|
||||
expect(compareEquals(actual, expected).message).toEqual(message);
|
||||
})
|
||||
});
|
||||
|
||||
describe("different length arrays", function() {
|
||||
it("actual array is longer", function() {
|
||||
@@ -702,7 +702,7 @@ describe("toEqual", function() {
|
||||
message = 'Expected $.length = 5 to equal 4.\n' +
|
||||
'Expected $[4] = 5 to equal undefined.';
|
||||
|
||||
expect(compareEquals(actual, expected).pass).toBe(false)
|
||||
expect(compareEquals(actual, expected).pass).toBe(false);
|
||||
expect(compareEquals(actual, expected).message).toEqual(message);
|
||||
});
|
||||
|
||||
@@ -712,7 +712,7 @@ describe("toEqual", function() {
|
||||
message = 'Expected $.length = 4 to equal 5.\n' +
|
||||
'Expected $[4] = undefined to equal 5.';
|
||||
|
||||
expect(compareEquals(actual, expected).pass).toBe(false)
|
||||
expect(compareEquals(actual, expected).pass).toBe(false);
|
||||
expect(compareEquals(actual, expected).message).toEqual(message);
|
||||
});
|
||||
|
||||
@@ -725,7 +725,7 @@ describe("toEqual", function() {
|
||||
'Expected $[5] = undefined to equal 8.\n' +
|
||||
'Expected $[6] = undefined to equal 13.';
|
||||
|
||||
expect(compareEquals(actual, expected).pass).toBe(false)
|
||||
expect(compareEquals(actual, expected).pass).toBe(false);
|
||||
expect(compareEquals(actual, expected).message).toEqual(message);
|
||||
});
|
||||
|
||||
@@ -736,7 +736,7 @@ describe("toEqual", function() {
|
||||
'Expected $[0] = 1 to equal 2.\n' +
|
||||
'Expected $[1] = undefined to equal 3.';
|
||||
|
||||
expect(compareEquals(actual, expected).pass).toBe(false)
|
||||
expect(compareEquals(actual, expected).pass).toBe(false);
|
||||
expect(compareEquals(actual, expected).message).toEqual(message);
|
||||
});
|
||||
|
||||
@@ -746,7 +746,7 @@ describe("toEqual", function() {
|
||||
message = 'Expected $.values.length = 4 to equal 3.\n' +
|
||||
'Expected $.values[3] = 3 to equal undefined.';
|
||||
|
||||
expect(compareEquals(actual, expected).pass).toBe(false)
|
||||
expect(compareEquals(actual, expected).pass).toBe(false);
|
||||
expect(compareEquals(actual, expected).message).toEqual(message);
|
||||
});
|
||||
|
||||
@@ -756,7 +756,7 @@ describe("toEqual", function() {
|
||||
message = 'Expected $.length = 4 to equal 3.\n' +
|
||||
'Expected $[3] = Object({ value: 3 }) to equal undefined.';
|
||||
|
||||
expect(compareEquals(actual, expected).pass).toBe(false)
|
||||
expect(compareEquals(actual, expected).pass).toBe(false);
|
||||
expect(compareEquals(actual, expected).message).toEqual(message);
|
||||
});
|
||||
|
||||
@@ -769,7 +769,7 @@ describe("toEqual", function() {
|
||||
'Expected $[1][0] = 1 to equal 2.\n' +
|
||||
'Expected $[1][1] = 2 to equal undefined.';
|
||||
|
||||
expect(compareEquals(actual, expected).pass).toBe(false)
|
||||
expect(compareEquals(actual, expected).pass).toBe(false);
|
||||
expect(compareEquals(actual, expected).message).toEqual(message);
|
||||
});
|
||||
|
||||
@@ -778,7 +778,7 @@ describe("toEqual", function() {
|
||||
expected = [1, 2, void 0],
|
||||
message = 'Expected $.length = 2 to equal 3.';
|
||||
|
||||
expect(compareEquals(actual, expected).pass).toBe(false)
|
||||
expect(compareEquals(actual, expected).pass).toBe(false);
|
||||
expect(compareEquals(actual, expected).message).toEqual(message);
|
||||
});
|
||||
})
|
||||
|
||||
@@ -1,16 +1,38 @@
|
||||
describe('toHaveClass', function() {
|
||||
beforeEach(function(done) {
|
||||
this.createElementWithClassName = function(className) {
|
||||
var el = this.doc.createElement('div');
|
||||
el.className = className;
|
||||
return el;
|
||||
};
|
||||
|
||||
if (typeof document !== 'undefined') {
|
||||
this.doc = document;
|
||||
done();
|
||||
} else {
|
||||
var jsdom = require('jsdom');
|
||||
var self = this;
|
||||
jsdom.env('', function(err, win) {
|
||||
if (err) {
|
||||
done.fail(err);
|
||||
} else {
|
||||
self.doc = win.document;
|
||||
done();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
it('fails for a DOM element that lacks the expected class', function() {
|
||||
var matcher = jasmineUnderTest.matchers.toHaveClass(),
|
||||
result = matcher.compare(document.createElement('div'), 'foo');
|
||||
result = matcher.compare(this.createElementWithClassName(''), 'foo');
|
||||
|
||||
expect(result.pass).toBe(false);
|
||||
});
|
||||
|
||||
it('passes for a DOM element that has the expected class', function() {
|
||||
var matcher = jasmineUnderTest.matchers.toHaveClass(),
|
||||
el = document.createElement('div');
|
||||
|
||||
el.className = 'foo bar baz';
|
||||
el = this.createElementWithClassName('foo bar baz');
|
||||
|
||||
expect(matcher.compare(el, 'foo').pass).toBe(true);
|
||||
expect(matcher.compare(el, 'bar').pass).toBe(true);
|
||||
@@ -19,9 +41,7 @@ describe('toHaveClass', function() {
|
||||
|
||||
it('fails for a DOM element that only has other classes', function() {
|
||||
var matcher = jasmineUnderTest.matchers.toHaveClass(),
|
||||
el = document.createElement('div');
|
||||
|
||||
el.className = 'foo bar';
|
||||
el = this.createElementWithClassName('foo bar');
|
||||
|
||||
expect(matcher.compare(el, 'fo').pass).toBe(false);
|
||||
});
|
||||
@@ -37,8 +57,9 @@ describe('toHaveClass', function() {
|
||||
matcher.compare(undefined, 'foo');
|
||||
}).toThrowError('undefined is not a DOM element');
|
||||
|
||||
var textNode = this.doc.createTextNode('');
|
||||
expect(function() {
|
||||
matcher.compare(document.createTextNode(''), 'foo')
|
||||
matcher.compare(textNode, 'foo')
|
||||
}).toThrowError('HTMLNode is not a DOM element');
|
||||
|
||||
expect(function() {
|
||||
@@ -1047,7 +1047,7 @@ describe("HtmlReporter", function() {
|
||||
beforeEach(function() {
|
||||
env = new jasmineUnderTest.Env();
|
||||
container = document.createElement("div");
|
||||
var getContainer = function() { return container; }
|
||||
var getContainer = function() { return container; };
|
||||
reporter = new jasmineUnderTest.HtmlReporter({
|
||||
env: env,
|
||||
getContainer: getContainer,
|
||||
|
||||
@@ -6,10 +6,10 @@ sauce:
|
||||
name: jasmine-core <%= Time.now.to_s %>
|
||||
username: <%= ENV['SAUCE_USERNAME'] %>
|
||||
access_key: <%= ENV['SAUCE_ACCESS_KEY'] %>
|
||||
build: <%= ENV['TRAVIS_BUILD_NUMBER'] || 'Ran locally' %>
|
||||
build: Core <%= ENV['TRAVIS_BUILD_NUMBER'] || 'Ran locally' %>
|
||||
tags:
|
||||
- <%= ENV['TRAVIS_RUBY_VERSION'] || RUBY_VERSION %>
|
||||
- CI
|
||||
- Jasmine-Core
|
||||
- "<%= ENV['TRAVIS_JOB_NUMBER'] %>"
|
||||
tunnel_identifier: <%= ENV['TRAVIS_JOB_NUMBER'] ? %Q("#{ENV['TRAVIS_JOB_NUMBER']}") : nil %>
|
||||
os: <%= ENV['SAUCE_OS'] %>
|
||||
browser_version: "<%= ENV['SAUCE_BROWSER_VERSION'] %>"
|
||||
|
||||
@@ -38,17 +38,29 @@ getJasmineRequireObj().Env = function(j$) {
|
||||
return currentSpec || currentSuite();
|
||||
};
|
||||
|
||||
var globalErrors = new j$.GlobalErrors();
|
||||
globalErrors.install();
|
||||
globalErrors.pushListener(function(message, filename, lineno) {
|
||||
topSuite.result.failedExpectations.push({
|
||||
passed: false,
|
||||
globalErrorType: 'load',
|
||||
message: message,
|
||||
filename: filename,
|
||||
lineno: lineno
|
||||
var globalErrors = null;
|
||||
|
||||
var installGlobalErrors = function() {
|
||||
if (globalErrors) {
|
||||
return;
|
||||
}
|
||||
|
||||
globalErrors = new j$.GlobalErrors();
|
||||
globalErrors.install();
|
||||
};
|
||||
|
||||
if (!options.suppressLoadErrors) {
|
||||
installGlobalErrors();
|
||||
globalErrors.pushListener(function(message, filename, lineno) {
|
||||
topSuite.result.failedExpectations.push({
|
||||
passed: false,
|
||||
globalErrorType: 'load',
|
||||
message: message,
|
||||
filename: filename,
|
||||
lineno: lineno
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
this.specFilter = function() {
|
||||
return true;
|
||||
@@ -193,18 +205,11 @@ getJasmineRequireObj().Env = function(j$) {
|
||||
return seed;
|
||||
};
|
||||
|
||||
this.suppressLoadErrors = function() {
|
||||
if (handlingLoadErrors) {
|
||||
globalErrors.popListener();
|
||||
}
|
||||
handlingLoadErrors = false;
|
||||
};
|
||||
|
||||
this.deprecated = function(msg) {
|
||||
this.deprecated = function(deprecation) {
|
||||
var runnable = currentRunnable() || topSuite;
|
||||
runnable.addDeprecationWarning(msg);
|
||||
if(typeof console !== 'undefined' && typeof console.warn !== 'undefined') {
|
||||
console.error('DEPRECATION: ' + msg);
|
||||
runnable.addDeprecationWarning(deprecation);
|
||||
if(typeof console !== 'undefined' && typeof console.error === 'function') {
|
||||
console.error('DEPRECATION:', deprecation);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -252,6 +257,8 @@ getJasmineRequireObj().Env = function(j$) {
|
||||
* @function
|
||||
* @name Reporter#jasmineStarted
|
||||
* @param {JasmineStartedInfo} suiteInfo Information about the full Jasmine suite that is being run
|
||||
* @param {Function} [done] Used to specify to Jasmine that this callback is asynchronous and Jasmine should wait until it has been called before moving on.
|
||||
* @returns {} Optionally return a Promise instead of using `done` to cause Jasmine to wait for completion.
|
||||
*/
|
||||
'jasmineStarted',
|
||||
/**
|
||||
@@ -259,6 +266,8 @@ getJasmineRequireObj().Env = function(j$) {
|
||||
* @function
|
||||
* @name Reporter#jasmineDone
|
||||
* @param {JasmineDoneInfo} suiteInfo Information about the full Jasmine suite that just finished running.
|
||||
* @param {Function} [done] Used to specify to Jasmine that this callback is asynchronous and Jasmine should wait until it has been called before moving on.
|
||||
* @returns {} Optionally return a Promise instead of using `done` to cause Jasmine to wait for completion.
|
||||
*/
|
||||
'jasmineDone',
|
||||
/**
|
||||
@@ -266,6 +275,8 @@ getJasmineRequireObj().Env = function(j$) {
|
||||
* @function
|
||||
* @name Reporter#suiteStarted
|
||||
* @param {SuiteResult} result Information about the individual {@link describe} being run
|
||||
* @param {Function} [done] Used to specify to Jasmine that this callback is asynchronous and Jasmine should wait until it has been called before moving on.
|
||||
* @returns {} Optionally return a Promise instead of using `done` to cause Jasmine to wait for completion.
|
||||
*/
|
||||
'suiteStarted',
|
||||
/**
|
||||
@@ -275,6 +286,8 @@ getJasmineRequireObj().Env = function(j$) {
|
||||
* @function
|
||||
* @name Reporter#suiteDone
|
||||
* @param {SuiteResult} result
|
||||
* @param {Function} [done] Used to specify to Jasmine that this callback is asynchronous and Jasmine should wait until it has been called before moving on.
|
||||
* @returns {} Optionally return a Promise instead of using `done` to cause Jasmine to wait for completion.
|
||||
*/
|
||||
'suiteDone',
|
||||
/**
|
||||
@@ -282,6 +295,8 @@ getJasmineRequireObj().Env = function(j$) {
|
||||
* @function
|
||||
* @name Reporter#specStarted
|
||||
* @param {SpecResult} result Information about the individual {@link it} being run
|
||||
* @param {Function} [done] Used to specify to Jasmine that this callback is asynchronous and Jasmine should wait until it has been called before moving on.
|
||||
* @returns {} Optionally return a Promise instead of using `done` to cause Jasmine to wait for completion.
|
||||
*/
|
||||
'specStarted',
|
||||
/**
|
||||
@@ -291,13 +306,15 @@ getJasmineRequireObj().Env = function(j$) {
|
||||
* @function
|
||||
* @name Reporter#specDone
|
||||
* @param {SpecResult} result
|
||||
* @param {Function} [done] Used to specify to Jasmine that this callback is asynchronous and Jasmine should wait until it has been called before moving on.
|
||||
* @returns {} Optionally return a Promise instead of using `done` to cause Jasmine to wait for completion.
|
||||
*/
|
||||
'specDone'
|
||||
], queueRunnerFactory);
|
||||
|
||||
this.execute = function(runnablesToRun) {
|
||||
var self = this;
|
||||
this.suppressLoadErrors();
|
||||
installGlobalErrors();
|
||||
|
||||
if(!runnablesToRun) {
|
||||
if (focusedRunnables.length) {
|
||||
|
||||
@@ -29,18 +29,22 @@ getJasmineRequireObj().ExceptionFormatter = function(j$) {
|
||||
|
||||
var stackTrace = new j$.StackTrace(error.stack);
|
||||
var lines = filterJasmine(stackTrace);
|
||||
var result = '';
|
||||
|
||||
if (stackTrace.message) {
|
||||
lines.unshift(stackTrace.message);
|
||||
}
|
||||
|
||||
return lines.join('\n');
|
||||
result += formatProperties(error);
|
||||
result += lines.join('\n');
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
function filterJasmine(stackTrace) {
|
||||
var result = [],
|
||||
jasmineMarker = stackTrace.style === 'webkit' ? '<Jasmine>' : ' at <Jasmine>';
|
||||
|
||||
|
||||
stackTrace.frames.forEach(function(frame) {
|
||||
if (frame.file && frame.file !== jasmineFile) {
|
||||
result.push(frame.raw);
|
||||
@@ -48,9 +52,33 @@ getJasmineRequireObj().ExceptionFormatter = function(j$) {
|
||||
result.push(jasmineMarker);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
function formatProperties(error) {
|
||||
if (!(error instanceof Object)) {
|
||||
return;
|
||||
}
|
||||
|
||||
var ignored = ['name', 'message', 'stack', 'fileName', 'sourceURL', 'line', 'lineNumber', 'column', 'description'];
|
||||
var result = {};
|
||||
var empty = true;
|
||||
|
||||
for (var prop in error) {
|
||||
if (j$.util.arrayContains(ignored, prop)) {
|
||||
continue;
|
||||
}
|
||||
result[prop] = error[prop];
|
||||
empty = false;
|
||||
}
|
||||
|
||||
if (!empty) {
|
||||
return 'error properties: ' + j$.pp(result) + '\n';
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
return ExceptionFormatter;
|
||||
|
||||
@@ -45,10 +45,14 @@ getJasmineRequireObj().buildExpectationResult = function() {
|
||||
|
||||
var error = options.error;
|
||||
if (!error) {
|
||||
try {
|
||||
throw new Error(message());
|
||||
} catch (e) {
|
||||
error = e;
|
||||
if (options.stack) {
|
||||
error = options;
|
||||
} else {
|
||||
try {
|
||||
throw new Error(message());
|
||||
} catch (e) {
|
||||
error = e;
|
||||
}
|
||||
}
|
||||
}
|
||||
return stackFormatter(error);
|
||||
|
||||
@@ -152,8 +152,11 @@ getJasmineRequireObj().Spec = function(j$) {
|
||||
return this.getSpecName(this);
|
||||
};
|
||||
|
||||
Spec.prototype.addDeprecationWarning = function(msg) {
|
||||
this.result.deprecationWarnings.push(this.expectationResultFactory({ message: msg }));
|
||||
Spec.prototype.addDeprecationWarning = function(deprecation) {
|
||||
if (typeof deprecation === 'string') {
|
||||
deprecation = { message: deprecation };
|
||||
}
|
||||
this.result.deprecationWarnings.push(this.expectationResultFactory(deprecation));
|
||||
};
|
||||
|
||||
var extractCustomPendingMessage = function(e) {
|
||||
|
||||
@@ -148,8 +148,11 @@ getJasmineRequireObj().Suite = function(j$) {
|
||||
}
|
||||
};
|
||||
|
||||
Suite.prototype.addDeprecationWarning = function(msg) {
|
||||
this.result.deprecationWarnings.push(this.expectationResultFactory({ message: msg }));
|
||||
Suite.prototype.addDeprecationWarning = function(deprecation) {
|
||||
if (typeof deprecation === 'string') {
|
||||
deprecation = { message: deprecation };
|
||||
}
|
||||
this.result.deprecationWarnings.push(this.expectationResultFactory(deprecation));
|
||||
};
|
||||
|
||||
function isFailure(args) {
|
||||
|
||||
25
src/core/asymmetric_equality/Empty.js
Normal file
25
src/core/asymmetric_equality/Empty.js
Normal file
@@ -0,0 +1,25 @@
|
||||
getJasmineRequireObj().Empty = function (j$) {
|
||||
|
||||
function Empty() {}
|
||||
|
||||
Empty.prototype.asymmetricMatch = function (other) {
|
||||
if (j$.isString_(other) || j$.isArray_(other) || j$.isTypedArray_(other)) {
|
||||
return other.length === 0;
|
||||
}
|
||||
|
||||
if (j$.isMap(other) || j$.isSet(other)) {
|
||||
return other.size === 0;
|
||||
}
|
||||
|
||||
if (j$.isObject_(other)) {
|
||||
return Object.keys(other).length === 0;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
Empty.prototype.jasmineToString = function () {
|
||||
return '<jasmine.empty>';
|
||||
};
|
||||
|
||||
return Empty;
|
||||
};
|
||||
14
src/core/asymmetric_equality/Falsy.js
Normal file
14
src/core/asymmetric_equality/Falsy.js
Normal file
@@ -0,0 +1,14 @@
|
||||
getJasmineRequireObj().Falsy = function(j$) {
|
||||
|
||||
function Falsy() {}
|
||||
|
||||
Falsy.prototype.asymmetricMatch = function(other) {
|
||||
return !other;
|
||||
};
|
||||
|
||||
Falsy.prototype.jasmineToString = function() {
|
||||
return '<jasmine.falsy>';
|
||||
};
|
||||
|
||||
return Falsy;
|
||||
};
|
||||
26
src/core/asymmetric_equality/NotEmpty.js
Normal file
26
src/core/asymmetric_equality/NotEmpty.js
Normal file
@@ -0,0 +1,26 @@
|
||||
getJasmineRequireObj().NotEmpty = function (j$) {
|
||||
|
||||
function NotEmpty() {}
|
||||
|
||||
NotEmpty.prototype.asymmetricMatch = function (other) {
|
||||
if (j$.isString_(other) || j$.isArray_(other) || j$.isTypedArray_(other)) {
|
||||
return other.length !== 0;
|
||||
}
|
||||
|
||||
if (j$.isMap(other) || j$.isSet(other)) {
|
||||
return other.size !== 0;
|
||||
}
|
||||
|
||||
if (j$.isObject_(other)) {
|
||||
return Object.keys(other).length !== 0;
|
||||
}
|
||||
|
||||
return false;
|
||||
};
|
||||
|
||||
NotEmpty.prototype.jasmineToString = function () {
|
||||
return '<jasmine.notEmpty>';
|
||||
};
|
||||
|
||||
return NotEmpty;
|
||||
};
|
||||
14
src/core/asymmetric_equality/Truthy.js
Normal file
14
src/core/asymmetric_equality/Truthy.js
Normal file
@@ -0,0 +1,14 @@
|
||||
getJasmineRequireObj().Truthy = function(j$) {
|
||||
|
||||
function Truthy() {}
|
||||
|
||||
Truthy.prototype.asymmetricMatch = function(other) {
|
||||
return !!other;
|
||||
};
|
||||
|
||||
Truthy.prototype.jasmineToString = function() {
|
||||
return '<jasmine.truthy>';
|
||||
};
|
||||
|
||||
return Truthy;
|
||||
};
|
||||
@@ -121,8 +121,8 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) {
|
||||
return func.name;
|
||||
}
|
||||
|
||||
var matches = func.toString().match(/^\s*function\s*(\w*)\s*\(/) ||
|
||||
func.toString().match(/^\s*\[object\s*(\w*)Constructor\]/);
|
||||
var matches = func.toString().match(/^\s*function\s*(\w+)\s*\(/) ||
|
||||
func.toString().match(/^\s*\[object\s*(\w+)Constructor\]/);
|
||||
|
||||
return matches ? matches[1] : '<anonymous>';
|
||||
};
|
||||
@@ -148,6 +148,38 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) {
|
||||
return new j$.Anything();
|
||||
};
|
||||
|
||||
/**
|
||||
* Get a matcher, usable in any {@link matchers|matcher} that uses Jasmine's equality (e.g. {@link matchers#toEqual|toEqual}, {@link matchers#toContain|toContain}, or {@link matchers#toHaveBeenCalledWith|toHaveBeenCalledWith}),
|
||||
* that will succeed if the actual value being compared is `true` or anything truthy.
|
||||
* @name jasmine.truthy
|
||||
* @function
|
||||
*/
|
||||
j$.truthy = function() {return new j$.Truthy();};
|
||||
|
||||
/**
|
||||
* Get a matcher, usable in any {@link matchers|matcher} that uses Jasmine's equality (e.g. {@link matchers#toEqual|toEqual}, {@link matchers#toContain|toContain}, or {@link matchers#toHaveBeenCalledWith|toHaveBeenCalledWith}),
|
||||
* that will succeed if the actual value being compared is `null`, `undefined`, `0`, `false` or anything falsey.
|
||||
* @name jasmine.falsy
|
||||
* @function
|
||||
*/
|
||||
j$.falsy = function() {return new j$.Falsy();};
|
||||
|
||||
/**
|
||||
* Get a matcher, usable in any {@link matchers|matcher} that uses Jasmine's equality (e.g. {@link matchers#toEqual|toEqual}, {@link matchers#toContain|toContain}, or {@link matchers#toHaveBeenCalledWith|toHaveBeenCalledWith}),
|
||||
* that will succeed if the actual value being compared is empty.
|
||||
* @name jasmine.empty
|
||||
* @function
|
||||
*/
|
||||
j$.empty = function() {return new j$.Empty();};
|
||||
|
||||
/**
|
||||
* Get a matcher, usable in any {@link matchers|matcher} that uses Jasmine's equality (e.g. {@link matchers#toEqual|toEqual}, {@link matchers#toContain|toContain}, or {@link matchers#toHaveBeenCalledWith|toHaveBeenCalledWith}),
|
||||
* that will succeed if the actual value being compared is not empty.
|
||||
* @name jasmine.notEmpty
|
||||
* @function
|
||||
*/
|
||||
j$.notEmpty = function() {return new j$.NotEmpty();};
|
||||
|
||||
/**
|
||||
* Get a matcher, usable in any {@link matchers|matcher} that uses Jasmine's equality (e.g. {@link matchers#toEqual|toEqual}, {@link matchers#toContain|toContain}, or {@link matchers#toHaveBeenCalledWith|toHaveBeenCalledWith}),
|
||||
* that will succeed if the actual value being compared contains at least the keys and values.
|
||||
|
||||
@@ -21,6 +21,7 @@ getJasmineRequireObj().requireMatchers = function(jRequire, j$) {
|
||||
'toHaveBeenCalledBefore',
|
||||
'toHaveBeenCalledTimes',
|
||||
'toHaveBeenCalledWith',
|
||||
'toHaveClass',
|
||||
'toMatch',
|
||||
'toThrow',
|
||||
'toThrowError',
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
jasmineRequire.toHaveClass = function(j$) {
|
||||
getJasmineRequireObj().toHaveClass = function(j$) {
|
||||
/**
|
||||
* {@link expect} the actual value to be a DOM element that has the expected class
|
||||
* @function
|
||||
@@ -63,6 +63,11 @@ var getJasmineRequireObj = (function (jasmineGlobal) {
|
||||
j$.ObjectPath = jRequire.ObjectPath(j$);
|
||||
j$.GlobalErrors = jRequire.GlobalErrors(j$);
|
||||
|
||||
j$.Truthy = jRequire.Truthy(j$);
|
||||
j$.Falsy = jRequire.Falsy(j$);
|
||||
j$.Empty = jRequire.Empty(j$);
|
||||
j$.NotEmpty = jRequire.NotEmpty(j$);
|
||||
|
||||
j$.matchers = jRequire.requireMatchers(jRequire, j$);
|
||||
|
||||
return j$;
|
||||
|
||||
@@ -3,5 +3,4 @@ jasmineRequire.html = function(j$) {
|
||||
j$.HtmlReporter = jasmineRequire.HtmlReporter(j$);
|
||||
j$.QueryString = jasmineRequire.QueryString();
|
||||
j$.HtmlSpecFilter = jasmineRequire.HtmlSpecFilter();
|
||||
j$.matchers.toHaveClass = jasmineRequire.toHaveClass(j$);
|
||||
};
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
#!/bin/bash -e
|
||||
|
||||
set -e
|
||||
|
||||
git clone https://github.com/jasmine/jasmine.github.io.git
|
||||
|
||||
cd jasmine.github.io
|
||||
export BUNDLE_GEMFILE=$PWD/Gemfile
|
||||
bundle
|
||||
|
||||
bundle exec rake update_edge_jasmine
|
||||
bundle exec rake phantom
|
||||
Reference in New Issue
Block a user