Skip afterEach fns in nested suites when a beforeEach fn errors

This matches the behavior of beforeAll errors.

* #1533
This commit is contained in:
Steve Gravrock
2021-10-01 16:36:36 -07:00
parent 5f1ef5ac2b
commit b67a3043c7
6 changed files with 178 additions and 56 deletions

View File

@@ -48,13 +48,16 @@ describe('Suite', function() {
env: env,
description: 'I am a suite'
}),
outerBefore = jasmine.createSpy('outerBeforeEach'),
innerBefore = jasmine.createSpy('insideBeforeEach');
outerBefore = { fn: 'outerBeforeEach' },
innerBefore = { fn: 'insideBeforeEach' };
suite.beforeEach(outerBefore);
suite.beforeEach(innerBefore);
expect(suite.beforeFns).toEqual([innerBefore, outerBefore]);
expect(suite.beforeFns).toEqual([
{ fn: innerBefore.fn, suite },
{ fn: outerBefore.fn, suite }
]);
});
it('adds after functions in order of needed execution', function() {
@@ -62,13 +65,16 @@ describe('Suite', function() {
env: env,
description: 'I am a suite'
}),
outerAfter = jasmine.createSpy('outerAfterEach'),
innerAfter = jasmine.createSpy('insideAfterEach');
outerAfter = { fn: 'outerAfterEach' },
innerAfter = { fn: 'insideAfterEach' };
suite.afterEach(outerAfter);
suite.afterEach(innerAfter);
expect(suite.afterFns).toEqual([innerAfter, outerAfter]);
expect(suite.afterFns).toEqual([
{ fn: innerAfter.fn, suite },
{ fn: outerAfter.fn, suite }
]);
});
it('has a status of failed if any expectations have failed', function() {