@locustjs/test 1.6.3 → 2.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 +16 -4
- package/dist/index.js +1569 -1765
- package/package.json +37 -39
- package/rollup.config.js +7 -0
- package/src/Expect.js +1204 -0
- package/src/Test.js +88 -0
- package/src/TestException.js +5 -0
- package/src/TestRunner.js +331 -0
- package/src/index.js +5 -1594
- package/tests/index.js +1 -1
- package/.babelrc +0 -3
package/README.md
CHANGED
|
@@ -6,9 +6,14 @@ This library provides a simple test runner for unit-testing.
|
|
|
6
6
|
npm i @locustjs/test
|
|
7
7
|
```
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
## Current Version
|
|
10
|
+
```
|
|
11
|
+
2.0.0
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
# Usage
|
|
10
15
|
```javascript
|
|
11
|
-
import TestRunner from '@locustjs/test';
|
|
16
|
+
import { TestRunner } from '@locustjs/test';
|
|
12
17
|
|
|
13
18
|
const tests = [
|
|
14
19
|
['test 1', expect => expect(2 + 2).toBe(4)],
|
|
@@ -21,8 +26,8 @@ const runner = new TestRunner();
|
|
|
21
26
|
|
|
22
27
|
await runner.run(tests);
|
|
23
28
|
|
|
24
|
-
runner.report();
|
|
25
|
-
runner.log();
|
|
29
|
+
runner.report(); // detailed report
|
|
30
|
+
runner.log(); // save report to file
|
|
26
31
|
```
|
|
27
32
|
|
|
28
33
|
Sample output:
|
|
@@ -63,6 +68,9 @@ Sample output:
|
|
|
63
68
|
- <span style="color:yellow">faulted</span>: Test crashed (no `expect` was called).
|
|
64
69
|
- <span style="color:magenta">unknown</span>: Test executed, however, no `expect` was seen.
|
|
65
70
|
|
|
71
|
+
|
|
72
|
+
Pay attention: `TestRunner` runs test simultaneously. Thus, tests should not have side-effects.
|
|
73
|
+
|
|
66
74
|
## expect
|
|
67
75
|
Positive
|
|
68
76
|
- `toBe(value)`
|
|
@@ -100,7 +108,9 @@ Positive
|
|
|
100
108
|
- `toBeNull()`
|
|
101
109
|
- `toBeNullOrUndefined()`
|
|
102
110
|
- `toBeValid(fnValidation)`
|
|
111
|
+
- `toThrow()`
|
|
103
112
|
- `toThrow(ex, shape = false, strict = false)`
|
|
113
|
+
- `async toThrowAsync()`
|
|
104
114
|
- `async toThrowAsync(ex, shape = false, strict = false)`
|
|
105
115
|
- `toBeTruthy()`
|
|
106
116
|
- `toBeTrue()`
|
|
@@ -136,7 +146,9 @@ Negative
|
|
|
136
146
|
- `notToBeNull()`
|
|
137
147
|
- `notToBeNullOrUndefined()`
|
|
138
148
|
- `notToBeValid(fnValidation)`
|
|
149
|
+
- `notToThrow()`
|
|
139
150
|
- `notToThrow(ex, shape = false, strict = false)`
|
|
151
|
+
- `async notToThrowAsync()`
|
|
140
152
|
- `async notToThrowAsync(ex, shape = false, strict = false)`
|
|
141
153
|
- `notToBeNaN()`
|
|
142
154
|
|