@sprucelabs/test-utils 5.2.13 → 5.3.1
Sign up to get free protection for your applications and to get access to all the features.
- package/build/AbstractSpruceTest.d.ts +7 -0
- package/build/AbstractSpruceTest.js +13 -0
- package/build/decorators.d.ts +1 -0
- package/build/decorators.js +17 -3
- package/build/esm/AbstractSpruceTest.d.ts +7 -0
- package/build/esm/AbstractSpruceTest.js +13 -0
- package/build/esm/decorators.d.ts +1 -0
- package/build/esm/decorators.js +16 -3
- package/package.json +1 -1
@@ -7,4 +7,11 @@ export default class AbstractSpruceTest {
|
|
7
7
|
protected static resolvePath(...filePath: string[]): string;
|
8
8
|
protected static wait(ms?: number): Promise<unknown>;
|
9
9
|
protected static log(...args: any[]): void;
|
10
|
+
protected wait(ms?: number): Promise<unknown>;
|
11
|
+
protected log(...args: any[]): void;
|
12
|
+
protected cwd: string;
|
13
|
+
protected beforeAll(): Promise<void>;
|
14
|
+
protected afterAll(): Promise<void>;
|
15
|
+
protected beforeEach(): Promise<void>;
|
16
|
+
protected afterEach(): Promise<void>;
|
10
17
|
}
|
@@ -30,9 +30,22 @@ class AbstractSpruceTest {
|
|
30
30
|
setTimeout(() => resolve(true), ms);
|
31
31
|
});
|
32
32
|
}
|
33
|
+
//instance declariations
|
33
34
|
static log(...args) {
|
34
35
|
const str = args.map((a) => `${a}`).join(' ');
|
35
36
|
process.stderr.write(str);
|
36
37
|
}
|
38
|
+
async wait(ms = 1000) {
|
39
|
+
return AbstractSpruceTest.wait(ms);
|
40
|
+
}
|
41
|
+
log(...args) {
|
42
|
+
AbstractSpruceTest.log(...args);
|
43
|
+
}
|
44
|
+
async beforeAll() {
|
45
|
+
this.cwd = process.cwd();
|
46
|
+
}
|
47
|
+
async afterAll() { }
|
48
|
+
async beforeEach() { }
|
49
|
+
async afterEach() { }
|
37
50
|
}
|
38
51
|
exports.default = AbstractSpruceTest;
|
package/build/decorators.d.ts
CHANGED
package/build/decorators.js
CHANGED
@@ -1,10 +1,16 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.default = test;
|
4
|
+
exports.suite = suite;
|
4
5
|
if (typeof it === 'undefined') {
|
5
6
|
//@ts-ignore
|
6
7
|
global.it = () => { };
|
7
8
|
}
|
9
|
+
class Test {
|
10
|
+
static resolveActiveTest(target) {
|
11
|
+
return this.ActiveTestClass ? new this.ActiveTestClass() : target;
|
12
|
+
}
|
13
|
+
}
|
8
14
|
/** Hooks up before, after, etc. */
|
9
15
|
function hookupTestClass(target) {
|
10
16
|
if (target.__isTestingHookedUp) {
|
@@ -31,9 +37,10 @@ function test(description, ...args) {
|
|
31
37
|
return function (target, propertyKey, descriptor) {
|
32
38
|
// Lets attach before/after
|
33
39
|
hookupTestClass(target);
|
34
|
-
const bound = descriptor.value.bind(target);
|
35
40
|
// Make sure each test gets the spruce
|
36
41
|
it(description ?? propertyKey, async () => {
|
42
|
+
const testClass = Test.resolveActiveTest(target);
|
43
|
+
const bound = descriptor.value.bind(testClass);
|
37
44
|
//@ts-ignore
|
38
45
|
global.activeTest = {
|
39
46
|
file: target.name,
|
@@ -43,14 +50,21 @@ function test(description, ...args) {
|
|
43
50
|
});
|
44
51
|
};
|
45
52
|
}
|
53
|
+
function suite() {
|
54
|
+
return function (Target) {
|
55
|
+
Test.ActiveTestClass = Target;
|
56
|
+
// Test.activeTest.__isTestingHookedUp = false
|
57
|
+
// hookupTestClass(Test.activeTest)
|
58
|
+
};
|
59
|
+
}
|
46
60
|
/** Only decorator */
|
47
61
|
test.only = (description, ...args) => {
|
48
62
|
return function (target, propertyKey, descriptor) {
|
49
63
|
// Lets attach before/after
|
50
64
|
hookupTestClass(target);
|
51
|
-
const bound = descriptor.value.bind(target);
|
52
65
|
// Make sure each test gets the spruce
|
53
66
|
it.only(description ?? propertyKey, async () => {
|
67
|
+
const bound = descriptor.value.bind(Test.resolveActiveTest(target));
|
54
68
|
return bound(...args);
|
55
69
|
});
|
56
70
|
};
|
@@ -69,9 +83,9 @@ test.skip = (description, ...args) => {
|
|
69
83
|
return function (target, propertyKey, descriptor) {
|
70
84
|
// Lets attach before/after
|
71
85
|
hookupTestClass(target);
|
72
|
-
const bound = descriptor.value.bind(target);
|
73
86
|
// Make sure each test gets the spruce
|
74
87
|
it.skip(description ?? propertyKey, async () => {
|
88
|
+
const bound = descriptor.value.bind(Test.resolveActiveTest(target));
|
75
89
|
return bound(...args);
|
76
90
|
});
|
77
91
|
};
|
@@ -7,4 +7,11 @@ export default class AbstractSpruceTest {
|
|
7
7
|
protected static resolvePath(...filePath: string[]): string;
|
8
8
|
protected static wait(ms?: number): Promise<unknown>;
|
9
9
|
protected static log(...args: any[]): void;
|
10
|
+
protected wait(ms?: number): Promise<unknown>;
|
11
|
+
protected log(...args: any[]): void;
|
12
|
+
protected cwd: string;
|
13
|
+
protected beforeAll(): Promise<void>;
|
14
|
+
protected afterAll(): Promise<void>;
|
15
|
+
protected beforeEach(): Promise<void>;
|
16
|
+
protected afterEach(): Promise<void>;
|
10
17
|
}
|
@@ -25,8 +25,21 @@ export default class AbstractSpruceTest {
|
|
25
25
|
setTimeout(() => resolve(true), ms);
|
26
26
|
});
|
27
27
|
}
|
28
|
+
//instance declariations
|
28
29
|
static log(...args) {
|
29
30
|
const str = args.map((a) => `${a}`).join(' ');
|
30
31
|
process.stderr.write(str);
|
31
32
|
}
|
33
|
+
async wait(ms = 1000) {
|
34
|
+
return AbstractSpruceTest.wait(ms);
|
35
|
+
}
|
36
|
+
log(...args) {
|
37
|
+
AbstractSpruceTest.log(...args);
|
38
|
+
}
|
39
|
+
async beforeAll() {
|
40
|
+
this.cwd = process.cwd();
|
41
|
+
}
|
42
|
+
async afterAll() { }
|
43
|
+
async beforeEach() { }
|
44
|
+
async afterEach() { }
|
32
45
|
}
|
package/build/esm/decorators.js
CHANGED
@@ -2,6 +2,11 @@ if (typeof it === 'undefined') {
|
|
2
2
|
//@ts-ignore
|
3
3
|
global.it = () => { };
|
4
4
|
}
|
5
|
+
class Test {
|
6
|
+
static resolveActiveTest(target) {
|
7
|
+
return this.ActiveTestClass ? new this.ActiveTestClass() : target;
|
8
|
+
}
|
9
|
+
}
|
5
10
|
/** Hooks up before, after, etc. */
|
6
11
|
function hookupTestClass(target) {
|
7
12
|
if (target.__isTestingHookedUp) {
|
@@ -28,9 +33,10 @@ export default function test(description, ...args) {
|
|
28
33
|
return function (target, propertyKey, descriptor) {
|
29
34
|
// Lets attach before/after
|
30
35
|
hookupTestClass(target);
|
31
|
-
const bound = descriptor.value.bind(target);
|
32
36
|
// Make sure each test gets the spruce
|
33
37
|
it(description !== null && description !== void 0 ? description : propertyKey, async () => {
|
38
|
+
const testClass = Test.resolveActiveTest(target);
|
39
|
+
const bound = descriptor.value.bind(testClass);
|
34
40
|
//@ts-ignore
|
35
41
|
global.activeTest = {
|
36
42
|
file: target.name,
|
@@ -40,14 +46,21 @@ export default function test(description, ...args) {
|
|
40
46
|
});
|
41
47
|
};
|
42
48
|
}
|
49
|
+
export function suite() {
|
50
|
+
return function (Target) {
|
51
|
+
Test.ActiveTestClass = Target;
|
52
|
+
// Test.activeTest.__isTestingHookedUp = false
|
53
|
+
// hookupTestClass(Test.activeTest)
|
54
|
+
};
|
55
|
+
}
|
43
56
|
/** Only decorator */
|
44
57
|
test.only = (description, ...args) => {
|
45
58
|
return function (target, propertyKey, descriptor) {
|
46
59
|
// Lets attach before/after
|
47
60
|
hookupTestClass(target);
|
48
|
-
const bound = descriptor.value.bind(target);
|
49
61
|
// Make sure each test gets the spruce
|
50
62
|
it.only(description !== null && description !== void 0 ? description : propertyKey, async () => {
|
63
|
+
const bound = descriptor.value.bind(Test.resolveActiveTest(target));
|
51
64
|
return bound(...args);
|
52
65
|
});
|
53
66
|
};
|
@@ -66,9 +79,9 @@ test.skip = (description, ...args) => {
|
|
66
79
|
return function (target, propertyKey, descriptor) {
|
67
80
|
// Lets attach before/after
|
68
81
|
hookupTestClass(target);
|
69
|
-
const bound = descriptor.value.bind(target);
|
70
82
|
// Make sure each test gets the spruce
|
71
83
|
it.skip(description !== null && description !== void 0 ? description : propertyKey, async () => {
|
84
|
+
const bound = descriptor.value.bind(Test.resolveActiveTest(target));
|
72
85
|
return bound(...args);
|
73
86
|
});
|
74
87
|
};
|