Compare commits
35 Commits
v2.0.0.rc5
...
v2.0.0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
812b14d000 | ||
|
|
a2a8b5dde2 | ||
|
|
78bed99ba3 | ||
|
|
f9191d7b0d | ||
|
|
83a692d5a8 | ||
|
|
14a8c2ca09 | ||
|
|
b2e8de7bcd | ||
|
|
1d98a23b14 | ||
|
|
16ffd3b3fb | ||
|
|
6bc87ad223 | ||
|
|
555d328cf2 | ||
|
|
c78fba4b13 | ||
|
|
8a6d7828c6 | ||
|
|
c888b0c1b8 | ||
|
|
72e9851217 | ||
|
|
7ee5073921 | ||
|
|
614a18453e | ||
|
|
916f889c01 | ||
|
|
4a7b79ad0d | ||
|
|
775e2ff0a9 | ||
|
|
1b6725ec25 | ||
|
|
952eb59707 | ||
|
|
de6a305b44 | ||
|
|
8513201fa3 | ||
|
|
6e07dccb68 | ||
|
|
fcc50cc6f4 | ||
|
|
9e8466ba2b | ||
|
|
4350045d61 | ||
|
|
666e9c341e | ||
|
|
5830d9f86b | ||
|
|
ea888e4c03 | ||
|
|
c7e3ca6c8a | ||
|
|
06db4a8583 | ||
|
|
a2debf60b6 | ||
|
|
ffa6138d75 |
@@ -5,7 +5,7 @@
|
||||
|
||||
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://pivotal.github.com/jasmine/](http://pivotal.github.com/jasmine/)
|
||||
Documentation & guides live here: [http://jasmine.github.io](http://jasmine.github.io/)
|
||||
|
||||
## Contributing
|
||||
|
||||
BIN
dist/jasmine-standalone-2.0.0.zip
vendored
Normal file
BIN
dist/jasmine-standalone-2.0.0.zip
vendored
Normal file
Binary file not shown.
@@ -50,10 +50,10 @@ getJasmineRequireObj().ConsoleReporter = function() {
|
||||
failedSpecs = [],
|
||||
pendingCount,
|
||||
ansi = {
|
||||
green: '\033[32m',
|
||||
red: '\033[31m',
|
||||
yellow: '\033[33m',
|
||||
none: '\033[0m'
|
||||
green: '\x1B[32m',
|
||||
red: '\x1B[31m',
|
||||
yellow: '\x1B[33m',
|
||||
none: '\x1B[0m'
|
||||
};
|
||||
|
||||
this.jasmineStarted = function() {
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
beforeEach(function () {
|
||||
jasmine.Expectation.addMatchers({
|
||||
toBePlaying: function () {
|
||||
return {
|
||||
compare: function (actual, expected) {
|
||||
var player = actual;
|
||||
jasmine.addMatchers({
|
||||
toBePlaying: function () {
|
||||
return {
|
||||
compare: function (actual, expected) {
|
||||
var player = actual;
|
||||
|
||||
return {
|
||||
pass: player.currentlyPlayingSong === expected && player.isPlaying
|
||||
}
|
||||
}
|
||||
};
|
||||
return {
|
||||
pass: player.currentlyPlayingSong === expected && player.isPlaying
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@@ -97,13 +97,12 @@ getJasmineRequireObj().base = function(j$) {
|
||||
j$.MAX_PRETTY_PRINT_DEPTH = 40;
|
||||
j$.DEFAULT_TIMEOUT_INTERVAL = 5000;
|
||||
|
||||
j$.getGlobal = function() {
|
||||
function getGlobal() {
|
||||
return this;
|
||||
}
|
||||
|
||||
return getGlobal();
|
||||
};
|
||||
j$.getGlobal = (function() {
|
||||
var jasmineGlobal = eval.call(null, "this");
|
||||
return function() {
|
||||
return jasmineGlobal;
|
||||
};
|
||||
})();
|
||||
|
||||
j$.getEnv = function(options) {
|
||||
var env = j$.currentEnv_ = j$.currentEnv_ || new j$.Env(options);
|
||||
@@ -231,14 +230,13 @@ getJasmineRequireObj().Spec = function(j$) {
|
||||
this.id = attrs.id;
|
||||
this.description = attrs.description || '';
|
||||
this.fn = attrs.fn;
|
||||
this.beforeFns = attrs.beforeFns || function() {};
|
||||
this.afterFns = attrs.afterFns || function() {};
|
||||
this.catchingExceptions = attrs.catchingExceptions;
|
||||
this.beforeFns = attrs.beforeFns || function() { return []; };
|
||||
this.afterFns = attrs.afterFns || function() { return []; };
|
||||
this.onStart = attrs.onStart || function() {};
|
||||
this.exceptionFormatter = attrs.exceptionFormatter || function() {};
|
||||
this.getSpecName = attrs.getSpecName || function() { return ''; };
|
||||
this.expectationResultFactory = attrs.expectationResultFactory || function() { };
|
||||
this.queueRunner = attrs.queueRunner || function() {};
|
||||
this.queueRunnerFactory = attrs.queueRunnerFactory || function() {};
|
||||
this.catchingExceptions = attrs.catchingExceptions || function() { return true; };
|
||||
|
||||
this.timer = attrs.timer || {setTimeout: setTimeout, clearTimeout: clearTimeout};
|
||||
@@ -267,7 +265,8 @@ getJasmineRequireObj().Spec = function(j$) {
|
||||
};
|
||||
|
||||
Spec.prototype.execute = function(onComplete) {
|
||||
var self = this;
|
||||
var self = this,
|
||||
timeout;
|
||||
|
||||
this.onStart(this);
|
||||
|
||||
@@ -278,13 +277,13 @@ getJasmineRequireObj().Spec = function(j$) {
|
||||
|
||||
function timeoutable(fn) {
|
||||
return function(done) {
|
||||
var timeout = Function.prototype.apply.apply(self.timer.setTimeout, [j$.getGlobal(), [function() {
|
||||
timeout = Function.prototype.apply.apply(self.timer.setTimeout, [j$.getGlobal(), [function() {
|
||||
onException(new Error('Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL.'));
|
||||
done();
|
||||
}, j$.DEFAULT_TIMEOUT_INTERVAL]]);
|
||||
|
||||
var callDone = function() {
|
||||
Function.prototype.apply.apply(self.timer.clearTimeout, [j$.getGlobal(), [timeout]]);
|
||||
clearTimeoutable();
|
||||
done();
|
||||
};
|
||||
|
||||
@@ -292,18 +291,26 @@ getJasmineRequireObj().Spec = function(j$) {
|
||||
};
|
||||
}
|
||||
|
||||
var befores = this.beforeFns() || [],
|
||||
afters = this.afterFns() || [],
|
||||
thisOne = (this.fn.length) ? timeoutable(this.fn) : this.fn;
|
||||
var allFns = befores.concat(thisOne).concat(afters);
|
||||
function clearTimeoutable() {
|
||||
Function.prototype.apply.apply(self.timer.clearTimeout, [j$.getGlobal(), [timeout]]);
|
||||
timeout = void 0;
|
||||
}
|
||||
|
||||
this.queueRunner({
|
||||
fns: allFns,
|
||||
var allFns = this.beforeFns().concat(this.fn).concat(this.afterFns()),
|
||||
allTimeoutableFns = [];
|
||||
for (var i = 0; i < allFns.length; i++) {
|
||||
var fn = allFns[i];
|
||||
allTimeoutableFns.push(fn.length > 0 ? timeoutable(fn) : fn);
|
||||
}
|
||||
|
||||
this.queueRunnerFactory({
|
||||
fns: allTimeoutableFns,
|
||||
onException: onException,
|
||||
onComplete: complete
|
||||
});
|
||||
|
||||
function onException(e) {
|
||||
clearTimeoutable();
|
||||
if (Spec.isPendingSpecException(e)) {
|
||||
self.pend();
|
||||
return;
|
||||
@@ -641,7 +648,7 @@ getJasmineRequireObj().Env = function(j$) {
|
||||
onStart: specStarted,
|
||||
description: description,
|
||||
expectationResultFactory: expectationResultFactory,
|
||||
queueRunner: queueRunnerFactory,
|
||||
queueRunnerFactory: queueRunnerFactory,
|
||||
fn: fn,
|
||||
timer: {setTimeout: realSetTimeout, clearTimeout: realClearTimeout}
|
||||
});
|
||||
@@ -976,14 +983,17 @@ getJasmineRequireObj().Clock = function() {
|
||||
getJasmineRequireObj().DelayedFunctionScheduler = function() {
|
||||
function DelayedFunctionScheduler() {
|
||||
var self = this;
|
||||
var scheduledLookup = [];
|
||||
var scheduledFunctions = {};
|
||||
var currentTime = 0;
|
||||
var delayedFnCount = 0;
|
||||
|
||||
self.tick = function(millis) {
|
||||
millis = millis || 0;
|
||||
currentTime = currentTime + millis;
|
||||
runFunctionsWithinRange(currentTime - millis, currentTime);
|
||||
var endTime = currentTime + millis;
|
||||
|
||||
runScheduledFunctions(endTime);
|
||||
currentTime = endTime;
|
||||
};
|
||||
|
||||
self.scheduleFunction = function(funcToCall, millis, params, recurring, timeoutKey, runAtMillis) {
|
||||
@@ -999,7 +1009,8 @@ getJasmineRequireObj().DelayedFunctionScheduler = function() {
|
||||
millis = millis || 0;
|
||||
timeoutKey = timeoutKey || ++delayedFnCount;
|
||||
runAtMillis = runAtMillis || (currentTime + millis);
|
||||
scheduledFunctions[timeoutKey] = {
|
||||
|
||||
var funcToSchedule = {
|
||||
runAtMillis: runAtMillis,
|
||||
funcToCall: f,
|
||||
recurring: recurring,
|
||||
@@ -1007,58 +1018,73 @@ getJasmineRequireObj().DelayedFunctionScheduler = function() {
|
||||
timeoutKey: timeoutKey,
|
||||
millis: millis
|
||||
};
|
||||
|
||||
if (runAtMillis in scheduledFunctions) {
|
||||
scheduledFunctions[runAtMillis].push(funcToSchedule);
|
||||
} else {
|
||||
scheduledFunctions[runAtMillis] = [funcToSchedule];
|
||||
scheduledLookup.push(runAtMillis);
|
||||
scheduledLookup.sort(function (a, b) {
|
||||
return a - b;
|
||||
});
|
||||
}
|
||||
|
||||
return timeoutKey;
|
||||
};
|
||||
|
||||
self.removeFunctionWithId = function(timeoutKey) {
|
||||
delete scheduledFunctions[timeoutKey];
|
||||
for (var runAtMillis in scheduledFunctions) {
|
||||
var funcs = scheduledFunctions[runAtMillis];
|
||||
var i = indexOfFirstToPass(funcs, function (func) {
|
||||
return func.timeoutKey === timeoutKey;
|
||||
});
|
||||
|
||||
if (i > -1) {
|
||||
if (funcs.length === 1) {
|
||||
delete scheduledFunctions[runAtMillis];
|
||||
deleteFromLookup(runAtMillis);
|
||||
} else {
|
||||
funcs.splice(i, 1);
|
||||
}
|
||||
|
||||
// intervals get rescheduled when executed, so there's never more
|
||||
// than a single scheduled function with a given timeoutKey
|
||||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
self.reset = function() {
|
||||
currentTime = 0;
|
||||
scheduledLookup = [];
|
||||
scheduledFunctions = {};
|
||||
delayedFnCount = 0;
|
||||
};
|
||||
|
||||
return self;
|
||||
|
||||
// finds/dupes functions within range and removes them.
|
||||
function functionsWithinRange(startMillis, endMillis) {
|
||||
var fnsToRun = [];
|
||||
for (var timeoutKey in scheduledFunctions) {
|
||||
var scheduledFunc = scheduledFunctions[timeoutKey];
|
||||
if (scheduledFunc &&
|
||||
scheduledFunc.runAtMillis >= startMillis &&
|
||||
scheduledFunc.runAtMillis <= endMillis) {
|
||||
function indexOfFirstToPass(array, testFn) {
|
||||
var index = -1;
|
||||
|
||||
// remove fn -- we'll reschedule later if it is recurring.
|
||||
self.removeFunctionWithId(timeoutKey);
|
||||
if (!scheduledFunc.recurring) {
|
||||
fnsToRun.push(scheduledFunc); // schedules each function only once
|
||||
} else {
|
||||
fnsToRun.push(buildNthInstanceOf(scheduledFunc, 0));
|
||||
var additionalTimesFnRunsInRange =
|
||||
Math.floor((endMillis - scheduledFunc.runAtMillis) / scheduledFunc.millis);
|
||||
for (var i = 0; i < additionalTimesFnRunsInRange; i++) {
|
||||
fnsToRun.push(buildNthInstanceOf(scheduledFunc, i + 1));
|
||||
}
|
||||
reschedule(buildNthInstanceOf(scheduledFunc, additionalTimesFnRunsInRange));
|
||||
}
|
||||
for (var i = 0; i < array.length; ++i) {
|
||||
if (testFn(array[i])) {
|
||||
index = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return fnsToRun;
|
||||
return index;
|
||||
}
|
||||
|
||||
function buildNthInstanceOf(scheduledFunc, n) {
|
||||
return {
|
||||
runAtMillis: scheduledFunc.runAtMillis + (scheduledFunc.millis * n),
|
||||
funcToCall: scheduledFunc.funcToCall,
|
||||
params: scheduledFunc.params,
|
||||
millis: scheduledFunc.millis,
|
||||
recurring: scheduledFunc.recurring,
|
||||
timeoutKey: scheduledFunc.timeoutKey
|
||||
};
|
||||
function deleteFromLookup(key) {
|
||||
var value = Number(key);
|
||||
var i = indexOfFirstToPass(scheduledLookup, function (millis) {
|
||||
return millis === value;
|
||||
});
|
||||
|
||||
if (i > -1) {
|
||||
scheduledLookup.splice(i, 1);
|
||||
}
|
||||
}
|
||||
|
||||
function reschedule(scheduledFn) {
|
||||
@@ -1070,21 +1096,30 @@ getJasmineRequireObj().DelayedFunctionScheduler = function() {
|
||||
scheduledFn.runAtMillis + scheduledFn.millis);
|
||||
}
|
||||
|
||||
|
||||
function runFunctionsWithinRange(startMillis, endMillis) {
|
||||
var funcsToRun = functionsWithinRange(startMillis, endMillis);
|
||||
if (funcsToRun.length === 0) {
|
||||
function runScheduledFunctions(endTime) {
|
||||
if (scheduledLookup.length === 0 || scheduledLookup[0] > endTime) {
|
||||
return;
|
||||
}
|
||||
|
||||
funcsToRun.sort(function(a, b) {
|
||||
return a.runAtMillis - b.runAtMillis;
|
||||
});
|
||||
do {
|
||||
currentTime = scheduledLookup.shift();
|
||||
|
||||
for (var i = 0; i < funcsToRun.length; ++i) {
|
||||
var funcToRun = funcsToRun[i];
|
||||
funcToRun.funcToCall.apply(null, funcToRun.params || []);
|
||||
}
|
||||
var funcsToRun = scheduledFunctions[currentTime];
|
||||
delete scheduledFunctions[currentTime];
|
||||
|
||||
for (var i = 0; i < funcsToRun.length; ++i) {
|
||||
var funcToRun = funcsToRun[i];
|
||||
funcToRun.funcToCall.apply(null, funcToRun.params || []);
|
||||
|
||||
if (funcToRun.recurring) {
|
||||
reschedule(funcToRun);
|
||||
}
|
||||
}
|
||||
} while (scheduledLookup.length > 0 &&
|
||||
// checking first if we're out of time prevents setTimeout(0)
|
||||
// scheduled in a funcToRun from forcing an extra iteration
|
||||
currentTime !== endTime &&
|
||||
scheduledLookup[0] <= endTime);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2363,5 +2398,5 @@ getJasmineRequireObj().toThrowError = function(j$) {
|
||||
};
|
||||
|
||||
getJasmineRequireObj().version = function() {
|
||||
return "2.0.0-rc5";
|
||||
return "2.0.0";
|
||||
};
|
||||
|
||||
@@ -4,6 +4,6 @@
|
||||
#
|
||||
module Jasmine
|
||||
module Core
|
||||
VERSION = "2.0.0.rc5"
|
||||
VERSION = "2.0.0"
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,7 +1,11 @@
|
||||
{
|
||||
"name": "jasmine-core",
|
||||
"license": "MIT",
|
||||
"version": "2.0.0-rc5",
|
||||
"version": "2.0.0",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/pivotal/jasmine.git"
|
||||
},
|
||||
"devDependencies": {
|
||||
"grunt": "~0.4.1",
|
||||
"grunt-contrib-jshint": "~0.7.0",
|
||||
|
||||
@@ -2,48 +2,48 @@
|
||||
|
||||
## Summary
|
||||
|
||||
These notes are for RC5 of Jasmine Core 2.0.
|
||||
These notes are for Jasmine Core 2.0.
|
||||
|
||||
## Breaking Changes
|
||||
|
||||
The [`introduction.js`][intro] page covers the current syntax, highlighting the changes. Here are known breaking interface changes that are not backwards compatible with 1.x.
|
||||
The [`introduction.js`][intro] page covers the current syntax, highlighting the changes. Here are the known interface changes that are not backwards compatible with 1.x.
|
||||
|
||||
* New syntax for asynchronous specs
|
||||
* New syntax for spies
|
||||
* New interface for reporters
|
||||
* Better Equality testing
|
||||
* Easier custom matchers
|
||||
* Replaced custom matchers for ease of use
|
||||
* Change to `toThrow` matcher
|
||||
* Clock does not uninstall itself at the end of a spec
|
||||
* Clock now remains installed when a spec finishes
|
||||
* More Jasmine internal variables/functions have been moved into closures
|
||||
|
||||
### New syntax for asynchronous specs
|
||||
|
||||
Similar to [Mocha][mocha], Jasmine befores, specs, and afters can take an optional "done" callback in order to force asynchronous tests. The next function, whether it's a before, spec or after, will wait until this function is called or if a timeout is reached.
|
||||
Similar to [Mocha][mocha], Jasmine `before`s, `spec`s, and `after`s can take an optional `done` callback in order to force asynchronous tests. The next function, whether it's a `before`, `spec` or `after`, will wait until this function is called or until a timeout is reached.
|
||||
|
||||
### New syntax for spies
|
||||
|
||||
Spies have a slightly modified syntax. The ideas came from a desire to preserve any of the properties on a spied-upon function and some better testing patterns.
|
||||
Spies have a slightly modified syntax. The idea came from a desire to preserve any of the properties on a spied-upon function and some better testing patterns.
|
||||
|
||||
### New interface for reporters
|
||||
|
||||
The reporter interface has changed. The callbacks are different and more consistent. The objects passed in should only provide what is needed to report results. This enforces an interface to result data so custom reporters will be less coupled to Jasmine implementation. The full suite execution time is also reported.
|
||||
The reporter interface has been **replaced**. The callbacks are different and more consistent. The objects passed in should only provide what is needed to report results. This enforces an interface to result data so custom reporters will be less coupled to the Jasmine implementation. The Jasmine reporter API now includes a slot for a `timer` object.
|
||||
|
||||
### Better Equality testing
|
||||
|
||||
We have tossed the previous equality code and are now using new code for testing equality. We started with [Underscore.js][underscore]'s `isEqual`, refactored a bit and added some additional tests.
|
||||
We removed the previous equality code and are now using new code for testing equality. We started with [Underscore.js][underscore]'s `isEqual`, refactored a bit and added some additional tests.
|
||||
|
||||
### Easier custom matchers
|
||||
### Replaced custom matchers for ease of use
|
||||
|
||||
Custom matchers have always been possible, but this was barely documented and clunky to test. We've changed how matchers are added and tested. Jasmine adds its own matchers by the same mechanism that as custom matchers use. Dogfooding FTW.
|
||||
The interface for adding custom matchers has been **replaced**. It has always been possible to add custom matchers, but the API was barely documented and difficult to test. We've changed how matchers are added and tested. Jasmine adds its own matchers by the same mechanism that custom matchers use. Dogfooding FTW.
|
||||
|
||||
### Change to `toThrow` matcher
|
||||
|
||||
We've changed the behavior of the `toThrow` matcher, moving some functionality to the `toThrowError` matcher. This should allow more of the requested use cases.
|
||||
|
||||
### Clock does not uninstall itself at the end of a spec
|
||||
### Clock now remains installed when a spec finishes
|
||||
|
||||
After installing the Jasmine Clock, it will stay installed until uninstall is called -- clearing up any ambiguity for when those timing functions will go back to being the actual ones.
|
||||
After installing the Jasmine Clock, it will stay installed until `uninstall` is called -- clearing up any ambiguity for when those timing functions will revert to using the global clock object.
|
||||
|
||||
## More Jasmine internal variables/functions have been moved into closures
|
||||
|
||||
@@ -53,9 +53,9 @@ Certain variables/functions like a function to get the next spec id have been mo
|
||||
|
||||
* Massive refactoring and better testing
|
||||
* Environment setup now in `boot.js`
|
||||
* Development & Build moved to Grunt
|
||||
* Change in how Jasmine is loaded
|
||||
* Change in how Jasmine is tested
|
||||
* Development and Build moved to Grunt
|
||||
* Changes to how Jasmine is loaded
|
||||
* Changes to how Jasmine is tested
|
||||
* Better node.js support
|
||||
* Better Continuous Integration Environment at Travis
|
||||
* Support matrix updated
|
||||
@@ -64,39 +64,39 @@ Certain variables/functions like a function to get the next spec id have been mo
|
||||
|
||||
## Massive refactoring and better testing
|
||||
|
||||
This is the biggest set of changes. We've touched nearly every file and every object. We've slammed objects back together and pulled out new extractions. We've made the code more consistently styled. We've improved the tests nearly everywhere.
|
||||
This is the biggest set of changes. We've touched nearly every file and every object. We've merged objects together and factored out code. We styled the code more consistently. We've improved nearly every test.
|
||||
|
||||
In general, Jasmine is made of smaller, more-loosely-coupled objects, unit-tested with explicit dependencies injected. This made tests easier to write, read, and maintain. We know this has made Jasmine development easier for the core team. We expect (and hope) this makes it easier for the community to extend Jasmine and provide pull requests that make more sense the first time out.
|
||||
In general, Jasmine is made of smaller, more-loosely-coupled objects, unit-tested with explicit dependencies injected. This made tests easier to read, write, and maintain. We know this has made Jasmine development easier for the core team. We expect (and hope) this makes it easier for the community to extend Jasmine and provide pull requests that make more sense the first time out.
|
||||
|
||||
## Environment setup now in `boot.js`
|
||||
|
||||
Instantiation and setup of the Jasmine environment, including building reporters, exposing the "global" functions, and executing tests has moved into its own file: `boot.js`. This should make it easier to add custom reporters, configure some objects, or just in general change how you use Jasmine from the outside.
|
||||
|
||||
For example, during development, Jasmine uses it's own `devboot.js` to load itself twice - once from `jasmine.js` and once from the source directories.
|
||||
For example, during development, Jasmine uses its own `devboot.js` to load itself twice - once from `jasmine.js` and once from the source directories.
|
||||
|
||||
## Development & Build moved to Grunt
|
||||
## Development and Build moved to Grunt
|
||||
|
||||
We've moved away from Ruby and embraced Node.js and [Grunt.js][grunt] for the various command line tasks during development. Yes, it's a just a different set of dependencies. But it's less code for the team to maintain - it turns out that JavaScript tools are pretty good at building JavaScript projects. This will make it easier for the community to make sure contributions work in browser and in Node.js before submitting Pull Requests. There is more detail in the [Contributor's Guide][contrib].
|
||||
We've moved away from Ruby and embraced [Node.js][node] and [Grunt.js][grunt] for the various command line tasks during development. Yes, it's a just a different set of dependencies. But it's less code for the team to maintain - it turns out that JavaScript tools are pretty good at building JavaScript projects. This will make it easier for the community to make sure contributions work in browsers and in Node.js before submitting Pull Requests. There is more detail in the [Contributor's Guide][contrib].
|
||||
|
||||
## Change in how Jasmine is loaded
|
||||
## Changes to how Jasmine is loaded
|
||||
|
||||
We did not want to add new run-time dependencies, yet we needed to be cleaner when loading Jasmine. So we wrote a custom "require" scheme that works in Node.js and in browsers. This only affects pull requests that add files - please be careful in these cases. Again, the [Contributor's Guide][contrib] should help.
|
||||
We did not want to add new run-time dependencies, yet we needed to be cleaner when loading Jasmine. So we wrote a custom "require" scheme that works in Node.js and in browsers. This only affects pull requests which add files - please be careful in these cases. Again, the [Contributor's Guide][contrib] should help.
|
||||
|
||||
## Change in how Jasmine is tested with Jasmine
|
||||
## Changes to how Jasmine is tested with Jasmine
|
||||
|
||||
Writing a custom require system helped enforce self-testing - the built `jasmine.js` testing Jasmine from the source directories. Overall this has improved the stability of the code. When you look at Jasmine's tests, you'll see both `jasmine` and `j$` used. The former, `jasmine`, will always be used to test the code from source, which is loaded into the reference `j$`. Please adhere to this pattern when writing tests for contributions.
|
||||
|
||||
## Better node.js support
|
||||
|
||||
Node.js is now officially a first-class citizen. For a long time we've made sure tests were green in Node before releasing. But it is now officially part of Jasmine's CI build at [Travis][travis]. For the curious, the [`node_suite.js`][node_suite], is essentially a `boot.js` for Node. An official npm is coming.
|
||||
`Node.js` is now officially a first-class citizen. For a long time we've made sure tests were green in Node before releasing. But it is now officially part of Jasmine's CI build at [Travis][travis]. For the curious, the [`node_suite.js`][node_suite], is essentially a `boot.js` for Node. An official `npm` is coming.
|
||||
|
||||
## Better Continuous Integration Environment at Travis
|
||||
|
||||
The [CI build at Travis][travis_jasmine] now runs the core specs in a build matrix across browsers. It's far from complete on the operating system matrix, but you will see that Jasmine runs against: Firefox, Chrome, Safari 5, Safari 6, Phantom.js, Node.js, and IE versions 8, 9, and 10. Big thanks to [SauceLabs][sauce] for their support of open source projects. We will happily take pull requests for additional OS/Browser combos within the matrix.
|
||||
The [CI build at Travis][travis_jasmine] now runs the core specs in a build matrix across browsers. It's far from complete on the operating system matrix, but you will see that Jasmine runs against: Firefox, Chrome, Safari 5, Safari 6, [Phantom.js][phantom], [Node.js][node], and IE versions 8, 9, and 10. Big thanks to [SauceLabs][sauce] for their support of open source projects. We will happily take pull requests for additional OS/Browser combos within the matrix.
|
||||
|
||||
## Support Matrix Updated
|
||||
|
||||
We're dropping support for IE < 8. Jasmine 1.x remains for projects supporting earlier versions of browsers.
|
||||
We're dropping support for IE < 8. [Jasmine 1.x][jasmine_downloads] remains for projects that need to support older browsers.
|
||||
|
||||
## Removed JsDoc Pages
|
||||
|
||||
@@ -108,7 +108,7 @@ Last year saw the posting of the [`introduction.js`][intro] page to document the
|
||||
|
||||
We are running Code Climate for Jasmine. We have some work to do here but it's helping us easily find code hotspots.
|
||||
|
||||
## Pull Requests & Issues
|
||||
## Pull Requests and Issues
|
||||
|
||||
The following Pull Requests were merged:
|
||||
|
||||
@@ -122,12 +122,21 @@ The following Pull Requests were merged:
|
||||
* Whitespace failures should be easier to understand #[332](https://github.com/pivotal/jasmine/issues/332) from bjornblomqvist
|
||||
* Fix for more markdown-y image for Build status #[329](https://github.com/pivotal/jasmine/issues/329) from sunliwen
|
||||
* UTF-8 encoding fixes #[333](https://github.com/pivotal/jasmine/issues/333) from bjornblomqvist
|
||||
* Replaced deprecated octal literal with hexadecimal from kris7t
|
||||
* Make getGlobal() work in strict mode from metaweta
|
||||
* Clears timeout timer even when async spec throws an exception from tidoust
|
||||
* Timeouts scheduled within a delayed function are correctly scheduled and executed from maciej-filip-sz
|
||||
|
||||
### Fixed in RC3
|
||||
### Bug Fixes
|
||||
* Improved the performance of the HTML output with a CSS change #[428](https://github.com/pivotal/jasmine/issues/428) - Thanks @tjgrathwell
|
||||
* Removed an accidental global pollution of `j$` as a reference to Jasmine. Thanks to Morten Maxild from the mailing list
|
||||
|
||||
### Fixed in RC5
|
||||
* There is now a consistent `this` between `beforeEach`, `it` and `afterEach` for a spec
|
||||
* A spy's strategy now has properties `returnValue` and `throwError` because they are better names
|
||||
* Make it easy to copy the title of failing specs from the HTML output
|
||||
* Don't add periods to the full name of a spec fix #[427](https://github.com/pivotal/jasmine/issues/427)
|
||||
* Allow Env to take optional spec/suite ids when asked to `execute`
|
||||
* [Mock clock now less intrusive, replacing global timer functions only when clock is installed](http://www.pivotaltracker.com/story/54168708)
|
||||
* Restore custom failure messages for `toHaveBeenCalledWith`
|
||||
* Jasmine global object has a addCustomEqualityTester and addMatchers (no longer directly on global)
|
||||
* Fixed a global leak of `timer`
|
||||
* Remove currentRunner from Env (users can use topSuite from Env instead)
|
||||
@@ -135,10 +144,11 @@ The following Pull Requests were merged:
|
||||
* Improve error message when a spec does not call the async callback within the default time interval
|
||||
* Allow passing a negativeCompare in a custom matcher for more custom implementations when `.not` is called
|
||||
* Update favicon to be higher resolution
|
||||
* Make all async functions be subject to the timeout
|
||||
|
||||
There were several other pull requests that either had already been fixed, or were good starting points for the various changes above. Thank you for all of the hard work to keep Jasmine awesome.
|
||||
|
||||
## Other Bugs & Features
|
||||
## Other Bugs and Features
|
||||
|
||||
There were a few small changes and fixes that didn't fit into any of the above categories:
|
||||
|
||||
@@ -151,18 +161,12 @@ There were a few small changes and fixes that didn't fit into any of the above c
|
||||
* Removed references to unused `jasmine.VERBOSE`
|
||||
* Removed references to unused `jasmine.XmlHttpRequest`
|
||||
|
||||
### Fixed in RC3
|
||||
* There is now a consistent `this` between `beforeEach`, `it` and `afterEach` for a spec
|
||||
* A spy's strategy now has properties `returnValue` and `throwError` because they are better names
|
||||
* Make it easy to copy the title of failing specs from the HTML output
|
||||
* Don't add periods to the full name of a spec fix #[427](https://github.com/pivotal/jasmine/issues/427)
|
||||
* Allow Env to take optional spec/suite ids when asked to `execute`
|
||||
* [Mock clock now less intrusive, replacing global timer functions only when clock is installed](http://www.pivotaltracker.com/story/54168708)
|
||||
* Restore custom failure messages for `toHaveBeenCalledWith`
|
||||
|
||||
[mocha]: http://visionmedia.github.io/mocha/
|
||||
[underscore]: http://underscorejs.org/
|
||||
[grunt]: http://gruntjs.com
|
||||
[node]: http://nodejs.org
|
||||
[phantom]: http://phantomjs.org
|
||||
[jasmine_downloads]: https://github.com/pivotal/jasmine/downloads
|
||||
[contrib]: https://github.com/pivotal/jasmine/blob/master/CONTRIBUTING.md
|
||||
[travis]: http://travis-ci.org
|
||||
[travis_jasmine]: http://travis-ci.org/jasmine
|
||||
@@ -1,138 +0,0 @@
|
||||
# Jasmine Core 2.0 Release Notes
|
||||
|
||||
## Summary
|
||||
|
||||
These notes are for RC1 of Jasmine Core 2.0.
|
||||
|
||||
## Breaking Changes
|
||||
|
||||
These changes have breaking interface changes and are not backwards compatible with 1.x.
|
||||
|
||||
* New syntax for asynchronous specs
|
||||
* New syntax for spies
|
||||
* New interface for reporters
|
||||
* Better Equality testing
|
||||
* Easier custom matchers
|
||||
* Change to `toThrow` matcher
|
||||
|
||||
### New syntax for asynchronous specs
|
||||
|
||||
Similar to [Mocha][mocha], Jasmine befores, specs, and afters can take an optional "done" callback in order to force asynchronous tests. The next function, whether it's a before, spec or after, will wait until this function is called or if a timeout is reached.
|
||||
|
||||
### New syntax for spies
|
||||
|
||||
Spies have a slightly modified syntax. The ideas came from a desire to preserve any of the properties on a spied-upon function and some better testing patterns.
|
||||
|
||||
### New interface for reporters
|
||||
|
||||
The reporter interface has changed. The callbacks are different and more consistent. The objects passed in should only provide what is needed to report results. This enforces an interface to result data so custom reporters will be less coupled to Jasmine implementation. The full suite execution time is also reported.
|
||||
|
||||
### Better Equality testing
|
||||
|
||||
We have tossed the previous equality code and are now using new code for testing equality. We started with [Underscore.js][underscore]'s `isEqual`, refactored a bit and added some additional tests.
|
||||
|
||||
### Easier custom matchers
|
||||
|
||||
Custom matchers have always been possible, but this was barely documented and clunky to test. We've changed how matchers are added and tested. Jasmine adds its own matchers by the same mechanism that as custom matchers use. Dogfooding FTW.
|
||||
|
||||
### Change to `toThrow` matcher
|
||||
|
||||
We've changed the behavior of the `toThrow` matcher, moving some functionality to the `toThrowError` matcher. This should allow more of the requested use cases.
|
||||
|
||||
## Other Changes
|
||||
|
||||
* Massive refactoring and better testing
|
||||
* Environment setup now in `boot.js`
|
||||
* Development & Build moved to Grunt
|
||||
* Change in how Jasmine is loaded
|
||||
* Change in how Jasmine is tested
|
||||
* Better node.js support
|
||||
* Better Continuous Integration Environment at Travis
|
||||
* Support matrix updated
|
||||
* Removed JsDoc Pages
|
||||
|
||||
## Massive refactoring and better testing
|
||||
|
||||
This is the biggest set of changes. We've touched nearly every file and every object. We've slammed objects back together and pulled out new extractions. We've made the code more consistently styled. We've improved the tests nearly everywhere.
|
||||
|
||||
In general, Jasmine is made of smaller, more-loosely-coupled objects, unit-tested with explicit dependencies injected. This made tests easier to write, read, and maintain. We know this has made Jasmine development easier for the core team. We expect (and hope) this makes it easier for the community to extend Jasmine and provide pull requests that make more sense the first time out.
|
||||
|
||||
## Environment setup now in `boot.js`
|
||||
|
||||
Instantiation and setup of the Jasmine environment, including building reporters, exposing the "global" functions, and executing tests has moved into its own file: `boot.js`. This should make it easier to add custom reporters, configure some objects, or just in general change how you use Jasmine from the outside.
|
||||
|
||||
For example, during development, Jasmine uses it's own `devboot.js` to load itself twice - once from `jasmine.js` and once from the source directories.
|
||||
|
||||
## Development & Build moved to Grunt
|
||||
|
||||
We've moved away from Ruby and embraced Node.js and [Grunt.js][grunt] for the various command line tasks during development. Yes, it's a just a different set of dependencies. But it's less code for the team to maintain - it turns out that JavaScript tools are pretty good at building JavaScript projects. This will make it easier for the community to make sure contributions work in browser and in Node.js before submitting Pull Requests. There is more detail in the [Contributor's Guide][contrib].
|
||||
|
||||
## Change in how Jasmine is loaded
|
||||
|
||||
We did not want to add new run-time dependencies, yet we needed to be cleaner when loading Jasmine. So we wrote a custom "require" scheme that works in Node.js and in browsers. This only affects pull requests that add files - please be careful in these cases. Again, the [Contributor's Guide][contrib] should help.
|
||||
|
||||
## Change in how Jasmine is tested with Jasmine
|
||||
|
||||
Writing a custom require system helped enforce self-testing - the built `jasmine.js` testing Jasmine from the source directories. Overall this has improved the stability of the code. When you look at Jasmine's tests, you'll see both `jasmine` and `j$` used. The former, `jasmine`, will always be used to test the code from source, which is loaded into the reference `j$`. Please adhere to this pattern when writing tests for contributions.
|
||||
|
||||
## Better node.js support
|
||||
|
||||
Node.js is now officially a first-class citizen. For a long time we've made sure tests were green in Node before releasing. But it is now officially part of Jasmine's CI build at [Travis][travis]. For the curious, the [`node_suite.js`][node_suite], is essentially a `boot.js` for Node. An official npm is coming.
|
||||
|
||||
## Better Continuous Integration Environment at Travis
|
||||
|
||||
The [CI build at Travis][travis_jasmine] now runs the core specs in a build matrix across browsers. It's far from complete on the operating system matrix, but you will see that Jasmine runs against: Firefox, Chrome, Safari 5, Safari 6, Phantom.js, Node.js, and IE versions 8, 9, and 10. Big thanks to [SauceLabs][sauce] for their support of open source projects. We will happily take pull requests for additional OS/Browser combos within the matrix.
|
||||
|
||||
## Support Matrix Updated
|
||||
|
||||
We're dropping support for IE < 8. Jasmine 1.x remains for projects supporting earlier versions of browsers.
|
||||
|
||||
## Removed JsDoc Pages
|
||||
|
||||
Comments in code are lies waiting to happen. Jasmine's JsDoc comments were no exception. The comments were out of date, the generated pages were even more out of date, and frankly they were not helpful. So they're gone.
|
||||
|
||||
Last year saw the posting of the [`introduction.js`][intro] page to document the real, practical interface for projects to use. This page has received a lot of positive feedback so expect more pages like this one.
|
||||
|
||||
## Pull Requests & Issues
|
||||
|
||||
The following Pull Requests were merged:
|
||||
|
||||
* ObjectContaining wrong filed value error message #[394](https://github.com/pivotal/jasmine/issues/394) from albertandrejev
|
||||
* Removed unnecessary parameter from `suiteFactory()` call #[397](https://github.com/pivotal/jasmine/issues/397) from valera-rozuvan
|
||||
* `jasmine.Any` supports `Boolean` #[392](https://github.com/pivotal/jasmine/issues/392) from albertandrejev
|
||||
* Reporters get execution time #[30](https://github.com/pivotal/jasmine/issues/30)
|
||||
* `toThrow` matchers handle falsy exceptions #[317](https://github.com/pivotal/jasmine/issues/371)
|
||||
* Removed deprecated `jasmine.Matchers.pp` #[363](https://github.com/pivotal/jasmine/issues/363) from robinboehm
|
||||
* Fix for Clock ticking to default to 0 #[340](https://github.com/pivotal/jasmine/issues/340) from Caio Cunha
|
||||
* Whitespace failures should be easier to understand #[332](https://github.com/pivotal/jasmine/issues/332) from bjornblomqvist
|
||||
* Fix for more markdown-y image for Build status #[329](https://github.com/pivotal/jasmine/issues/329) from sunliwen
|
||||
* UTF-8 encoding fixes #[333](https://github.com/pivotal/jasmine/issues/333) from bjornblomqvist
|
||||
|
||||
There were several other pull requests that either had already been fixed, or were good starting points for the various changes above. Thank you for all of the hard work to keep Jasmine awesome.
|
||||
|
||||
## Other Bugs & Features
|
||||
|
||||
There were a few small changes and fixes that didn't fit into any of the above categories:
|
||||
|
||||
* HTML Reporter refactored for simplicity and performance
|
||||
* Default character encoding on the HTML runner page is UTF-8
|
||||
* [Escape special regex characters from the spec param](http://www.pivotaltracker.com/story/52731407)
|
||||
* Favicon returns
|
||||
* [Clock supports `eval`'d strings as functions](http://www.pivotaltracker.com/story/40853563)
|
||||
* There should always be stack traces on failures
|
||||
* Removed references to unused `jasmine.VERBOSE`
|
||||
* Removed references to unused `jasmine.XmlHttpRequest`
|
||||
|
||||
------
|
||||
|
||||
_Release Notes generated with [Anchorman](http://github.com/infews/anchorman)_
|
||||
|
||||
[mocha]: http://visionmedia.github.io/mocha/
|
||||
[underscore]: http://underscorejs.org/
|
||||
[grunt]: http://gruntjs.com
|
||||
[contrib]: https://github.com/pivotal/jasmine/blob/master/Contribute.markdown
|
||||
[travis]: http://travis-ci.org
|
||||
[travis_jasmine]: http://travis-ci.org/jasmine
|
||||
[sauce]: http://saucelabs.com
|
||||
[node_suite]: https://github.com/pivotal/jasmine/blob/master/spec/node_suite.js
|
||||
[intro]: http://pivotal.github.com/jasmine/
|
||||
@@ -1,151 +0,0 @@
|
||||
# Jasmine Core 2.0 Release Notes
|
||||
|
||||
## Summary
|
||||
|
||||
These notes are for RC3 of Jasmine Core 2.0.
|
||||
|
||||
## Breaking Changes
|
||||
|
||||
The [`introduction.js`][intro] page covers the current syntax, highlighting the changes. Here are known breaking interface changes that are not backwards compatible with 1.x.
|
||||
|
||||
* New syntax for asynchronous specs
|
||||
* New syntax for spies
|
||||
* New interface for reporters
|
||||
* Better Equality testing
|
||||
* Easier custom matchers
|
||||
* Change to `toThrow` matcher
|
||||
|
||||
### New syntax for asynchronous specs
|
||||
|
||||
Similar to [Mocha][mocha], Jasmine befores, specs, and afters can take an optional "done" callback in order to force asynchronous tests. The next function, whether it's a before, spec or after, will wait until this function is called or if a timeout is reached.
|
||||
|
||||
### New syntax for spies
|
||||
|
||||
Spies have a slightly modified syntax. The ideas came from a desire to preserve any of the properties on a spied-upon function and some better testing patterns.
|
||||
|
||||
### New interface for reporters
|
||||
|
||||
The reporter interface has changed. The callbacks are different and more consistent. The objects passed in should only provide what is needed to report results. This enforces an interface to result data so custom reporters will be less coupled to Jasmine implementation. The full suite execution time is also reported.
|
||||
|
||||
### Better Equality testing
|
||||
|
||||
We have tossed the previous equality code and are now using new code for testing equality. We started with [Underscore.js][underscore]'s `isEqual`, refactored a bit and added some additional tests.
|
||||
|
||||
### Easier custom matchers
|
||||
|
||||
Custom matchers have always been possible, but this was barely documented and clunky to test. We've changed how matchers are added and tested. Jasmine adds its own matchers by the same mechanism that as custom matchers use. Dogfooding FTW.
|
||||
|
||||
### Change to `toThrow` matcher
|
||||
|
||||
We've changed the behavior of the `toThrow` matcher, moving some functionality to the `toThrowError` matcher. This should allow more of the requested use cases.
|
||||
|
||||
## Other Changes
|
||||
|
||||
* Massive refactoring and better testing
|
||||
* Environment setup now in `boot.js`
|
||||
* Development & Build moved to Grunt
|
||||
* Change in how Jasmine is loaded
|
||||
* Change in how Jasmine is tested
|
||||
* Better node.js support
|
||||
* Better Continuous Integration Environment at Travis
|
||||
* Support matrix updated
|
||||
* Removed JsDoc Pages
|
||||
|
||||
## Massive refactoring and better testing
|
||||
|
||||
This is the biggest set of changes. We've touched nearly every file and every object. We've slammed objects back together and pulled out new extractions. We've made the code more consistently styled. We've improved the tests nearly everywhere.
|
||||
|
||||
In general, Jasmine is made of smaller, more-loosely-coupled objects, unit-tested with explicit dependencies injected. This made tests easier to write, read, and maintain. We know this has made Jasmine development easier for the core team. We expect (and hope) this makes it easier for the community to extend Jasmine and provide pull requests that make more sense the first time out.
|
||||
|
||||
## Environment setup now in `boot.js`
|
||||
|
||||
Instantiation and setup of the Jasmine environment, including building reporters, exposing the "global" functions, and executing tests has moved into its own file: `boot.js`. This should make it easier to add custom reporters, configure some objects, or just in general change how you use Jasmine from the outside.
|
||||
|
||||
For example, during development, Jasmine uses it's own `devboot.js` to load itself twice - once from `jasmine.js` and once from the source directories.
|
||||
|
||||
## Development & Build moved to Grunt
|
||||
|
||||
We've moved away from Ruby and embraced Node.js and [Grunt.js][grunt] for the various command line tasks during development. Yes, it's a just a different set of dependencies. But it's less code for the team to maintain - it turns out that JavaScript tools are pretty good at building JavaScript projects. This will make it easier for the community to make sure contributions work in browser and in Node.js before submitting Pull Requests. There is more detail in the [Contributor's Guide][contrib].
|
||||
|
||||
## Change in how Jasmine is loaded
|
||||
|
||||
We did not want to add new run-time dependencies, yet we needed to be cleaner when loading Jasmine. So we wrote a custom "require" scheme that works in Node.js and in browsers. This only affects pull requests that add files - please be careful in these cases. Again, the [Contributor's Guide][contrib] should help.
|
||||
|
||||
## Change in how Jasmine is tested with Jasmine
|
||||
|
||||
Writing a custom require system helped enforce self-testing - the built `jasmine.js` testing Jasmine from the source directories. Overall this has improved the stability of the code. When you look at Jasmine's tests, you'll see both `jasmine` and `j$` used. The former, `jasmine`, will always be used to test the code from source, which is loaded into the reference `j$`. Please adhere to this pattern when writing tests for contributions.
|
||||
|
||||
## Better node.js support
|
||||
|
||||
Node.js is now officially a first-class citizen. For a long time we've made sure tests were green in Node before releasing. But it is now officially part of Jasmine's CI build at [Travis][travis]. For the curious, the [`node_suite.js`][node_suite], is essentially a `boot.js` for Node. An official npm is coming.
|
||||
|
||||
## Better Continuous Integration Environment at Travis
|
||||
|
||||
The [CI build at Travis][travis_jasmine] now runs the core specs in a build matrix across browsers. It's far from complete on the operating system matrix, but you will see that Jasmine runs against: Firefox, Chrome, Safari 5, Safari 6, Phantom.js, Node.js, and IE versions 8, 9, and 10. Big thanks to [SauceLabs][sauce] for their support of open source projects. We will happily take pull requests for additional OS/Browser combos within the matrix.
|
||||
|
||||
## Support Matrix Updated
|
||||
|
||||
We're dropping support for IE < 8. Jasmine 1.x remains for projects supporting earlier versions of browsers.
|
||||
|
||||
## Removed JsDoc Pages
|
||||
|
||||
Comments in code are lies waiting to happen. Jasmine's JsDoc comments were no exception. The comments were out of date, the generated pages were even more out of date, and frankly they were not helpful. So they're gone.
|
||||
|
||||
Last year saw the posting of the [`introduction.js`][intro] page to document the real, practical interface for projects to use. This page has received a lot of positive feedback so expect more pages like this one.
|
||||
|
||||
## Pull Requests & Issues
|
||||
|
||||
The following Pull Requests were merged:
|
||||
|
||||
* ObjectContaining wrong filed value error message #[394](https://github.com/pivotal/jasmine/issues/394) from albertandrejev
|
||||
* Removed unnecessary parameter from `suiteFactory()` call #[397](https://github.com/pivotal/jasmine/issues/397) from valera-rozuvan
|
||||
* `jasmine.Any` supports `Boolean` #[392](https://github.com/pivotal/jasmine/issues/392) from albertandrejev
|
||||
* Reporters get execution time #[30](https://github.com/pivotal/jasmine/issues/30)
|
||||
* `toThrow` matchers handle falsy exceptions #[317](https://github.com/pivotal/jasmine/issues/371)
|
||||
* Removed deprecated `jasmine.Matchers.pp` #[363](https://github.com/pivotal/jasmine/issues/363) from robinboehm
|
||||
* Fix for Clock ticking to default to 0 #[340](https://github.com/pivotal/jasmine/issues/340) from Caio Cunha
|
||||
* Whitespace failures should be easier to understand #[332](https://github.com/pivotal/jasmine/issues/332) from bjornblomqvist
|
||||
* Fix for more markdown-y image for Build status #[329](https://github.com/pivotal/jasmine/issues/329) from sunliwen
|
||||
* UTF-8 encoding fixes #[333](https://github.com/pivotal/jasmine/issues/333) from bjornblomqvist
|
||||
|
||||
### Fixed in RC3
|
||||
* Improved the performance of the HTML output with a CSS change #[428](https://github.com/pivotal/jasmine/issues/428) - Thanks @tjgrathwell
|
||||
* Removed an accidental global pollution of `j$` as a reference to Jasmine. Thanks to Morten Maxild from the mailing list
|
||||
|
||||
There were several other pull requests that either had already been fixed, or were good starting points for the various changes above. Thank you for all of the hard work to keep Jasmine awesome.
|
||||
|
||||
## Other Bugs & Features
|
||||
|
||||
There were a few small changes and fixes that didn't fit into any of the above categories:
|
||||
|
||||
* HTML Reporter refactored for simplicity and performance
|
||||
* Default character encoding on the HTML runner page is UTF-8
|
||||
* [Escape special regex characters from the spec param](http://www.pivotaltracker.com/story/52731407)
|
||||
* Favicon returns
|
||||
* [Clock supports `eval`'d strings as functions](http://www.pivotaltracker.com/story/40853563)
|
||||
* There should always be stack traces on failures
|
||||
* Removed references to unused `jasmine.VERBOSE`
|
||||
* Removed references to unused `jasmine.XmlHttpRequest`
|
||||
|
||||
### Fixed in RC3
|
||||
* There is now a consistent `this` between `beforeEach`, `it` and `afterEach` for a spec
|
||||
* A spy's strategy now has properties `returnValue` and `throwError` because they are better names
|
||||
* Make it easy to copy the title of failing specs from the HTML output
|
||||
* Don't add periods to the full name of a spec fix #[427](https://github.com/pivotal/jasmine/issues/427)
|
||||
* Allow Env to take optional spec/suite ids when asked to `execute`
|
||||
* [Mock clock now less intrusive, replacing global timer functions only when clock is installed](http://www.pivotaltracker.com/story/54168708)
|
||||
* Restore custom failure messages for `toHaveBeenCalledWith`
|
||||
|
||||
[mocha]: http://visionmedia.github.io/mocha/
|
||||
[underscore]: http://underscorejs.org/
|
||||
[grunt]: http://gruntjs.com
|
||||
[contrib]: https://github.com/pivotal/jasmine/blob/master/CONTRIBUTING.md
|
||||
[travis]: http://travis-ci.org
|
||||
[travis_jasmine]: http://travis-ci.org/jasmine
|
||||
[sauce]: http://saucelabs.com
|
||||
[node_suite]: https://github.com/pivotal/jasmine/blob/master/spec/node_suite.js
|
||||
[intro]: http://jasmine.github.io/2.0/introduction.html
|
||||
|
||||
------
|
||||
|
||||
_Release Notes generated with [Anchorman](http://github.com/infews/anchorman)_
|
||||
@@ -80,7 +80,7 @@ describe("ConsoleReporter", function() {
|
||||
expect(out.getOutput()).toEqual("*");
|
||||
});
|
||||
|
||||
it("reports a summary when done (singluar spec and time)", function() {
|
||||
it("reports a summary when done (singular spec and time)", function() {
|
||||
var timerSpy = jasmine.createSpyObj('timer', ['start', 'elapsed']),
|
||||
reporter = new j$.ConsoleReporter({
|
||||
print: out.print,
|
||||
@@ -198,7 +198,7 @@ describe("ConsoleReporter", function() {
|
||||
|
||||
reporter.specDone({status: "passed"});
|
||||
|
||||
expect(out.getOutput()).toEqual("\033[32m.\033[0m");
|
||||
expect(out.getOutput()).toEqual("\x1B[32m.\x1B[0m");
|
||||
});
|
||||
|
||||
it("does not report a disabled spec", function() {
|
||||
@@ -220,7 +220,7 @@ describe("ConsoleReporter", function() {
|
||||
|
||||
reporter.specDone({status: 'failed'});
|
||||
|
||||
expect(out.getOutput()).toEqual("\033[31mF\033[0m");
|
||||
expect(out.getOutput()).toEqual("\x1B[31mF\x1B[0m");
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -341,4 +341,19 @@ describe("Clock (acceptance)", function() {
|
||||
clock.tick();
|
||||
expect(delayedFn2).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("correctly calls functions scheduled while the Clock is advancing", function() {
|
||||
var delayedFn1 = jasmine.createSpy('delayedFn1'),
|
||||
delayedFn2 = jasmine.createSpy('delayedFn2'),
|
||||
delayedFunctionScheduler = new j$.DelayedFunctionScheduler(),
|
||||
clock = new j$.Clock({setTimeout: function() {}}, delayedFunctionScheduler);
|
||||
|
||||
delayedFn1.and.callFake(function() { clock.setTimeout(delayedFn2, 1); });
|
||||
clock.install();
|
||||
clock.setTimeout(delayedFn1, 5);
|
||||
|
||||
clock.tick(6);
|
||||
expect(delayedFn1).toHaveBeenCalled();
|
||||
expect(delayedFn2).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -175,5 +175,72 @@ describe("DelayedFunctionScheduler", function() {
|
||||
expect(fn).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("schedules a function for later execution during a tick", function () {
|
||||
var scheduler = new j$.DelayedFunctionScheduler(),
|
||||
fn = jasmine.createSpy('fn'),
|
||||
fnDelay = 10;
|
||||
|
||||
scheduler.scheduleFunction(function () {
|
||||
scheduler.scheduleFunction(fn, fnDelay);
|
||||
}, 0);
|
||||
|
||||
expect(fn).not.toHaveBeenCalled();
|
||||
|
||||
scheduler.tick(fnDelay);
|
||||
|
||||
expect(fn).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("#removeFunctionWithId removes a previously scheduled function with a given id during a tick", function () {
|
||||
var scheduler = new j$.DelayedFunctionScheduler(),
|
||||
fn = jasmine.createSpy('fn'),
|
||||
fnDelay = 10,
|
||||
timeoutKey;
|
||||
|
||||
scheduler.scheduleFunction(function () {
|
||||
scheduler.removeFunctionWithId(timeoutKey);
|
||||
}, 0);
|
||||
timeoutKey = scheduler.scheduleFunction(fn, fnDelay);
|
||||
|
||||
expect(fn).not.toHaveBeenCalled();
|
||||
|
||||
scheduler.tick(fnDelay);
|
||||
|
||||
expect(fn).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("executes recurring functions interleaved with regular functions and functions scheduled during a tick in the correct order", function () {
|
||||
var scheduler = new j$.DelayedFunctionScheduler(),
|
||||
fn = jasmine.createSpy('fn'),
|
||||
recurringCallCount = 0,
|
||||
recurring = jasmine.createSpy('recurring').and.callFake(function() {
|
||||
recurringCallCount++;
|
||||
if (recurringCallCount < 5) {
|
||||
expect(fn).not.toHaveBeenCalled();
|
||||
}
|
||||
}),
|
||||
innerFn = jasmine.createSpy('innerFn').and.callFake(function() {
|
||||
expect(recurring.calls.count()).toBe(4);
|
||||
expect(fn).not.toHaveBeenCalled();
|
||||
}),
|
||||
scheduling = jasmine.createSpy('scheduling').and.callFake(function() {
|
||||
expect(recurring.calls.count()).toBe(3);
|
||||
expect(fn).not.toHaveBeenCalled();
|
||||
scheduler.scheduleFunction(innerFn, 10); // 41ms absolute
|
||||
});
|
||||
|
||||
scheduler.scheduleFunction(recurring, 10, [], true);
|
||||
scheduler.scheduleFunction(fn, 50);
|
||||
scheduler.scheduleFunction(scheduling, 31);
|
||||
|
||||
scheduler.tick(60);
|
||||
|
||||
expect(recurring).toHaveBeenCalled();
|
||||
expect(recurring.calls.count()).toBe(6);
|
||||
expect(fn).toHaveBeenCalled();
|
||||
expect(scheduling).toHaveBeenCalled();
|
||||
expect(innerFn).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
|
||||
@@ -33,13 +33,13 @@ describe("Env", function() {
|
||||
});
|
||||
|
||||
describe("#spyOn", function() {
|
||||
it("checks for the existance of the object", function() {
|
||||
it("checks for the existence of the object", function() {
|
||||
expect(function() {
|
||||
env.spyOn(void 0, 'pants');
|
||||
}).toThrowError(/could not find an object/);
|
||||
});
|
||||
|
||||
it("checks for the existance of the method", function() {
|
||||
it("checks for the existence of the method", function() {
|
||||
var subject = {};
|
||||
|
||||
expect(function() {
|
||||
@@ -61,26 +61,9 @@ describe("Env", function() {
|
||||
var originalFunctionWasCalled = false;
|
||||
var subject = { spiedFunc: function() { originalFunctionWasCalled = true; } };
|
||||
|
||||
originalFunc = subject.spiedFunc;
|
||||
|
||||
var spy = env.spyOn(subject, 'spiedFunc');
|
||||
|
||||
expect(subject.spiedFunc).toEqual(spy);
|
||||
|
||||
expect(subject.spiedFunc.calls.any()).toEqual(false);
|
||||
expect(subject.spiedFunc.calls.count()).toEqual(0);
|
||||
|
||||
subject.spiedFunc('foo');
|
||||
|
||||
expect(subject.spiedFunc.calls.any()).toEqual(true);
|
||||
expect(subject.spiedFunc.calls.count()).toEqual(1);
|
||||
expect(subject.spiedFunc.calls.mostRecent().args).toEqual(['foo']);
|
||||
expect(subject.spiedFunc.calls.mostRecent().object).toEqual(subject);
|
||||
expect(originalFunctionWasCalled).toEqual(false);
|
||||
|
||||
subject.spiedFunc('bar');
|
||||
expect(subject.spiedFunc.calls.count()).toEqual(2);
|
||||
expect(subject.spiedFunc.calls.mostRecent().args).toEqual(['bar']);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -100,465 +83,3 @@ describe("Env", function() {
|
||||
});
|
||||
});
|
||||
|
||||
// TODO: move these into a separate file
|
||||
describe("Env integration", function() {
|
||||
|
||||
it("Suites execute as expected (no nesting)", function(done) {
|
||||
var env = new j$.Env(),
|
||||
calls = [];
|
||||
|
||||
var assertions = function() {
|
||||
expect(calls).toEqual([
|
||||
"with a spec",
|
||||
"and another spec"
|
||||
]);
|
||||
|
||||
done();
|
||||
};
|
||||
|
||||
env.addReporter({ jasmineDone: assertions});
|
||||
|
||||
env.describe("A Suite", function() {
|
||||
env.it("with a spec", function() {
|
||||
calls.push("with a spec");
|
||||
});
|
||||
env.it("and another spec", function() {
|
||||
calls.push("and another spec");
|
||||
});
|
||||
});
|
||||
|
||||
env.execute();
|
||||
});
|
||||
|
||||
it("Nested Suites execute as expected", function(done) {
|
||||
var env = new j$.Env(),
|
||||
calls = [];
|
||||
|
||||
var assertions = function() {
|
||||
expect(calls).toEqual([
|
||||
'an outer spec',
|
||||
'an inner spec',
|
||||
'another inner spec'
|
||||
]);
|
||||
|
||||
done();
|
||||
};
|
||||
|
||||
env.addReporter({ jasmineDone: assertions });
|
||||
|
||||
env.describe("Outer suite", function() {
|
||||
env.it("an outer spec", function() {
|
||||
calls.push('an outer spec')
|
||||
});
|
||||
env.describe("Inner suite", function() {
|
||||
env.it("an inner spec", function() {
|
||||
calls.push('an inner spec');
|
||||
});
|
||||
env.it("another inner spec", function() {
|
||||
calls.push('another inner spec');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
env.execute();
|
||||
});
|
||||
|
||||
it("Multiple top-level Suites execute as expected", function(done) {
|
||||
var env = new j$.Env(),
|
||||
calls = [];
|
||||
|
||||
var assertions = function() {
|
||||
expect(calls).toEqual([
|
||||
'an outer spec',
|
||||
'an inner spec',
|
||||
'another inner spec',
|
||||
'a 2nd outer spec'
|
||||
]);
|
||||
|
||||
done();
|
||||
};
|
||||
|
||||
env.addReporter({ jasmineDone: assertions });
|
||||
|
||||
|
||||
env.describe("Outer suite", function() {
|
||||
env.it("an outer spec", function() {
|
||||
calls.push('an outer spec')
|
||||
});
|
||||
env.describe("Inner suite", function() {
|
||||
env.it("an inner spec", function() {
|
||||
calls.push('an inner spec');
|
||||
});
|
||||
env.it("another inner spec", function() {
|
||||
calls.push('another inner spec');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
env.describe("Another outer suite", function() {
|
||||
env.it("a 2nd outer spec", function() {
|
||||
calls.push('a 2nd outer spec')
|
||||
});
|
||||
});
|
||||
|
||||
env.execute();
|
||||
});
|
||||
|
||||
it("calls associated befores/specs/afters with the same 'this'", function(done) {
|
||||
var env = new j$.Env();
|
||||
|
||||
env.addReporter({jasmineDone: done});
|
||||
|
||||
env.describe("tests", function() {
|
||||
var firstTimeThrough = true, firstSpecContext, secondSpecContext;
|
||||
|
||||
env.beforeEach(function() {
|
||||
if (firstTimeThrough) {
|
||||
firstSpecContext = this;
|
||||
} else {
|
||||
secondSpecContext = this;
|
||||
}
|
||||
expect(this).toEqual({});
|
||||
});
|
||||
|
||||
env.it("sync spec", function() {
|
||||
expect(this).toBe(firstSpecContext);
|
||||
});
|
||||
|
||||
env.it("another sync spec", function() {
|
||||
expect(this).toBe(secondSpecContext);
|
||||
});
|
||||
|
||||
env.afterEach(function() {
|
||||
if (firstTimeThrough) {
|
||||
expect(this).toBe(firstSpecContext);
|
||||
firstTimeThrough = false;
|
||||
} else {
|
||||
expect(this).toBe(secondSpecContext);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
env.execute();
|
||||
});
|
||||
|
||||
it("calls associated befores/its/afters with the same 'this' for an async spec", function(done) {
|
||||
var env = new j$.Env();
|
||||
|
||||
env.addReporter({jasmineDone: done});
|
||||
|
||||
env.describe("with an async spec", function() {
|
||||
var specContext;
|
||||
|
||||
env.beforeEach(function() {
|
||||
specContext = this;
|
||||
expect(this).toEqual({});
|
||||
});
|
||||
|
||||
env.it("sync spec", function(underTestCallback) {
|
||||
expect(this).toBe(specContext);
|
||||
underTestCallback();
|
||||
});
|
||||
|
||||
env.afterEach(function() {
|
||||
expect(this).toBe(specContext);
|
||||
});
|
||||
});
|
||||
|
||||
env.execute();
|
||||
});
|
||||
|
||||
it("Allows specifying which specs and suites to run", function(done) {
|
||||
var env = new j$.Env(),
|
||||
calls = [],
|
||||
suiteCallback = jasmine.createSpy('suite callback'),
|
||||
firstSpec,
|
||||
secondSuite;
|
||||
|
||||
var assertions = function() {
|
||||
expect(calls).toEqual([
|
||||
'third spec',
|
||||
'first spec'
|
||||
]);
|
||||
expect(suiteCallback).toHaveBeenCalled();
|
||||
done();
|
||||
};
|
||||
|
||||
env.addReporter({jasmineDone: assertions, suiteDone: suiteCallback});
|
||||
|
||||
env.describe("first suite", function() {
|
||||
firstSpec = env.it("first spec", function() {
|
||||
calls.push('first spec');
|
||||
});
|
||||
env.it("second spec", function() {
|
||||
calls.push('second spec');
|
||||
});
|
||||
});
|
||||
|
||||
secondSuite = env.describe("second suite", function() {
|
||||
env.it("third spec", function() {
|
||||
calls.push('third spec');
|
||||
});
|
||||
});
|
||||
|
||||
env.execute([secondSuite.id, firstSpec.id]);
|
||||
});
|
||||
|
||||
it("Mock clock can be installed and used in tests", function(done) {
|
||||
var globalSetTimeout = jasmine.createSpy('globalSetTimeout'),
|
||||
delayedFunctionForGlobalClock = jasmine.createSpy('delayedFunctionForGlobalClock'),
|
||||
delayedFunctionForMockClock = jasmine.createSpy('delayedFunctionForMockClock'),
|
||||
env = new j$.Env({global: { setTimeout: globalSetTimeout }});
|
||||
|
||||
var assertions = function() {
|
||||
expect(delayedFunctionForMockClock).toHaveBeenCalled();
|
||||
expect(globalSetTimeout).toHaveBeenCalledWith(delayedFunctionForGlobalClock, 100);
|
||||
|
||||
done();
|
||||
};
|
||||
|
||||
env.addReporter({ jasmineDone: assertions });
|
||||
|
||||
env.describe("tests", function() {
|
||||
env.it("test with mock clock", function() {
|
||||
env.clock.install();
|
||||
env.clock.setTimeout(delayedFunctionForMockClock, 100);
|
||||
env.clock.tick(100);
|
||||
env.clock.uninstall();
|
||||
});
|
||||
env.it("test without mock clock", function() {
|
||||
env.clock.setTimeout(delayedFunctionForGlobalClock, 100);
|
||||
});
|
||||
});
|
||||
|
||||
expect(globalSetTimeout).not.toHaveBeenCalled();
|
||||
expect(delayedFunctionForMockClock).not.toHaveBeenCalled();
|
||||
|
||||
env.execute();
|
||||
});
|
||||
|
||||
it("should run async specs in order, waiting for them to complete", function(done) {
|
||||
var env = new j$.Env(), mutatedVar;
|
||||
|
||||
env.describe("tests", function() {
|
||||
env.beforeEach(function() {
|
||||
mutatedVar = 2;
|
||||
});
|
||||
|
||||
env.it("async spec", function(underTestCallback) {
|
||||
setTimeout(function() {
|
||||
expect(mutatedVar).toEqual(2);
|
||||
underTestCallback();
|
||||
done();
|
||||
}, 0);
|
||||
});
|
||||
|
||||
env.it("after async spec", function() {
|
||||
mutatedVar = 3;
|
||||
});
|
||||
});
|
||||
|
||||
env.execute();
|
||||
});
|
||||
|
||||
describe("with a mock clock", function() {
|
||||
var originalTimeout;
|
||||
|
||||
beforeEach(function() {
|
||||
originalTimeout = j$.DEFAULT_TIMEOUT_INTERVAL;
|
||||
jasmine.getEnv().clock.install();
|
||||
});
|
||||
|
||||
afterEach(function() {
|
||||
jasmine.getEnv().clock.uninstall();
|
||||
j$.DEFAULT_TIMEOUT_INTERVAL = originalTimeout;
|
||||
});
|
||||
|
||||
it("should wait a specified interval before failing specs haven't called done yet", function(done) {
|
||||
var env = new j$.Env(),
|
||||
reporter = jasmine.createSpyObj('fakeReporter', [ "specDone" ]);
|
||||
|
||||
reporter.specDone.and.callFake(function() {
|
||||
expect(reporter.specDone).toHaveBeenCalledWith(jasmine.objectContaining({status: 'failed'}));
|
||||
done();
|
||||
});
|
||||
|
||||
env.addReporter(reporter);
|
||||
j$.DEFAULT_TIMEOUT_INTERVAL = 8414;
|
||||
|
||||
env.it("async spec that doesn't call done", function(underTestCallback) {
|
||||
env.expect(true).toBeTruthy();
|
||||
jasmine.getEnv().clock.tick(8414);
|
||||
});
|
||||
|
||||
env.execute();
|
||||
});
|
||||
});
|
||||
|
||||
// TODO: something is wrong with this spec
|
||||
it("should report as expected", function(done) {
|
||||
var env = new j$.Env(),
|
||||
reporter = jasmine.createSpyObj('fakeReporter', [
|
||||
"jasmineStarted",
|
||||
"jasmineDone",
|
||||
"suiteStarted",
|
||||
"suiteDone",
|
||||
"specStarted",
|
||||
"specDone"
|
||||
]);
|
||||
|
||||
reporter.jasmineDone.and.callFake(function() {
|
||||
expect(reporter.jasmineStarted).toHaveBeenCalledWith({
|
||||
totalSpecsDefined: 3
|
||||
});
|
||||
var suiteResult = reporter.suiteStarted.calls.first().args[0];
|
||||
expect(suiteResult.description).toEqual("A Suite");
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
env.addReporter(reporter);
|
||||
|
||||
env.describe("A Suite", function() {
|
||||
env.it("with a top level spec", function() {
|
||||
env.expect(true).toBe(true);
|
||||
});
|
||||
env.describe("with a nested suite", function() {
|
||||
env.xit("with a pending spec", function() {
|
||||
env.expect(true).toBe(true);
|
||||
});
|
||||
env.it("with a spec", function() {
|
||||
env.expect(true).toBe(false);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
env.execute();
|
||||
});
|
||||
|
||||
it("should be possible to get full name from a spec", function() {
|
||||
var env = new j$.Env({global: { setTimeout: setTimeout }}),
|
||||
topLevelSpec, nestedSpec, doublyNestedSpec;
|
||||
|
||||
env.describe("my tests", function() {
|
||||
topLevelSpec = env.it("are sometimes top level", function() {
|
||||
});
|
||||
env.describe("are sometimes", function() {
|
||||
nestedSpec = env.it("singly nested", function() {
|
||||
});
|
||||
env.describe("even", function() {
|
||||
doublyNestedSpec = env.it("doubly nested", function() {
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
expect(topLevelSpec.getFullName()).toBe("my tests are sometimes top level");
|
||||
expect(nestedSpec.getFullName()).toBe("my tests are sometimes singly nested");
|
||||
expect(doublyNestedSpec.getFullName()).toBe("my tests are sometimes even doubly nested");
|
||||
});
|
||||
|
||||
it("Custom equality testers should be per spec", function(done) {
|
||||
var env = new j$.Env({global: { setTimeout: setTimeout }}),
|
||||
reporter = jasmine.createSpyObj('fakeReproter', [
|
||||
"jasmineStarted",
|
||||
"jasmineDone",
|
||||
"suiteStarted",
|
||||
"suiteDone",
|
||||
"specStarted",
|
||||
"specDone"
|
||||
]);
|
||||
|
||||
reporter.jasmineDone.and.callFake(function() {
|
||||
var firstSpecResult = reporter.specDone.calls.first().args[0],
|
||||
secondSpecResult = reporter.specDone.calls.mostRecent().args[0];
|
||||
|
||||
expect(firstSpecResult.status).toEqual("passed");
|
||||
expect(secondSpecResult.status).toEqual("failed");
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
env.addReporter(reporter);
|
||||
|
||||
env.describe("testing custom equality testers", function() {
|
||||
env.it("with a custom tester", function() {
|
||||
env.addCustomEqualityTester(function(a, b) { return true; });
|
||||
env.expect("a").toEqual("b");
|
||||
});
|
||||
|
||||
env.it("without a custom tester", function() {
|
||||
env.expect("a").toEqual("b");
|
||||
});
|
||||
});
|
||||
|
||||
env.execute();
|
||||
});
|
||||
|
||||
it("Custom matchers should be per spec", function() {
|
||||
var env = new j$.Env({global: { setTimeout: setTimeout }}),
|
||||
matchers = {
|
||||
toFoo: function() {}
|
||||
},
|
||||
reporter = jasmine.createSpyObj('fakeReproter', [
|
||||
"jasmineStarted",
|
||||
"jasmineDone",
|
||||
"suiteStarted",
|
||||
"suiteDone",
|
||||
"specStarted",
|
||||
"specDone"
|
||||
]);
|
||||
|
||||
env.addReporter(reporter);
|
||||
|
||||
env.describe("testing custom matchers", function() {
|
||||
env.it("with a custom matcher", function() {
|
||||
env.addMatchers(matchers);
|
||||
expect(env.expect().toFoo).toBeDefined();
|
||||
});
|
||||
|
||||
env.it("without a custom matcher", function() {
|
||||
expect(env.expect().toFoo).toBeUndefined();
|
||||
});
|
||||
});
|
||||
|
||||
env.execute();
|
||||
});
|
||||
|
||||
it("Custom equality testers for toContain should be per spec", function(done) {
|
||||
var env = new j$.Env({global: { setTimeout: setTimeout }}),
|
||||
reporter = jasmine.createSpyObj('fakeReproter', [
|
||||
"jasmineStarted",
|
||||
"jasmineDone",
|
||||
"suiteStarted",
|
||||
"suiteDone",
|
||||
"specStarted",
|
||||
"specDone"
|
||||
]);
|
||||
|
||||
reporter.jasmineDone.and.callFake(function() {
|
||||
var firstSpecResult = reporter.specDone.calls.first().args[0],
|
||||
secondSpecResult = reporter.specDone.calls.mostRecent().args[0];
|
||||
|
||||
expect(firstSpecResult.status).toEqual("passed");
|
||||
expect(secondSpecResult.status).toEqual("failed");
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
env.addReporter(reporter);
|
||||
|
||||
env.describe("testing custom equality testers", function() {
|
||||
env.it("with a custom tester", function() {
|
||||
env.addCustomEqualityTester(function(a, b) { return true; });
|
||||
env.expect(["a"]).toContain("b");
|
||||
});
|
||||
|
||||
env.it("without a custom tester", function() {
|
||||
env.expect("a").toContain("b");
|
||||
});
|
||||
});
|
||||
|
||||
env.execute();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -13,20 +13,20 @@ describe('Exceptions:', function() {
|
||||
throw new Error('I should hit a breakpoint!');
|
||||
});
|
||||
});
|
||||
var dont_change = 'I will never change!';
|
||||
var spy = jasmine.createSpy('spy');
|
||||
|
||||
try {
|
||||
env.execute();
|
||||
dont_change = 'oops I changed';
|
||||
spy();
|
||||
}
|
||||
catch (e) {}
|
||||
|
||||
expect(dont_change).toEqual('I will never change!');
|
||||
expect(spy).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
describe("with catch on exception", function() {
|
||||
it('should handle exceptions thrown, but continue', function() {
|
||||
it('should handle exceptions thrown, but continue', function(done) {
|
||||
var secondTest = jasmine.createSpy('second test');
|
||||
env.describe('Suite for handles exceptions', function () {
|
||||
env.it('should be a test that fails because it throws an exception', function() {
|
||||
@@ -35,11 +35,16 @@ describe('Exceptions:', function() {
|
||||
env.it('should be a passing test that runs after exceptions are thrown from a async test', secondTest);
|
||||
});
|
||||
|
||||
expectations = function() {
|
||||
expect(secondTest).toHaveBeenCalled();
|
||||
done();
|
||||
};
|
||||
|
||||
env.addReporter({ jasmineDone: expectations });
|
||||
env.execute();
|
||||
expect(secondTest).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("should handle exceptions thrown directly in top-level describe blocks and continue", function () {
|
||||
it("should handle exceptions thrown directly in top-level describe blocks and continue", function(done) {
|
||||
var secondDescribe = jasmine.createSpy("second describe");
|
||||
env.describe("a suite that throws an exception", function () {
|
||||
env.it("is a test that should pass", function () {
|
||||
@@ -50,8 +55,13 @@ describe('Exceptions:', function() {
|
||||
});
|
||||
env.describe("a suite that doesn't throw an exception", secondDescribe);
|
||||
|
||||
expectations = function() {
|
||||
expect(secondDescribe).toHaveBeenCalled();
|
||||
done();
|
||||
};
|
||||
|
||||
env.addReporter({ jasmineDone: expectations });
|
||||
env.execute();
|
||||
expect(secondDescribe).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -9,7 +9,7 @@ describe("buildExpectationResult", function() {
|
||||
expect(result.message).toBe('Passed.');
|
||||
});
|
||||
|
||||
it("message returns the message for failing expecations", function() {
|
||||
it("message returns the message for failing expectations", function() {
|
||||
var result = j$.buildExpectationResult({passed: false, message: 'some-value'});
|
||||
expect(result.message).toBe('some-value');
|
||||
});
|
||||
|
||||
@@ -46,7 +46,7 @@ describe("Expectation", function() {
|
||||
expect(expectation.toFoo).toBeUndefined();
|
||||
});
|
||||
|
||||
it("Factory builds an expectaion/negative expectation", function() {
|
||||
it("Factory builds an expectation/negative expectation", function() {
|
||||
var builtExpectation = j$.Expectation.Factory();
|
||||
|
||||
expect(builtExpectation instanceof j$.Expectation).toBe(true);
|
||||
@@ -254,7 +254,7 @@ describe("Expectation", function() {
|
||||
}
|
||||
},
|
||||
util = {
|
||||
buildFailureMessage: function() { return "default messge"; }
|
||||
buildFailureMessage: function() { return "default message"; }
|
||||
},
|
||||
addExpectationResult = jasmine.createSpy("addExpectationResult"),
|
||||
actual = "an actual",
|
||||
@@ -277,7 +277,7 @@ describe("Expectation", function() {
|
||||
passed: false,
|
||||
expected: "hello",
|
||||
actual: actual,
|
||||
message: "default messge"
|
||||
message: "default message"
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ describe("Spec", function() {
|
||||
description: 'my test',
|
||||
id: 'some-id',
|
||||
fn: function() {},
|
||||
queueRunner: fakeQueueRunner
|
||||
queueRunnerFactory: fakeQueueRunner
|
||||
});
|
||||
|
||||
spec.execute();
|
||||
@@ -42,7 +42,7 @@ describe("Spec", function() {
|
||||
description: 'foo bar',
|
||||
fn: function() {},
|
||||
onStart: startCallback,
|
||||
queueRunner: fakeQueueRunner
|
||||
queueRunnerFactory: fakeQueueRunner
|
||||
});
|
||||
|
||||
spec.execute();
|
||||
@@ -69,7 +69,7 @@ describe("Spec", function() {
|
||||
}]
|
||||
},
|
||||
onStart: startCallback,
|
||||
queueRunner: fakeQueueRunner
|
||||
queueRunnerFactory: fakeQueueRunner
|
||||
});
|
||||
|
||||
spec.execute();
|
||||
@@ -93,7 +93,7 @@ describe("Spec", function() {
|
||||
afterFns: function() {
|
||||
return [after]
|
||||
},
|
||||
queueRunner: fakeQueueRunner
|
||||
queueRunnerFactory: fakeQueueRunner
|
||||
});
|
||||
|
||||
spec.execute();
|
||||
@@ -111,7 +111,7 @@ describe("Spec", function() {
|
||||
onStart: startCallback,
|
||||
fn: null,
|
||||
resultCallback: resultCallback,
|
||||
queueRunner: fakeQueueRunner
|
||||
queueRunnerFactory: fakeQueueRunner
|
||||
});
|
||||
|
||||
|
||||
@@ -127,7 +127,7 @@ describe("Spec", function() {
|
||||
onStart:startCallback,
|
||||
fn: specBody,
|
||||
resultCallback: resultCallback,
|
||||
queueRunner: fakeQueueRunner
|
||||
queueRunnerFactory: fakeQueueRunner
|
||||
});
|
||||
|
||||
spec.disable();
|
||||
@@ -154,7 +154,7 @@ describe("Spec", function() {
|
||||
getSpecName: function() {
|
||||
return "a suite with a spec"
|
||||
},
|
||||
queueRunner: fakeQueueRunner
|
||||
queueRunnerFactory: fakeQueueRunner
|
||||
});
|
||||
|
||||
spec.pend();
|
||||
@@ -181,7 +181,7 @@ describe("Spec", function() {
|
||||
fn: function() {},
|
||||
catchExceptions: function() { return false; },
|
||||
resultCallback: function() {},
|
||||
queueRunner: function(attrs) { attrs.onComplete(); }
|
||||
queueRunnerFactory: function(attrs) { attrs.onComplete(); }
|
||||
});
|
||||
|
||||
spec.execute(done);
|
||||
@@ -208,17 +208,99 @@ describe("Spec", function() {
|
||||
});
|
||||
|
||||
it("can return its full name", function() {
|
||||
var spec;
|
||||
spec = new j$.Spec({
|
||||
getSpecName: function(passedVal) {
|
||||
// expect(passedVal).toBe(spec); TODO: a exec time, spec is undefined WTF?
|
||||
return 'expected val';
|
||||
}
|
||||
var specNameSpy = jasmine.createSpy('specNameSpy').and.returnValue('expected val');
|
||||
|
||||
var spec = new j$.Spec({
|
||||
getSpecName: specNameSpy
|
||||
});
|
||||
|
||||
expect(spec.getFullName()).toBe('expected val');
|
||||
expect(specNameSpy.calls.mostRecent().args[0].id).toEqual(spec.id);
|
||||
});
|
||||
|
||||
it("sets a timeout for async functions to keep them from running forever", function() {
|
||||
var queueRunnerSpy = jasmine.createSpy('queue runner'),
|
||||
setTimeoutSpy = jasmine.createSpy('setTimeout'),
|
||||
spec = new j$.Spec({
|
||||
beforeFns: function() { return [function(done) { }]; },
|
||||
fn: function(done) { },
|
||||
afterFns: function() { return [function(done) { }]; },
|
||||
timer: {
|
||||
setTimeout: setTimeoutSpy,
|
||||
clearTimeout: function() {}
|
||||
},
|
||||
queueRunnerFactory: queueRunnerSpy
|
||||
});
|
||||
|
||||
spec.execute();
|
||||
var fns = queueRunnerSpy.calls.mostRecent().args[0].fns;
|
||||
|
||||
for (var i = 0; i < fns.length; i++) {
|
||||
fns[i]();
|
||||
}
|
||||
|
||||
expect(setTimeoutSpy.calls.count()).toEqual(3);
|
||||
expect(setTimeoutSpy).toHaveBeenCalledWith(jasmine.any(Function), j$.DEFAULT_TIMEOUT_INTERVAL);
|
||||
});
|
||||
|
||||
it("resets the timeout timer when an async before throws an exception", function() {
|
||||
var queueRunnerSpy = jasmine.createSpy('queueRunner'),
|
||||
clearTimeoutSpy = jasmine.createSpy('clear timeout'),
|
||||
spec = new j$.Spec({
|
||||
beforeFns: function() { return [function(done) {}]; },
|
||||
fn: function() { },
|
||||
timer: {
|
||||
setTimeout: function () { return 920; },
|
||||
clearTimeout: clearTimeoutSpy
|
||||
},
|
||||
queueRunnerFactory: queueRunnerSpy
|
||||
});
|
||||
|
||||
spec.execute();
|
||||
queueRunnerSpy.calls.mostRecent().args[0].fns[0]();
|
||||
queueRunnerSpy.calls.mostRecent().args[0].onException(new Error());
|
||||
|
||||
expect(clearTimeoutSpy).toHaveBeenCalledWith(920);
|
||||
});
|
||||
|
||||
it("resets the timeout timer when an async spec throws an exception", function() {
|
||||
var queueRunnerSpy = jasmine.createSpy('queueRunner'),
|
||||
clearTimeoutSpy = jasmine.createSpy('clear timeout'),
|
||||
spec = new j$.Spec({
|
||||
fn: function(done) { },
|
||||
timer: {
|
||||
setTimeout: function () { return 920; },
|
||||
clearTimeout: clearTimeoutSpy
|
||||
},
|
||||
queueRunnerFactory: queueRunnerSpy
|
||||
});
|
||||
|
||||
spec.execute();
|
||||
queueRunnerSpy.calls.mostRecent().args[0].fns[0]();
|
||||
queueRunnerSpy.calls.mostRecent().args[0].onException(new Error());
|
||||
|
||||
expect(clearTimeoutSpy).toHaveBeenCalledWith(920);
|
||||
});
|
||||
|
||||
it("resets the timeout timer when an async after spec throws an exception", function() {
|
||||
var queueRunnerSpy = jasmine.createSpy('queueRunner'),
|
||||
clearTimeoutSpy = jasmine.createSpy('clear timeout'),
|
||||
spec = new j$.Spec({
|
||||
fn: function() { },
|
||||
afterFns: function() { return [function(done) {}]; },
|
||||
timer: {
|
||||
setTimeout: function () { return 920; },
|
||||
clearTimeout: clearTimeoutSpy
|
||||
},
|
||||
queueRunnerFactory: queueRunnerSpy
|
||||
});
|
||||
|
||||
spec.execute();
|
||||
queueRunnerSpy.calls.mostRecent().args[0].fns[1]();
|
||||
queueRunnerSpy.calls.mostRecent().args[0].onException(new Error());
|
||||
|
||||
expect(clearTimeoutSpy).toHaveBeenCalledWith(920);
|
||||
});
|
||||
describe("when a spec is marked pending during execution", function() {
|
||||
it("should mark the spec as pending", function() {
|
||||
var fakeQueueRunner = function(opts) {
|
||||
@@ -228,7 +310,7 @@ describe("Spec", function() {
|
||||
description: 'my test',
|
||||
id: 'some-id',
|
||||
fn: function() { },
|
||||
queueRunner: fakeQueueRunner
|
||||
queueRunnerFactory: fakeQueueRunner
|
||||
});
|
||||
|
||||
spec.execute();
|
||||
|
||||
@@ -14,7 +14,7 @@ describe('Spies', function () {
|
||||
expect(spy.bob).toEqual("test");
|
||||
});
|
||||
|
||||
it("warns the user that we indend to overwrite an existing property", function() {
|
||||
it("warns the user that we intend to overwrite an existing property", function() {
|
||||
TestClass.prototype.someFunction.and = "turkey";
|
||||
|
||||
expect(function() {
|
||||
@@ -28,6 +28,25 @@ describe('Spies', function () {
|
||||
expect(spy.and).toEqual(jasmine.any(j$.SpyStrategy));
|
||||
expect(spy.calls).toEqual(jasmine.any(j$.CallTracker));
|
||||
});
|
||||
|
||||
it("tracks the argument of calls", function () {
|
||||
var spy = j$.createSpy(TestClass.prototype, TestClass.prototype.someFunction);
|
||||
var trackSpy = spyOn(spy.calls, "track");
|
||||
|
||||
spy("arg");
|
||||
|
||||
expect(trackSpy.calls.mostRecent().args[0].args).toEqual(["arg"]);
|
||||
});
|
||||
|
||||
it("tracks the context of calls", function () {
|
||||
var spy = j$.createSpy(TestClass.prototype, TestClass.prototype.someFunction);
|
||||
var trackSpy = spyOn(spy.calls, "track");
|
||||
|
||||
var contextObject = { spyMethod: spy };
|
||||
contextObject.spyMethod();
|
||||
|
||||
expect(trackSpy.calls.mostRecent().args[0].object).toEqual(contextObject);
|
||||
});
|
||||
});
|
||||
|
||||
describe("createSpyObj", function() {
|
||||
|
||||
488
spec/core/integration/EnvSpec.js
Normal file
488
spec/core/integration/EnvSpec.js
Normal file
@@ -0,0 +1,488 @@
|
||||
describe("Env integration", function() {
|
||||
|
||||
it("Suites execute as expected (no nesting)", function(done) {
|
||||
var env = new j$.Env(),
|
||||
calls = [];
|
||||
|
||||
var assertions = function() {
|
||||
expect(calls).toEqual([
|
||||
"with a spec",
|
||||
"and another spec"
|
||||
]);
|
||||
|
||||
done();
|
||||
};
|
||||
|
||||
env.addReporter({ jasmineDone: assertions});
|
||||
|
||||
env.describe("A Suite", function() {
|
||||
env.it("with a spec", function() {
|
||||
calls.push("with a spec");
|
||||
});
|
||||
env.it("and another spec", function() {
|
||||
calls.push("and another spec");
|
||||
});
|
||||
});
|
||||
|
||||
env.execute();
|
||||
});
|
||||
|
||||
it("Nested Suites execute as expected", function(done) {
|
||||
var env = new j$.Env(),
|
||||
calls = [];
|
||||
|
||||
var assertions = function() {
|
||||
expect(calls).toEqual([
|
||||
'an outer spec',
|
||||
'an inner spec',
|
||||
'another inner spec'
|
||||
]);
|
||||
|
||||
done();
|
||||
};
|
||||
|
||||
env.addReporter({ jasmineDone: assertions });
|
||||
|
||||
env.describe("Outer suite", function() {
|
||||
env.it("an outer spec", function() {
|
||||
calls.push('an outer spec')
|
||||
});
|
||||
env.describe("Inner suite", function() {
|
||||
env.it("an inner spec", function() {
|
||||
calls.push('an inner spec');
|
||||
});
|
||||
env.it("another inner spec", function() {
|
||||
calls.push('another inner spec');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
env.execute();
|
||||
});
|
||||
|
||||
it("Multiple top-level Suites execute as expected", function(done) {
|
||||
var env = new j$.Env(),
|
||||
calls = [];
|
||||
|
||||
var assertions = function() {
|
||||
expect(calls).toEqual([
|
||||
'an outer spec',
|
||||
'an inner spec',
|
||||
'another inner spec',
|
||||
'a 2nd outer spec'
|
||||
]);
|
||||
|
||||
done();
|
||||
};
|
||||
|
||||
env.addReporter({ jasmineDone: assertions });
|
||||
|
||||
|
||||
env.describe("Outer suite", function() {
|
||||
env.it("an outer spec", function() {
|
||||
calls.push('an outer spec')
|
||||
});
|
||||
env.describe("Inner suite", function() {
|
||||
env.it("an inner spec", function() {
|
||||
calls.push('an inner spec');
|
||||
});
|
||||
env.it("another inner spec", function() {
|
||||
calls.push('another inner spec');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
env.describe("Another outer suite", function() {
|
||||
env.it("a 2nd outer spec", function() {
|
||||
calls.push('a 2nd outer spec')
|
||||
});
|
||||
});
|
||||
|
||||
env.execute();
|
||||
});
|
||||
|
||||
it("calls associated befores/specs/afters with the same 'this'", function(done) {
|
||||
var env = new j$.Env();
|
||||
|
||||
env.addReporter({jasmineDone: done});
|
||||
|
||||
env.describe("tests", function() {
|
||||
var firstTimeThrough = true, firstSpecContext, secondSpecContext;
|
||||
|
||||
env.beforeEach(function() {
|
||||
if (firstTimeThrough) {
|
||||
firstSpecContext = this;
|
||||
} else {
|
||||
secondSpecContext = this;
|
||||
}
|
||||
expect(this).toEqual({});
|
||||
});
|
||||
|
||||
env.it("sync spec", function() {
|
||||
expect(this).toBe(firstSpecContext);
|
||||
});
|
||||
|
||||
env.it("another sync spec", function() {
|
||||
expect(this).toBe(secondSpecContext);
|
||||
});
|
||||
|
||||
env.afterEach(function() {
|
||||
if (firstTimeThrough) {
|
||||
expect(this).toBe(firstSpecContext);
|
||||
firstTimeThrough = false;
|
||||
} else {
|
||||
expect(this).toBe(secondSpecContext);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
env.execute();
|
||||
});
|
||||
|
||||
it("calls associated befores/its/afters with the same 'this' for an async spec", function(done) {
|
||||
var env = new j$.Env();
|
||||
|
||||
env.addReporter({jasmineDone: done});
|
||||
|
||||
env.describe("with an async spec", function() {
|
||||
var specContext;
|
||||
|
||||
env.beforeEach(function() {
|
||||
specContext = this;
|
||||
expect(this).toEqual({});
|
||||
});
|
||||
|
||||
env.it("sync spec", function(underTestCallback) {
|
||||
expect(this).toBe(specContext);
|
||||
underTestCallback();
|
||||
});
|
||||
|
||||
env.afterEach(function() {
|
||||
expect(this).toBe(specContext);
|
||||
});
|
||||
});
|
||||
|
||||
env.execute();
|
||||
});
|
||||
|
||||
it("Allows specifying which specs and suites to run", function(done) {
|
||||
var env = new j$.Env(),
|
||||
calls = [],
|
||||
suiteCallback = jasmine.createSpy('suite callback'),
|
||||
firstSpec,
|
||||
secondSuite;
|
||||
|
||||
var assertions = function() {
|
||||
expect(calls).toEqual([
|
||||
'third spec',
|
||||
'first spec'
|
||||
]);
|
||||
expect(suiteCallback).toHaveBeenCalled();
|
||||
done();
|
||||
};
|
||||
|
||||
env.addReporter({jasmineDone: assertions, suiteDone: suiteCallback});
|
||||
|
||||
env.describe("first suite", function() {
|
||||
firstSpec = env.it("first spec", function() {
|
||||
calls.push('first spec');
|
||||
});
|
||||
env.it("second spec", function() {
|
||||
calls.push('second spec');
|
||||
});
|
||||
});
|
||||
|
||||
secondSuite = env.describe("second suite", function() {
|
||||
env.it("third spec", function() {
|
||||
calls.push('third spec');
|
||||
});
|
||||
});
|
||||
|
||||
env.execute([secondSuite.id, firstSpec.id]);
|
||||
});
|
||||
|
||||
it("Functions can be spied on and have their calls tracked", function () {
|
||||
var env = new j$.Env();
|
||||
|
||||
var originalFunctionWasCalled = false;
|
||||
var subject = { spiedFunc: function() { originalFunctionWasCalled = true; } };
|
||||
|
||||
var spy = env.spyOn(subject, 'spiedFunc');
|
||||
|
||||
expect(subject.spiedFunc).toEqual(spy);
|
||||
|
||||
expect(subject.spiedFunc.calls.any()).toEqual(false);
|
||||
expect(subject.spiedFunc.calls.count()).toEqual(0);
|
||||
|
||||
subject.spiedFunc('foo');
|
||||
|
||||
expect(subject.spiedFunc.calls.any()).toEqual(true);
|
||||
expect(subject.spiedFunc.calls.count()).toEqual(1);
|
||||
expect(subject.spiedFunc.calls.mostRecent().args).toEqual(['foo']);
|
||||
expect(subject.spiedFunc.calls.mostRecent().object).toEqual(subject);
|
||||
expect(originalFunctionWasCalled).toEqual(false);
|
||||
|
||||
subject.spiedFunc('bar');
|
||||
expect(subject.spiedFunc.calls.count()).toEqual(2);
|
||||
expect(subject.spiedFunc.calls.mostRecent().args).toEqual(['bar']);
|
||||
});
|
||||
|
||||
it("Mock clock can be installed and used in tests", function(done) {
|
||||
var globalSetTimeout = jasmine.createSpy('globalSetTimeout'),
|
||||
delayedFunctionForGlobalClock = jasmine.createSpy('delayedFunctionForGlobalClock'),
|
||||
delayedFunctionForMockClock = jasmine.createSpy('delayedFunctionForMockClock'),
|
||||
env = new j$.Env({global: { setTimeout: globalSetTimeout }});
|
||||
|
||||
var assertions = function() {
|
||||
expect(delayedFunctionForMockClock).toHaveBeenCalled();
|
||||
expect(globalSetTimeout).toHaveBeenCalledWith(delayedFunctionForGlobalClock, 100);
|
||||
|
||||
done();
|
||||
};
|
||||
|
||||
env.addReporter({ jasmineDone: assertions });
|
||||
|
||||
env.describe("tests", function() {
|
||||
env.it("test with mock clock", function() {
|
||||
env.clock.install();
|
||||
env.clock.setTimeout(delayedFunctionForMockClock, 100);
|
||||
env.clock.tick(100);
|
||||
env.clock.uninstall();
|
||||
});
|
||||
env.it("test without mock clock", function() {
|
||||
env.clock.setTimeout(delayedFunctionForGlobalClock, 100);
|
||||
});
|
||||
});
|
||||
|
||||
expect(globalSetTimeout).not.toHaveBeenCalled();
|
||||
expect(delayedFunctionForMockClock).not.toHaveBeenCalled();
|
||||
|
||||
env.execute();
|
||||
});
|
||||
|
||||
it("should run async specs in order, waiting for them to complete", function(done) {
|
||||
var env = new j$.Env(), mutatedVar;
|
||||
|
||||
env.describe("tests", function() {
|
||||
env.beforeEach(function() {
|
||||
mutatedVar = 2;
|
||||
});
|
||||
|
||||
env.it("async spec", function(underTestCallback) {
|
||||
setTimeout(function() {
|
||||
expect(mutatedVar).toEqual(2);
|
||||
underTestCallback();
|
||||
done();
|
||||
}, 0);
|
||||
});
|
||||
|
||||
env.it("after async spec", function() {
|
||||
mutatedVar = 3;
|
||||
});
|
||||
});
|
||||
|
||||
env.execute();
|
||||
});
|
||||
|
||||
describe("with a mock clock", function() {
|
||||
var originalTimeout;
|
||||
|
||||
beforeEach(function() {
|
||||
originalTimeout = j$.DEFAULT_TIMEOUT_INTERVAL;
|
||||
jasmine.getEnv().clock.install();
|
||||
});
|
||||
|
||||
afterEach(function() {
|
||||
jasmine.getEnv().clock.uninstall();
|
||||
j$.DEFAULT_TIMEOUT_INTERVAL = originalTimeout;
|
||||
});
|
||||
|
||||
it("should wait a specified interval before failing specs haven't called done yet", function(done) {
|
||||
var env = new j$.Env(),
|
||||
reporter = jasmine.createSpyObj('fakeReporter', [ "specDone" ]);
|
||||
|
||||
reporter.specDone.and.callFake(function() {
|
||||
expect(reporter.specDone).toHaveBeenCalledWith(jasmine.objectContaining({status: 'failed'}));
|
||||
done();
|
||||
});
|
||||
|
||||
env.addReporter(reporter);
|
||||
j$.DEFAULT_TIMEOUT_INTERVAL = 8414;
|
||||
|
||||
env.it("async spec that doesn't call done", function(underTestCallback) {
|
||||
env.expect(true).toBeTruthy();
|
||||
jasmine.getEnv().clock.tick(8415);
|
||||
});
|
||||
|
||||
env.execute();
|
||||
});
|
||||
});
|
||||
|
||||
// TODO: something is wrong with this spec
|
||||
it("should report as expected", function(done) {
|
||||
var env = new j$.Env(),
|
||||
reporter = jasmine.createSpyObj('fakeReporter', [
|
||||
"jasmineStarted",
|
||||
"jasmineDone",
|
||||
"suiteStarted",
|
||||
"suiteDone",
|
||||
"specStarted",
|
||||
"specDone"
|
||||
]);
|
||||
|
||||
reporter.jasmineDone.and.callFake(function() {
|
||||
expect(reporter.jasmineStarted).toHaveBeenCalledWith({
|
||||
totalSpecsDefined: 3
|
||||
});
|
||||
var suiteResult = reporter.suiteStarted.calls.first().args[0];
|
||||
expect(suiteResult.description).toEqual("A Suite");
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
env.addReporter(reporter);
|
||||
|
||||
env.describe("A Suite", function() {
|
||||
env.it("with a top level spec", function() {
|
||||
env.expect(true).toBe(true);
|
||||
});
|
||||
env.describe("with a nested suite", function() {
|
||||
env.xit("with a pending spec", function() {
|
||||
env.expect(true).toBe(true);
|
||||
});
|
||||
env.it("with a spec", function() {
|
||||
env.expect(true).toBe(false);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
env.execute();
|
||||
});
|
||||
|
||||
it("should be possible to get full name from a spec", function() {
|
||||
var env = new j$.Env({global: { setTimeout: setTimeout }}),
|
||||
topLevelSpec, nestedSpec, doublyNestedSpec;
|
||||
|
||||
env.describe("my tests", function() {
|
||||
topLevelSpec = env.it("are sometimes top level", function() {
|
||||
});
|
||||
env.describe("are sometimes", function() {
|
||||
nestedSpec = env.it("singly nested", function() {
|
||||
});
|
||||
env.describe("even", function() {
|
||||
doublyNestedSpec = env.it("doubly nested", function() {
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
expect(topLevelSpec.getFullName()).toBe("my tests are sometimes top level");
|
||||
expect(nestedSpec.getFullName()).toBe("my tests are sometimes singly nested");
|
||||
expect(doublyNestedSpec.getFullName()).toBe("my tests are sometimes even doubly nested");
|
||||
});
|
||||
|
||||
it("Custom equality testers should be per spec", function(done) {
|
||||
var env = new j$.Env({global: { setTimeout: setTimeout }}),
|
||||
reporter = jasmine.createSpyObj('fakeReporter', [
|
||||
"jasmineStarted",
|
||||
"jasmineDone",
|
||||
"suiteStarted",
|
||||
"suiteDone",
|
||||
"specStarted",
|
||||
"specDone"
|
||||
]);
|
||||
|
||||
reporter.jasmineDone.and.callFake(function() {
|
||||
var firstSpecResult = reporter.specDone.calls.first().args[0],
|
||||
secondSpecResult = reporter.specDone.calls.mostRecent().args[0];
|
||||
|
||||
expect(firstSpecResult.status).toEqual("passed");
|
||||
expect(secondSpecResult.status).toEqual("failed");
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
env.addReporter(reporter);
|
||||
|
||||
env.describe("testing custom equality testers", function() {
|
||||
env.it("with a custom tester", function() {
|
||||
env.addCustomEqualityTester(function(a, b) { return true; });
|
||||
env.expect("a").toEqual("b");
|
||||
});
|
||||
|
||||
env.it("without a custom tester", function() {
|
||||
env.expect("a").toEqual("b");
|
||||
});
|
||||
});
|
||||
|
||||
env.execute();
|
||||
});
|
||||
|
||||
it("Custom matchers should be per spec", function() {
|
||||
var env = new j$.Env({global: { setTimeout: setTimeout }}),
|
||||
matchers = {
|
||||
toFoo: function() {}
|
||||
},
|
||||
reporter = jasmine.createSpyObj('fakeReporter', [
|
||||
"jasmineStarted",
|
||||
"jasmineDone",
|
||||
"suiteStarted",
|
||||
"suiteDone",
|
||||
"specStarted",
|
||||
"specDone"
|
||||
]);
|
||||
|
||||
env.addReporter(reporter);
|
||||
|
||||
env.describe("testing custom matchers", function() {
|
||||
env.it("with a custom matcher", function() {
|
||||
env.addMatchers(matchers);
|
||||
expect(env.expect().toFoo).toBeDefined();
|
||||
});
|
||||
|
||||
env.it("without a custom matcher", function() {
|
||||
expect(env.expect().toFoo).toBeUndefined();
|
||||
});
|
||||
});
|
||||
|
||||
env.execute();
|
||||
});
|
||||
|
||||
it("Custom equality testers for toContain should be per spec", function(done) {
|
||||
var env = new j$.Env({global: { setTimeout: setTimeout }}),
|
||||
reporter = jasmine.createSpyObj('fakeReporter', [
|
||||
"jasmineStarted",
|
||||
"jasmineDone",
|
||||
"suiteStarted",
|
||||
"suiteDone",
|
||||
"specStarted",
|
||||
"specDone"
|
||||
]);
|
||||
|
||||
reporter.jasmineDone.and.callFake(function() {
|
||||
var firstSpecResult = reporter.specDone.calls.first().args[0],
|
||||
secondSpecResult = reporter.specDone.calls.mostRecent().args[0];
|
||||
|
||||
expect(firstSpecResult.status).toEqual("passed");
|
||||
expect(secondSpecResult.status).toEqual("failed");
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
env.addReporter(reporter);
|
||||
|
||||
env.describe("testing custom equality testers", function() {
|
||||
env.it("with a custom tester", function() {
|
||||
env.addCustomEqualityTester(function(a, b) { return true; });
|
||||
env.expect(["a"]).toContain("b");
|
||||
});
|
||||
|
||||
env.it("without a custom tester", function() {
|
||||
env.expect("a").toContain("b");
|
||||
});
|
||||
});
|
||||
|
||||
env.execute();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
// TODO: This should really be part of the Env Integration Spec
|
||||
describe("jasmine spec running", function () {
|
||||
var env;
|
||||
var fakeTimer;
|
||||
@@ -1,6 +1,6 @@
|
||||
describe("matchersUtil", function() {
|
||||
describe("equals", function() {
|
||||
it("passes for literals that are threequal", function() {
|
||||
it("passes for literals that are triple-equal", function() {
|
||||
expect(j$.matchersUtil.equals(null, null)).toBe(true);
|
||||
expect(j$.matchersUtil.equals(void 0, void 0)).toBe(true);
|
||||
});
|
||||
|
||||
@@ -246,7 +246,7 @@ describe("toThrowError", function() {
|
||||
expect(result.message).toEqual("Expected function to throw TypeError with message \"bar\", but it threw TypeError with message \"foo\".");
|
||||
});
|
||||
|
||||
it("passes if thrown is a type of Error and has the same type as the expected Error and the message matches the exepcted message", function() {
|
||||
it("passes if thrown is a type of Error and has the same type as the expected Error and the message matches the expected message", function() {
|
||||
var util = {
|
||||
equals: jasmine.createSpy('delegated-equal').and.returnValue(true)
|
||||
},
|
||||
|
||||
@@ -15,10 +15,10 @@ getJasmineRequireObj().ConsoleReporter = function() {
|
||||
failedSpecs = [],
|
||||
pendingCount,
|
||||
ansi = {
|
||||
green: '\033[32m',
|
||||
red: '\033[31m',
|
||||
yellow: '\033[33m',
|
||||
none: '\033[0m'
|
||||
green: '\x1B[32m',
|
||||
red: '\x1B[31m',
|
||||
yellow: '\x1B[33m',
|
||||
none: '\x1B[0m'
|
||||
};
|
||||
|
||||
this.jasmineStarted = function() {
|
||||
|
||||
@@ -1,14 +1,17 @@
|
||||
getJasmineRequireObj().DelayedFunctionScheduler = function() {
|
||||
function DelayedFunctionScheduler() {
|
||||
var self = this;
|
||||
var scheduledLookup = [];
|
||||
var scheduledFunctions = {};
|
||||
var currentTime = 0;
|
||||
var delayedFnCount = 0;
|
||||
|
||||
self.tick = function(millis) {
|
||||
millis = millis || 0;
|
||||
currentTime = currentTime + millis;
|
||||
runFunctionsWithinRange(currentTime - millis, currentTime);
|
||||
var endTime = currentTime + millis;
|
||||
|
||||
runScheduledFunctions(endTime);
|
||||
currentTime = endTime;
|
||||
};
|
||||
|
||||
self.scheduleFunction = function(funcToCall, millis, params, recurring, timeoutKey, runAtMillis) {
|
||||
@@ -24,7 +27,8 @@ getJasmineRequireObj().DelayedFunctionScheduler = function() {
|
||||
millis = millis || 0;
|
||||
timeoutKey = timeoutKey || ++delayedFnCount;
|
||||
runAtMillis = runAtMillis || (currentTime + millis);
|
||||
scheduledFunctions[timeoutKey] = {
|
||||
|
||||
var funcToSchedule = {
|
||||
runAtMillis: runAtMillis,
|
||||
funcToCall: f,
|
||||
recurring: recurring,
|
||||
@@ -32,58 +36,73 @@ getJasmineRequireObj().DelayedFunctionScheduler = function() {
|
||||
timeoutKey: timeoutKey,
|
||||
millis: millis
|
||||
};
|
||||
|
||||
if (runAtMillis in scheduledFunctions) {
|
||||
scheduledFunctions[runAtMillis].push(funcToSchedule);
|
||||
} else {
|
||||
scheduledFunctions[runAtMillis] = [funcToSchedule];
|
||||
scheduledLookup.push(runAtMillis);
|
||||
scheduledLookup.sort(function (a, b) {
|
||||
return a - b;
|
||||
});
|
||||
}
|
||||
|
||||
return timeoutKey;
|
||||
};
|
||||
|
||||
self.removeFunctionWithId = function(timeoutKey) {
|
||||
delete scheduledFunctions[timeoutKey];
|
||||
for (var runAtMillis in scheduledFunctions) {
|
||||
var funcs = scheduledFunctions[runAtMillis];
|
||||
var i = indexOfFirstToPass(funcs, function (func) {
|
||||
return func.timeoutKey === timeoutKey;
|
||||
});
|
||||
|
||||
if (i > -1) {
|
||||
if (funcs.length === 1) {
|
||||
delete scheduledFunctions[runAtMillis];
|
||||
deleteFromLookup(runAtMillis);
|
||||
} else {
|
||||
funcs.splice(i, 1);
|
||||
}
|
||||
|
||||
// intervals get rescheduled when executed, so there's never more
|
||||
// than a single scheduled function with a given timeoutKey
|
||||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
self.reset = function() {
|
||||
currentTime = 0;
|
||||
scheduledLookup = [];
|
||||
scheduledFunctions = {};
|
||||
delayedFnCount = 0;
|
||||
};
|
||||
|
||||
return self;
|
||||
|
||||
// finds/dupes functions within range and removes them.
|
||||
function functionsWithinRange(startMillis, endMillis) {
|
||||
var fnsToRun = [];
|
||||
for (var timeoutKey in scheduledFunctions) {
|
||||
var scheduledFunc = scheduledFunctions[timeoutKey];
|
||||
if (scheduledFunc &&
|
||||
scheduledFunc.runAtMillis >= startMillis &&
|
||||
scheduledFunc.runAtMillis <= endMillis) {
|
||||
function indexOfFirstToPass(array, testFn) {
|
||||
var index = -1;
|
||||
|
||||
// remove fn -- we'll reschedule later if it is recurring.
|
||||
self.removeFunctionWithId(timeoutKey);
|
||||
if (!scheduledFunc.recurring) {
|
||||
fnsToRun.push(scheduledFunc); // schedules each function only once
|
||||
} else {
|
||||
fnsToRun.push(buildNthInstanceOf(scheduledFunc, 0));
|
||||
var additionalTimesFnRunsInRange =
|
||||
Math.floor((endMillis - scheduledFunc.runAtMillis) / scheduledFunc.millis);
|
||||
for (var i = 0; i < additionalTimesFnRunsInRange; i++) {
|
||||
fnsToRun.push(buildNthInstanceOf(scheduledFunc, i + 1));
|
||||
}
|
||||
reschedule(buildNthInstanceOf(scheduledFunc, additionalTimesFnRunsInRange));
|
||||
}
|
||||
for (var i = 0; i < array.length; ++i) {
|
||||
if (testFn(array[i])) {
|
||||
index = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return fnsToRun;
|
||||
return index;
|
||||
}
|
||||
|
||||
function buildNthInstanceOf(scheduledFunc, n) {
|
||||
return {
|
||||
runAtMillis: scheduledFunc.runAtMillis + (scheduledFunc.millis * n),
|
||||
funcToCall: scheduledFunc.funcToCall,
|
||||
params: scheduledFunc.params,
|
||||
millis: scheduledFunc.millis,
|
||||
recurring: scheduledFunc.recurring,
|
||||
timeoutKey: scheduledFunc.timeoutKey
|
||||
};
|
||||
function deleteFromLookup(key) {
|
||||
var value = Number(key);
|
||||
var i = indexOfFirstToPass(scheduledLookup, function (millis) {
|
||||
return millis === value;
|
||||
});
|
||||
|
||||
if (i > -1) {
|
||||
scheduledLookup.splice(i, 1);
|
||||
}
|
||||
}
|
||||
|
||||
function reschedule(scheduledFn) {
|
||||
@@ -95,21 +114,30 @@ getJasmineRequireObj().DelayedFunctionScheduler = function() {
|
||||
scheduledFn.runAtMillis + scheduledFn.millis);
|
||||
}
|
||||
|
||||
|
||||
function runFunctionsWithinRange(startMillis, endMillis) {
|
||||
var funcsToRun = functionsWithinRange(startMillis, endMillis);
|
||||
if (funcsToRun.length === 0) {
|
||||
function runScheduledFunctions(endTime) {
|
||||
if (scheduledLookup.length === 0 || scheduledLookup[0] > endTime) {
|
||||
return;
|
||||
}
|
||||
|
||||
funcsToRun.sort(function(a, b) {
|
||||
return a.runAtMillis - b.runAtMillis;
|
||||
});
|
||||
do {
|
||||
currentTime = scheduledLookup.shift();
|
||||
|
||||
for (var i = 0; i < funcsToRun.length; ++i) {
|
||||
var funcToRun = funcsToRun[i];
|
||||
funcToRun.funcToCall.apply(null, funcToRun.params || []);
|
||||
}
|
||||
var funcsToRun = scheduledFunctions[currentTime];
|
||||
delete scheduledFunctions[currentTime];
|
||||
|
||||
for (var i = 0; i < funcsToRun.length; ++i) {
|
||||
var funcToRun = funcsToRun[i];
|
||||
funcToRun.funcToCall.apply(null, funcToRun.params || []);
|
||||
|
||||
if (funcToRun.recurring) {
|
||||
reschedule(funcToRun);
|
||||
}
|
||||
}
|
||||
} while (scheduledLookup.length > 0 &&
|
||||
// checking first if we're out of time prevents setTimeout(0)
|
||||
// scheduled in a funcToRun from forcing an extra iteration
|
||||
currentTime !== endTime &&
|
||||
scheduledLookup[0] <= endTime);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -270,7 +270,7 @@ getJasmineRequireObj().Env = function(j$) {
|
||||
onStart: specStarted,
|
||||
description: description,
|
||||
expectationResultFactory: expectationResultFactory,
|
||||
queueRunner: queueRunnerFactory,
|
||||
queueRunnerFactory: queueRunnerFactory,
|
||||
fn: fn,
|
||||
timer: {setTimeout: realSetTimeout, clearTimeout: realClearTimeout}
|
||||
});
|
||||
|
||||
@@ -5,14 +5,13 @@ getJasmineRequireObj().Spec = function(j$) {
|
||||
this.id = attrs.id;
|
||||
this.description = attrs.description || '';
|
||||
this.fn = attrs.fn;
|
||||
this.beforeFns = attrs.beforeFns || function() {};
|
||||
this.afterFns = attrs.afterFns || function() {};
|
||||
this.catchingExceptions = attrs.catchingExceptions;
|
||||
this.beforeFns = attrs.beforeFns || function() { return []; };
|
||||
this.afterFns = attrs.afterFns || function() { return []; };
|
||||
this.onStart = attrs.onStart || function() {};
|
||||
this.exceptionFormatter = attrs.exceptionFormatter || function() {};
|
||||
this.getSpecName = attrs.getSpecName || function() { return ''; };
|
||||
this.expectationResultFactory = attrs.expectationResultFactory || function() { };
|
||||
this.queueRunner = attrs.queueRunner || function() {};
|
||||
this.queueRunnerFactory = attrs.queueRunnerFactory || function() {};
|
||||
this.catchingExceptions = attrs.catchingExceptions || function() { return true; };
|
||||
|
||||
this.timer = attrs.timer || {setTimeout: setTimeout, clearTimeout: clearTimeout};
|
||||
@@ -41,7 +40,8 @@ getJasmineRequireObj().Spec = function(j$) {
|
||||
};
|
||||
|
||||
Spec.prototype.execute = function(onComplete) {
|
||||
var self = this;
|
||||
var self = this,
|
||||
timeout;
|
||||
|
||||
this.onStart(this);
|
||||
|
||||
@@ -52,13 +52,13 @@ getJasmineRequireObj().Spec = function(j$) {
|
||||
|
||||
function timeoutable(fn) {
|
||||
return function(done) {
|
||||
var timeout = Function.prototype.apply.apply(self.timer.setTimeout, [j$.getGlobal(), [function() {
|
||||
timeout = Function.prototype.apply.apply(self.timer.setTimeout, [j$.getGlobal(), [function() {
|
||||
onException(new Error('Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL.'));
|
||||
done();
|
||||
}, j$.DEFAULT_TIMEOUT_INTERVAL]]);
|
||||
|
||||
var callDone = function() {
|
||||
Function.prototype.apply.apply(self.timer.clearTimeout, [j$.getGlobal(), [timeout]]);
|
||||
clearTimeoutable();
|
||||
done();
|
||||
};
|
||||
|
||||
@@ -66,18 +66,26 @@ getJasmineRequireObj().Spec = function(j$) {
|
||||
};
|
||||
}
|
||||
|
||||
var befores = this.beforeFns() || [],
|
||||
afters = this.afterFns() || [],
|
||||
thisOne = (this.fn.length) ? timeoutable(this.fn) : this.fn;
|
||||
var allFns = befores.concat(thisOne).concat(afters);
|
||||
function clearTimeoutable() {
|
||||
Function.prototype.apply.apply(self.timer.clearTimeout, [j$.getGlobal(), [timeout]]);
|
||||
timeout = void 0;
|
||||
}
|
||||
|
||||
this.queueRunner({
|
||||
fns: allFns,
|
||||
var allFns = this.beforeFns().concat(this.fn).concat(this.afterFns()),
|
||||
allTimeoutableFns = [];
|
||||
for (var i = 0; i < allFns.length; i++) {
|
||||
var fn = allFns[i];
|
||||
allTimeoutableFns.push(fn.length > 0 ? timeoutable(fn) : fn);
|
||||
}
|
||||
|
||||
this.queueRunnerFactory({
|
||||
fns: allTimeoutableFns,
|
||||
onException: onException,
|
||||
onComplete: complete
|
||||
});
|
||||
|
||||
function onException(e) {
|
||||
clearTimeoutable();
|
||||
if (Spec.isPendingSpecException(e)) {
|
||||
self.pend();
|
||||
return;
|
||||
|
||||
@@ -6,13 +6,12 @@ getJasmineRequireObj().base = function(j$) {
|
||||
j$.MAX_PRETTY_PRINT_DEPTH = 40;
|
||||
j$.DEFAULT_TIMEOUT_INTERVAL = 5000;
|
||||
|
||||
j$.getGlobal = function() {
|
||||
function getGlobal() {
|
||||
return this;
|
||||
}
|
||||
|
||||
return getGlobal();
|
||||
};
|
||||
j$.getGlobal = (function() {
|
||||
var jasmineGlobal = eval.call(null, "this");
|
||||
return function() {
|
||||
return jasmineGlobal;
|
||||
};
|
||||
})();
|
||||
|
||||
j$.getEnv = function(options) {
|
||||
var env = j$.currentEnv_ = j$.currentEnv_ || new j$.Env(options);
|
||||
|
||||
Reference in New Issue
Block a user