@creative-introvert/tons-of-tests 0.7.0 → 0.7.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.
Files changed (2) hide show
  1. package/README.md +97 -114
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -38,8 +38,8 @@ Further, a cautionary note on stability:
38
38
  With your package manager of choice, install the following packages:
39
39
 
40
40
  ```bash
41
- @creative-introvert/tots
42
- @creative-introvert/tots-cli
41
+ @creative-introvert/tons-of-tests
42
+ @creative-introvert/tons-of-tests-cli
43
43
  effect
44
44
  ```
45
45
 
@@ -53,15 +53,14 @@ Define your test-suite.
53
53
 
54
54
  ```ts
55
55
  // my-test-suite.ts
56
- import * as CLI from '@creative-introvert/tots-cli';
56
+ import * as CLI from '@creative-introvert/tons-of-tests-cli';
57
57
  import {Effect} from 'effect';
58
58
 
59
59
  const myFunction = (input: number) => Promise.resolve(input * 1.7);
60
60
 
61
61
  void CLI.run({
62
62
  testSuite: {
63
- // Convert myFunction to Effect-returning.
64
- program: (input: number) => Effect.promise(() => myFunction(input)),
63
+ name: 'with-cli-simple',
65
64
  testCases: [
66
65
  {input: 0, expected: 0},
67
66
  {input: 1, expected: 2},
@@ -69,12 +68,10 @@ void CLI.run({
69
68
  {input: 3, expected: 4},
70
69
  {input: 4, expected: 5},
71
70
  ],
71
+ program: (input: number) => Effect.promise(() => myFunction(input)),
72
72
  },
73
- testSuiteName: 'simple',
74
- // Currently, test results are written to the file-system.
75
- // This will be replaced by an SQLite backend soon™.
76
- dirPath: '.metrics',
77
- filePostfix: 'ptest',
73
+ dbPath: 'with-cli-simple.db',
74
+ concurrency: 10,
78
75
  });
79
76
  ```
80
77
 
@@ -83,31 +80,34 @@ void CLI.run({
83
80
  ```
84
81
  pnpx tsx my-test-suite.ts summarize
85
82
 
86
- =============================================================================
87
- SUMMARY
88
- =============================================================================
89
- index | id | input | tags | label | expected | result | previous result
90
- -----------------------------------------------------------------------------
91
- 1/5 │ 5feceb66 │ 0 │ │ TP │ 0 │ 0 │ ∅
92
- -----------------------------------------------------------------------------
93
- 2/5 │ 6b86b273 │ 1 │ │ FP │ 2 │ 1.7 │ ∅
94
- -----------------------------------------------------------------------------
95
- 3/5 │ d4735e3a │ 2 │ │ FP │ 3 │ 3.4 │ ∅
96
- -----------------------------------------------------------------------------
97
- 4/5 │ 4e074085 │ 3 │ │ FP │ 4 │ 5.1 │ ∅
98
- -----------------------------------------------------------------------------
99
- 5/5 │ 4b227777 │ 4 │ │ FP │ 5 │ 6.8 │ ∅
100
- =============================================================================
101
- index | id | input | tags | label | expected | result | previous result
102
- =============================================================================
103
-
104
- ======================================
105
- STATS
106
- ======================================
107
- TP | TN | FP | FN | precision | recall
108
- --------------------------------------
109
- 1 | 0 | 4 | 0 | 0.20 | 1.00
110
- ======================================
83
+ ┌───────────────────────────────────────────────────────────────────────────┐
84
+ │ SUMMARY │
85
+ ├─────┬──────────┬────────┬──────┬───────┬──────────┬────────┬──────────────┤
86
+ │ #/∑ │ hash │ ms │ tags │ input │ expected │ label₀ │ diff result₀ │
87
+ ├─────┼──────────┼────────┼──────┼───────┼──────────┼────────┼──────────────┤
88
+ │ 1/5 │ bd04cb2c │ 0.69ms │ │ 0 │ 0 │ TP │ │
89
+ ├─────┼──────────┼────────┼──────┼───────┼──────────┼────────┼──────────────┤
90
+ │ 2/5 │ 562e2cca │ 0.36ms │ │ 1 │ 2 │ FP │ 2 => 1.7 │
91
+ ├─────┼──────────┼────────┼──────┼───────┼──────────┼────────┼──────────────┤
92
+ │ 3/5 │ a5afd52f │ 3.30ms │ │ 2 │ 3 │ FP │ 3 => 3.4 │
93
+ ├─────┼──────────┼────────┼──────┼───────┼──────────┼────────┼──────────────┤
94
+ │ 4/5 │ 5f7f8725 │ 1.19ms │ │ 3 │ 4 │ FP │ 4 => 5.1 │
95
+ ├─────┼──────────┼────────┼──────┼───────┼──────────┼────────┼──────────────┤
96
+ │ 5/5 │ 6cc26923 │ 1.22ms │ │ 4 │ 5 │ FP │ 5 => 6.8 │
97
+ ├─────┼──────────┼────────┼──────┼───────┼──────────┼────────┼──────────────┤
98
+ │ #/∑ │ hash │ ms │ tags │ input │ expected │ label₀ │ diff result₀ │
99
+ └─────┴──────────┴────────┴──────┴───────┴──────────┴────────┴──────────────┘
100
+
101
+
102
+ ┌────────────────────────────────────────────────────────────────────┐
103
+ │ STATS │
104
+ ├───┬────┬────┬────┬────┬───────────┬────────┬──────────┬────────────┤
105
+ │ ∑ │ TP │ TN │ FP │ FN │ precision │ recall │ timeMean │ timeMedian │
106
+ ├───┼────┼────┼────┼────┼───────────┼────────┼──────────┼────────────┤
107
+ │ 5 │ 1 │ 0 │ 4 │ 0 │ 0.20 │ 1.00 │ 1.35ms │ 1.19ms │
108
+ ├───┼────┼────┼────┼────┼───────────┼────────┼──────────┼────────────┤
109
+ │ ∑ │ TP │ TN │ FP │ FN │ precision │ recall │ timeMean │ timeMedian │
110
+ └───┴────┴────┴────┴────┴───────────┴────────┴──────────┴────────────┘
111
111
  ```
112
112
 
113
113
  #### Summarize With Labels Filter
@@ -115,29 +115,32 @@ TP | TN | FP | FN | precision | recall
115
115
  ```
116
116
  pnpx tsx my-test-suite.ts summarize --labels TP
117
117
 
118
- =============================================================================
119
- SUMMARY
120
- =============================================================================
121
- index | id | input | tags | label | expected | result | previous result
122
- -----------------------------------------------------------------------------
123
- 1/1 │ 5feceb66 │ 0 │ │ TP │ 0 │ 0 │ ∅
124
- =============================================================================
125
- index | id | input | tags | label | expected | result | previous result
126
- =============================================================================
127
-
128
- ======================================
129
- STATS
130
- ======================================
131
- TP | TN | FP | FN | precision | recall
132
- --------------------------------------
133
- 1 | 0 | 0 | 0 | 1.00 | 1.00
134
- ======================================
118
+ ┌───────────────────────────────────────────────────────────────────────────┐
119
+ │ SUMMARY │
120
+ ├─────┬──────────┬────────┬──────┬───────┬──────────┬────────┬──────────────┤
121
+ │ #/∑ │ hash │ ms │ tags │ input │ expected │ label₀ │ diff result₀ │
122
+ ├─────┼──────────┼────────┼──────┼───────┼──────────┼────────┼──────────────┤
123
+ │ 1/1 │ bd04cb2c │ 0.52ms │ │ 0 │ 0 │ TP │ │
124
+ ├─────┼──────────┼────────┼──────┼───────┼──────────┼────────┼──────────────┤
125
+ │ #/∑ │ hash │ ms │ tags │ input │ expected │ label₀ │ diff result₀ │
126
+ └─────┴──────────┴────────┴──────┴───────┴──────────┴────────┴──────────────┘
127
+
128
+
129
+ ┌────────────────────────────────────────────────────────────────────┐
130
+ │ STATS │
131
+ ├───┬────┬────┬────┬────┬───────────┬────────┬──────────┬────────────┤
132
+ │ ∑ │ TP │ TN │ FP │ FN │ precision │ recall │ timeMean │ timeMedian │
133
+ ├───┼────┼────┼────┼────┼───────────┼────────┼──────────┼────────────┤
134
+ │ 5 │ 1 │ 0 │ 4 │ 0 │ 0.20 │ 1.00 │ 1.23ms │ 1.28ms │
135
+ ├───┼────┼────┼────┼────┼───────────┼────────┼──────────┼────────────┤
136
+ │ ∑ │ TP │ TN │ FP │ FN │ precision │ recall │ timeMean │ timeMedian │
137
+ └───┴────┴────┴────┴────┴───────────┴────────┴──────────┴────────────┘
135
138
  ```
136
139
 
137
140
  #### Write Test Results
138
141
 
139
142
  ```bash
140
- pnpx tsx my-test-suite.ts write
143
+ pnpx tsx my-test-suite.ts commit
141
144
  ```
142
145
 
143
146
  #### Diff
@@ -165,31 +168,45 @@ index 21cd713..ab1b6dc 100644
165
168
  ```
166
169
  pnpx tsx my-test-suite.ts diff
167
170
  # or, if you want it to process.exit(1) on diff
168
- pnpx tsx my-test-suite.ts diff --ci
169
-
170
- =============================================================================
171
- SUMMARY
172
- =============================================================================
173
- index | id | input | tags | label | expected | result | previous result
174
- -----------------------------------------------------------------------------
175
- 1/4 │ 6b86b273 │ 1 │ │ TP │ 2 │ 2 │ 1.7
176
- -----------------------------------------------------------------------------
177
- 2/4 │ d4735e3a │ 2 │ │ FP │ 3 │ 4 │ 3.4
178
- -----------------------------------------------------------------------------
179
- 3/4 │ 4e074085 │ 3 │ │ FP │ 4 │ 6 │ 5.1
180
- -----------------------------------------------------------------------------
181
- 4/4 │ 4b227777 │ 4 │ │ FP │ 5 │ 8 │ 6.8
182
- =============================================================================
183
- index | id | input | tags | label | expected | result | previous result
184
- =============================================================================
185
-
186
- ======================================
187
- DIFF
188
- ======================================
189
- TP | TN | FP | FN | precision | recall
190
- --------------------------------------
191
- 0 │ 0 │ -1 │ 0 │ 0.05 │ 0.00
192
- ======================================
171
+ pnpx tsx my-test-suite.ts diff --exit-on-diff
172
+
173
+ ┌─────────────────────────────────────────────────────────────────────────────────────────────────────┐
174
+ │ SUMMARY │
175
+ ├─────┬──────────┬────────┬──────┬───────┬──────────┬────────┬──────────────┬─────────┬───────────────┤
176
+ │ #/∑ │ hash │ ms │ tags │ input │ expected │ label₀ │ diff result₀ │ label₋₁ │ diff result₋₁ │
177
+ ├─────┼──────────┼────────┼──────┼───────┼──────────┼────────┼──────────────┼─────────┼───────────────┤
178
+ │ 1/4 │ 562e2cca │ 0.23ms │ │ 1 │ 2 │ TP │ │ FP │ 2 => 1.7 │
179
+ ├─────┼──────────┼────────┼──────┼───────┼──────────┼────────┼──────────────┼─────────┼───────────────┤
180
+ │ 2/4 │ a5afd52f │ 3.66ms │ │ 2 │ 3 │ FP │ 3 => 4 │ FP │ 3 => 3.4 │
181
+ ├─────┼──────────┼────────┼──────┼───────┼──────────┼────────┼──────────────┼─────────┼───────────────┤
182
+ │ 3/4 │ 5f7f8725 │ 1.19ms │ │ 3 │ 4 │ FP │ 4 => 6 │ FP │ 4 => 5.1 │
183
+ ├─────┼──────────┼────────┼──────┼───────┼──────────┼────────┼──────────────┼─────────┼───────────────┤
184
+ │ 4/4 │ 6cc26923 │ 0.98ms │ │ 4 │ 5 │ FP │ 5 => 8 │ FP │ 5 => 6.8 │
185
+ ├─────┼──────────┼────────┼──────┼───────┼──────────┼────────┼──────────────┼─────────┼───────────────┤
186
+ │ #/∑ │ hash │ ms │ tags │ input │ expected │ label₀ │ diff result₀ │ label₋₁ │ diff result₋₁ │
187
+ └─────┴──────────┴────────┴──────┴───────┴──────────┴────────┴──────────────┴─────────┴───────────────┘
188
+
189
+
190
+ ┌────────────────────────────────────────────────────────────────────┐
191
+ │ STATS │
192
+ ├───┬────┬────┬────┬────┬───────────┬────────┬──────────┬────────────┤
193
+ │ ∑ │ TP │ TN │ FP │ FN │ precision │ recall │ timeMean │ timeMedian │
194
+ ├───┼────┼────┼────┼────┼───────────┼────────┼──────────┼────────────┤
195
+ │ 5 │ 2 │ 0 │ 3 │ 0 │ 0.40 │ 1.00 │ 1.30ms │ 0.98ms │
196
+ ├───┼────┼────┼────┼────┼───────────┼────────┼──────────┼────────────┤
197
+ │ ∑ │ TP │ TN │ FP │ FN │ precision │ recall │ timeMean │ timeMedian │
198
+ └───┴────┴────┴────┴────┴───────────┴────────┴──────────┴────────────┘
199
+
200
+
201
+ ┌────────────────────────────────────────┐
202
+ │ DIFF │
203
+ ├────┬────┬────┬────┬───────────┬────────┤
204
+ │ TP │ TN │ FP │ FN │ precision │ recall │
205
+ ├────┼────┼────┼────┼───────────┼────────┤
206
+ │ 1 │ 0 │ -1 │ 0 │ 0.20 │ 0.00 │
207
+ ├────┼────┼────┼────┼───────────┼────────┤
208
+ │ TP │ TN │ FP │ FN │ precision │ recall │
209
+ └────┴────┴────┴────┴───────────┴────────┘
193
210
  ```
194
211
 
195
212
  Checkout `workspace/examples/src/with-cli` for more examples.
@@ -200,47 +217,13 @@ pnpx tsx <file-path>
200
217
  pnpx tsx ./workspace/examples/src/with-cli/simple.ts
201
218
  ```
202
219
 
203
- ### Without CLI
204
220
 
205
- For full control over execution, and if you're not afraid of using [effect](https://effect.website/)
206
- you may simply import the runner functions individually.
207
-
208
- ```ts
209
- import * as PT from '@creative-introvert/tots';
210
- import {Console, Duration, Effect, Stream} from 'effect';
211
-
212
- type Input = number;
213
- type Result = number;
214
-
215
- const program = (input: Input) =>
216
- Effect.promise(() => Promise.resolve(input * 2)).pipe(
217
- Effect.delay(Duration.millis(500)),
218
- );
219
-
220
- const testCases: PT.TestCase<Input, Result>[] = [
221
- {input: 0, expected: 0},
222
- {input: 1, expected: 1},
223
- {input: 2, expected: 2},
224
- {input: 3, expected: 3},
225
- {input: 4, expected: 4},
226
- ];
227
-
228
- await PT.testAll({
229
- testCases,
230
- program,
231
- }).pipe(
232
- PT.runFoldEffect,
233
- Effect.tap(testRun => Console.log(PT.Show.summary({testRun}))),
234
- Effect.runPromise,
235
- );
236
- ```
237
-
238
- Checkout `workspace/examples/src/as-library` for more examples.
221
+ Checkout `workspace/examples` for more examples.
239
222
 
240
223
  ```bash
241
224
  pnpx tsx <file-path>
242
225
  # e.g.
243
- pnpx tsx ./workspace/examples/src/as-library/simple.ts
226
+ pnpx tsx ./workspace/examples/src/with-cli/simple.ts
244
227
  ```
245
228
 
246
229
  ## Why No Runtime?
package/package.json CHANGED
@@ -25,7 +25,7 @@
25
25
  "test-runner",
26
26
  "coverage"
27
27
  ],
28
- "version": "0.7.0",
28
+ "version": "0.7.1",
29
29
  "files": [
30
30
  "dist/**/*"
31
31
  ],