nole 2.2.1 → 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 +44 -42
- 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 +35 -11
- 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 +201 -239
- 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.d.ts +1 -1
- package/dist/utils/executor.js +20 -20
- package/dist/utils/executor.test.d.ts +7 -5
- package/dist/utils/executor.test.d.ts.map +1 -1
- package/dist/utils/executor.test.js +22 -49
- package/dist/utils/time_difference.d.ts +15 -6
- package/dist/utils/time_difference.d.ts.map +1 -1
- package/dist/utils/time_difference.js +22 -13
- package/dist/utils/time_difference.test.d.ts +5 -3
- package/dist/utils/time_difference.test.d.ts.map +1 -1
- package/dist/utils/time_difference.test.js +11 -24
- package/dist/utils/time_factor.d.ts +3 -3
- package/dist/utils/time_factor.d.ts.map +1 -1
- package/dist/utils/time_factor.js +26 -27
- package/dist/utils/time_factor.test.d.ts +5 -3
- package/dist/utils/time_factor.test.d.ts.map +1 -1
- package/dist/utils/time_factor.test.js +27 -42
- package/package.json +11 -8
- 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 +9 -18
- 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
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { HookType, TestWrap } from "../test-wrap.js";
|
|
2
|
+
import { Executor } from "../utils/executor.js";
|
|
3
|
+
import { TimeFactor } from "../utils/time_factor.js";
|
|
4
|
+
import {
|
|
5
|
+
colors,
|
|
6
|
+
DEFAULT_TIMEOUT,
|
|
7
|
+
HOOK_FAILED_TEXT,
|
|
8
|
+
OK_TEXT,
|
|
9
|
+
} from "../const.js";
|
|
10
|
+
|
|
11
|
+
export async function handleBeforeEachHooks(test: TestWrap) {
|
|
12
|
+
const timeout = test.config.timeout ?? DEFAULT_TIMEOUT;
|
|
13
|
+
|
|
14
|
+
for (let [propertyKey, hook] of test.hooks.entries()) {
|
|
15
|
+
if (hook.type != HookType.BeforeEach) continue;
|
|
16
|
+
let hookName = colors.bold(
|
|
17
|
+
colors.yellow(
|
|
18
|
+
test.name +
|
|
19
|
+
(propertyKey != "beforeEach"
|
|
20
|
+
? `.${propertyKey}:beforeEach`
|
|
21
|
+
: ":beforeEach"),
|
|
22
|
+
),
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
try {
|
|
26
|
+
await Executor(
|
|
27
|
+
test.testInstance[propertyKey].bind(test.testInstance),
|
|
28
|
+
timeout,
|
|
29
|
+
);
|
|
30
|
+
|
|
31
|
+
let timeText = TimeFactor(0, timeout);
|
|
32
|
+
|
|
33
|
+
console.log(`${OK_TEXT} ${timeText} ${hookName}()`);
|
|
34
|
+
} catch (e) {
|
|
35
|
+
console.error(`${HOOK_FAILED_TEXT} ${hookName}()`);
|
|
36
|
+
console.error((e as any)?.stack ?? e);
|
|
37
|
+
throw e;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { HookType, TestWrap } from "../test-wrap.js";
|
|
2
|
+
import { Executor } from "../utils/executor.js";
|
|
3
|
+
import { TimeFactor } from "../utils/time_factor.js";
|
|
4
|
+
import {
|
|
5
|
+
colors,
|
|
6
|
+
DEFAULT_TIMEOUT,
|
|
7
|
+
HOOK_FAILED_TEXT,
|
|
8
|
+
OK_TEXT,
|
|
9
|
+
} from "../const.js";
|
|
10
|
+
|
|
11
|
+
export async function handleBeforeHooks(test: TestWrap) {
|
|
12
|
+
const timeout = test.config.timeout ?? DEFAULT_TIMEOUT;
|
|
13
|
+
|
|
14
|
+
for (let [propertyKey, hook] of test.hooks.entries()) {
|
|
15
|
+
if (hook.type != HookType.Before) continue;
|
|
16
|
+
|
|
17
|
+
let hookName = colors.bold(
|
|
18
|
+
colors.yellow(
|
|
19
|
+
test.name +
|
|
20
|
+
(propertyKey != "before" ? `.${propertyKey}:before` : ":before"),
|
|
21
|
+
),
|
|
22
|
+
);
|
|
23
|
+
|
|
24
|
+
try {
|
|
25
|
+
await Executor(
|
|
26
|
+
test.testInstance[propertyKey].bind(test.testInstance),
|
|
27
|
+
timeout,
|
|
28
|
+
);
|
|
29
|
+
|
|
30
|
+
let timeText = TimeFactor(0, timeout);
|
|
31
|
+
|
|
32
|
+
console.log(`${OK_TEXT} ${timeText} ${hookName}()`);
|
|
33
|
+
} catch (e) {
|
|
34
|
+
console.error(`${HOOK_FAILED_TEXT} ${hookName}()`);
|
|
35
|
+
console.error((e as any)?.stack ?? e);
|
|
36
|
+
throw e;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { HookType, TestWrap } from "../test-wrap.js";
|
|
2
|
+
import { Executor } from "../utils/executor.js";
|
|
3
|
+
import { TimeDifference } from "../utils/time_difference.js";
|
|
4
|
+
import { TimeFactor } from "../utils/time_factor.js";
|
|
5
|
+
import {
|
|
6
|
+
colors,
|
|
7
|
+
DEFAULT_TIMEOUT,
|
|
8
|
+
HOOK_FAILED_TEXT,
|
|
9
|
+
OK_TEXT,
|
|
10
|
+
} from "../const.js";
|
|
11
|
+
|
|
12
|
+
export async function handleCleanUp(test: TestWrap) {
|
|
13
|
+
const timeout = test.config.timeout ?? DEFAULT_TIMEOUT;
|
|
14
|
+
|
|
15
|
+
if (test.cleanUpCalled) return;
|
|
16
|
+
if (
|
|
17
|
+
!test.dependents.every(
|
|
18
|
+
(dependent) => dependent.isFinished && dependent.cleanUpCalled,
|
|
19
|
+
)
|
|
20
|
+
)
|
|
21
|
+
return;
|
|
22
|
+
|
|
23
|
+
test.cleanUpCalled = true;
|
|
24
|
+
|
|
25
|
+
for (let [propertyKey, hook] of test.hooks.entries()) {
|
|
26
|
+
if (hook.type != HookType.CleanUp) continue;
|
|
27
|
+
|
|
28
|
+
let hookName = colors.bold(
|
|
29
|
+
colors.yellow(
|
|
30
|
+
test.name +
|
|
31
|
+
(propertyKey != "cleanUp" ? `.${propertyKey}:cleanUp` : ":cleanUp"),
|
|
32
|
+
),
|
|
33
|
+
);
|
|
34
|
+
let start = TimeDifference.begin();
|
|
35
|
+
|
|
36
|
+
try {
|
|
37
|
+
await Executor(
|
|
38
|
+
test.testInstance[propertyKey].bind(test.testInstance),
|
|
39
|
+
timeout,
|
|
40
|
+
);
|
|
41
|
+
|
|
42
|
+
let timeText = TimeFactor(start.end(), timeout);
|
|
43
|
+
|
|
44
|
+
console.log(`${OK_TEXT} ${timeText} ${hookName}()`);
|
|
45
|
+
} catch (e) {
|
|
46
|
+
console.error(`${HOOK_FAILED_TEXT} ${hookName}()`);
|
|
47
|
+
console.error((e as any)?.stack ?? e);
|
|
48
|
+
throw e;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
for (let tree of test.dependencies) {
|
|
53
|
+
await handleCleanUp(tree.dependency);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { HookType, TestWrap } from "../test-wrap.js";
|
|
2
|
+
import { Executor } from "../utils/executor.js";
|
|
3
|
+
import { TimeDifference } from "../utils/time_difference.js";
|
|
4
|
+
import { TimeFactor } from "../utils/time_factor.js";
|
|
5
|
+
import { handleAfterEachHooks } from "./after-each-hooks.js";
|
|
6
|
+
import { handleBeforeEachHooks } from "./before-each-hooks.js";
|
|
7
|
+
import {
|
|
8
|
+
colors,
|
|
9
|
+
DEFAULT_TIMEOUT,
|
|
10
|
+
DYNAMIC_SKIP_TEXT,
|
|
11
|
+
FAILED_TEXT,
|
|
12
|
+
OK_TEXT,
|
|
13
|
+
SKIP_TEXT,
|
|
14
|
+
} from "../const.js";
|
|
15
|
+
|
|
16
|
+
export async function handleSpecs(test: TestWrap) {
|
|
17
|
+
const timeout = test.config.timeout ?? DEFAULT_TIMEOUT;
|
|
18
|
+
|
|
19
|
+
for (let [propertyKey, spec] of test.specs.entries()) {
|
|
20
|
+
let testName = colors.bold(colors.yellow(test.name + "." + propertyKey));
|
|
21
|
+
|
|
22
|
+
const shouldPropertySkip = test.skip.has(propertyKey);
|
|
23
|
+
if (shouldPropertySkip || test.skipClass) {
|
|
24
|
+
let reason = shouldPropertySkip
|
|
25
|
+
? test.skip.get(propertyKey)!.reason
|
|
26
|
+
: test.skipClass!.reason;
|
|
27
|
+
console.log(
|
|
28
|
+
`${SKIP_TEXT} ${" ".repeat(9)} ${testName}() ${
|
|
29
|
+
reason ? "{" + reason + "}" : ""
|
|
30
|
+
}`,
|
|
31
|
+
);
|
|
32
|
+
continue;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
await handleBeforeEachHooks(test);
|
|
36
|
+
|
|
37
|
+
let start = TimeDifference.begin();
|
|
38
|
+
|
|
39
|
+
try {
|
|
40
|
+
await Executor(
|
|
41
|
+
test.testInstance[propertyKey].bind(test.testInstance),
|
|
42
|
+
timeout,
|
|
43
|
+
);
|
|
44
|
+
|
|
45
|
+
let timeText = TimeFactor(start.end(), timeout);
|
|
46
|
+
|
|
47
|
+
console.log(`${OK_TEXT} ${timeText} ${testName}()`);
|
|
48
|
+
} catch (e) {
|
|
49
|
+
if ((e as any)?._nole_anchor) {
|
|
50
|
+
let reason = (e as any).reason;
|
|
51
|
+
console.log(
|
|
52
|
+
`${DYNAMIC_SKIP_TEXT} ${" ".repeat(8)} ${testName}() ${
|
|
53
|
+
reason ? "{" + reason + "}" : ""
|
|
54
|
+
}`,
|
|
55
|
+
);
|
|
56
|
+
continue;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
let timeText = TimeFactor(start.end(), timeout);
|
|
60
|
+
|
|
61
|
+
console.error(`${FAILED_TEXT} ${timeText} ${testName}()`);
|
|
62
|
+
console.error((e as any)?.stack ?? e);
|
|
63
|
+
throw e;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
await handleAfterEachHooks(test);
|
|
67
|
+
}
|
|
68
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -1,13 +1,3 @@
|
|
|
1
|
-
export {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
Hook,
|
|
5
|
-
Skip,
|
|
6
|
-
SkipClass,
|
|
7
|
-
Dependencies,
|
|
8
|
-
Dependencies as After,
|
|
9
|
-
Dependents as Before,
|
|
10
|
-
Dependents,
|
|
11
|
-
} from "./decorators.js";
|
|
12
|
-
export { HookType } from "./test.js";
|
|
13
|
-
export { skipTest } from "./dynamic.js";
|
|
1
|
+
export { HookType } from "./test-wrap.js";
|
|
2
|
+
export { Test } from "./core.js";
|
|
3
|
+
export { skipTest, getTest, addTest } from "./dynamic.js";
|