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

patch jasmine beforeAll/afterAll #1176

Merged
merged 1 commit into from
Jan 16, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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