@sprucelabs/test-utils 5.3.1 → 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.
- package/build/AbstractSpruceTest.d.ts +0 -2
- package/build/AbstractSpruceTest.js +0 -4
- package/build/decorators.js +7 -4
- package/build/esm/AbstractSpruceTest.d.ts +0 -2
- package/build/esm/AbstractSpruceTest.js +0 -4
- package/build/esm/decorators.js +7 -4
- package/build/esm/index.d.ts +1 -0
- package/build/esm/index.js +1 -0
- package/build/index.d.ts +1 -0
- package/build/index.js +1 -0
- package/package.json +1 -1
@@ -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 */
|
package/build/esm/index.d.ts
CHANGED
@@ -5,6 +5,7 @@ export { default } from './AbstractSpruceTest';
|
|
5
5
|
export { default as assert } from './assert/assert';
|
6
6
|
export * from './assert/assert';
|
7
7
|
export { default as test } from './decorators';
|
8
|
+
export * from './decorators';
|
8
9
|
export { default as assertUtil } from './assert/assert.utility';
|
9
10
|
export { default as StackCleaner } from './StackCleaner';
|
10
11
|
export { default as Spier } from './utilities/spies/Spier';
|
package/build/esm/index.js
CHANGED
@@ -5,6 +5,7 @@ export { default } from './AbstractSpruceTest.js';
|
|
5
5
|
export { default as assert } from './assert/assert.js';
|
6
6
|
export * from './assert/assert.js';
|
7
7
|
export { default as test } from './decorators.js';
|
8
|
+
export * from './decorators.js';
|
8
9
|
export { default as assertUtil } from './assert/assert.utility.js';
|
9
10
|
export { default as StackCleaner } from './StackCleaner.js';
|
10
11
|
export { default as Spier } from './utilities/spies/Spier.js';
|
package/build/index.d.ts
CHANGED
@@ -5,6 +5,7 @@ export { default } from './AbstractSpruceTest';
|
|
5
5
|
export { default as assert } from './assert/assert';
|
6
6
|
export * from './assert/assert';
|
7
7
|
export { default as test } from './decorators';
|
8
|
+
export * from './decorators';
|
8
9
|
export { default as assertUtil } from './assert/assert.utility';
|
9
10
|
export { default as StackCleaner } from './StackCleaner';
|
10
11
|
export { default as Spier } from './utilities/spies/Spier';
|
package/build/index.js
CHANGED
@@ -31,6 +31,7 @@ Object.defineProperty(exports, "assert", { enumerable: true, get: function () {
|
|
31
31
|
__exportStar(require("./assert/assert"), exports);
|
32
32
|
var decorators_1 = require("./decorators");
|
33
33
|
Object.defineProperty(exports, "test", { enumerable: true, get: function () { return __importDefault(decorators_1).default; } });
|
34
|
+
__exportStar(require("./decorators"), exports);
|
34
35
|
var assert_utility_1 = require("./assert/assert.utility");
|
35
36
|
Object.defineProperty(exports, "assertUtil", { enumerable: true, get: function () { return __importDefault(assert_utility_1).default; } });
|
36
37
|
var StackCleaner_1 = require("./StackCleaner");
|