nole 2.1.2 → 2.2.1
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/README.md +47 -0
- package/bin/nole.js +80 -58
- package/dist/data.js +2 -2
- package/dist/data.js.map +1 -1
- package/dist/decorators.d.ts +2 -1
- package/dist/decorators.d.ts.map +1 -1
- package/dist/decorators.js +51 -27
- package/dist/decorators.js.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/dist/run.d.ts.map +1 -1
- package/dist/run.js +40 -24
- package/dist/run.js.map +1 -1
- package/dist/test.d.ts.map +1 -1
- package/dist/utils/executor.js +1 -1
- package/dist/utils/executor.test.js +1 -1
- package/dist/utils/executor.test.js.map +1 -1
- package/dist/utils/time_difference.d.ts.map +1 -1
- package/dist/utils/time_difference.js.map +1 -1
- package/dist/utils/time_difference.test.js.map +1 -1
- package/dist/utils/time_factor.d.ts.map +1 -1
- package/dist/utils/time_factor.js +19 -14
- package/dist/utils/time_factor.js.map +1 -1
- package/dist/utils/time_factor.test.js +1 -1
- package/package.json +1 -1
- package/src/data.ts +3 -3
- package/src/decorators.ts +106 -48
- package/src/dynamic.ts +1 -1
- package/src/index.ts +13 -4
- package/src/run.ts +106 -42
- package/src/test.ts +10 -8
- package/src/utils/executor.test.ts +3 -3
- package/src/utils/executor.ts +2 -2
- package/src/utils/time_difference.test.ts +1 -1
- package/src/utils/time_difference.ts +1 -3
- package/src/utils/time_factor.test.ts +1 -1
- package/src/utils/time_factor.ts +24 -9
- package/test/basic.test.ts +8 -4
- package/test/before.test.ts +54 -0
- package/test/clean-up.test.ts +3 -5
- package/test/dynamic-skip.test.ts +1 -1
- package/test/dynamic.test.ts +1 -1
- package/test/hook.test.ts +3 -3
- package/test/multi-dependency.test.ts +31 -9
- package/test/multiple-uppercased-chars.test.ts +8 -7
- package/test/skip-all.test.ts +7 -7
- package/test/turkish-chars.test.ts +8 -7
package/README.md
CHANGED
|
@@ -176,6 +176,52 @@ class Redis {
|
|
|
176
176
|
}
|
|
177
177
|
```
|
|
178
178
|
|
|
179
|
+
## Lazy multi Dependencies / after
|
|
180
|
+
|
|
181
|
+
Can solve order of execution issues
|
|
182
|
+
|
|
183
|
+
```ts
|
|
184
|
+
// test/redis.test.ts
|
|
185
|
+
import { Spec, Dependencies, After } from 'nole';
|
|
186
|
+
|
|
187
|
+
@Dependencies(() => [ B ])
|
|
188
|
+
// or
|
|
189
|
+
// @After(() => [ B ])
|
|
190
|
+
class A {
|
|
191
|
+
b: B;
|
|
192
|
+
|
|
193
|
+
@Spec()
|
|
194
|
+
async DoThings() { }
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
class B {
|
|
198
|
+
@Spec()
|
|
199
|
+
async DoThings() { }
|
|
200
|
+
}
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
## Reverse dependency / dependent / before
|
|
204
|
+
|
|
205
|
+
|
|
206
|
+
|
|
207
|
+
```ts
|
|
208
|
+
// test/redis.test.ts
|
|
209
|
+
import { Spec, Dependents, Before } from 'nole';
|
|
210
|
+
|
|
211
|
+
class A {
|
|
212
|
+
b: B;
|
|
213
|
+
|
|
214
|
+
@Spec()
|
|
215
|
+
async DoThings() { }
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
@Before(() => [ A ])
|
|
219
|
+
class B {
|
|
220
|
+
@Spec()
|
|
221
|
+
async DoThings() { }
|
|
222
|
+
}
|
|
223
|
+
```
|
|
224
|
+
|
|
179
225
|
## Hook
|
|
180
226
|
|
|
181
227
|
Hooks will help you to develop helper methods.
|
|
@@ -338,4 +384,5 @@ $ nole -T ./build/test/**/*.test.js
|
|
|
338
384
|
```
|
|
339
385
|
NOLE_PRESERVE_CONSECUTIVE_UPPERCASE=true
|
|
340
386
|
NOLE_PASCALCASE=false
|
|
387
|
+
NOLE_WAIT_PERIOD=500
|
|
341
388
|
```
|
package/bin/nole.js
CHANGED
|
@@ -1,86 +1,108 @@
|
|
|
1
1
|
#!/usr/bin/env node --loader=ts-node/esm
|
|
2
2
|
|
|
3
|
-
import program from
|
|
4
|
-
import glob from
|
|
5
|
-
import path from
|
|
6
|
-
import fs from
|
|
7
|
-
import colors from
|
|
8
|
-
import { ManualRun } from
|
|
9
|
-
import { TimeDifference } from
|
|
10
|
-
import { TimeResolve } from
|
|
11
|
-
|
|
12
|
-
const pkg = JSON.parse(
|
|
3
|
+
import program from "commander";
|
|
4
|
+
import glob from "glob";
|
|
5
|
+
import path from "path";
|
|
6
|
+
import fs from "fs";
|
|
7
|
+
import colors from "colors/safe.js";
|
|
8
|
+
import { ManualRun } from "../dist/run.js";
|
|
9
|
+
import { TimeDifference } from "../dist/utils/time_difference.js";
|
|
10
|
+
import { Delay, TimeResolve } from "../dist/utils/time_factor.js";
|
|
11
|
+
|
|
12
|
+
const pkg = JSON.parse(
|
|
13
|
+
fs.readFileSync(new URL("../package.json", import.meta.url)).toString()
|
|
14
|
+
);
|
|
13
15
|
|
|
14
16
|
program
|
|
15
|
-
.usage(
|
|
16
|
-
.option(
|
|
17
|
-
.option(
|
|
17
|
+
.usage("<glob> ...")
|
|
18
|
+
.option("-L, --no-log", "disable console.log")
|
|
19
|
+
.option("-O, --order-debug", "shows execution order")
|
|
18
20
|
.version(pkg.version)
|
|
19
21
|
.parse(process.argv);
|
|
20
22
|
|
|
21
|
-
|
|
22
23
|
if (!program.args.length) {
|
|
23
|
-
program.help()
|
|
24
|
+
program.help();
|
|
24
25
|
} else {
|
|
25
26
|
let time = TimeDifference.begin();
|
|
26
27
|
|
|
27
28
|
let log = console.log.bind(console);
|
|
28
29
|
|
|
29
30
|
if (!program.log) {
|
|
30
|
-
console.log = function () {
|
|
31
|
+
console.log = function () {};
|
|
31
32
|
}
|
|
32
33
|
|
|
33
|
-
Promise.all(
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
34
|
+
Promise.all(
|
|
35
|
+
program.args.map(
|
|
36
|
+
(arg) =>
|
|
37
|
+
new Promise((resolve, reject) => {
|
|
38
|
+
glob(arg, (err, matches) => {
|
|
39
|
+
if (err) {
|
|
40
|
+
return reject(err);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
resolve(matches);
|
|
44
|
+
});
|
|
45
|
+
})
|
|
46
|
+
)
|
|
47
|
+
)
|
|
48
|
+
.then(async (list) => {
|
|
49
|
+
const fileList = [];
|
|
50
|
+
|
|
51
|
+
for (const item of list) {
|
|
52
|
+
while (item.length)
|
|
53
|
+
fileList.push(path.resolve(process.cwd(), item.pop()));
|
|
37
54
|
}
|
|
38
55
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
for (let item of list) {
|
|
45
|
-
while (item.length) fileList.push(path.resolve(process.cwd(), item.pop()));
|
|
46
|
-
}
|
|
56
|
+
if (!fileList.length) {
|
|
57
|
+
failed("0 files found");
|
|
58
|
+
process.exit(1);
|
|
59
|
+
}
|
|
47
60
|
|
|
48
|
-
|
|
49
|
-
failed('0 files found');
|
|
50
|
-
process.exit(1);
|
|
51
|
-
}
|
|
61
|
+
const file = time.end();
|
|
52
62
|
|
|
53
|
-
|
|
63
|
+
for (const file of fileList) {
|
|
64
|
+
await import(`file://${file}`);
|
|
65
|
+
}
|
|
54
66
|
|
|
55
|
-
|
|
56
|
-
await import(`file://${file}`);
|
|
57
|
-
}
|
|
67
|
+
const prop = time.end();
|
|
58
68
|
|
|
59
|
-
|
|
69
|
+
let dependencyResolveWaitPeriod = +process.env.NOLE_WAIT_PERIOD;
|
|
60
70
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
}
|
|
71
|
+
if (
|
|
72
|
+
isNaN(dependencyResolveWaitPeriod) ||
|
|
73
|
+
dependencyResolveWaitPeriod < 0
|
|
74
|
+
) {
|
|
75
|
+
dependencyResolveWaitPeriod = 500;
|
|
76
|
+
}
|
|
67
77
|
|
|
68
|
-
log(
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
78
|
+
log("Nole tests v" + pkg.version);
|
|
79
|
+
try {
|
|
80
|
+
await Delay(dependencyResolveWaitPeriod);
|
|
81
|
+
|
|
82
|
+
await ManualRun({
|
|
83
|
+
log,
|
|
84
|
+
orderDebug: program.orderDebug,
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
log(" discover: %s", TimeResolve(file));
|
|
88
|
+
log(" resolve: %s", TimeResolve(prop - file));
|
|
89
|
+
log(
|
|
90
|
+
" tests: %s",
|
|
91
|
+
TimeResolve(time.end() - prop - dependencyResolveWaitPeriod)
|
|
92
|
+
);
|
|
93
|
+
process.exit(0);
|
|
94
|
+
} catch (e) {
|
|
95
|
+
console.error(e);
|
|
96
|
+
process.exit(1);
|
|
97
|
+
}
|
|
98
|
+
})
|
|
99
|
+
.catch((e) => {
|
|
100
|
+
failed("Error occurred on resolving files");
|
|
101
|
+
console.error(e.stack || e);
|
|
74
102
|
process.exit(1);
|
|
75
|
-
}
|
|
76
|
-
}).catch(e => {
|
|
77
|
-
failed('Error occurred on resolving files');
|
|
78
|
-
console.error(e.stack || e);
|
|
79
|
-
process.exit(1);
|
|
80
|
-
})
|
|
103
|
+
});
|
|
81
104
|
}
|
|
82
105
|
|
|
83
|
-
|
|
84
106
|
function failed(message) {
|
|
85
|
-
console.error(colors.bold(colors.red(
|
|
86
|
-
}
|
|
107
|
+
console.error(colors.bold(colors.red(" (failed) " + message)));
|
|
108
|
+
}
|
package/dist/data.js
CHANGED
package/dist/data.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"data.js","sourceRoot":"","sources":["../src/data.ts"],"names":[],"mappings":"AAEA,MAAM,GAAG,GAAG,YAAY,CAAC;AAEzB,MAAM,UAAU,OAAO;IACrB,IAAI,CAAC,GAAQ,MAAM,CAAC;IAEpB,IAAI,CAAC,CAAC,GAAG,CAAC,EAAE;QACV,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC;KACf;IAED,OAAO,CAAC,CAAC,GAAG,CAAC,GAAG,IAAI,GAAG,EAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"data.js","sourceRoot":"","sources":["../src/data.ts"],"names":[],"mappings":"AAEA,MAAM,GAAG,GAAG,YAAY,CAAC;AAEzB,MAAM,UAAU,OAAO;IACrB,IAAI,CAAC,GAAQ,MAAM,CAAC;IAEpB,IAAI,CAAC,CAAC,GAAG,CAAC,EAAE;QACV,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC;KACf;IAED,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,IAAI,GAAG,EAAa,CAAC,CAAC;AACzC,CAAC"}
|
package/dist/decorators.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { HookType, ClassDefition } from "./test.js";
|
|
2
2
|
export declare function Spec(timeout?: number): MethodDecorator;
|
|
3
3
|
export declare function Dependency<T>(dependency: ClassDefition<T>): PropertyDecorator;
|
|
4
|
-
export declare function Dependencies(dependencies: ClassDefition<any>[]): ClassDecorator;
|
|
4
|
+
export declare function Dependencies(dependencies: (() => ClassDefition<any>[]) | ClassDefition<any>[]): ClassDecorator;
|
|
5
|
+
export declare function Dependents(dependents: (() => ClassDefition<any>[]) | ClassDefition<any>[]): ClassDecorator;
|
|
5
6
|
export declare function Hook(type: HookType, timeout?: number): MethodDecorator;
|
|
6
7
|
export declare function Skip(reason?: string): MethodDecorator;
|
|
7
8
|
export declare function SkipClass(reason?: string): ClassDecorator;
|
package/dist/decorators.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"decorators.d.ts","sourceRoot":"","sources":["../src/decorators.ts"],"names":[],"mappings":"AACA,OAAO,EAAQ,QAAQ,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAO1D,wBAAgB,IAAI,CAAC,OAAO,GAAE,MAAa,GAAG,eAAe,CAI5D;
|
|
1
|
+
{"version":3,"file":"decorators.d.ts","sourceRoot":"","sources":["../src/decorators.ts"],"names":[],"mappings":"AACA,OAAO,EAAQ,QAAQ,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAO1D,wBAAgB,IAAI,CAAC,OAAO,GAAE,MAAa,GAAG,eAAe,CAI5D;AAMD,wBAAgB,UAAU,CAAC,CAAC,EAAE,UAAU,EAAE,aAAa,CAAC,CAAC,CAAC,GAAG,iBAAiB,CAI7E;AAMD,wBAAgB,YAAY,CAC1B,YAAY,EAAE,CAAC,MAAM,aAAa,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,aAAa,CAAC,GAAG,CAAC,EAAE,GAChE,cAAc,CAgBhB;AAMD,wBAAgB,UAAU,CACxB,UAAU,EAAE,CAAC,MAAM,aAAa,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,aAAa,CAAC,GAAG,CAAC,EAAE,GAC9D,cAAc,CAgBhB;AAOD,wBAAgB,IAAI,CAAC,IAAI,EAAE,QAAQ,EAAE,OAAO,GAAE,MAAa,GAAG,eAAe,CAI5E;AAMD,wBAAgB,IAAI,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,eAAe,CAIrD;AAMD,wBAAgB,SAAS,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,cAAc,CAIzD"}
|
package/dist/decorators.js
CHANGED
|
@@ -13,14 +13,24 @@ export function Dependency(dependency) {
|
|
|
13
13
|
}
|
|
14
14
|
export function Dependencies(dependencies) {
|
|
15
15
|
return function (target) {
|
|
16
|
-
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
|
|
16
|
+
setImmediate(() => {
|
|
17
|
+
const value = isFunction(dependencies) ? dependencies() : dependencies;
|
|
18
|
+
for (const dependency of value) {
|
|
19
|
+
const propertyKey = validPropertyName(dependency.name);
|
|
20
|
+
DeclareDependencyForTestClass({ constructor: target }, propertyKey, dependency);
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
export function Dependents(dependents) {
|
|
26
|
+
return function (target) {
|
|
27
|
+
setImmediate(() => {
|
|
28
|
+
const value = isFunction(dependents) ? dependents() : dependents;
|
|
29
|
+
for (const dependent of value) {
|
|
30
|
+
const propertyKey = validPropertyName(target.name);
|
|
31
|
+
DeclareDependencyForTestClass({ constructor: dependent }, propertyKey, target);
|
|
32
|
+
}
|
|
33
|
+
});
|
|
24
34
|
};
|
|
25
35
|
}
|
|
26
36
|
export function Hook(type, timeout = 5000) {
|
|
@@ -30,57 +40,57 @@ export function Hook(type, timeout = 5000) {
|
|
|
30
40
|
}
|
|
31
41
|
export function Skip(reason) {
|
|
32
42
|
return function (target, propertyKey) {
|
|
33
|
-
DeclareAsSkipped(target, propertyKey, reason ? reason :
|
|
43
|
+
DeclareAsSkipped(target, propertyKey, reason ? reason : "");
|
|
34
44
|
};
|
|
35
45
|
}
|
|
36
46
|
export function SkipClass(reason) {
|
|
37
47
|
return function (target) {
|
|
38
|
-
DeclareAsSkippedClass(target, reason ? reason :
|
|
48
|
+
DeclareAsSkippedClass(target, reason ? reason : "");
|
|
39
49
|
};
|
|
40
50
|
}
|
|
41
51
|
function GetTestInstanceOfTarget(target) {
|
|
42
52
|
let instance = HashMap().get(target);
|
|
43
53
|
if (!instance) {
|
|
44
|
-
HashMap().set(target, instance = new Test(target));
|
|
54
|
+
HashMap().set(target, (instance = new Test(target)));
|
|
45
55
|
}
|
|
46
56
|
return instance;
|
|
47
57
|
}
|
|
48
58
|
function DeclareDependencyForTestClass(protoOfTarget, propertyKey, dependency) {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
59
|
+
const target = protoOfTarget.constructor;
|
|
60
|
+
const test = GetTestInstanceOfTarget(target);
|
|
61
|
+
const depTest = GetTestInstanceOfTarget(dependency);
|
|
52
62
|
test.dependencies.push({ propertyKey, dependency: depTest });
|
|
53
63
|
depTest.dependents.push(test);
|
|
54
64
|
}
|
|
55
65
|
function DeclareSpecForTestClass(protoOfTarget, propertyKey, timeout) {
|
|
56
|
-
|
|
57
|
-
|
|
66
|
+
const target = protoOfTarget.constructor;
|
|
67
|
+
const test = GetTestInstanceOfTarget(target);
|
|
58
68
|
if (test.hooks.has(propertyKey)) {
|
|
59
|
-
throw new Error(
|
|
69
|
+
throw new Error("@Hook cannot be used with @Spec! Test: ");
|
|
60
70
|
}
|
|
61
71
|
if (test.specs.has(propertyKey)) {
|
|
62
|
-
throw new Error(
|
|
72
|
+
throw new Error("Multiple @Spec for a single method is prohibited");
|
|
63
73
|
}
|
|
64
74
|
test.specs.set(propertyKey, { timeout });
|
|
65
75
|
}
|
|
66
76
|
function DeclareHookForTestClass(protoOfTarget, propertyKey, hookType, timeout) {
|
|
67
|
-
|
|
68
|
-
|
|
77
|
+
const target = protoOfTarget.constructor;
|
|
78
|
+
const test = GetTestInstanceOfTarget(target);
|
|
69
79
|
if (test.specs.has(propertyKey)) {
|
|
70
|
-
throw new Error(
|
|
80
|
+
throw new Error("@Hook cannot be used with @Spec");
|
|
71
81
|
}
|
|
72
82
|
if (test.hooks.has(propertyKey)) {
|
|
73
|
-
throw new Error(
|
|
83
|
+
throw new Error("Multiple @Hook for a single method is prohibited");
|
|
74
84
|
}
|
|
75
85
|
test.hooks.set(propertyKey, { type: hookType, timeout });
|
|
76
86
|
}
|
|
77
87
|
function DeclareAsSkipped(protoOfTarget, propertyKey, reason) {
|
|
78
|
-
|
|
79
|
-
|
|
88
|
+
const target = protoOfTarget.constructor;
|
|
89
|
+
const test = GetTestInstanceOfTarget(target);
|
|
80
90
|
if (test.skip.has(propertyKey)) {
|
|
81
|
-
|
|
91
|
+
const obj = test.skip.get(propertyKey);
|
|
82
92
|
if (reason) {
|
|
83
|
-
obj.reason = (obj.reason ? obj.reason +
|
|
93
|
+
obj.reason = (obj.reason ? obj.reason + ", " : "") + reason;
|
|
84
94
|
}
|
|
85
95
|
}
|
|
86
96
|
else {
|
|
@@ -88,7 +98,21 @@ function DeclareAsSkipped(protoOfTarget, propertyKey, reason) {
|
|
|
88
98
|
}
|
|
89
99
|
}
|
|
90
100
|
function DeclareAsSkippedClass(target, reason) {
|
|
91
|
-
|
|
101
|
+
const test = GetTestInstanceOfTarget(target);
|
|
92
102
|
test.skipClass = { reason };
|
|
93
103
|
}
|
|
104
|
+
function validPropertyName(name) {
|
|
105
|
+
return camelcase(name, {
|
|
106
|
+
preserveConsecutiveUppercase: process.env.NOLE_PRESERVE_CONSECUTIVE_UPPERCASE == undefined
|
|
107
|
+
? true
|
|
108
|
+
: process.env.NOLE_PRESERVE_CONSECUTIVE_UPPERCASE === "true",
|
|
109
|
+
pascalCase: process.env.NOLE_PASCALCASE == undefined
|
|
110
|
+
? false
|
|
111
|
+
: process.env.NOLE_PASCALCASE === "true",
|
|
112
|
+
locale: "en-US",
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
function isFunction(thing) {
|
|
116
|
+
return typeof thing !== "object" && typeof thing === "function";
|
|
117
|
+
}
|
|
94
118
|
//# sourceMappingURL=decorators.js.map
|
package/dist/decorators.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"decorators.js","sourceRoot":"","sources":["../src/decorators.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,IAAI,EAA2B,MAAM,WAAW,CAAC;AAC1D,OAAO,SAAS,MAAM,WAAW,CAAC;AAMlC,MAAM,UAAU,IAAI,CAAC,UAAkB,IAAI;IACzC,OAAO,UAAU,MAAM,EAAE,WAAW;QAClC,uBAAuB,CAAC,MAAM,EAAU,WAAW,EAAE,OAAO,CAAC,CAAC;IAChE,CAAC,
|
|
1
|
+
{"version":3,"file":"decorators.js","sourceRoot":"","sources":["../src/decorators.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC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K,QAAQ,IAAI,OAAO,KAAK,KAAK,UAAU,CAAC;AAClE,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { Dependency, Spec, Hook, Skip, SkipClass, Dependencies } from
|
|
2
|
-
export { HookType } from
|
|
3
|
-
export { skipTest } from
|
|
1
|
+
export { Dependency, Spec, Hook, Skip, SkipClass, Dependencies, Dependencies as After, Dependents as Before, Dependents, } from "./decorators.js";
|
|
2
|
+
export { HookType } from "./test.js";
|
|
3
|
+
export { skipTest } from "./dynamic.js";
|
|
4
4
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,SAAS,EACT,YAAY,EACZ,YAAY,IAAI,KAAK,EACrB,UAAU,IAAI,MAAM,EACpB,UAAU,GACX,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACrC,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { Dependency, Spec, Hook, Skip, SkipClass, Dependencies } from
|
|
2
|
-
export { HookType } from
|
|
3
|
-
export { skipTest } from
|
|
1
|
+
export { Dependency, Spec, Hook, Skip, SkipClass, Dependencies, Dependencies as After, Dependents as Before, Dependents, } from "./decorators.js";
|
|
2
|
+
export { HookType } from "./test.js";
|
|
3
|
+
export { skipTest } from "./dynamic.js";
|
|
4
4
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,SAAS,EACT,YAAY,EACZ,YAAY,IAAI,KAAK,EACrB,UAAU,IAAI,MAAM,EACpB,UAAU,GACX,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACrC,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC"}
|
package/dist/run.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../src/run.ts"],"names":[],"mappings":"AAeA,UAAU,OAAO;IACf,GAAG,EAAE,QAAQ,CAAC;IACd,UAAU,EAAE,OAAO,
|
|
1
|
+
{"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../src/run.ts"],"names":[],"mappings":"AAeA,UAAU,OAAO;IACf,GAAG,EAAE,QAAQ,CAAC;IACd,UAAU,EAAE,OAAO,CAAC;CACrB;AAED,wBAAgB,SAAS,CAAC,OAAO,EAAE,OAAO,iBA2CzC"}
|
package/dist/run.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { HashMap } from "./data.js";
|
|
2
2
|
import { TimeDifference } from "./utils/time_difference.js";
|
|
3
3
|
import { TimeFactor } from "./utils/time_factor.js";
|
|
4
|
-
import * as clrs from
|
|
4
|
+
import * as clrs from "colors/safe.js";
|
|
5
5
|
import { Executor } from "./utils/executor.js";
|
|
6
6
|
import { HookType } from "./test.js";
|
|
7
7
|
const colors = clrs.default;
|
|
8
|
-
const OK_TEXT = colors.bold(colors.green(
|
|
9
|
-
const SKIP_TEXT = colors.bold(colors.yellow(
|
|
10
|
-
const DYNAMIC_SKIP_TEXT = colors.bold(colors.blue(
|
|
11
|
-
const FAILED_TEXT = colors.bold(colors.red(
|
|
12
|
-
const HOOK_FAILED_TEXT = colors.bold(colors.red(
|
|
8
|
+
const OK_TEXT = colors.bold(colors.green(" (ok) "));
|
|
9
|
+
const SKIP_TEXT = colors.bold(colors.yellow(" (skip) "));
|
|
10
|
+
const DYNAMIC_SKIP_TEXT = colors.bold(colors.blue(" (dskip) "));
|
|
11
|
+
const FAILED_TEXT = colors.bold(colors.red(" (failed) "));
|
|
12
|
+
const HOOK_FAILED_TEXT = colors.bold(colors.red(" (hook failed) "));
|
|
13
13
|
export function ManualRun(options) {
|
|
14
14
|
if (!options.log) {
|
|
15
15
|
options.log = console.log.bind(console);
|
|
@@ -20,7 +20,7 @@ export function ManualRun(options) {
|
|
|
20
20
|
let hashMap = new Map(HashMap());
|
|
21
21
|
if (!hashMap.size) {
|
|
22
22
|
log(`${FAILED_TEXT} no specs found`);
|
|
23
|
-
throw new Error(
|
|
23
|
+
throw new Error("No specs found");
|
|
24
24
|
}
|
|
25
25
|
while (hashMap.size) {
|
|
26
26
|
let test = PickNextTestFromHashMap(hashMap);
|
|
@@ -51,26 +51,28 @@ function PickNextTestFromHashMap(hashMap) {
|
|
|
51
51
|
for (let test of hashMap.values()) {
|
|
52
52
|
if (test.isFinished)
|
|
53
53
|
continue;
|
|
54
|
-
if (!test.dependencies.every(x => x.dependency.isFinished))
|
|
54
|
+
if (!test.dependencies.every((x) => x.dependency.isFinished))
|
|
55
55
|
continue;
|
|
56
56
|
return test;
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
59
|
function CreateInstanceIfNotExists(test) {
|
|
60
60
|
if (!test.testInstance) {
|
|
61
|
-
test.testInstance = new
|
|
61
|
+
test.testInstance = new test.target();
|
|
62
62
|
}
|
|
63
63
|
}
|
|
64
64
|
function HandleDependencies(test) {
|
|
65
65
|
for (let dependency of test.dependencies) {
|
|
66
|
-
test.testInstance[dependency.propertyKey] =
|
|
66
|
+
test.testInstance[dependency.propertyKey] =
|
|
67
|
+
dependency.dependency.testInstance;
|
|
67
68
|
}
|
|
68
69
|
}
|
|
69
70
|
async function HandleBeforeHooks(test, options) {
|
|
70
71
|
for (let [propertyKey, hook] of test.hooks.entries()) {
|
|
71
72
|
if (hook.type != HookType.Before)
|
|
72
73
|
continue;
|
|
73
|
-
let hookName = colors.bold(colors.yellow(test.name +
|
|
74
|
+
let hookName = colors.bold(colors.yellow(test.name +
|
|
75
|
+
(propertyKey != "before" ? `.${propertyKey}:before` : ":before")));
|
|
74
76
|
try {
|
|
75
77
|
if (!options.orderDebug) {
|
|
76
78
|
await Executor(test.testInstance[propertyKey].bind(test.testInstance), hook.timeout);
|
|
@@ -91,7 +93,10 @@ async function HandleBeforeEachHooks(test, options) {
|
|
|
91
93
|
for (let [propertyKey, hook] of test.hooks.entries()) {
|
|
92
94
|
if (hook.type != HookType.BeforeEach)
|
|
93
95
|
continue;
|
|
94
|
-
let hookName = colors.bold(colors.yellow(test.name +
|
|
96
|
+
let hookName = colors.bold(colors.yellow(test.name +
|
|
97
|
+
(propertyKey != "beforeEach"
|
|
98
|
+
? `.${propertyKey}:beforeEach`
|
|
99
|
+
: ":beforeEach")));
|
|
95
100
|
try {
|
|
96
101
|
if (!options.orderDebug) {
|
|
97
102
|
await Executor(test.testInstance[propertyKey].bind(test.testInstance), hook.timeout);
|
|
@@ -112,7 +117,10 @@ async function HandleAfterEachHooks(test, options) {
|
|
|
112
117
|
for (let [propertyKey, hook] of test.hooks.entries()) {
|
|
113
118
|
if (hook.type != HookType.AfterEach)
|
|
114
119
|
continue;
|
|
115
|
-
let hookName = colors.bold(colors.yellow(test.name +
|
|
120
|
+
let hookName = colors.bold(colors.yellow(test.name +
|
|
121
|
+
(propertyKey != "afterEach"
|
|
122
|
+
? `.${propertyKey}:afterEach`
|
|
123
|
+
: ":afterEach")));
|
|
116
124
|
try {
|
|
117
125
|
if (!options.orderDebug) {
|
|
118
126
|
await Executor(test.testInstance[propertyKey].bind(test.testInstance), hook.timeout);
|
|
@@ -132,11 +140,13 @@ async function HandleAfterEachHooks(test, options) {
|
|
|
132
140
|
async function HandleSpecs(test, options) {
|
|
133
141
|
const log = options.log;
|
|
134
142
|
for (let [propertyKey, spec] of test.specs.entries()) {
|
|
135
|
-
let testName = colors.bold(colors.yellow(test.name +
|
|
143
|
+
let testName = colors.bold(colors.yellow(test.name + "." + propertyKey));
|
|
136
144
|
const shouldPropertySkip = test.skip.has(propertyKey);
|
|
137
145
|
if (shouldPropertySkip || test.skipClass) {
|
|
138
|
-
let reason = shouldPropertySkip
|
|
139
|
-
|
|
146
|
+
let reason = shouldPropertySkip
|
|
147
|
+
? test.skip.get(propertyKey).reason
|
|
148
|
+
: test.skipClass.reason;
|
|
149
|
+
log(`${SKIP_TEXT} ${" ".repeat(9)} ${testName}() ${reason ? "{" + reason + "}" : ""}`);
|
|
140
150
|
continue;
|
|
141
151
|
}
|
|
142
152
|
await HandleBeforeEachHooks(test, options);
|
|
@@ -151,7 +161,7 @@ async function HandleSpecs(test, options) {
|
|
|
151
161
|
catch (e) {
|
|
152
162
|
if (e?._nole_anchor) {
|
|
153
163
|
let reason = e.reason;
|
|
154
|
-
log(`${DYNAMIC_SKIP_TEXT} ${
|
|
164
|
+
log(`${DYNAMIC_SKIP_TEXT} ${" ".repeat(8)} ${testName}() ${reason ? "{" + reason + "}" : ""}`);
|
|
155
165
|
continue;
|
|
156
166
|
}
|
|
157
167
|
let timeText = TimeFactor(start.end(), spec.timeout);
|
|
@@ -166,7 +176,8 @@ async function HandleAfterHooks(test, options) {
|
|
|
166
176
|
for (let [propertyKey, hook] of test.hooks.entries()) {
|
|
167
177
|
if (hook.type != HookType.After)
|
|
168
178
|
continue;
|
|
169
|
-
let hookName = colors.bold(colors.yellow(test.name +
|
|
179
|
+
let hookName = colors.bold(colors.yellow(test.name +
|
|
180
|
+
(propertyKey != "after" ? `.${propertyKey}:after` : ":after")));
|
|
170
181
|
try {
|
|
171
182
|
if (!options.orderDebug) {
|
|
172
183
|
await Executor(test.testInstance[propertyKey].bind(test.testInstance), hook.timeout);
|
|
@@ -186,14 +197,15 @@ async function HandleAfterHooks(test, options) {
|
|
|
186
197
|
async function HandleCleanUp(test, options) {
|
|
187
198
|
if (test.cleanUpCalled)
|
|
188
199
|
return;
|
|
189
|
-
if (!test.dependents.every(dependent => dependent.isFinished && dependent.cleanUpCalled))
|
|
200
|
+
if (!test.dependents.every((dependent) => dependent.isFinished && dependent.cleanUpCalled))
|
|
190
201
|
return;
|
|
191
202
|
test.cleanUpCalled = true;
|
|
192
203
|
const log = options.log;
|
|
193
204
|
for (let [propertyKey, hook] of test.hooks.entries()) {
|
|
194
205
|
if (hook.type != HookType.CleanUp)
|
|
195
206
|
continue;
|
|
196
|
-
let hookName = colors.bold(colors.yellow(test.name +
|
|
207
|
+
let hookName = colors.bold(colors.yellow(test.name +
|
|
208
|
+
(propertyKey != "cleanUp" ? `.${propertyKey}:cleanUp` : ":cleanUp")));
|
|
197
209
|
let start = TimeDifference.begin();
|
|
198
210
|
try {
|
|
199
211
|
if (!options.orderDebug) {
|
|
@@ -213,11 +225,15 @@ async function HandleCleanUp(test, options) {
|
|
|
213
225
|
}
|
|
214
226
|
}
|
|
215
227
|
function DependencyLock(hashMap) {
|
|
216
|
-
console.error(FAILED_TEXT +
|
|
217
|
-
|
|
228
|
+
console.error(FAILED_TEXT +
|
|
229
|
+
colors.red("Looks like there is confict issue for dependency resolving!"));
|
|
230
|
+
console.error("Possible conflicts;");
|
|
218
231
|
for (let test of hashMap.values()) {
|
|
219
|
-
console.error(`- class ${test.name} { ${test.dependencies
|
|
232
|
+
console.error(`- class ${test.name} { ${test.dependencies
|
|
233
|
+
.filter((x) => !x.dependency.isFinished)
|
|
234
|
+
.map((x) => `@Dependency(${x.dependency.name}) ${x.propertyKey}`)
|
|
235
|
+
.join(", ")} }`);
|
|
220
236
|
}
|
|
221
|
-
throw new Error(
|
|
237
|
+
throw new Error("Dependency lock occurred!");
|
|
222
238
|
}
|
|
223
239
|
//# sourceMappingURL=run.js.map
|