@sprucelabs/test-utils 5.3.5 → 5.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,3 +1,9 @@
1
+ export declare class SpruceTestDecoratorResolver {
2
+ static ActiveTestClass?: any;
3
+ private static __activeTest;
4
+ static resolveActiveTest(target: any): any;
5
+ static getActiveTest(): any;
6
+ }
1
7
  /** Test decorator */
2
8
  declare function test(description?: string, ...args: any[]): (target: any, propertyKey: string, descriptor: PropertyDescriptor) => void;
3
9
  declare namespace test {
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SpruceTestDecoratorResolver = void 0;
3
4
  exports.default = test;
4
5
  exports.suite = suite;
5
6
  if (typeof it === 'undefined') {
@@ -8,9 +9,16 @@ if (typeof it === 'undefined') {
8
9
  }
9
10
  class SpruceTestDecoratorResolver {
10
11
  static resolveActiveTest(target) {
11
- return this.ActiveTestClass ? new this.ActiveTestClass() : target;
12
+ this.__activeTest = this.ActiveTestClass
13
+ ? new this.ActiveTestClass()
14
+ : target;
15
+ return this.__activeTest;
16
+ }
17
+ static getActiveTest() {
18
+ return this.__activeTest;
12
19
  }
13
20
  }
21
+ exports.SpruceTestDecoratorResolver = SpruceTestDecoratorResolver;
14
22
  /** Hooks up before, after, etc. */
15
23
  function hookupTestClass(target, h) {
16
24
  if (target.__isTestingHookedUp) {
@@ -32,6 +40,10 @@ function hookupTestClass(target, h) {
32
40
  if (global[hook]) {
33
41
  // @ts-ignore
34
42
  global[hook](async () => {
43
+ if (hook === 'afterAll') {
44
+ //@ts-ignore
45
+ SpruceTestDecoratorResolver.__activeTest = null;
46
+ }
35
47
  return target[hook]();
36
48
  });
37
49
  }
@@ -1,3 +1,9 @@
1
+ export declare class SpruceTestDecoratorResolver {
2
+ static ActiveTestClass?: any;
3
+ private static __activeTest;
4
+ static resolveActiveTest(target: any): any;
5
+ static getActiveTest(): any;
6
+ }
1
7
  /** Test decorator */
2
8
  declare function test(description?: string, ...args: any[]): (target: any, propertyKey: string, descriptor: PropertyDescriptor) => void;
3
9
  declare namespace test {
@@ -2,9 +2,15 @@ if (typeof it === 'undefined') {
2
2
  //@ts-ignore
3
3
  global.it = () => { };
4
4
  }
5
- class SpruceTestDecoratorResolver {
5
+ export class SpruceTestDecoratorResolver {
6
6
  static resolveActiveTest(target) {
7
- return this.ActiveTestClass ? new this.ActiveTestClass() : target;
7
+ this.__activeTest = this.ActiveTestClass
8
+ ? new this.ActiveTestClass()
9
+ : target;
10
+ return this.__activeTest;
11
+ }
12
+ static getActiveTest() {
13
+ return this.__activeTest;
8
14
  }
9
15
  }
10
16
  /** Hooks up before, after, etc. */
@@ -28,6 +34,10 @@ function hookupTestClass(target, h) {
28
34
  if (global[hook]) {
29
35
  // @ts-ignore
30
36
  global[hook](async () => {
37
+ if (hook === 'afterAll') {
38
+ //@ts-ignore
39
+ SpruceTestDecoratorResolver.__activeTest = null;
40
+ }
31
41
  return target[hook]();
32
42
  });
33
43
  }
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "5.3.5",
6
+ "version": "5.4.0",
7
7
  "files": [
8
8
  "build"
9
9
  ],