@sprucelabs/test-utils 5.3.2 → 5.3.3
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.
@@ -10,8 +10,6 @@ export default class AbstractSpruceTest {
|
|
10
10
|
protected wait(ms?: number): Promise<unknown>;
|
11
11
|
protected log(...args: any[]): void;
|
12
12
|
protected cwd: string;
|
13
|
-
protected beforeAll(): Promise<void>;
|
14
|
-
protected afterAll(): Promise<void>;
|
15
13
|
protected beforeEach(): Promise<void>;
|
16
14
|
protected afterEach(): Promise<void>;
|
17
15
|
}
|
package/build/decorators.js
CHANGED
@@ -12,17 +12,20 @@ class Test {
|
|
12
12
|
}
|
13
13
|
}
|
14
14
|
/** Hooks up before, after, etc. */
|
15
|
-
function hookupTestClass(target) {
|
15
|
+
function hookupTestClass(target, h) {
|
16
16
|
if (target.__isTestingHookedUp) {
|
17
17
|
return;
|
18
18
|
}
|
19
|
-
target.__isTestingHookedUp =
|
20
|
-
const hooks = ['beforeAll', 'beforeEach', 'afterAll', 'afterEach'];
|
19
|
+
target.__isTestingHookedUp = !h;
|
20
|
+
const hooks = h ?? ['beforeAll', 'beforeEach', 'afterAll', 'afterEach'];
|
21
21
|
hooks.forEach((hook) => {
|
22
22
|
// Have they defined a hook
|
23
23
|
if (!target[hook]) {
|
24
24
|
return;
|
25
25
|
}
|
26
|
+
if (Test.ActiveTestClass && !h && hook === 'beforeAll') {
|
27
|
+
throw new Error(`beforeAll() and afterAll() must be static`);
|
28
|
+
}
|
26
29
|
// @ts-ignore
|
27
30
|
if (global[hook]) {
|
28
31
|
// @ts-ignore
|
@@ -54,7 +57,7 @@ function suite() {
|
|
54
57
|
return function (Target) {
|
55
58
|
Test.ActiveTestClass = Target;
|
56
59
|
// Test.activeTest.__isTestingHookedUp = false
|
57
|
-
|
60
|
+
hookupTestClass(Target, ['beforeAll', 'afterAll']);
|
58
61
|
};
|
59
62
|
}
|
60
63
|
/** Only decorator */
|
@@ -10,8 +10,6 @@ export default class AbstractSpruceTest {
|
|
10
10
|
protected wait(ms?: number): Promise<unknown>;
|
11
11
|
protected log(...args: any[]): void;
|
12
12
|
protected cwd: string;
|
13
|
-
protected beforeAll(): Promise<void>;
|
14
|
-
protected afterAll(): Promise<void>;
|
15
13
|
protected beforeEach(): Promise<void>;
|
16
14
|
protected afterEach(): Promise<void>;
|
17
15
|
}
|
package/build/esm/decorators.js
CHANGED
@@ -8,17 +8,20 @@ class Test {
|
|
8
8
|
}
|
9
9
|
}
|
10
10
|
/** Hooks up before, after, etc. */
|
11
|
-
function hookupTestClass(target) {
|
11
|
+
function hookupTestClass(target, h) {
|
12
12
|
if (target.__isTestingHookedUp) {
|
13
13
|
return;
|
14
14
|
}
|
15
|
-
target.__isTestingHookedUp =
|
16
|
-
const hooks = ['beforeAll', 'beforeEach', 'afterAll', 'afterEach'];
|
15
|
+
target.__isTestingHookedUp = !h;
|
16
|
+
const hooks = h !== null && h !== void 0 ? h : ['beforeAll', 'beforeEach', 'afterAll', 'afterEach'];
|
17
17
|
hooks.forEach((hook) => {
|
18
18
|
// Have they defined a hook
|
19
19
|
if (!target[hook]) {
|
20
20
|
return;
|
21
21
|
}
|
22
|
+
if (Test.ActiveTestClass && !h && hook === 'beforeAll') {
|
23
|
+
throw new Error(`beforeAll() and afterAll() must be static`);
|
24
|
+
}
|
22
25
|
// @ts-ignore
|
23
26
|
if (global[hook]) {
|
24
27
|
// @ts-ignore
|
@@ -50,7 +53,7 @@ export function suite() {
|
|
50
53
|
return function (Target) {
|
51
54
|
Test.ActiveTestClass = Target;
|
52
55
|
// Test.activeTest.__isTestingHookedUp = false
|
53
|
-
|
56
|
+
hookupTestClass(Target, ['beforeAll', 'afterAll']);
|
54
57
|
};
|
55
58
|
}
|
56
59
|
/** Only decorator */
|