Suite result status added when suite is complete
- This makes it easier to detect afterAll failures, because we can rely only complete runnables having statuses [#78306786 & #73741654]
This commit is contained in:
@@ -643,12 +643,14 @@ getJasmineRequireObj().Env = function(j$) {
|
|||||||
return suite;
|
return suite;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var focusedRunnables = [];
|
||||||
|
|
||||||
this.fdescribe = function(description, specDefinitions) {
|
this.fdescribe = function(description, specDefinitions) {
|
||||||
var suite = suiteFactory(description);
|
var suite = suiteFactory(description);
|
||||||
suite.isFocused = true;
|
suite.isFocused = true;
|
||||||
|
|
||||||
focusedRunnables.push(suite.id);
|
focusedRunnables.push(suite.id);
|
||||||
unfocusAncestors();
|
unfocusAncestor();
|
||||||
addSpecsToSuite(suite, specDefinitions);
|
addSpecsToSuite(suite, specDefinitions);
|
||||||
|
|
||||||
return suite;
|
return suite;
|
||||||
@@ -686,7 +688,7 @@ getJasmineRequireObj().Env = function(j$) {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
function unfocusAncestors() {
|
function unfocusAncestor() {
|
||||||
var focusedAncestor = findFocusedAncestor(currentDeclarationSuite);
|
var focusedAncestor = findFocusedAncestor(currentDeclarationSuite);
|
||||||
if (focusedAncestor) {
|
if (focusedAncestor) {
|
||||||
for (var i = 0; i < focusedRunnables.length; i++) {
|
for (var i = 0; i < focusedRunnables.length; i++) {
|
||||||
@@ -755,13 +757,11 @@ getJasmineRequireObj().Env = function(j$) {
|
|||||||
return spec;
|
return spec;
|
||||||
};
|
};
|
||||||
|
|
||||||
var focusedRunnables = [];
|
|
||||||
|
|
||||||
this.fit = function(description, fn ){
|
this.fit = function(description, fn ){
|
||||||
var spec = this.it(description, fn);
|
var spec = this.it(description, fn);
|
||||||
|
|
||||||
focusedRunnables.push(spec.id);
|
focusedRunnables.push(spec.id);
|
||||||
unfocusAncestors();
|
unfocusAncestor();
|
||||||
return spec;
|
return spec;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -1877,7 +1877,6 @@ getJasmineRequireObj().Suite = function() {
|
|||||||
|
|
||||||
this.result = {
|
this.result = {
|
||||||
id: this.id,
|
id: this.id,
|
||||||
status: this.disabled ? 'disabled' : '',
|
|
||||||
description: this.description,
|
description: this.description,
|
||||||
fullName: this.getFullName(),
|
fullName: this.getFullName(),
|
||||||
failedExpectations: []
|
failedExpectations: []
|
||||||
@@ -1951,6 +1950,7 @@ getJasmineRequireObj().Suite = function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
function complete() {
|
function complete() {
|
||||||
|
self.result.status = self.disabled ? 'disabled' : 'finished';
|
||||||
self.resultCallback(self.result);
|
self.resultCallback(self.result);
|
||||||
|
|
||||||
if (onComplete) {
|
if (onComplete) {
|
||||||
|
|||||||
@@ -260,7 +260,7 @@ describe("Suite", function() {
|
|||||||
|
|
||||||
expect(suiteResultsCallback).toHaveBeenCalledWith({
|
expect(suiteResultsCallback).toHaveBeenCalledWith({
|
||||||
id: suite.id,
|
id: suite.id,
|
||||||
status: '',
|
status: 'finished',
|
||||||
description: "with a child suite",
|
description: "with a child suite",
|
||||||
fullName: "with a child suite",
|
fullName: "with a child suite",
|
||||||
failedExpectations: []
|
failedExpectations: []
|
||||||
|
|||||||
@@ -368,110 +368,140 @@ describe("Env integration", function() {
|
|||||||
env.execute();
|
env.execute();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("reports when an afterAll fails an expectation", function(done) {
|
describe('suiteDone reporting', function(){
|
||||||
var env = new j$.Env(),
|
it("reports when an afterAll fails an expectation", function(done) {
|
||||||
reporter = jasmine.createSpyObj('fakeReport', ['jasmineDone','suiteDone']);
|
var env = new j$.Env(),
|
||||||
|
reporter = jasmine.createSpyObj('fakeReport', ['jasmineDone','suiteDone']);
|
||||||
|
|
||||||
reporter.jasmineDone.and.callFake(function() {
|
reporter.jasmineDone.and.callFake(function() {
|
||||||
expect(reporter.suiteDone).toHaveFailedExpecationsForSuite('my suite', [
|
expect(reporter.suiteDone).toHaveFailedExpecationsForSuite('my suite', [
|
||||||
'Expected 1 to equal 2.',
|
'Expected 1 to equal 2.',
|
||||||
'Expected 2 to equal 3.'
|
'Expected 2 to equal 3.'
|
||||||
]);
|
]);
|
||||||
done();
|
done();
|
||||||
});
|
|
||||||
|
|
||||||
env.addReporter(reporter);
|
|
||||||
|
|
||||||
env.describe('my suite', function() {
|
|
||||||
env.it('my spec', function() {
|
|
||||||
});
|
});
|
||||||
|
|
||||||
env.afterAll(function() {
|
env.addReporter(reporter);
|
||||||
env.expect(1).toEqual(2);
|
|
||||||
env.expect(2).toEqual(3);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
env.execute();
|
env.describe('my suite', function() {
|
||||||
});
|
env.it('my spec', function() {
|
||||||
|
});
|
||||||
|
|
||||||
it("reports when afterAll throws an exception", function(done) {
|
env.afterAll(function() {
|
||||||
var env = new j$.Env(),
|
env.expect(1).toEqual(2);
|
||||||
error = new Error('After All Exception'),
|
env.expect(2).toEqual(3);
|
||||||
reporter = jasmine.createSpyObj('fakeReport', ['jasmineDone','suiteDone']);
|
});
|
||||||
|
|
||||||
reporter.jasmineDone.and.callFake(function() {
|
|
||||||
expect(reporter.suiteDone).toHaveFailedExpecationsForSuite('my suite', [
|
|
||||||
(/^Error: After All Exception/)
|
|
||||||
]);
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
|
|
||||||
env.addReporter(reporter);
|
|
||||||
|
|
||||||
env.describe('my suite', function() {
|
|
||||||
env.it('my spec', function() {
|
|
||||||
});
|
});
|
||||||
|
|
||||||
env.afterAll(function() {
|
env.execute();
|
||||||
throw error;
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
env.execute();
|
it("if there are no specs, it still reports correctly", function(done) {
|
||||||
});
|
var env = new j$.Env(),
|
||||||
|
reporter = jasmine.createSpyObj('fakeReport', ['jasmineDone','suiteDone']);
|
||||||
|
|
||||||
it("reports when an async afterAll fails an expectation", function(done) {
|
reporter.jasmineDone.and.callFake(function() {
|
||||||
var env = new j$.Env(),
|
expect(reporter.suiteDone).toHaveFailedExpecationsForSuite('outer suite', [
|
||||||
reporter = jasmine.createSpyObj('fakeReport', ['jasmineDone','suiteDone']);
|
'Expected 1 to equal 2.',
|
||||||
|
'Expected 2 to equal 3.'
|
||||||
|
]);
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
|
||||||
reporter.jasmineDone.and.callFake(function() {
|
env.addReporter(reporter);
|
||||||
expect(reporter.suiteDone).toHaveFailedExpecationsForSuite('my suite', [
|
|
||||||
'Expected 1 to equal 2.'
|
|
||||||
]);
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
|
|
||||||
env.addReporter(reporter);
|
env.describe('outer suite', function() {
|
||||||
|
env.describe('inner suite', function() {
|
||||||
|
env.it('spec', function(){ });
|
||||||
|
});
|
||||||
|
|
||||||
env.describe('my suite', function() {
|
env.afterAll(function() {
|
||||||
env.it('my spec', function() {
|
env.expect(1).toEqual(2);
|
||||||
|
env.expect(2).toEqual(3);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
env.execute();
|
||||||
});
|
});
|
||||||
|
|
||||||
env.afterAll(function(afterAllDone) {
|
it("reports when afterAll throws an exception", function(done) {
|
||||||
env.expect(1).toEqual(2);
|
var env = new j$.Env(),
|
||||||
afterAllDone();
|
error = new Error('After All Exception'),
|
||||||
});
|
reporter = jasmine.createSpyObj('fakeReport', ['jasmineDone','suiteDone']);
|
||||||
});
|
|
||||||
|
|
||||||
env.execute();
|
reporter.jasmineDone.and.callFake(function() {
|
||||||
});
|
expect(reporter.suiteDone).toHaveFailedExpecationsForSuite('my suite', [
|
||||||
|
(/^Error: After All Exception/)
|
||||||
it("reports when an async afterAll throws an exception", function(done) {
|
]);
|
||||||
var env = new j$.Env(),
|
done();
|
||||||
error = new Error('After All Exception'),
|
|
||||||
reporter = jasmine.createSpyObj('fakeReport', ['jasmineDone','suiteDone']);
|
|
||||||
|
|
||||||
|
|
||||||
reporter.jasmineDone.and.callFake(function() {
|
|
||||||
expect(reporter.suiteDone).toHaveFailedExpecationsForSuite('my suite', [
|
|
||||||
(/^Error: After All Exception/)
|
|
||||||
]);
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
|
|
||||||
env.addReporter(reporter);
|
|
||||||
|
|
||||||
env.describe('my suite', function() {
|
|
||||||
env.it('my spec', function() {
|
|
||||||
});
|
});
|
||||||
|
|
||||||
env.afterAll(function(afterAllDone) {
|
env.addReporter(reporter);
|
||||||
throw error;
|
|
||||||
|
env.describe('my suite', function() {
|
||||||
|
env.it('my spec', function() {
|
||||||
|
});
|
||||||
|
|
||||||
|
env.afterAll(function() {
|
||||||
|
throw error;
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
env.execute();
|
||||||
});
|
});
|
||||||
|
|
||||||
env.execute();
|
it("reports when an async afterAll fails an expectation", function(done) {
|
||||||
|
var env = new j$.Env(),
|
||||||
|
reporter = jasmine.createSpyObj('fakeReport', ['jasmineDone','suiteDone']);
|
||||||
|
|
||||||
|
reporter.jasmineDone.and.callFake(function() {
|
||||||
|
expect(reporter.suiteDone).toHaveFailedExpecationsForSuite('my suite', [
|
||||||
|
'Expected 1 to equal 2.'
|
||||||
|
]);
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
|
||||||
|
env.addReporter(reporter);
|
||||||
|
|
||||||
|
env.describe('my suite', function() {
|
||||||
|
env.it('my spec', function() {
|
||||||
|
});
|
||||||
|
|
||||||
|
env.afterAll(function(afterAllDone) {
|
||||||
|
env.expect(1).toEqual(2);
|
||||||
|
afterAllDone();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
env.execute();
|
||||||
|
});
|
||||||
|
|
||||||
|
it("reports when an async afterAll throws an exception", function(done) {
|
||||||
|
var env = new j$.Env(),
|
||||||
|
error = new Error('After All Exception'),
|
||||||
|
reporter = jasmine.createSpyObj('fakeReport', ['jasmineDone','suiteDone']);
|
||||||
|
|
||||||
|
|
||||||
|
reporter.jasmineDone.and.callFake(function() {
|
||||||
|
expect(reporter.suiteDone).toHaveFailedExpecationsForSuite('my suite', [
|
||||||
|
(/^Error: After All Exception/)
|
||||||
|
]);
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
|
||||||
|
env.addReporter(reporter);
|
||||||
|
|
||||||
|
env.describe('my suite', function() {
|
||||||
|
env.it('my spec', function() {
|
||||||
|
});
|
||||||
|
|
||||||
|
env.afterAll(function(afterAllDone) {
|
||||||
|
throw error;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
env.execute();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it("Allows specifying which specs and suites to run", function(done) {
|
it("Allows specifying which specs and suites to run", function(done) {
|
||||||
|
|||||||
@@ -21,7 +21,6 @@ getJasmineRequireObj().Suite = function() {
|
|||||||
|
|
||||||
this.result = {
|
this.result = {
|
||||||
id: this.id,
|
id: this.id,
|
||||||
status: this.disabled ? 'disabled' : '',
|
|
||||||
description: this.description,
|
description: this.description,
|
||||||
fullName: this.getFullName(),
|
fullName: this.getFullName(),
|
||||||
failedExpectations: []
|
failedExpectations: []
|
||||||
@@ -95,6 +94,7 @@ getJasmineRequireObj().Suite = function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
function complete() {
|
function complete() {
|
||||||
|
self.result.status = self.disabled ? 'disabled' : 'finished';
|
||||||
self.resultCallback(self.result);
|
self.resultCallback(self.result);
|
||||||
|
|
||||||
if (onComplete) {
|
if (onComplete) {
|
||||||
|
|||||||
Reference in New Issue
Block a user