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

2 files changed

Lines changed: 10 additions & 1 deletion

File tree

‎lib/jasmine/jasmine.ts‎

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

‎test/jasmine-patch.spec.ts‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ ifEnvSupports(supportJasmineSpec, () => {
2323
describe('jasmine',()=>{
2424
letthrowOnAsync=false;
2525
letbeforeEachZone: Zone|null=null;
26+
letbeforeAllZone: Zone|null=null;
2627
letitZone: Zone|null=null;
2728
constsyncZone=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+
letzone=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)