nole 2.2.2 → 3.0.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.
- package/README.md +142 -236
- package/bin/nole.js +43 -44
- package/dist/const.d.ts +8 -0
- package/dist/const.d.ts.map +1 -0
- package/dist/const.js +9 -0
- package/dist/core.d.ts +22 -0
- package/dist/core.d.ts.map +1 -0
- package/dist/core.js +56 -0
- package/dist/dynamic.d.ts +4 -1
- package/dist/dynamic.d.ts.map +1 -1
- package/dist/dynamic.js +25 -1
- package/dist/handle/after-each-hooks.d.ts +3 -0
- package/dist/handle/after-each-hooks.d.ts.map +1 -0
- package/dist/handle/after-each-hooks.js +26 -0
- package/dist/handle/after-hooks.d.ts +3 -0
- package/dist/handle/after-hooks.d.ts.map +1 -0
- package/dist/handle/after-hooks.js +24 -0
- package/dist/handle/before-each-hooks.d.ts +3 -0
- package/dist/handle/before-each-hooks.d.ts.map +1 -0
- package/dist/handle/before-each-hooks.js +26 -0
- package/dist/handle/before-hooks.d.ts +3 -0
- package/dist/handle/before-hooks.d.ts.map +1 -0
- package/dist/handle/before-hooks.js +24 -0
- package/dist/handle/cleanup-hooks.d.ts +3 -0
- package/dist/handle/cleanup-hooks.d.ts.map +1 -0
- package/dist/handle/cleanup-hooks.js +34 -0
- package/dist/handle/specs.d.ts +3 -0
- package/dist/handle/specs.d.ts.map +1 -0
- package/dist/handle/specs.js +41 -0
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -4
- package/dist/run.d.ts +7 -6
- package/dist/run.d.ts.map +1 -1
- package/dist/run.js +158 -196
- package/dist/symbol.d.ts +2 -0
- package/dist/symbol.d.ts.map +1 -0
- package/dist/symbol.js +2 -0
- package/dist/test-wrap.d.ts +37 -0
- package/dist/test-wrap.d.ts.map +1 -0
- package/dist/test-wrap.js +30 -0
- package/dist/utils/executor.js +1 -1
- package/dist/utils/executor.test.d.ts +3 -1
- package/dist/utils/executor.test.d.ts.map +1 -1
- package/dist/utils/executor.test.js +3 -30
- package/dist/utils/time_difference.d.ts +9 -0
- package/dist/utils/time_difference.d.ts.map +1 -1
- package/dist/utils/time_difference.js +10 -1
- package/dist/utils/time_difference.test.d.ts +3 -1
- package/dist/utils/time_difference.test.d.ts.map +1 -1
- package/dist/utils/time_difference.test.js +5 -18
- package/dist/utils/time_factor.d.ts.map +1 -1
- package/dist/utils/time_factor.js +2 -3
- package/dist/utils/time_factor.test.d.ts +3 -1
- package/dist/utils/time_factor.test.d.ts.map +1 -1
- package/dist/utils/time_factor.test.js +3 -18
- package/package.json +6 -6
- package/src/const.ts +11 -0
- package/src/core.ts +89 -0
- package/src/dynamic.ts +43 -1
- package/src/handle/after-each-hooks.ts +41 -0
- package/src/handle/after-hooks.ts +38 -0
- package/src/handle/before-each-hooks.ts +40 -0
- package/src/handle/before-hooks.ts +39 -0
- package/src/handle/cleanup-hooks.ts +55 -0
- package/src/handle/specs.ts +68 -0
- package/src/index.ts +3 -13
- package/src/run.ts +184 -256
- package/src/symbol.ts +1 -0
- package/src/{test.ts → test-wrap.ts} +13 -12
- package/src/utils/executor.test.ts +2 -5
- package/src/utils/executor.ts +1 -1
- package/src/utils/time_difference.test.ts +2 -3
- package/src/utils/time_factor.test.ts +2 -3
- package/src/utils/time_factor.ts +1 -3
- package/test/basic.test.ts +8 -9
- package/test/before.test.ts +14 -27
- package/test/clean-up.test.ts +12 -16
- package/test/dynamic-skip.test.ts +2 -4
- package/test/dynamic.test.ts +23 -8
- package/test/extend.test.ts +43 -0
- package/test/hook.test.ts +9 -10
- package/test/multi-dependency.test.ts +25 -27
- package/test/multiple-uppercased-chars.test.ts +8 -7
- package/test/skip-all.test.ts +4 -13
- package/test/turkish-chars.test.ts +8 -7
- package/tsconfig.json +5 -7
- package/dist/data.d.ts +0 -3
- package/dist/data.d.ts.map +0 -1
- package/dist/data.js +0 -9
- package/dist/data.js.map +0 -1
- package/dist/decorators.d.ts +0 -9
- package/dist/decorators.d.ts.map +0 -1
- package/dist/decorators.js +0 -118
- package/dist/decorators.js.map +0 -1
- package/dist/dynamic.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/run.js.map +0 -1
- package/dist/test.d.ts +0 -39
- package/dist/test.d.ts.map +0 -1
- package/dist/test.js +0 -25
- package/dist/test.js.map +0 -1
- package/dist/utils/executor.js.map +0 -1
- package/dist/utils/executor.test.js.map +0 -1
- package/dist/utils/time_difference.js.map +0 -1
- package/dist/utils/time_difference.test.js.map +0 -1
- package/dist/utils/time_factor.js.map +0 -1
- package/dist/utils/time_factor.test.js.map +0 -1
- package/src/data.ts +0 -13
- package/src/decorators.ts +0 -208
package/dist/test.d.ts
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
export interface IDependency {
|
|
2
|
-
propertyKey: string;
|
|
3
|
-
dependency: Test;
|
|
4
|
-
}
|
|
5
|
-
export interface ISpec {
|
|
6
|
-
timeout: number;
|
|
7
|
-
}
|
|
8
|
-
export interface IHook {
|
|
9
|
-
type: HookType;
|
|
10
|
-
timeout: number;
|
|
11
|
-
}
|
|
12
|
-
export interface ISkip {
|
|
13
|
-
reason: string;
|
|
14
|
-
}
|
|
15
|
-
export declare class Test {
|
|
16
|
-
target: any;
|
|
17
|
-
dependencies: IDependency[];
|
|
18
|
-
dependents: Test[];
|
|
19
|
-
skip: Map<string, ISkip>;
|
|
20
|
-
skipClass: ISkip | null;
|
|
21
|
-
specs: Map<string, ISpec>;
|
|
22
|
-
hooks: Map<string, IHook>;
|
|
23
|
-
isFinished: boolean;
|
|
24
|
-
cleanUpCalled: boolean;
|
|
25
|
-
testInstance: any;
|
|
26
|
-
constructor(target: any);
|
|
27
|
-
get name(): any;
|
|
28
|
-
}
|
|
29
|
-
export declare enum HookType {
|
|
30
|
-
Before = 0,
|
|
31
|
-
After = 1,
|
|
32
|
-
BeforeEach = 2,
|
|
33
|
-
AfterEach = 3,
|
|
34
|
-
CleanUp = 4
|
|
35
|
-
}
|
|
36
|
-
export interface ClassDefition<T> {
|
|
37
|
-
new (): T;
|
|
38
|
-
}
|
|
39
|
-
//# sourceMappingURL=test.d.ts.map
|
package/dist/test.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"test.d.ts","sourceRoot":"","sources":["../src/test.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,WAAW;IAC1B,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,IAAI,CAAC;CAClB;AAED,MAAM,WAAW,KAAK;IACpB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,KAAK;IACpB,IAAI,EAAE,QAAQ,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,KAAK;IACpB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,qBAAa,IAAI;IAWI,MAAM,EAAE,GAAG;IAV9B,YAAY,EAAE,WAAW,EAAE,CAAM;IACjC,UAAU,EAAE,IAAI,EAAE,CAAM;IACxB,IAAI,qBAA4B;IAChC,SAAS,EAAE,KAAK,GAAG,IAAI,CAAQ;IAC/B,KAAK,qBAA4B;IACjC,KAAK,qBAA4B;IACjC,UAAU,EAAE,OAAO,CAAS;IAC5B,aAAa,EAAE,OAAO,CAAS;IAC/B,YAAY,EAAE,GAAG,CAAC;gBAEC,MAAM,EAAE,GAAG;IAE9B,IAAI,IAAI,QAEP;CACF;AAED,oBAAY,QAAQ;IAClB,MAAM,IAAA;IACN,KAAK,IAAA;IACL,UAAU,IAAA;IACV,SAAS,IAAA;IACT,OAAO,IAAA;CACR;AAED,MAAM,WAAW,aAAa,CAAC,CAAC;IAC9B,QAAQ,CAAC,CAAC;CACX"}
|
package/dist/test.js
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
export class Test {
|
|
2
|
-
constructor(target) {
|
|
3
|
-
this.target = target;
|
|
4
|
-
this.dependencies = [];
|
|
5
|
-
this.dependents = [];
|
|
6
|
-
this.skip = new Map();
|
|
7
|
-
this.skipClass = null;
|
|
8
|
-
this.specs = new Map();
|
|
9
|
-
this.hooks = new Map();
|
|
10
|
-
this.isFinished = false;
|
|
11
|
-
this.cleanUpCalled = false;
|
|
12
|
-
}
|
|
13
|
-
get name() {
|
|
14
|
-
return this.target.name;
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
export var HookType;
|
|
18
|
-
(function (HookType) {
|
|
19
|
-
HookType[HookType["Before"] = 0] = "Before";
|
|
20
|
-
HookType[HookType["After"] = 1] = "After";
|
|
21
|
-
HookType[HookType["BeforeEach"] = 2] = "BeforeEach";
|
|
22
|
-
HookType[HookType["AfterEach"] = 3] = "AfterEach";
|
|
23
|
-
HookType[HookType["CleanUp"] = 4] = "CleanUp";
|
|
24
|
-
})(HookType || (HookType = {}));
|
|
25
|
-
//# sourceMappingURL=test.js.map
|
package/dist/test.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"test.js","sourceRoot":"","sources":["../src/test.ts"],"names":[],"mappings":"AAkBA,MAAM,OAAO,IAAI;IAWf,YAAmB,MAAW;QAAX,WAAM,GAAN,MAAM,CAAK;QAV9B,iBAAY,GAAkB,EAAE,CAAC;QACjC,eAAU,GAAW,EAAE,CAAC;QACxB,SAAI,GAAG,IAAI,GAAG,EAAiB,CAAC;QAChC,cAAS,GAAiB,IAAI,CAAC;QAC/B,UAAK,GAAG,IAAI,GAAG,EAAiB,CAAC;QACjC,UAAK,GAAG,IAAI,GAAG,EAAiB,CAAC;QACjC,eAAU,GAAY,KAAK,CAAC;QAC5B,kBAAa,GAAY,KAAK,CAAC;IAGE,CAAC;IAElC,IAAI,IAAI;QACN,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC;IAC1B,CAAC;CACF;AAED,MAAM,CAAN,IAAY,QAMX;AAND,WAAY,QAAQ;IAClB,2CAAM,CAAA;IACN,yCAAK,CAAA;IACL,mDAAU,CAAA;IACV,iDAAS,CAAA;IACT,6CAAO,CAAA;AACT,CAAC,EANW,QAAQ,KAAR,QAAQ,QAMnB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"executor.js","sourceRoot":"","sources":["../../src/utils/executor.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,QAAQ,CAAC,EAAY,EAAE,OAAe;IACpD,OAAO,IAAI,OAAO,CAAC,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE;QAC3C,IAAI,QAAQ,GAAG,IAAI,CAAC;QAEpB,IAAI,CAAC;YACH,IAAI,aAAa,GAAG,EAAE,EAAE,CAAC;YACzB,IAAI,aAAa,IAAI,aAAa,CAAC,IAAI,EAAE,CAAC;gBACxC,QAAQ,GAAG,UAAU,CAAC;oBACpB,MAAM,CAAC,IAAI,KAAK,CAAC,2BAA2B,GAAG,OAAO,CAAC,CAAC,CAAC;gBAC3D,CAAC,EAAE,OAAO,CAAC,CAAC;gBAEZ,MAAM,aAAa,CAAC;YACtB,CAAC;QACH,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,MAAM,CAAC,CAAC,CAAC,CAAC;QACZ,CAAC;QAED,YAAY,CAAC,QAAS,CAAC,CAAC;QAExB,OAAO,EAAE,CAAC;IACZ,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"executor.test.js","sourceRoot":"","sources":["../../src/utils/executor.test.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AACjC,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AACnC,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAEzC,MAAM,OAAO,YAAY;IAEjB,AAAN,KAAK,CAAC,QAAQ;QACZ,MAAM,QAAQ,CAAC,GAAG,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;QAC3B,MAAM,QAAQ,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IACnC,CAAC;IAGK,AAAN,KAAK,CAAC,MAAM;QACV,MAAM,MAAM,CAAC,OAAO,CAAC,GAAG,EAAE;YACxB,OAAO,QAAQ,CAAC,GAAG,EAAE;gBACnB,MAAM,IAAI,KAAK,CAAC,QAAQ,CAAC,CAAC;YAC5B,CAAC,EAAE,CAAC,CAAC,CAAC;QACR,CAAC,CAAC,CAAC;IACL,CAAC;IAGK,AAAN,KAAK,CAAC,OAAO;QACX,MAAM,MAAM,CAAC,OAAO,CAAC,GAAG,EAAE;YACxB,OAAO,QAAQ,CAAC,GAAG,EAAE,CAAC,IAAI,OAAO,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;QACnD,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AApBO;IADL,IAAI,EAAE;;;;4CAIN;AAGK;IADL,IAAI,EAAE;;;;0CAON;AAGK;IADL,IAAI,EAAE;;;;2CAKN"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"time_difference.js","sourceRoot":"","sources":["../../src/utils/time_difference.ts"],"names":[],"mappings":"AAGA,MAAM,OAAO,cAAc;IAGzB;QACE,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IAClC,CAAC;IAKM,MAAM,CAAC,KAAK;QACjB,OAAO,IAAI,cAAc,EAAE,CAAC;IAC9B,CAAC;IAKD,GAAG;QACD,IAAI,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAExC,OAAO,IAAI,CAAC,CAAC,CAAC,GAAG,IAAI,GAAG,IAAI,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC;IACxC,CAAC;CACF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"time_difference.test.js","sourceRoot":"","sources":["../../src/utils/time_difference.test.ts"],"names":[],"mappings":";;;;;;;;;AACA,OAAO,EAAE,IAA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E,CAAC,CAAC,CAAC;YACvB,UAAU,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,CAAC;YACtB,UAAU,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC;YACrB,UAAU,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC;YACrB,UAAU,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC;YACrB,UAAU,CAAC,CAAC,GAAG,GAAG,EAAE,CAAC,CAAC,CAAC;YACvB,UAAU,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;YACjB,UAAU,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC;QACvB,CAAC;IACH,CAAC;CACF;AAvBO;IADL,IAAI,EAAE;;;;8CAuBN"}
|
package/src/data.ts
DELETED
package/src/decorators.ts
DELETED
|
@@ -1,208 +0,0 @@
|
|
|
1
|
-
import { HashMap } from "./data.js";
|
|
2
|
-
import { Test, HookType, ClassDefition } from "./test.js";
|
|
3
|
-
import camelcase from "camelcase";
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Assignes method as test case
|
|
7
|
-
* @param timeout Timeout of case in milliseconds
|
|
8
|
-
*/
|
|
9
|
-
export function Spec(timeout: number = 5000): MethodDecorator {
|
|
10
|
-
return function (target, propertyKey) {
|
|
11
|
-
DeclareSpecForTestClass(target, <string>propertyKey, timeout);
|
|
12
|
-
};
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Assignes dependency for test class
|
|
17
|
-
* @param dependency a Test class that needed
|
|
18
|
-
*/
|
|
19
|
-
export function Dependency<T>(dependency: ClassDefition<T>): PropertyDecorator {
|
|
20
|
-
return function (target, propertyKey) {
|
|
21
|
-
DeclareDependencyForTestClass(target, <string>propertyKey, dependency);
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Assignes dependencies for test class
|
|
27
|
-
* @param dependencies a Test class array that needed
|
|
28
|
-
*/
|
|
29
|
-
export function Dependencies(
|
|
30
|
-
dependencies: (() => ClassDefition<any>[]) | ClassDefition<any>[]
|
|
31
|
-
): ClassDecorator {
|
|
32
|
-
return function (target) {
|
|
33
|
-
setImmediate(() => {
|
|
34
|
-
const value = isFunction(dependencies) ? dependencies() : dependencies;
|
|
35
|
-
|
|
36
|
-
for (const dependency of value) {
|
|
37
|
-
const propertyKey = validPropertyName(dependency.name);
|
|
38
|
-
|
|
39
|
-
DeclareDependencyForTestClass(
|
|
40
|
-
{ constructor: target },
|
|
41
|
-
propertyKey,
|
|
42
|
-
dependency
|
|
43
|
-
);
|
|
44
|
-
}
|
|
45
|
-
});
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* Reverse dependencies for assuring execution order
|
|
51
|
-
* @param dependents a function that returns a Test class array
|
|
52
|
-
*/
|
|
53
|
-
export function Dependents(
|
|
54
|
-
dependents: (() => ClassDefition<any>[]) | ClassDefition<any>[]
|
|
55
|
-
): ClassDecorator {
|
|
56
|
-
return function (target) {
|
|
57
|
-
setImmediate(() => {
|
|
58
|
-
const value = isFunction(dependents) ? dependents() : dependents;
|
|
59
|
-
|
|
60
|
-
for (const dependent of value) {
|
|
61
|
-
const propertyKey = validPropertyName(target.name);
|
|
62
|
-
|
|
63
|
-
DeclareDependencyForTestClass(
|
|
64
|
-
{ constructor: dependent },
|
|
65
|
-
propertyKey,
|
|
66
|
-
target
|
|
67
|
-
);
|
|
68
|
-
}
|
|
69
|
-
});
|
|
70
|
-
};
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
* Creates hook for test case
|
|
75
|
-
* @param type Hook type
|
|
76
|
-
* @param timeout Timeout of case in milliseconds
|
|
77
|
-
*/
|
|
78
|
-
export function Hook(type: HookType, timeout: number = 5000): MethodDecorator {
|
|
79
|
-
return function (target, propertyKey) {
|
|
80
|
-
DeclareHookForTestClass(target, <string>propertyKey, type, timeout);
|
|
81
|
-
};
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
/**
|
|
85
|
-
* Assigns test spec as skipped
|
|
86
|
-
* @param reason Why skipped
|
|
87
|
-
*/
|
|
88
|
-
export function Skip(reason?: string): MethodDecorator {
|
|
89
|
-
return function (target, propertyKey) {
|
|
90
|
-
DeclareAsSkipped(target, <string>propertyKey, reason ? reason : "");
|
|
91
|
-
};
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
/**
|
|
95
|
-
* Assigns test spec as skipped
|
|
96
|
-
* @param reason Why skipped
|
|
97
|
-
*/
|
|
98
|
-
export function SkipClass(reason?: string): ClassDecorator {
|
|
99
|
-
return function (target) {
|
|
100
|
-
DeclareAsSkippedClass(target, reason ? reason : "");
|
|
101
|
-
};
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
function GetTestInstanceOfTarget(target: any) {
|
|
105
|
-
let instance = HashMap().get(target);
|
|
106
|
-
if (!instance) {
|
|
107
|
-
HashMap().set(target, (instance = new Test(target)));
|
|
108
|
-
}
|
|
109
|
-
return instance;
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
function DeclareDependencyForTestClass(
|
|
113
|
-
protoOfTarget: any,
|
|
114
|
-
propertyKey: string,
|
|
115
|
-
dependency: any
|
|
116
|
-
) {
|
|
117
|
-
const target = protoOfTarget.constructor;
|
|
118
|
-
|
|
119
|
-
const test = GetTestInstanceOfTarget(target);
|
|
120
|
-
const depTest = GetTestInstanceOfTarget(dependency);
|
|
121
|
-
|
|
122
|
-
test.dependencies.push({ propertyKey, dependency: depTest });
|
|
123
|
-
depTest.dependents.push(test);
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
function DeclareSpecForTestClass(
|
|
127
|
-
protoOfTarget: any,
|
|
128
|
-
propertyKey: string,
|
|
129
|
-
timeout: number
|
|
130
|
-
) {
|
|
131
|
-
const target = protoOfTarget.constructor;
|
|
132
|
-
const test = GetTestInstanceOfTarget(target);
|
|
133
|
-
|
|
134
|
-
if (test.hooks.has(propertyKey)) {
|
|
135
|
-
throw new Error("@Hook cannot be used with @Spec! Test: ");
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
if (test.specs.has(propertyKey)) {
|
|
139
|
-
throw new Error("Multiple @Spec for a single method is prohibited");
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
test.specs.set(propertyKey, { timeout });
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
function DeclareHookForTestClass(
|
|
146
|
-
protoOfTarget: any,
|
|
147
|
-
propertyKey: string,
|
|
148
|
-
hookType: HookType,
|
|
149
|
-
timeout: number
|
|
150
|
-
) {
|
|
151
|
-
const target = protoOfTarget.constructor;
|
|
152
|
-
const test = GetTestInstanceOfTarget(target);
|
|
153
|
-
|
|
154
|
-
if (test.specs.has(propertyKey)) {
|
|
155
|
-
throw new Error("@Hook cannot be used with @Spec");
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
if (test.hooks.has(propertyKey)) {
|
|
159
|
-
throw new Error("Multiple @Hook for a single method is prohibited");
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
test.hooks.set(propertyKey, { type: hookType, timeout });
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
function DeclareAsSkipped(
|
|
166
|
-
protoOfTarget: any,
|
|
167
|
-
propertyKey: string,
|
|
168
|
-
reason: string
|
|
169
|
-
) {
|
|
170
|
-
const target = protoOfTarget.constructor;
|
|
171
|
-
const test = GetTestInstanceOfTarget(target);
|
|
172
|
-
|
|
173
|
-
if (test.skip.has(propertyKey)) {
|
|
174
|
-
const obj = test.skip.get(propertyKey)!;
|
|
175
|
-
|
|
176
|
-
if (reason) {
|
|
177
|
-
obj.reason = (obj.reason ? obj.reason + ", " : "") + reason;
|
|
178
|
-
}
|
|
179
|
-
} else {
|
|
180
|
-
test.skip.set(propertyKey, { reason });
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
function DeclareAsSkippedClass(target: any, reason: string) {
|
|
185
|
-
const test = GetTestInstanceOfTarget(target);
|
|
186
|
-
|
|
187
|
-
test.skipClass = { reason };
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
function validPropertyName(name: string) {
|
|
191
|
-
return camelcase(name, {
|
|
192
|
-
preserveConsecutiveUppercase:
|
|
193
|
-
process.env.NOLE_PRESERVE_CONSECUTIVE_UPPERCASE == undefined
|
|
194
|
-
? true
|
|
195
|
-
: process.env.NOLE_PRESERVE_CONSECUTIVE_UPPERCASE === "true",
|
|
196
|
-
|
|
197
|
-
pascalCase:
|
|
198
|
-
process.env.NOLE_PASCALCASE == undefined
|
|
199
|
-
? false
|
|
200
|
-
: process.env.NOLE_PASCALCASE === "true",
|
|
201
|
-
|
|
202
|
-
locale: "en-US",
|
|
203
|
-
});
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
function isFunction(thing: any): thing is (...args: any[]) => void {
|
|
207
|
-
return typeof thing !== "object" && typeof thing === "function";
|
|
208
|
-
}
|