beforeAll can have expectations and passes expectation failures to its children
[#66789174]
This commit is contained in:
@@ -79,6 +79,14 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|||||||
return env.afterEach(afterEachFunction);
|
return env.afterEach(afterEachFunction);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
beforeAll: function(beforeAllFunction) {
|
||||||
|
return env.beforeAll(beforeAllFunction);
|
||||||
|
},
|
||||||
|
|
||||||
|
afterAll: function(afterAllFunction) {
|
||||||
|
return env.afterAll(afterAllFunction);
|
||||||
|
},
|
||||||
|
|
||||||
expect: function(actual) {
|
expect: function(actual) {
|
||||||
return env.expect(actual);
|
return env.expect(actual);
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -57,6 +57,14 @@
|
|||||||
return env.afterEach(afterEachFunction);
|
return env.afterEach(afterEachFunction);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
beforeAll: function(beforeAllFunction) {
|
||||||
|
return env.beforeAll(beforeAllFunction);
|
||||||
|
},
|
||||||
|
|
||||||
|
afterAll: function(afterAllFunction) {
|
||||||
|
return env.afterAll(afterAllFunction);
|
||||||
|
},
|
||||||
|
|
||||||
expect: function(actual) {
|
expect: function(actual) {
|
||||||
return env.expect(actual);
|
return env.expect(actual);
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -599,6 +599,7 @@ getJasmineRequireObj().Env = function(j$) {
|
|||||||
parentSuite: currentDeclarationSuite,
|
parentSuite: currentDeclarationSuite,
|
||||||
queueRunner: queueRunnerFactory,
|
queueRunner: queueRunnerFactory,
|
||||||
onStart: suiteStarted,
|
onStart: suiteStarted,
|
||||||
|
expectationFactory: expectationFactory,
|
||||||
resultCallback: function(attrs) {
|
resultCallback: function(attrs) {
|
||||||
if (!suite.disabled) {
|
if (!suite.disabled) {
|
||||||
clearResourcesForRunnable(suite.id);
|
clearResourcesForRunnable(suite.id);
|
||||||
@@ -704,7 +705,7 @@ getJasmineRequireObj().Env = function(j$) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
this.expect = function(actual) {
|
this.expect = function(actual) {
|
||||||
return currentSpec.expect(actual);
|
return currentRunnable().expect(actual);
|
||||||
};
|
};
|
||||||
|
|
||||||
this.beforeEach = function(beforeEachFunction) {
|
this.beforeEach = function(beforeEachFunction) {
|
||||||
@@ -1795,6 +1796,7 @@ getJasmineRequireObj().Suite = function() {
|
|||||||
this.onStart = attrs.onStart || function() {};
|
this.onStart = attrs.onStart || function() {};
|
||||||
this.resultCallback = attrs.resultCallback || function() {};
|
this.resultCallback = attrs.resultCallback || function() {};
|
||||||
this.clearStack = attrs.clearStack || function(fn) {fn();};
|
this.clearStack = attrs.clearStack || function(fn) {fn();};
|
||||||
|
this.expectationFactory = attrs.expectationFactory;
|
||||||
|
|
||||||
this.beforeFns = [];
|
this.beforeFns = [];
|
||||||
this.afterFns = [];
|
this.afterFns = [];
|
||||||
@@ -1813,6 +1815,10 @@ getJasmineRequireObj().Suite = function() {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Suite.prototype.expect = function(actual) {
|
||||||
|
return this.expectationFactory(actual, this);
|
||||||
|
};
|
||||||
|
|
||||||
Suite.prototype.getFullName = function() {
|
Suite.prototype.getFullName = function() {
|
||||||
var fullName = this.description;
|
var fullName = this.description;
|
||||||
for (var parentSuite = this.parentSuite; parentSuite; parentSuite = parentSuite.parentSuite) {
|
for (var parentSuite = this.parentSuite; parentSuite; parentSuite = parentSuite.parentSuite) {
|
||||||
@@ -1918,6 +1924,13 @@ getJasmineRequireObj().Suite = function() {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Suite.prototype.addExpectationResult = function () {
|
||||||
|
for (var i = 0; i < this.children.length; i++) {
|
||||||
|
var child = this.children[i];
|
||||||
|
child.addExpectationResult.apply(child, arguments);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
function clone(obj) {
|
function clone(obj) {
|
||||||
var clonedObj = {};
|
var clonedObj = {};
|
||||||
for (var prop in obj) {
|
for (var prop in obj) {
|
||||||
|
|||||||
@@ -290,6 +290,44 @@ describe("Env integration", function() {
|
|||||||
env.execute();
|
env.execute();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("fails all underlying specs when the beforeAll fails", function (done) {
|
||||||
|
var env = new j$.Env(),
|
||||||
|
reporter = jasmine.createSpyObj('fakeReporter', [ "specDone", "jasmineDone" ]);
|
||||||
|
|
||||||
|
reporter.jasmineDone.and.callFake(function() {
|
||||||
|
expect(reporter.specDone.calls.count()).toEqual(2);
|
||||||
|
|
||||||
|
expect(reporter.specDone.calls.argsFor(0)[0])
|
||||||
|
.toEqual(jasmine.objectContaining({status: 'failed'}));
|
||||||
|
expect(reporter.specDone.calls.argsFor(0)[0].failedExpectations[0].message)
|
||||||
|
.toEqual("Expected 1 to be 2.");
|
||||||
|
|
||||||
|
expect(reporter.specDone.calls.argsFor(1)[0])
|
||||||
|
.toEqual(jasmine.objectContaining({status: 'failed'}));
|
||||||
|
expect(reporter.specDone.calls.argsFor(1)[0].failedExpectations[0].message)
|
||||||
|
.toEqual("Expected 1 to be 2.");
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
|
||||||
|
env.addReporter(reporter);
|
||||||
|
|
||||||
|
env.describe('A suite', function(){
|
||||||
|
env.beforeAll(function() {
|
||||||
|
env.expect(1).toBe(2);
|
||||||
|
});
|
||||||
|
|
||||||
|
env.it("spec that will be failed", function() {
|
||||||
|
});
|
||||||
|
|
||||||
|
env.describe("nesting", function() {
|
||||||
|
env.it("another spec to fail", function() {
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
env.execute();
|
||||||
|
});
|
||||||
|
|
||||||
it("Allows specifying which specs and suites to run", function(done) {
|
it("Allows specifying which specs and suites to run", function(done) {
|
||||||
var env = new j$.Env(),
|
var env = new j$.Env(),
|
||||||
calls = [],
|
calls = [],
|
||||||
@@ -871,5 +909,4 @@ describe("Env integration", function() {
|
|||||||
|
|
||||||
env.execute();
|
env.execute();
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -225,6 +225,7 @@ getJasmineRequireObj().Env = function(j$) {
|
|||||||
parentSuite: currentDeclarationSuite,
|
parentSuite: currentDeclarationSuite,
|
||||||
queueRunner: queueRunnerFactory,
|
queueRunner: queueRunnerFactory,
|
||||||
onStart: suiteStarted,
|
onStart: suiteStarted,
|
||||||
|
expectationFactory: expectationFactory,
|
||||||
resultCallback: function(attrs) {
|
resultCallback: function(attrs) {
|
||||||
if (!suite.disabled) {
|
if (!suite.disabled) {
|
||||||
clearResourcesForRunnable(suite.id);
|
clearResourcesForRunnable(suite.id);
|
||||||
@@ -330,7 +331,7 @@ getJasmineRequireObj().Env = function(j$) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
this.expect = function(actual) {
|
this.expect = function(actual) {
|
||||||
return currentSpec.expect(actual);
|
return currentRunnable().expect(actual);
|
||||||
};
|
};
|
||||||
|
|
||||||
this.beforeEach = function(beforeEachFunction) {
|
this.beforeEach = function(beforeEachFunction) {
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ getJasmineRequireObj().Suite = function() {
|
|||||||
this.onStart = attrs.onStart || function() {};
|
this.onStart = attrs.onStart || function() {};
|
||||||
this.resultCallback = attrs.resultCallback || function() {};
|
this.resultCallback = attrs.resultCallback || function() {};
|
||||||
this.clearStack = attrs.clearStack || function(fn) {fn();};
|
this.clearStack = attrs.clearStack || function(fn) {fn();};
|
||||||
|
this.expectationFactory = attrs.expectationFactory;
|
||||||
|
|
||||||
this.beforeFns = [];
|
this.beforeFns = [];
|
||||||
this.afterFns = [];
|
this.afterFns = [];
|
||||||
@@ -25,6 +26,10 @@ getJasmineRequireObj().Suite = function() {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Suite.prototype.expect = function(actual) {
|
||||||
|
return this.expectationFactory(actual, this);
|
||||||
|
};
|
||||||
|
|
||||||
Suite.prototype.getFullName = function() {
|
Suite.prototype.getFullName = function() {
|
||||||
var fullName = this.description;
|
var fullName = this.description;
|
||||||
for (var parentSuite = this.parentSuite; parentSuite; parentSuite = parentSuite.parentSuite) {
|
for (var parentSuite = this.parentSuite; parentSuite; parentSuite = parentSuite.parentSuite) {
|
||||||
@@ -130,6 +135,13 @@ getJasmineRequireObj().Suite = function() {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Suite.prototype.addExpectationResult = function () {
|
||||||
|
for (var i = 0; i < this.children.length; i++) {
|
||||||
|
var child = this.children[i];
|
||||||
|
child.addExpectationResult.apply(child, arguments);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
function clone(obj) {
|
function clone(obj) {
|
||||||
var clonedObj = {};
|
var clonedObj = {};
|
||||||
for (var prop in obj) {
|
for (var prop in obj) {
|
||||||
|
|||||||
Reference in New Issue
Block a user