Implement TreeProcessor to solve some issues with running the suite

- execute beforeAll/afterAll once per suite instead of once per child
  when running focused specs/suites Fixes #773
- refuse to execute an order if it would cause a suite with a beforeAll
  or afterAll to be re-entered after leaving once
- report children of an xdescribe similarly to how they would be
  reported if they were themselves x'd out Fixes #774
- only process the tree once instead of figuring it out again at each
  level

[finishes #87545620]
Fixes #776
This commit is contained in:
slackersoft
2015-02-27 11:16:53 -08:00
committed by Chris Amavisca and Gregg Van Hove
parent 0c68cc4afc
commit 715de7aa38
11 changed files with 1289 additions and 503 deletions

View File

@@ -1,6 +1,5 @@
describe("jasmine spec running", function () {
var env;
var fakeTimer;
beforeEach(function() {
env = new j$.Env();
@@ -61,13 +60,17 @@ describe("jasmine spec running", function () {
expect(bar).toEqual(0);
expect(baz).toEqual(0);
expect(quux).toEqual(0);
nested.execute(function() {
var assertions = function() {
expect(foo).toEqual(1);
expect(bar).toEqual(1);
expect(baz).toEqual(1);
expect(quux).toEqual(1);
done();
});
};
env.addReporter({ jasmineDone: assertions });
env.execute();
});
it("should permit nested describes", function(done) {
@@ -289,7 +292,7 @@ describe("jasmine spec running", function () {
env.execute();
});
it('should run beforeAlls and afterAlls as beforeEachs and afterEachs in the order declared when runnablesToRun is provided', function(done) {
it('should run beforeAlls and afterAlls in the order declared when runnablesToRun is provided', function(done) {
var actions = [],
spec,
spec2;
@@ -342,17 +345,13 @@ describe("jasmine spec running", function () {
"inner beforeAll",
"runner beforeEach",
"inner beforeEach",
"it",
"it2",
"inner afterEach",
"runner afterEach",
"inner afterAll",
"runner afterAll",
"runner beforeAll",
"inner beforeAll",
"runner beforeEach",
"inner beforeEach",
"it2",
"it",
"inner afterEach",
"runner afterEach",
"inner afterAll",
@@ -363,7 +362,7 @@ describe("jasmine spec running", function () {
};
env.addReporter({jasmineDone: assertions});
env.execute([spec.id, spec2.id]);
env.execute([spec2.id, spec.id]);
});
it('only runs *Alls once in a focused suite', function(done){
@@ -416,9 +415,7 @@ describe("jasmine spec running", function () {
'beforeEach',
'spec in fdescribe',
'afterEach',
'afterAll',
'beforeAll',
'beforeEach',
'focused spec',
'afterEach',
@@ -549,10 +546,14 @@ describe("jasmine spec running", function () {
pendingSpec = env.it("I am a pending spec");
});
suite.execute(function() {
var assertions = function() {
expect(pendingSpec.status()).toBe("pending");
done();
});
};
env.addReporter({jasmineDone: assertions});
env.execute();
});
// TODO: is this useful? It doesn't catch syntax errors
@@ -603,4 +604,96 @@ describe("jasmine spec running", function () {
));
});
it("re-enters suites that have no *Alls", function(done) {
var actions = [],
spec1, spec2, spec3;
env.describe("top", function() {
spec1 = env.it("spec1", function() {
actions.push("spec1");
});
spec2 = env.it("spec2", function() {
actions.push("spec2");
});
});
spec3 = env.it("spec3", function() {
actions.push("spec3");
});
env.addReporter({
jasmineDone: function() {
expect(actions).toEqual(["spec2", "spec3", "spec1"]);
done();
}
});
env.execute([spec2.id, spec3.id, spec1.id]);
});
it("refuses to re-enter suites with a beforeAll", function() {
var actions = [],
spec1, spec2, spec3;
env.describe("top", function() {
env.beforeAll(function() {});
spec1 = env.it("spec1", function() {
actions.push("spec1");
});
spec2 = env.it("spec2", function() {
actions.push("spec2");
});
});
spec3 = env.it("spec3", function() {
actions.push("spec3");
});
env.addReporter({
jasmineDone: function() {
expect(actions).toEqual([]);
done();
}
});
expect(function() {
env.execute([spec2.id, spec3.id, spec1.id]);
}).toThrowError(/beforeAll/);
});
it("refuses to re-enter suites with a afterAll", function() {
var actions = [],
spec1, spec2, spec3;
env.describe("top", function() {
env.afterAll(function() {});
spec1 = env.it("spec1", function() {
actions.push("spec1");
});
spec2 = env.it("spec2", function() {
actions.push("spec2");
});
});
spec3 = env.it("spec3", function() {
actions.push("spec3");
});
env.addReporter({
jasmineDone: function() {
expect(actions).toEqual([]);
done();
}
});
expect(function() {
env.execute([spec2.id, spec3.id, spec1.id]);
}).toThrowError(/afterAll/);
});
});