Specs/Suites wait for an async spec to finish
Go back to having all suites and specs run asynchronously so that they properly wait for any async specs that there might be
This commit is contained in:
@@ -1323,13 +1323,10 @@ getJasmineRequireObj().QueueRunner = function() {
|
||||
}
|
||||
}
|
||||
|
||||
var runnerDone = iterativeIndex >= length,
|
||||
hasBeenAsyncSpec = recursiveIndex > 0;
|
||||
var runnerDone = iterativeIndex >= length;
|
||||
|
||||
if (runnerDone && hasBeenAsyncSpec) {
|
||||
if (runnerDone) {
|
||||
this.clearStack(this.onComplete);
|
||||
} else if(runnerDone) {
|
||||
this.onComplete();
|
||||
}
|
||||
|
||||
function attempt(fn) {
|
||||
@@ -1550,7 +1547,7 @@ getJasmineRequireObj().Suite = function() {
|
||||
children = this.children_;
|
||||
|
||||
for (var i = 0; i < children.length; i++) {
|
||||
allFns.push(wrapChild(children[i]));
|
||||
allFns.push(wrapChildAsAsync(children[i]));
|
||||
}
|
||||
|
||||
this.onStart(this);
|
||||
@@ -1568,8 +1565,8 @@ getJasmineRequireObj().Suite = function() {
|
||||
}
|
||||
}
|
||||
|
||||
function wrapChild(child) {
|
||||
return function() { child.execute(); };
|
||||
function wrapChildAsAsync(child) {
|
||||
return function(done) { child.execute(done); };
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -189,6 +189,30 @@ describe("Env integration", function() {
|
||||
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();
|
||||
});
|
||||
|
||||
// TODO: something is wrong with this spec
|
||||
it("should report as expected", function(done) {
|
||||
var env = new j$.Env(),
|
||||
|
||||
@@ -127,7 +127,7 @@ describe("QueueRunner", function() {
|
||||
expect(completeCallback).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("with an async spec, calls a provided stack clearing function when done", function() {
|
||||
it("calls a provided stack clearing function when done", function() {
|
||||
var asyncFn = function(done) { done() },
|
||||
afterFn = jasmine.createSpy('afterFn'),
|
||||
completeCallback = jasmine.createSpy('completeCallback'),
|
||||
|
||||
@@ -32,13 +32,10 @@ getJasmineRequireObj().QueueRunner = function() {
|
||||
}
|
||||
}
|
||||
|
||||
var runnerDone = iterativeIndex >= length,
|
||||
hasBeenAsyncSpec = recursiveIndex > 0;
|
||||
var runnerDone = iterativeIndex >= length;
|
||||
|
||||
if (runnerDone && hasBeenAsyncSpec) {
|
||||
if (runnerDone) {
|
||||
this.clearStack(this.onComplete);
|
||||
} else if(runnerDone) {
|
||||
this.onComplete();
|
||||
}
|
||||
|
||||
function attempt(fn) {
|
||||
|
||||
@@ -74,7 +74,7 @@ getJasmineRequireObj().Suite = function() {
|
||||
children = this.children_;
|
||||
|
||||
for (var i = 0; i < children.length; i++) {
|
||||
allFns.push(wrapChild(children[i]));
|
||||
allFns.push(wrapChildAsAsync(children[i]));
|
||||
}
|
||||
|
||||
this.onStart(this);
|
||||
@@ -92,8 +92,8 @@ getJasmineRequireObj().Suite = function() {
|
||||
}
|
||||
}
|
||||
|
||||
function wrapChild(child) {
|
||||
return function() { child.execute(); };
|
||||
function wrapChildAsAsync(child) {
|
||||
return function(done) { child.execute(done); };
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user