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/README.md
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|

|
|
2
2
|
|
|
3
|
-
Nole
|
|
4
|
-
==========
|
|
3
|
+
# Nole
|
|
5
4
|
|
|
6
|
-
Nole is a testing platform just like mocha..
|
|
5
|
+
Nole is a testing platform just like mocha..
|
|
6
|
+
|
|
7
|
+
> Breaking change at nole v3, plain old classes are better at this task.
|
|
7
8
|
|
|
8
9
|
> Use nole 2.x for ESM and Typescript.
|
|
9
10
|
|
|
@@ -11,23 +12,20 @@ Nole is a testing platform just like mocha.. You can create test classes and dec
|
|
|
11
12
|
|
|
12
13
|
```ts
|
|
13
14
|
// test/queue.test.ts
|
|
14
|
-
import {
|
|
15
|
+
import { Test } from "nole";
|
|
15
16
|
|
|
16
|
-
class QueueTest {
|
|
17
|
+
export class QueueTest extends Test() {
|
|
17
18
|
queue!: Queue;
|
|
18
19
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
this.queue = new Queue();
|
|
20
|
+
createInstance() {
|
|
21
|
+
this.queue = new Queue();
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
|
|
25
|
-
Push() {
|
|
24
|
+
push() {
|
|
26
25
|
this.queue.push(10);
|
|
27
26
|
}
|
|
28
27
|
|
|
29
|
-
|
|
30
|
-
async Pipe() {
|
|
28
|
+
async pipe() {
|
|
31
29
|
await this.queue.pipe(somewhere);
|
|
32
30
|
}
|
|
33
31
|
}
|
|
@@ -35,96 +33,62 @@ class QueueTest {
|
|
|
35
33
|
|
|
36
34
|
```bash
|
|
37
35
|
$ nole ./test/**/*.test.ts
|
|
38
|
-
(ok) 0.09 ms QueueTest.
|
|
39
|
-
(ok) 0.11 ms QueueTest.
|
|
40
|
-
(ok) 1.09 ms QueueTest.
|
|
41
|
-
```
|
|
42
|
-
|
|
43
|
-
## Spec
|
|
44
|
-
|
|
45
|
-
Declaring the spec tag will notify the nole core and assigns the tasks for later use. You can also specify timeout. Default timeout is 5000 ms.
|
|
46
|
-
|
|
47
|
-
```ts
|
|
48
|
-
// test/queue.test.ts
|
|
49
|
-
import { Spec } from 'nole';
|
|
50
|
-
|
|
51
|
-
class QueueTest {
|
|
52
|
-
@Spec(10000)
|
|
53
|
-
Push() {
|
|
54
|
-
this.queue.push(10);
|
|
55
|
-
}
|
|
56
|
-
}
|
|
36
|
+
(ok) 0.09 ms QueueTest.createInstance()
|
|
37
|
+
(ok) 0.11 ms QueueTest.push()
|
|
38
|
+
(ok) 1.09 ms QueueTest.pipe()
|
|
57
39
|
```
|
|
58
40
|
|
|
59
|
-
> * All specs will be executed as creation order.
|
|
60
|
-
> * Timing colors are defined by timeout value. If value smaller than (timeout / 5) output will be green. If value bigger than this but smaller than (timeout / 2.5); it will be yellow. In all other cases color will be red.
|
|
61
|
-
|
|
62
|
-
|
|
63
41
|
## Skip
|
|
64
42
|
|
|
65
|
-
You can skip tests.
|
|
43
|
+
You can skip tests. Make sure method name starts with skip
|
|
66
44
|
|
|
67
45
|
```ts
|
|
68
46
|
// test/queue.test.ts
|
|
69
|
-
import {
|
|
47
|
+
import { Test } from "nole";
|
|
70
48
|
|
|
71
|
-
class QueueTest {
|
|
72
|
-
|
|
73
|
-
@Spec()
|
|
74
|
-
Push() {
|
|
49
|
+
export class QueueTest extends Test() {
|
|
50
|
+
skip_Push() {
|
|
75
51
|
this.queue.push(10);
|
|
76
52
|
}
|
|
77
53
|
}
|
|
78
54
|
```
|
|
79
55
|
|
|
80
|
-
> * Skipping the task make it yellow colored.
|
|
81
|
-
|
|
82
56
|
```bash
|
|
83
57
|
$ nole ./**/test/*.test.ts
|
|
84
|
-
(skip) QueueTest.
|
|
58
|
+
(skip) QueueTest.skip_Push() {marked as skipped}
|
|
85
59
|
```
|
|
86
60
|
|
|
87
|
-
## SkipClass
|
|
88
|
-
|
|
89
|
-
You can skip whole test classes. It's equivalent of spec skipping, but you don't have to select one by one.
|
|
90
|
-
**Kindly reminder**: Dependents might require this test class and props.
|
|
91
|
-
|
|
92
61
|
```ts
|
|
93
|
-
// test/queue
|
|
94
|
-
import {
|
|
95
|
-
|
|
96
|
-
@SkipClass('No need anymore')
|
|
97
|
-
class QueueTest {
|
|
98
|
-
@Spec()
|
|
99
|
-
Push() { }
|
|
62
|
+
// test/queue.test.ts
|
|
63
|
+
import { Test } from "nole";
|
|
100
64
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
65
|
+
export class QueueTest extends Test({
|
|
66
|
+
skip: "no need",
|
|
67
|
+
}) {
|
|
68
|
+
push() {
|
|
69
|
+
this.queue.push(10);
|
|
70
|
+
}
|
|
104
71
|
}
|
|
105
72
|
```
|
|
106
73
|
|
|
107
74
|
```bash
|
|
108
75
|
$ nole ./**/test/*.test.ts
|
|
109
|
-
(skip) QueueTest.
|
|
110
|
-
(skip) QueueTest.PushButSomehowDifferent() {deprecated unit}
|
|
76
|
+
(skip) QueueTest.skip_Push() {no need}
|
|
111
77
|
```
|
|
112
78
|
|
|
113
|
-
|
|
114
79
|
## Dependencies
|
|
115
80
|
|
|
116
81
|
You can include other tests and wait them to complete.
|
|
117
82
|
|
|
118
83
|
```ts
|
|
119
84
|
// test/database.test.ts
|
|
120
|
-
import {
|
|
85
|
+
import { Test } from "nole";
|
|
121
86
|
|
|
122
|
-
export class Database {
|
|
87
|
+
export class Database extends Test() {
|
|
123
88
|
connection!: any;
|
|
124
89
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
connection = new Connection('...');
|
|
90
|
+
async connect() {
|
|
91
|
+
connection = new Connection("...");
|
|
128
92
|
|
|
129
93
|
await connection.connect();
|
|
130
94
|
}
|
|
@@ -133,92 +97,35 @@ export class Database {
|
|
|
133
97
|
|
|
134
98
|
```ts
|
|
135
99
|
// test/other.test.ts
|
|
136
|
-
import {
|
|
137
|
-
import { Database } from
|
|
138
|
-
|
|
139
|
-
class Other {
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
async DoThings() {
|
|
145
|
-
await database.connection.doStuff();
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
```
|
|
149
|
-
|
|
150
|
-
> * All dependencies will be waited until done
|
|
151
|
-
> * If dependencies cannot resolve, it will occurr an error after the available tests done.
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
## Multi Dependencies
|
|
155
|
-
|
|
156
|
-
Easier way to declare dependencies by decorating class with an array.
|
|
157
|
-
|
|
158
|
-
```ts
|
|
159
|
-
// test/redis.test.ts
|
|
160
|
-
import { Spec, Dependencies } from 'nole';
|
|
161
|
-
import { Database } from './database.test';
|
|
162
|
-
import { Other } from './other.test';
|
|
163
|
-
|
|
164
|
-
@Dependencies([
|
|
165
|
-
Database,
|
|
166
|
-
Other
|
|
167
|
-
])
|
|
168
|
-
class Redis {
|
|
169
|
-
database: Database; // camel-case syntax
|
|
170
|
-
// even though other does not exist in this test, but nole will make sure it is completed when this test runs
|
|
171
|
-
|
|
172
|
-
@Spec()
|
|
100
|
+
import { Test } from "nole";
|
|
101
|
+
import { Database } from "./database.test";
|
|
102
|
+
|
|
103
|
+
export class Other extends Test({
|
|
104
|
+
dependencies: {
|
|
105
|
+
database: () => Database,
|
|
106
|
+
},
|
|
107
|
+
}) {
|
|
173
108
|
async DoThings() {
|
|
174
|
-
await database.connection.doStuff();
|
|
109
|
+
await this.database.connection.doStuff();
|
|
175
110
|
}
|
|
176
111
|
}
|
|
177
112
|
```
|
|
178
113
|
|
|
179
|
-
|
|
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
|
-
|
|
114
|
+
> - All dependencies will be waited until done
|
|
115
|
+
> - If dependencies cannot resolve, it will occurr an error after the available tests done.
|
|
205
116
|
|
|
117
|
+
## Wait other tests
|
|
206
118
|
|
|
207
119
|
```ts
|
|
208
120
|
// test/redis.test.ts
|
|
209
|
-
import {
|
|
210
|
-
|
|
211
|
-
class A {
|
|
212
|
-
b: B;
|
|
121
|
+
import { Test } from "nole";
|
|
213
122
|
|
|
214
|
-
|
|
215
|
-
async
|
|
123
|
+
export class A extends Test() {
|
|
124
|
+
async doThings() {}
|
|
216
125
|
}
|
|
217
126
|
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
@Spec()
|
|
221
|
-
async DoThings() { }
|
|
127
|
+
export class B extends Test({ before: () => [A] }) {
|
|
128
|
+
async doThings() {}
|
|
222
129
|
}
|
|
223
130
|
```
|
|
224
131
|
|
|
@@ -228,161 +135,160 @@ Hooks will help you to develop helper methods.
|
|
|
228
135
|
|
|
229
136
|
```ts
|
|
230
137
|
// test/hook.test.ts
|
|
231
|
-
import {
|
|
138
|
+
import { Test } from "nole";
|
|
232
139
|
|
|
233
|
-
class HookTest {
|
|
140
|
+
export class HookTest {
|
|
234
141
|
value!: number;
|
|
235
142
|
|
|
236
|
-
@Hook(HookType.BeforeEach)
|
|
237
143
|
async beforeEach() {
|
|
238
144
|
this.value = Math.random();
|
|
239
145
|
}
|
|
240
146
|
|
|
241
|
-
|
|
242
|
-
ValidateNumber() {
|
|
147
|
+
validateNumber() {
|
|
243
148
|
if (this.value > 0.5) {
|
|
244
|
-
throw new Error(
|
|
149
|
+
throw new Error("Should not be higher than 0.5");
|
|
245
150
|
}
|
|
246
151
|
}
|
|
247
152
|
}
|
|
248
153
|
```
|
|
249
154
|
|
|
250
|
-
> * Hooks can be async tasks.
|
|
251
|
-
> * Hooks do have timeout, you can change it by second parameter.
|
|
252
|
-
> * If you name hook same as hook type then; When it occurr an error, It will print "class:hookType" otherwise "class.name:hoopType"
|
|
253
|
-
> * Hooks cannot be spec
|
|
254
|
-
> * Hooks cannot skipped
|
|
255
|
-
|
|
256
155
|
## Dynamic Tests
|
|
257
156
|
|
|
258
|
-
|
|
157
|
+
```ts
|
|
158
|
+
// test/dynamic.test.ts
|
|
159
|
+
import { Test, addTest } from "nole";
|
|
259
160
|
|
|
161
|
+
// not exported, nole cannot auto-bind this class
|
|
162
|
+
class DynamicTest extends Test() {
|
|
163
|
+
test() {}
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
// adds it anyway
|
|
167
|
+
addTest(() => DynamicTest);
|
|
168
|
+
```
|
|
260
169
|
|
|
261
170
|
```ts
|
|
262
|
-
// test/
|
|
263
|
-
import {
|
|
171
|
+
// test/dynamic2.test.ts
|
|
172
|
+
import { Test, addTest } from "nole";
|
|
173
|
+
|
|
174
|
+
if (something) {
|
|
175
|
+
addTest(
|
|
176
|
+
() =>
|
|
177
|
+
class Special extends Test() {
|
|
178
|
+
check() {}
|
|
179
|
+
},
|
|
180
|
+
);
|
|
181
|
+
}
|
|
182
|
+
```
|
|
264
183
|
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
for (let i = 0; i < 10; i++) {
|
|
269
|
-
this.single(i);
|
|
270
|
-
}
|
|
271
|
-
}
|
|
184
|
+
```ts
|
|
185
|
+
// test/dynamic3.test.ts
|
|
186
|
+
import { Test, addTest } from "nole";
|
|
272
187
|
|
|
273
|
-
|
|
274
|
-
|
|
188
|
+
export class DeepTest extends Test() {
|
|
189
|
+
check() {
|
|
190
|
+
if (something) {
|
|
191
|
+
addTest(() => class Wololo extends Test() {});
|
|
192
|
+
}
|
|
275
193
|
}
|
|
276
194
|
}
|
|
277
195
|
```
|
|
278
196
|
|
|
279
|
-
##
|
|
197
|
+
## Test cleanup
|
|
280
198
|
|
|
281
|
-
|
|
199
|
+
There is a special hook that can be used to capture test finishing stage.
|
|
282
200
|
|
|
201
|
+
> **Lifecycle:**
|
|
202
|
+
>
|
|
203
|
+
> - (class) Before
|
|
204
|
+
> - - (method) BeforeEach
|
|
205
|
+
> - - (method) Spec
|
|
206
|
+
> - - (method) AfterEach
|
|
207
|
+
> - (class) After
|
|
208
|
+
> - (class) CleanUp \*called after dependency execution
|
|
283
209
|
|
|
284
210
|
```ts
|
|
285
211
|
// test/database-with-cleanup.test.ts
|
|
286
|
-
import {
|
|
212
|
+
import { Test } from "nole";
|
|
287
213
|
|
|
288
|
-
export class DatabaseWithCleanup {
|
|
214
|
+
export class DatabaseWithCleanup extends Test() {
|
|
289
215
|
connection!: any;
|
|
290
216
|
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
connection = new Connection('...');
|
|
217
|
+
async connect() {
|
|
218
|
+
this.connection = new Connection("...");
|
|
294
219
|
|
|
295
220
|
await connection.connect();
|
|
296
221
|
}
|
|
297
222
|
|
|
298
|
-
@Hook(HookType.CleanUp)
|
|
299
223
|
async cleanUp() {
|
|
300
224
|
this.connection.close();
|
|
301
|
-
console.log(
|
|
225
|
+
console.log("Connection closed!");
|
|
302
226
|
}
|
|
303
227
|
}
|
|
304
228
|
```
|
|
305
229
|
|
|
306
230
|
```ts
|
|
307
231
|
// test/other.test.ts
|
|
308
|
-
import {
|
|
309
|
-
import { Database } from
|
|
310
|
-
|
|
311
|
-
class Other {
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
async
|
|
317
|
-
await database.connection.doStuff();
|
|
232
|
+
import { Test } from "nole";
|
|
233
|
+
import { Database } from "./database.test";
|
|
234
|
+
|
|
235
|
+
export class Other extends Test({
|
|
236
|
+
dependencies: {
|
|
237
|
+
database: () => DatabaseWithCleanup,
|
|
238
|
+
},
|
|
239
|
+
}) {
|
|
240
|
+
async doThings() {
|
|
241
|
+
await this.database.connection.doStuff();
|
|
318
242
|
}
|
|
319
243
|
}
|
|
320
244
|
```
|
|
321
245
|
|
|
322
246
|
```bash
|
|
323
247
|
$ nole ./test/**/*.test.ts
|
|
324
|
-
(ok) 0.09 ms DatabaseWithCleanup.
|
|
325
|
-
(ok) 0.11 ms Other.
|
|
248
|
+
(ok) 0.09 ms DatabaseWithCleanup.connect()
|
|
249
|
+
(ok) 0.11 ms Other.doThings()
|
|
326
250
|
Connection closed!
|
|
327
251
|
```
|
|
328
252
|
|
|
253
|
+
## Test extending
|
|
329
254
|
|
|
255
|
+
If they are classes we should be able to extend them right
|
|
330
256
|
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
## Debugging
|
|
336
|
-
|
|
337
|
-
Having cleanup features with missing dependencies could lead to issues and time loses. To make sure execution of tests correct, use `-O` parameter to print out every spec and hook without calling the function. It will also print before/after hook orders.
|
|
257
|
+
```ts
|
|
258
|
+
// test/extending.test.ts
|
|
259
|
+
import { Test } from "nole";
|
|
338
260
|
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
(skip) SkipAllTest.wontRunToo() {wont run too}
|
|
343
|
-
(skip) SkipAllWithoutReason.wontRun()
|
|
344
|
-
(ok) 0 ms BasicTest.checkEqual()
|
|
345
|
-
(ok) 0 ms DependencyTest.check()
|
|
346
|
-
(ok) 0 ms CleanUpLayer1Test.start()
|
|
347
|
-
(ok) 0 ms CleanUpLayer2Test.start()
|
|
348
|
-
(ok) 0 ms CleanUpLayer3Test.start()
|
|
349
|
-
(ok) 0 ms DynamicSkipTest.thisShouldBeSkipped()
|
|
350
|
-
(ok) 0 ms HookTest.pushFourIntoArray:beforeEach()
|
|
351
|
-
(ok) 0 ms HookTest.hasToBe4()
|
|
352
|
-
(skip) HookTest.hasToBe4Again() {no need}
|
|
353
|
-
(ok) 0 ms HookTest.pushFourIntoArray:beforeEach()
|
|
354
|
-
(ok) 0.03 ms HookTest.hasToBe4AgainButNotSkipped()
|
|
355
|
-
(ok) 0 ms MultiDependency.test()
|
|
356
|
-
(ok) 0 ms CleanUpLayer3Test:cleanUp()
|
|
357
|
-
(ok) 0 ms CleanUpLayer2Test:cleanUp()
|
|
358
|
-
(ok) 0 ms CleanUpLayer1Test:cleanUp()
|
|
359
|
-
(ok) 0 ms DynamicTest.thisTestsShouldNotFail()
|
|
360
|
-
(ok) 0 ms TimeFactorTest.evaluate()
|
|
361
|
-
(ok) 0 ms TimeDifferenceTest.evaluate()
|
|
362
|
-
(ok) 0 ms ExecutorTest.evaluate()
|
|
363
|
-
(ok) 0 ms ExecutorTest.throws()
|
|
364
|
-
(ok) 0 ms ExecutorTest.timeout()
|
|
365
|
-
```
|
|
261
|
+
// Simple is not exported, so nole wont handle it
|
|
262
|
+
class Simple extends Test() {
|
|
263
|
+
value = 1;
|
|
366
264
|
|
|
367
|
-
|
|
265
|
+
check() {
|
|
266
|
+
if (this.value !== 1) {
|
|
267
|
+
// yeah it should be 1 anyway
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
}
|
|
368
271
|
|
|
369
|
-
|
|
272
|
+
export class Complex extends Simple {
|
|
273
|
+
check() {
|
|
274
|
+
if (this.value > 0) {
|
|
275
|
+
// maybe it is more than just 1?
|
|
276
|
+
}
|
|
370
277
|
|
|
371
|
-
|
|
278
|
+
super.check(); // or
|
|
279
|
+
}
|
|
280
|
+
}
|
|
372
281
|
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
282
|
+
export class MoreComplex extends Simple {
|
|
283
|
+
moreSpecs() {
|
|
284
|
+
// mooree
|
|
285
|
+
}
|
|
286
|
+
}
|
|
378
287
|
```
|
|
379
288
|
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
289
|
+
```bash
|
|
290
|
+
$ nole ./test/**/*.test.ts
|
|
291
|
+
(ok) 0.09 ms Complex.check()
|
|
292
|
+
(ok) 0.11 ms MoreComplex.check()
|
|
293
|
+
(ok) 0.11 ms MoreComplex.moreSpecs()
|
|
384
294
|
```
|
|
385
|
-
NOLE_PRESERVE_CONSECUTIVE_UPPERCASE=true
|
|
386
|
-
NOLE_PASCALCASE=false
|
|
387
|
-
NOLE_WAIT_PERIOD=500
|
|
388
|
-
```
|
package/bin/nole.js
CHANGED
|
@@ -1,59 +1,37 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
import program from "commander";
|
|
4
|
-
import glob from "glob";
|
|
4
|
+
import { glob } from "glob";
|
|
5
5
|
import path from "path";
|
|
6
6
|
import fs from "fs";
|
|
7
7
|
import colors from "colors/safe.js";
|
|
8
|
-
import {
|
|
8
|
+
import { register } from "tsx/esm/api";
|
|
9
|
+
const unregister = register();
|
|
10
|
+
|
|
9
11
|
import { TimeDifference } from "../dist/utils/time_difference.js";
|
|
10
12
|
import { Delay, TimeResolve } from "../dist/utils/time_factor.js";
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
register("ts-node/esm", pathToFileURL("./"));
|
|
13
|
+
import { TEST_CLASS_KEY } from "../dist/symbol.js";
|
|
14
|
+
import { ManualRun } from "../dist/run.js";
|
|
14
15
|
|
|
15
16
|
const pkg = JSON.parse(
|
|
16
|
-
fs.readFileSync(new URL("../package.json", import.meta.url)).toString()
|
|
17
|
+
fs.readFileSync(new URL("../package.json", import.meta.url)).toString(),
|
|
17
18
|
);
|
|
18
19
|
|
|
19
|
-
program
|
|
20
|
-
.usage("<glob> ...")
|
|
21
|
-
.option("-L, --no-log", "disable console.log")
|
|
22
|
-
.option("-O, --order-debug", "shows execution order")
|
|
23
|
-
.version(pkg.version)
|
|
24
|
-
.parse(process.argv);
|
|
20
|
+
program.usage("<glob> ...").version(pkg.version).parse(process.argv);
|
|
25
21
|
|
|
26
22
|
if (!program.args.length) {
|
|
27
23
|
program.help();
|
|
28
24
|
} else {
|
|
29
25
|
let time = TimeDifference.begin();
|
|
30
26
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
if (!program.log) {
|
|
34
|
-
console.log = function () {};
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
Promise.all(
|
|
38
|
-
program.args.map(
|
|
39
|
-
(arg) =>
|
|
40
|
-
new Promise((resolve, reject) => {
|
|
41
|
-
glob(arg, (err, matches) => {
|
|
42
|
-
if (err) {
|
|
43
|
-
return reject(err);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
resolve(matches);
|
|
47
|
-
});
|
|
48
|
-
})
|
|
49
|
-
)
|
|
50
|
-
)
|
|
27
|
+
Promise.all(program.args.map((arg) => glob(arg)))
|
|
51
28
|
.then(async (list) => {
|
|
52
29
|
const fileList = [];
|
|
53
30
|
|
|
54
31
|
for (const item of list) {
|
|
55
|
-
while (item.length)
|
|
32
|
+
while (item.length) {
|
|
56
33
|
fileList.push(path.resolve(process.cwd(), item.pop()));
|
|
34
|
+
}
|
|
57
35
|
}
|
|
58
36
|
|
|
59
37
|
if (!fileList.length) {
|
|
@@ -63,8 +41,24 @@ if (!program.args.length) {
|
|
|
63
41
|
|
|
64
42
|
const file = time.end();
|
|
65
43
|
|
|
44
|
+
const tests = new Set();
|
|
45
|
+
|
|
66
46
|
for (const file of fileList) {
|
|
67
|
-
await import(`file://${file}`);
|
|
47
|
+
const module = await import(`file://${file}`);
|
|
48
|
+
|
|
49
|
+
for (const key in module) {
|
|
50
|
+
const value = module[key];
|
|
51
|
+
|
|
52
|
+
if (!value) {
|
|
53
|
+
continue;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
if (!value[TEST_CLASS_KEY]) {
|
|
57
|
+
continue;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
tests.add(value);
|
|
61
|
+
}
|
|
68
62
|
}
|
|
69
63
|
|
|
70
64
|
const prop = time.end();
|
|
@@ -78,20 +72,25 @@ if (!program.args.length) {
|
|
|
78
72
|
dependencyResolveWaitPeriod = 500;
|
|
79
73
|
}
|
|
80
74
|
|
|
81
|
-
log("Nole tests v" + pkg.version);
|
|
75
|
+
console.log("Nole tests v" + pkg.version);
|
|
76
|
+
|
|
82
77
|
try {
|
|
83
78
|
await Delay(dependencyResolveWaitPeriod);
|
|
84
79
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
80
|
+
try {
|
|
81
|
+
await ManualRun(tests);
|
|
82
|
+
} catch (e) {
|
|
83
|
+
if (e.message === "No specs found") {
|
|
84
|
+
log(`${FAILED_TEXT} no specs found`);
|
|
85
|
+
}
|
|
86
|
+
throw e;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
console.log(" discover: %s", TimeResolve(file));
|
|
90
|
+
console.log(" resolve: %s", TimeResolve(prop - file));
|
|
91
|
+
console.log(
|
|
93
92
|
" tests: %s",
|
|
94
|
-
TimeResolve(time.end() - prop - dependencyResolveWaitPeriod)
|
|
93
|
+
TimeResolve(time.end() - prop - dependencyResolveWaitPeriod),
|
|
95
94
|
);
|
|
96
95
|
process.exit(0);
|
|
97
96
|
} catch (e) {
|
package/dist/const.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare const colors: any;
|
|
2
|
+
export declare const OK_TEXT: any;
|
|
3
|
+
export declare const SKIP_TEXT: any;
|
|
4
|
+
export declare const DYNAMIC_SKIP_TEXT: any;
|
|
5
|
+
export declare const FAILED_TEXT: any;
|
|
6
|
+
export declare const HOOK_FAILED_TEXT: any;
|
|
7
|
+
export declare const DEFAULT_TIMEOUT = 5000;
|
|
8
|
+
//# sourceMappingURL=const.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"const.d.ts","sourceRoot":"","sources":["../src/const.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,MAAM,KAAwB,CAAC;AAE5C,eAAO,MAAM,OAAO,KAA0C,CAAC;AAC/D,eAAO,MAAM,SAAS,KAA2C,CAAC;AAClE,eAAO,MAAM,iBAAiB,KAA0C,CAAC;AACzE,eAAO,MAAM,WAAW,KAAwC,CAAC;AACjE,eAAO,MAAM,gBAAgB,KAA6C,CAAC;AAE3E,eAAO,MAAM,eAAe,OAAO,CAAC"}
|
package/dist/const.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import * as clrs from "colors/safe.js";
|
|
2
|
+
export const colors = clrs.default;
|
|
3
|
+
export const OK_TEXT = colors.bold(colors.green(" (ok) "));
|
|
4
|
+
export const SKIP_TEXT = colors.bold(colors.yellow(" (skip) "));
|
|
5
|
+
export const DYNAMIC_SKIP_TEXT = colors.bold(colors.blue(" (dskip) "));
|
|
6
|
+
export const FAILED_TEXT = colors.bold(colors.red(" (failed) "));
|
|
7
|
+
export const HOOK_FAILED_TEXT = colors.bold(colors.red(" (hook failed) "));
|
|
8
|
+
export const DEFAULT_TIMEOUT = 5000;
|
|
9
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29uc3QuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi9zcmMvY29uc3QudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxLQUFLLElBQUksTUFBTSxnQkFBZ0IsQ0FBQztBQUV2QyxNQUFNLENBQUMsTUFBTSxNQUFNLEdBQUksSUFBWSxDQUFDLE9BQU8sQ0FBQztBQUU1QyxNQUFNLENBQUMsTUFBTSxPQUFPLEdBQUcsTUFBTSxDQUFDLElBQUksQ0FBQyxNQUFNLENBQUMsS0FBSyxDQUFDLFlBQVksQ0FBQyxDQUFDLENBQUM7QUFDL0QsTUFBTSxDQUFDLE1BQU0sU0FBUyxHQUFHLE1BQU0sQ0FBQyxJQUFJLENBQUMsTUFBTSxDQUFDLE1BQU0sQ0FBQyxZQUFZLENBQUMsQ0FBQyxDQUFDO0FBQ2xFLE1BQU0sQ0FBQyxNQUFNLGlCQUFpQixHQUFHLE1BQU0sQ0FBQyxJQUFJLENBQUMsTUFBTSxDQUFDLElBQUksQ0FBQyxhQUFhLENBQUMsQ0FBQyxDQUFDO0FBQ3pFLE1BQU0sQ0FBQyxNQUFNLFdBQVcsR0FBRyxNQUFNLENBQUMsSUFBSSxDQUFDLE1BQU0sQ0FBQyxHQUFHLENBQUMsWUFBWSxDQUFDLENBQUMsQ0FBQztBQUNqRSxNQUFNLENBQUMsTUFBTSxnQkFBZ0IsR0FBRyxNQUFNLENBQUMsSUFBSSxDQUFDLE1BQU0sQ0FBQyxHQUFHLENBQUMsaUJBQWlCLENBQUMsQ0FBQyxDQUFDO0FBRTNFLE1BQU0sQ0FBQyxNQUFNLGVBQWUsR0FBRyxJQUFJLENBQUMifQ==
|