supertape 8.0.0 → 8.1.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/ChangeLog +14 -0
- package/README.md +92 -74
- package/lib/operators.mjs +6 -2
- package/package.json +3 -3
package/ChangeLog
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
2022.09.15, v8.1.0
|
|
2
|
+
|
|
3
|
+
feature:
|
|
4
|
+
- supertape: add ability to return value from operator
|
|
5
|
+
- package: @supertape/operator-stub v3.0.0
|
|
6
|
+
- @supertape/operator-stub: type: Result -> OperationResult
|
|
7
|
+
|
|
8
|
+
2022.09.07, v8.0.1
|
|
9
|
+
|
|
10
|
+
feature:
|
|
11
|
+
- package: @supertape/operator-stub v3.0.0
|
|
12
|
+
- @supertape/operator-stub: type: Result -> OperationResult
|
|
13
|
+
- (package) supertape v8.0.0
|
|
14
|
+
|
|
1
15
|
2022.09.07, v8.0.0
|
|
2
16
|
|
|
3
17
|
fix:
|
package/README.md
CHANGED
|
@@ -1,38 +1,42 @@
|
|
|
1
|
-
# 📼 Supertape [![NPM version][NPMIMGURL]][NPMURL] [![Build Status][BuildStatusIMGURL]][BuildStatusURL] [![Coverage Status][CoverageIMGURL]][CoverageURL]
|
|
1
|
+
# 📼 Supertape [![NPM version][NPMIMGURL]][NPMURL] [![Build Status][BuildStatusIMGURL]][BuildStatusURL] [![Coverage Status][CoverageIMGURL]][CoverageURL] [![License: MIT][MITLicenseIMGURL]][MITLicenseURL]
|
|
2
2
|
|
|
3
3
|
[NPMURL]: https://npmjs.org/package/supertape "npm"
|
|
4
4
|
[NPMIMGURL]: https://img.shields.io/npm/v/supertape.svg?style=flat&longCache=true
|
|
5
|
-
[BuildStatusURL]: https://github.com/coderaiser/
|
|
6
|
-
[BuildStatusIMGURL]: https://github.com/coderaiser/
|
|
5
|
+
[BuildStatusURL]: https://github.com/coderaiser/supertape/actions?query=workflow%3A%22Node+CI%22 "Build Status"
|
|
6
|
+
[BuildStatusIMGURL]: https://github.com/coderaiser/supertape/workflows/Node%20CI/badge.svg
|
|
7
7
|
[BuildStatusURL]: https://travis-ci.org/coderaiser/supertape "Build Status"
|
|
8
8
|
[CoverageURL]: https://coveralls.io/github/coderaiser/supertape?branch=master
|
|
9
9
|
[CoverageIMGURL]: https://coveralls.io/repos/coderaiser/supertape/badge.svg?branch=master&service=github
|
|
10
|
+
[MITLicenseURL]: https://opensource.org/licenses/MIT
|
|
11
|
+
[MITLicenseIMGURL]: https://img.shields.io/badge/License-MIT-green.svg
|
|
10
12
|
|
|
11
13
|
[](https://asciinema.org/a/Cgc3rDOfZAeDnJSxzEYpPfBMY)
|
|
12
14
|
|
|
13
|
-
[Tape](https://github.com/substack/tape)-inspired [TAP](https://testanything.org/)-compatible simplest high speed test runner with superpowers.
|
|
15
|
+
[**Tape**](https://github.com/substack/tape)-inspired [`TAP`](https://testanything.org/)-compatible simplest high speed test runner with superpowers.
|
|
14
16
|
|
|
15
|
-
|
|
16
|
-
and has a couple differences. It contains:
|
|
17
|
+
📼 **Supertape** is a fast, minimal test runner with the soul of **tape**. It's designed to be as compatible as possible with **tape** while still having some key improvements, such as:
|
|
17
18
|
|
|
18
|
-
- ability to work with [
|
|
19
|
-
-
|
|
20
|
-
-
|
|
21
|
-
-
|
|
22
|
-
-
|
|
23
|
-
-
|
|
24
|
-
-
|
|
25
|
-
- more natural assertions: `expected, result` -> `result, expected
|
|
19
|
+
- the ability to work with [ESM Modules](https://nodejs.org/api/esm.html) (take a look at [mock-import](https://github.com/coderaiser/mock-import) for mocking and 🎩[ESCover](https://github.com/coderaiser/escover) for coverage)
|
|
20
|
+
- a number of [built-in pretty output formatters](#formatters)
|
|
21
|
+
- the ability to [extend](#testextendextensions)
|
|
22
|
+
- showing colored diff when using the [`t.equal()`](#tequalresult-any-expected-any-message-string) and [`t.deepEqual()`](#tdeepequalresult-any-expected-any-message-string) assertion operators
|
|
23
|
+
- detailed stack traces for `async` functions
|
|
24
|
+
- multiple [`test.only`'s](#testonlyname-cb)
|
|
25
|
+
- [smart timeouts](#environment-variables) for long running tests 🏃♂️
|
|
26
|
+
- more natural assertions: `expected, result` -> `result, expected`:
|
|
26
27
|
|
|
27
|
-
```js
|
|
28
|
-
t.equal(error.message, 'hello world', `expected error.message to be 'hello world'`);
|
|
29
|
-
```
|
|
28
|
+
```js
|
|
29
|
+
t.equal(error.message, 'hello world', `expected error.message to be 'hello world'`);
|
|
30
|
+
```
|
|
30
31
|
|
|
31
|
-
|
|
32
|
+
📼 **Supertape** doesn't contain:
|
|
32
33
|
|
|
33
|
-
-
|
|
34
|
-
-
|
|
35
|
-
- `throws`, `
|
|
34
|
+
- assertion aliases, making the available operators far more concise
|
|
35
|
+
- `es3 code` and lot's of [ponyfills](https://github.com/sindresorhus/ponyfill#how-are-ponyfills-better-than-polyfills)
|
|
36
|
+
- `t.throws()`, `t.doesNotThrow()` - use [**tryCatch**](https://github.com/coderaiser/try-catch) or [**tryToCatch**](https://github.com/coderaiser/try-to-catch) with [`t.equal()`](#tequalresult-any-expected-any-message-string) instead
|
|
37
|
+
- [`t.plan()`](https://github.com/substack/tape#tplann)
|
|
38
|
+
|
|
39
|
+
For a list of all built-in assertions, see [Operators](#operators).
|
|
36
40
|
|
|
37
41
|
## Install
|
|
38
42
|
|
|
@@ -85,7 +89,73 @@ Here is [result example](https://github.com/coderaiser/cloudcmd/commit/74d56f795
|
|
|
85
89
|
|
|
86
90
|
## Operators
|
|
87
91
|
|
|
88
|
-
|
|
92
|
+
The assertion methods of 📼 **Supertape** are heavily influenced by [**tape**](https://github.com/substack/tape). However, to keep a minimal core of assertions, there are no aliases and some superfluous operators have been removed (such as `t.throws()`).
|
|
93
|
+
|
|
94
|
+
The following is a list of the base methods maintained by 📼 **Supertape**. Others, such as assertions for stubbing, are maintained in [special operators](#special-operators). To add custom assertion operators, see [Extending](#testextendextensions).
|
|
95
|
+
|
|
96
|
+
### Core Operators
|
|
97
|
+
|
|
98
|
+
#### `t.equal(result: any, expected: any, message?: string)`
|
|
99
|
+
|
|
100
|
+
Asserts that `result` and `expected` are strictly equal. If `message` is provided, it will be outputted as a description of the assertion.
|
|
101
|
+
|
|
102
|
+
*Note: uses `Object.is(result, expected)`*
|
|
103
|
+
|
|
104
|
+
#### `t.notEqual(result: any, expected: any, message?: string)`
|
|
105
|
+
|
|
106
|
+
Asserts that `result` and `expected` are not strictly equal. If `message` is provided, it will be outputted as a description of the assertion.
|
|
107
|
+
|
|
108
|
+
*Note: uses `!Object.is(result, expected)`*
|
|
109
|
+
|
|
110
|
+
#### `t.deepEqual(result: any, expected: any, message?: string)`
|
|
111
|
+
|
|
112
|
+
Asserts that `result` and `expected` are loosely equal, with the same structure and nested values. If `message` is provided, it will be outputted as a description of the assertion.
|
|
113
|
+
|
|
114
|
+
*Note: uses [node's deepEqual() algorithm][NodeDeepEqual] with strict comparisons (`===`) on leaf nodes*
|
|
115
|
+
|
|
116
|
+
#### `t.notDeepEqual(result: any, expected: any, message?: string)`
|
|
117
|
+
|
|
118
|
+
Asserts that `result` and `expected` not loosely equal, with different structure and/or nested values. If `message` is provided, it will be outputted as a description of the assertion.
|
|
119
|
+
|
|
120
|
+
*Note: uses [node's deepEqual() algorithm][NodeDeepEqual] with strict comparisons (`===`) on leaf nodes*
|
|
121
|
+
|
|
122
|
+
[NodeDeepEqual]: https://github.com/substack/node-deep-equal
|
|
123
|
+
|
|
124
|
+
#### `t.ok(result: boolean | any, message?: string)`
|
|
125
|
+
|
|
126
|
+
Asserts that `result` is truthy. If `message` is provided, it will be outputted as a description of the assertion.
|
|
127
|
+
|
|
128
|
+
#### `t.notOk(result: boolean | any, message?: string)`
|
|
129
|
+
|
|
130
|
+
Asserts that `result` is falsy. If `message` is provided, it will be outputted as a description of the assertion.
|
|
131
|
+
|
|
132
|
+
#### `t.pass(message: string)`
|
|
133
|
+
|
|
134
|
+
Generates a passing assertion with `message` as a description.
|
|
135
|
+
|
|
136
|
+
#### `t.fail(message: string)`
|
|
137
|
+
|
|
138
|
+
Generates a failing assertion with `message` as a description.
|
|
139
|
+
|
|
140
|
+
#### `t.end()`
|
|
141
|
+
|
|
142
|
+
Declares the end of a test explicitly. Must be called exactly once per test. (See: [Single Call to `t.end()`](#single-tend))
|
|
143
|
+
|
|
144
|
+
#### `t.match(result: string, pattern: string | RegExp, message?: string)`
|
|
145
|
+
|
|
146
|
+
Asserts that `result` matches the regex `pattern`. If `pattern` is not a valid regex, the assertion fails. If `message` is provided, it will be outputted as a description of the assertion.
|
|
147
|
+
|
|
148
|
+
#### `t.notMatch(result: string, pattern: string | RegExp, message?: string)`
|
|
149
|
+
|
|
150
|
+
Asserts that `result` does not match the regex `pattern`. If `pattern` is not a valid regex, the assertion always fails. If `message` is provided, it will be outputted as a description of the assertion.
|
|
151
|
+
|
|
152
|
+
#### `t.comment(message: string)`
|
|
153
|
+
|
|
154
|
+
Print a message without breaking the `TAP` output. Useful when using a `tap`-reporter such as `tap-colorize`, where the output is buffered and `console.log()` will print in incorrect order vis-a-vis `TAP` output.
|
|
155
|
+
|
|
156
|
+
### Special Operators
|
|
157
|
+
|
|
158
|
+
To simplify the core of 📼 **Supertape**, other operators are maintained in separate packages. The following is a list of all such packages:
|
|
89
159
|
|
|
90
160
|
Here is a list of built-int operators:
|
|
91
161
|
|
|
@@ -177,58 +247,6 @@ test('assertion', (t) => {
|
|
|
177
247
|
});
|
|
178
248
|
```
|
|
179
249
|
|
|
180
|
-
## t.end()
|
|
181
|
-
|
|
182
|
-
Declare the end of a test explicitly.
|
|
183
|
-
|
|
184
|
-
## t.fail(msg)
|
|
185
|
-
|
|
186
|
-
Generate a failing assertion with a message `msg`.
|
|
187
|
-
|
|
188
|
-
## t.pass(msg)
|
|
189
|
-
|
|
190
|
-
Generate a passing assertion with a message `msg`.
|
|
191
|
-
|
|
192
|
-
## t.ok(value, msg)
|
|
193
|
-
|
|
194
|
-
Assert that `value` is truthy with an optional description of the assertion `msg`.
|
|
195
|
-
|
|
196
|
-
## t.notOk(value, msg)
|
|
197
|
-
|
|
198
|
-
Assert that `value` is falsy with an optional description of the assertion `msg`.
|
|
199
|
-
|
|
200
|
-
## t.match(result, pattern[, msg])
|
|
201
|
-
|
|
202
|
-
Assert that `pattern: string | regexp` matches `result` with an optional description of the assertion `msg`.
|
|
203
|
-
|
|
204
|
-
## t.notMatch(result, pattern[, msg])
|
|
205
|
-
|
|
206
|
-
Assert that `pattern: string | regexp` not matches `result` with an optional description of the assertion `msg`.
|
|
207
|
-
|
|
208
|
-
## t.equal(result, expected, msg)
|
|
209
|
-
|
|
210
|
-
Assert that `Object.is(result, expected)` with an optional description of the assertion `msg`.
|
|
211
|
-
|
|
212
|
-
## t.notEqual(result, expected, msg)
|
|
213
|
-
|
|
214
|
-
Assert that `!Object.is(result, expected)` with an optional description of the assertion `msg`.
|
|
215
|
-
|
|
216
|
-
## t.deepEqual(result, expected, msg)
|
|
217
|
-
|
|
218
|
-
Assert that `result` and `expected` have the same structure and nested values using
|
|
219
|
-
[node's deepEqual() algorithm](https://github.com/substack/node-deep-equal)
|
|
220
|
-
with strict comparisons (`===`) on leaf nodes and an optional description of the assertion `msg`.
|
|
221
|
-
|
|
222
|
-
## t.notDeepEqual(result, expected, msg)
|
|
223
|
-
|
|
224
|
-
Assert that `result` and `expected` do not have the same structure and nested values using
|
|
225
|
-
[node's deepEqual() algorithm](https://github.com/substack/node-deep-equal)
|
|
226
|
-
with strict comparisons (`===`) on leaf nodes and an optional description of the assertion `msg`.
|
|
227
|
-
|
|
228
|
-
## t.comment(message)
|
|
229
|
-
|
|
230
|
-
Print a message without breaking the tap output. (Useful when using e.g. `tap-colorize` where output is buffered & `console.log` will print in incorrect order vis-a-vis tap output.)
|
|
231
|
-
|
|
232
250
|
## Example
|
|
233
251
|
|
|
234
252
|
```js
|
package/lib/operators.mjs
CHANGED
|
@@ -179,7 +179,9 @@ const initOperator = (runnerState) => (name) => {
|
|
|
179
179
|
return end;
|
|
180
180
|
|
|
181
181
|
const testState = await fn(...a);
|
|
182
|
-
|
|
182
|
+
run(name, runnerState, testState);
|
|
183
|
+
|
|
184
|
+
return testState;
|
|
183
185
|
};
|
|
184
186
|
|
|
185
187
|
return (...a) => {
|
|
@@ -193,7 +195,9 @@ const initOperator = (runnerState) => (name) => {
|
|
|
193
195
|
return end;
|
|
194
196
|
|
|
195
197
|
const testState = fn(...a);
|
|
196
|
-
|
|
198
|
+
run(name, runnerState, testState);
|
|
199
|
+
|
|
200
|
+
return testState;
|
|
197
201
|
};
|
|
198
202
|
};
|
|
199
203
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "supertape",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.1.0",
|
|
4
4
|
"author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
|
|
5
5
|
"description": "📼 Supertape simplest high speed test runner with superpowers",
|
|
6
6
|
"homepage": "http://github.com/coderaiser/supertape",
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"@supertape/formatter-progress-bar": "^3.0.0",
|
|
50
50
|
"@supertape/formatter-short": "^2.0.0",
|
|
51
51
|
"@supertape/formatter-tap": "^3.0.0",
|
|
52
|
-
"@supertape/operator-stub": "^
|
|
52
|
+
"@supertape/operator-stub": "^3.0.0",
|
|
53
53
|
"cli-progress": "^3.8.2",
|
|
54
54
|
"deep-equal": "^2.0.3",
|
|
55
55
|
"fullstore": "^3.0.0",
|
|
@@ -79,7 +79,7 @@
|
|
|
79
79
|
"c8": "^7.3.5",
|
|
80
80
|
"check-dts": "^0.6.5",
|
|
81
81
|
"eslint": "^8.0.0",
|
|
82
|
-
"eslint-plugin-
|
|
82
|
+
"eslint-plugin-n": "^15.2.5",
|
|
83
83
|
"eslint-plugin-putout": "^16.0.1",
|
|
84
84
|
"find-up": "^6.3.0",
|
|
85
85
|
"madrun": "^9.0.0",
|