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

Commit

Permalink
patch jasmine beforeAll/afterAll (#1176)
Browse files Browse the repository at this point in the history
  • Loading branch information
JiaLiPassion authored and vikerman committed Jan 16, 2019
1 parent d8c3b9d commit 9d27abc
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/jasmine/jasmine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
return originalJasmineFn.apply(this, arguments);
};
});
['beforeEach', 'afterEach'].forEach(methodName => {
['beforeEach', 'afterEach', 'beforeAll', 'afterAll'].forEach(methodName => {
let originalJasmineFn: Function = jasmineEnv[methodName];
jasmineEnv[symbol(methodName)] = originalJasmineFn;
jasmineEnv[methodName] = function(specDefinitions: Function, timeout: number) {
Expand Down
9 changes: 9 additions & 0 deletions test/jasmine-patch.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ ifEnvSupports(supportJasmineSpec, () => {
describe('jasmine', () => {
let throwOnAsync = false;
let beforeEachZone: Zone|null = null;
let beforeAllZone: Zone|null = null;
let itZone: Zone|null = null;
const syncZone = Zone.current;
try {
Expand All @@ -31,6 +32,8 @@ ifEnvSupports(supportJasmineSpec, () => {
throwOnAsync = true;
}

beforeAll(() => beforeAllZone = Zone.current);

beforeEach(() => beforeEachZone = Zone.current);

it('should throw on async in describe', () => {
Expand All @@ -47,6 +50,12 @@ ifEnvSupports(supportJasmineSpec, () => {
expect(beforeEachZone!.name).toEqual(zone.name);
expect(itZone).toBe(zone);
});

afterAll(() => {
let zone = Zone.current;
expect(zone.name).toEqual('ProxyZone');
expect(beforeAllZone!.name).toEqual(zone.name);
});
});

describe('return promise', () => {
Expand Down

0 comments on commit 9d27abc

Please sign in to comment.