supertape 6.13.0 → 7.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 +31 -0
- package/README.md +75 -18
- package/help.json +2 -2
- package/lib/cli.js +5 -14
- package/lib/exit-codes.js +0 -2
- package/lib/supertape.js +4 -4
- package/package.json +7 -6
package/ChangeLog
CHANGED
|
@@ -1,3 +1,34 @@
|
|
|
1
|
+
2022.02.18, v7.1.0
|
|
2
|
+
|
|
3
|
+
feature:
|
|
4
|
+
- (supertape) exclude node_modules
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
2022.02.17, v7.0.1
|
|
8
|
+
|
|
9
|
+
fix:
|
|
10
|
+
- (supertape) drop support of node < 16
|
|
11
|
+
|
|
12
|
+
feature:
|
|
13
|
+
- (package) madrun v9.0.0
|
|
14
|
+
- (package) putout v25.0.0
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
2022.02.14, v7.0.0
|
|
18
|
+
|
|
19
|
+
fix:
|
|
20
|
+
- chore(actions) add ability to fix
|
|
21
|
+
|
|
22
|
+
feature:
|
|
23
|
+
- supertape: check-scopes, check-assertions-count: enable by default
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
2022.01.15, v6.13.1
|
|
27
|
+
|
|
28
|
+
fix:
|
|
29
|
+
- (supertape) revert: add exit code 5 for skip"
|
|
30
|
+
|
|
31
|
+
|
|
1
32
|
2022.01.15, v6.13.0
|
|
2
33
|
|
|
3
34
|
feature:
|
package/README.md
CHANGED
|
@@ -1,19 +1,25 @@
|
|
|
1
|
-
# 📼
|
|
1
|
+
# 📼 Supertape [![NPM version][NPMIMGURL]][NPMURL] [![Build Status][BuildStatusIMGURL]][BuildStatusURL] [![Coverage Status][CoverageIMGURL]][CoverageURL]
|
|
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/putout/actions?query=workflow%3A%22Node+CI%22 "Build Status"
|
|
6
|
+
[BuildStatusIMGURL]: https://github.com/coderaiser/putout/workflows/Node%20CI/badge.svg
|
|
7
|
+
[BuildStatusURL]: https://travis-ci.org/coderaiser/supertape "Build Status"
|
|
7
8
|
[CoverageURL]: https://coveralls.io/github/coderaiser/supertape?branch=master
|
|
8
9
|
[CoverageIMGURL]: https://coveralls.io/repos/coderaiser/supertape/badge.svg?branch=master&service=github
|
|
9
10
|
|
|
10
|
-
[
|
|
11
|
+
[](https://asciinema.org/a/Cgc3rDOfZAeDnJSxzEYpPfBMY)
|
|
12
|
+
|
|
13
|
+
[Tape](https://github.com/substack/tape)-inspired [TAP](https://testanything.org/)-compatible simplest high speed test runner with superpowers.
|
|
14
|
+
|
|
15
|
+
📼`Supertape` written from scratch after messing a lot with `tape`, it willing to be compatible with it as much as possible.
|
|
16
|
+
and has a couple differences. It contains:
|
|
11
17
|
|
|
12
18
|
- 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).
|
|
13
19
|
- shows colored diff when test not `equal` or not `deepEqual`;
|
|
14
20
|
- produces deteiled stack traces for `async functions`;
|
|
15
|
-
- as many `only` as you wish
|
|
16
|
-
- ability to extend
|
|
21
|
+
- as many `only` as you wish;
|
|
22
|
+
- ability to extend;
|
|
17
23
|
- smart timeouts for long running tests 🏃♂️(configured with `SUPERTAPE_TIMEOUT`);
|
|
18
24
|
- more natural assertions: `expected, result` -> `result, expected`, for example:
|
|
19
25
|
|
|
@@ -27,8 +33,6 @@ Doesn't contain:
|
|
|
27
33
|
- aliases, methods list much shorter;
|
|
28
34
|
- `throws`, `doesNotThrows` - use [tryCatch](https://github.com/coderaiser/try-catch), [tryToCatch](https://github.com/coderaiser/try-to-catch) with `equal` instead.
|
|
29
35
|
|
|
30
|
-
`Supertape` was written from scratch after messing a lot with `tape`, it inspired by `tape` and willing to be compatible with it.
|
|
31
|
-
|
|
32
36
|
## Install
|
|
33
37
|
|
|
34
38
|
```
|
|
@@ -44,8 +48,8 @@ Options
|
|
|
44
48
|
-v, --version output version information and exit
|
|
45
49
|
-f, --format use a specific output format - default: progress-bar/tap on CI
|
|
46
50
|
-r, --require require module
|
|
47
|
-
--check-scopes
|
|
48
|
-
--check-assertions-count
|
|
51
|
+
--no-check-scopes do not check that messages contains scope: 'scope: message'
|
|
52
|
+
--no-check-assertions-count do not check that assertion count is no more then 1
|
|
49
53
|
--no-check-duplicates do not check messages for duplicates
|
|
50
54
|
```
|
|
51
55
|
|
|
@@ -63,20 +67,74 @@ test('tape: error', (t) => {
|
|
|
63
67
|
});
|
|
64
68
|
```
|
|
65
69
|
|
|
66
|
-
##
|
|
70
|
+
## 🤷 How to migrate from `tape`?
|
|
71
|
+
|
|
72
|
+
You can convert your codebase from `tape` to 📼`Supertape` with help of 🐊[`Putout`](https://github.com/coderaiser/putout), which has built-in [@putout/plugin-tape](https://github.com/coderaiser/putout/tree/master/packages/plugin-tape),
|
|
73
|
+
which has a lot of rules that helps to write tests.
|
|
74
|
+
Here is [result example](https://github.com/coderaiser/cloudcmd/commit/74d56f795d22e98937dce0641ee3c7514a79e9e6).
|
|
75
|
+
|
|
76
|
+
## `ESLint` rules
|
|
77
|
+
|
|
78
|
+
[`eslint-plugin-putout`](https://github.com/coderaiser/putout/tree/master/packages/eslint-plugin-putout#readme) has rules for 📼`Supertape`:
|
|
79
|
+
|
|
80
|
+
- ✅ [`remove-newline-before-t-end`](https://github.com/coderaiser/putout/tree/master/packages/eslint-plugin-putout/lib/tape-remove-newline-before-t-end#readme)
|
|
81
|
+
- ✅ [`add-newline-before-assertion`](https://github.com/coderaiser/putout/tree/master/packages/eslint-plugin-putout/lib/tape-add-newline-before-assertion#readme)
|
|
82
|
+
- ✅ [`add-newline-between-tests`](https://github.com/coderaiser/putout/tree/master/packages/eslint-plugin-putout/lib/tape-add-newline-between-tests#readme)
|
|
83
|
+
|
|
84
|
+
## Operators
|
|
85
|
+
|
|
86
|
+
To simplify `supertape` core operators located in separate packages, called `operators`:
|
|
87
|
+
|
|
88
|
+
Here is a list of built-int operators:
|
|
89
|
+
|
|
90
|
+
| Package | Version |
|
|
91
|
+
|--------|-------|
|
|
92
|
+
| [`@supertape/operator-stub`](/packages/operator-stub) | [](https://www.npmjs.com/package/@supertape/operator-stub) |
|
|
93
|
+
|
|
94
|
+
## Formatters
|
|
67
95
|
|
|
68
|
-
|
|
69
|
-
|
|
96
|
+
There is a list of built-int `formatters` to customize output:
|
|
97
|
+
|
|
98
|
+
| Package | Version |
|
|
99
|
+
|--------|-------|
|
|
100
|
+
| [`@supertape/formatter-tap`](/packages/formatter-tap) | [](https://www.npmjs.com/package/@supertape/formatter-tap) |
|
|
101
|
+
| [`@supertape/formatter-fail`](/packages/formatter-fail) | [](https://www.npmjs.com/package/@supertape/formatter-fail) |
|
|
102
|
+
| [`@supertape/formatter-short`](/packages/formatter-short) | [](https://www.npmjs.com/package/@supertape/formatter-short) |
|
|
103
|
+
| [`@supertape/formatter-progress-bar`](/packages/formatter-progress-bar) | [](https://www.npmjs.com/package/@supertape/formatter-progress-bar) |
|
|
104
|
+
| [`@supertape/formatter-json-lines`](/packages/formatter-json-lines) | [](https://www.npmjs.com/package/@supertape/formatter-json-lines) |
|
|
70
105
|
|
|
71
106
|
## API
|
|
72
107
|
|
|
73
108
|
### Methods
|
|
74
109
|
|
|
75
|
-
The assertion methods in `supertape` are heavily influenced
|
|
76
|
-
in [tape](https://github.com/substack/tape).
|
|
110
|
+
The assertion methods in `supertape` are heavily influenced by [tape](https://github.com/substack/tape).
|
|
77
111
|
|
|
78
112
|
```js
|
|
79
113
|
const test = require('supertape');
|
|
114
|
+
const {sum} = require('./calc.js');
|
|
115
|
+
|
|
116
|
+
test('calc: sum', (t) => {
|
|
117
|
+
const result = sum(1, 2);
|
|
118
|
+
const expected = 3;
|
|
119
|
+
|
|
120
|
+
t.equal(result, expected);
|
|
121
|
+
t.end();
|
|
122
|
+
});
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
or in `ESM`:
|
|
126
|
+
|
|
127
|
+
```js
|
|
128
|
+
import {test} from 'supertape';
|
|
129
|
+
import {sum} from './calc.js';
|
|
130
|
+
|
|
131
|
+
test('calc: sum', (t) => {
|
|
132
|
+
const result = sum(1, 2);
|
|
133
|
+
const expected = 3;
|
|
134
|
+
|
|
135
|
+
t.equal(result, expected);
|
|
136
|
+
t.end();
|
|
137
|
+
});
|
|
80
138
|
```
|
|
81
139
|
|
|
82
140
|
## test(name, cb)
|
|
@@ -176,9 +234,8 @@ const test = require('supertape');
|
|
|
176
234
|
|
|
177
235
|
test('lib: arguments', async (t) => {
|
|
178
236
|
throw Error('hello');
|
|
179
|
-
// will call t.fail
|
|
180
|
-
// will call t.end
|
|
181
|
-
t.end();
|
|
237
|
+
// will call t.fail with an error
|
|
238
|
+
// will call t.end
|
|
182
239
|
});
|
|
183
240
|
|
|
184
241
|
test('lib: diff', (t) => {
|
package/help.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"-v, --version ": "output version information and exit",
|
|
4
4
|
"-f, --format ": "use a specific output format - default: progress-bar/tap on CI",
|
|
5
5
|
"-r, --require ": "require module",
|
|
6
|
-
"--check-scopes
|
|
7
|
-
"--check-assertions-count
|
|
6
|
+
"--no-check-scopes ": "do not check that messages contains scope: 'scope: message'",
|
|
7
|
+
"--no-check-assertions-count": "do not check that assertion count is no more then 1",
|
|
8
8
|
"--no-check-duplicates ": "do not check messages for duplicates"
|
|
9
9
|
}
|
package/lib/cli.js
CHANGED
|
@@ -18,13 +18,13 @@ const {
|
|
|
18
18
|
WAS_STOP,
|
|
19
19
|
UNHANDLED,
|
|
20
20
|
INVALID_OPTION,
|
|
21
|
-
SKIP,
|
|
22
21
|
} = require('./exit-codes');
|
|
23
22
|
|
|
24
23
|
const {isArray} = Array;
|
|
25
24
|
|
|
26
25
|
const maybeFirst = (a) => isArray(a) ? a.pop() : a;
|
|
27
26
|
const maybeArray = (a) => isArray(a) ? a : [a];
|
|
27
|
+
const isExclude = (a) => !a.includes('node_modules');
|
|
28
28
|
|
|
29
29
|
const removeDuplicates = (a) => Array.from(new Set(a));
|
|
30
30
|
const filesCount = fullstore(0);
|
|
@@ -52,7 +52,6 @@ module.exports = async ({argv, cwd, stdout, stderr, exit}) => {
|
|
|
52
52
|
|
|
53
53
|
const {
|
|
54
54
|
failed,
|
|
55
|
-
skiped,
|
|
56
55
|
code,
|
|
57
56
|
message,
|
|
58
57
|
} = result;
|
|
@@ -66,13 +65,8 @@ module.exports = async ({argv, cwd, stdout, stderr, exit}) => {
|
|
|
66
65
|
return exit(code);
|
|
67
66
|
}
|
|
68
67
|
|
|
69
|
-
if (isStop())
|
|
68
|
+
if (isStop())
|
|
70
69
|
return exit(WAS_STOP);
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
if (skiped) {
|
|
74
|
-
return exit(SKIP);
|
|
75
|
-
}
|
|
76
70
|
|
|
77
71
|
return exit(OK);
|
|
78
72
|
};
|
|
@@ -147,7 +141,7 @@ async function cli({argv, cwd, stdout, isStop}) {
|
|
|
147
141
|
|
|
148
142
|
const allFiles = [];
|
|
149
143
|
for (const arg of args._) {
|
|
150
|
-
const files = glob.sync(arg);
|
|
144
|
+
const files = glob.sync(arg).filter(isExclude);
|
|
151
145
|
allFiles.push(...files);
|
|
152
146
|
}
|
|
153
147
|
|
|
@@ -182,16 +176,13 @@ async function cli({argv, cwd, stdout, isStop}) {
|
|
|
182
176
|
filesCount(files.length);
|
|
183
177
|
|
|
184
178
|
if (!promises.length)
|
|
185
|
-
return
|
|
186
|
-
failed: false,
|
|
187
|
-
};
|
|
179
|
+
return OK;
|
|
188
180
|
|
|
189
181
|
await Promise.all(promises);
|
|
190
|
-
const [{failed
|
|
182
|
+
const [{failed}] = await once(supertape.run(), 'end');
|
|
191
183
|
|
|
192
184
|
return {
|
|
193
185
|
failed,
|
|
194
|
-
skiped,
|
|
195
186
|
};
|
|
196
187
|
}
|
|
197
188
|
|
package/lib/exit-codes.js
CHANGED
package/lib/supertape.js
CHANGED
|
@@ -34,8 +34,8 @@ const defaultOptions = {
|
|
|
34
34
|
isStop: () => false,
|
|
35
35
|
checkDuplicates: true,
|
|
36
36
|
checkIfEnded: true,
|
|
37
|
-
checkAssertionsCount:
|
|
38
|
-
checkScopes:
|
|
37
|
+
checkAssertionsCount: true,
|
|
38
|
+
checkScopes: true,
|
|
39
39
|
};
|
|
40
40
|
|
|
41
41
|
function _createEmitter({quiet, format, getOperators, isStop}) {
|
|
@@ -68,13 +68,13 @@ function _createEmitter({quiet, format, getOperators, isStop}) {
|
|
|
68
68
|
harness.pipe(stdout);
|
|
69
69
|
|
|
70
70
|
const operators = await getOperators();
|
|
71
|
-
const {failed
|
|
71
|
+
const {failed} = await runTests(tests, {
|
|
72
72
|
formatter,
|
|
73
73
|
operators,
|
|
74
74
|
isStop,
|
|
75
75
|
});
|
|
76
76
|
|
|
77
|
-
emitter.emit('end', {failed
|
|
77
|
+
emitter.emit('end', {failed});
|
|
78
78
|
});
|
|
79
79
|
|
|
80
80
|
return emitter;
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "supertape",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "7.1.0",
|
|
4
4
|
"author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
|
|
5
|
-
"description": "📼 Supertape
|
|
5
|
+
"description": "📼 Supertape simplest high speed test runner with superpowers",
|
|
6
6
|
"homepage": "http://github.com/coderaiser/supertape",
|
|
7
7
|
"main": "./lib/supertape.js",
|
|
8
8
|
"exports": {
|
|
@@ -77,22 +77,23 @@
|
|
|
77
77
|
"@iocmd/wait": "^1.0.0",
|
|
78
78
|
"c8": "^7.3.5",
|
|
79
79
|
"check-dts": "^0.6.5",
|
|
80
|
-
"eslint": "^8.0.0
|
|
80
|
+
"eslint": "^8.0.0",
|
|
81
81
|
"eslint-plugin-node": "^11.1.0",
|
|
82
82
|
"eslint-plugin-putout": "^13.0.1",
|
|
83
|
-
"
|
|
83
|
+
"find-up": "^6.3.0",
|
|
84
|
+
"madrun": "^9.0.0",
|
|
84
85
|
"mock-require": "^3.0.2",
|
|
85
86
|
"montag": "^1.0.0",
|
|
86
87
|
"nodemon": "^2.0.2",
|
|
87
88
|
"pullout": "^4.0.0",
|
|
88
|
-
"putout": "^
|
|
89
|
+
"putout": "^25.0.0",
|
|
89
90
|
"runsome": "^1.0.0",
|
|
90
91
|
"try-catch": "^3.0.0",
|
|
91
92
|
"typescript": "^4.4.4"
|
|
92
93
|
},
|
|
93
94
|
"license": "MIT",
|
|
94
95
|
"engines": {
|
|
95
|
-
"node": ">=
|
|
96
|
+
"node": ">=16"
|
|
96
97
|
},
|
|
97
98
|
"publishConfig": {
|
|
98
99
|
"access": "public"
|