Skip to content
This repository was archived by the owner on Feb 26, 2024. It is now read-only.

Commit 9d27abc

Browse files
JiaLiPassionvikerman
authored andcommitted
patch jasmine beforeAll/afterAll (#1176)
1 parent d8c3b9d commit 9d27abc

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

Diff for: lib/jasmine/jasmine.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
return originalJasmineFn.apply(this, arguments);
6060
};
6161
});
62-
['beforeEach', 'afterEach'].forEach(methodName => {
62+
['beforeEach', 'afterEach', 'beforeAll', 'afterAll'].forEach(methodName => {
6363
let originalJasmineFn: Function = jasmineEnv[methodName];
6464
jasmineEnv[symbol(methodName)] = originalJasmineFn;
6565
jasmineEnv[methodName] = function(specDefinitions: Function, timeout: number) {

Diff for: test/jasmine-patch.spec.ts

+9
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ ifEnvSupports(supportJasmineSpec, () => {
2323
describe('jasmine', () => {
2424
let throwOnAsync = false;
2525
let beforeEachZone: Zone|null = null;
26+
let beforeAllZone: Zone|null = null;
2627
let itZone: Zone|null = null;
2728
const syncZone = Zone.current;
2829
try {
@@ -31,6 +32,8 @@ ifEnvSupports(supportJasmineSpec, () => {
3132
throwOnAsync = true;
3233
}
3334

35+
beforeAll(() => beforeAllZone = Zone.current);
36+
3437
beforeEach(() => beforeEachZone = Zone.current);
3538

3639
it('should throw on async in describe', () => {
@@ -47,6 +50,12 @@ ifEnvSupports(supportJasmineSpec, () => {
4750
expect(beforeEachZone!.name).toEqual(zone.name);
4851
expect(itZone).toBe(zone);
4952
});
53+
54+
afterAll(() => {
55+
let zone = Zone.current;
56+
expect(zone.name).toEqual('ProxyZone');
57+
expect(beforeAllZone!.name).toEqual(zone.name);
58+
});
5059
});
5160

5261
describe('return promise', () => {

0 commit comments

Comments
 (0)