supertape 8.3.0 → 8.4.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.
- package/ChangeLog +18 -0
- package/README.md +1 -0
- package/bin/supertape.mjs +0 -1
- package/lib/cli.js +4 -2
- package/lib/diff.mjs +0 -2
- package/lib/exit-codes.js +0 -1
- package/lib/format.js +0 -1
- package/lib/formatter/harness.js +0 -1
- package/lib/formatter/index.js +0 -1
- package/lib/help.js +1 -5
- package/lib/is-debug.js +0 -1
- package/lib/operators.mjs +11 -15
- package/lib/run-tests.js +1 -3
- package/lib/supertape.d.ts +9 -15
- package/lib/supertape.js +1 -2
- package/lib/validator.js +23 -9
- package/package.json +8 -9
- package/supertape.json +1 -3
package/ChangeLog
CHANGED
|
@@ -1,3 +1,21 @@
|
|
|
1
|
+
2023.08.07, v8.4.1
|
|
2
|
+
|
|
3
|
+
feature:
|
|
4
|
+
- 7e7cec1 supertape: validator: simplify
|
|
5
|
+
- 0cfa5f1 package: eslint-plugin-putout v19.0.3
|
|
6
|
+
- 1bba62a package: putout v31.0.3
|
|
7
|
+
|
|
8
|
+
2023.07.10, v8.4.0
|
|
9
|
+
|
|
10
|
+
feature:
|
|
11
|
+
- f3faec5 package: c8 v8.0.0
|
|
12
|
+
- 74f7265 package: eslint-plugin-n v16.0.1
|
|
13
|
+
- 098bc4a package: eslint-plugin-putout v18.0.0
|
|
14
|
+
- 1a73835 package: putout v30.2.3
|
|
15
|
+
- 4ca9bb2 package: typescript v5.1.6
|
|
16
|
+
- 4b4842e package: putout v29.0.4
|
|
17
|
+
- ebaca5b (package) check-dts v0.7.0
|
|
18
|
+
|
|
1
19
|
2023.02.03, v8.3.0
|
|
2
20
|
|
|
3
21
|
fix:
|
package/README.md
CHANGED
package/bin/supertape.mjs
CHANGED
package/lib/cli.js
CHANGED
|
@@ -148,7 +148,10 @@ async function cli({argv, cwd, stdout, isStop}) {
|
|
|
148
148
|
const allFiles = [];
|
|
149
149
|
|
|
150
150
|
for (const arg of args._) {
|
|
151
|
-
const files = glob
|
|
151
|
+
const files = glob
|
|
152
|
+
.sync(arg)
|
|
153
|
+
.filter(isExclude);
|
|
154
|
+
|
|
152
155
|
allFiles.push(...files);
|
|
153
156
|
}
|
|
154
157
|
|
|
@@ -194,4 +197,3 @@ async function cli({argv, cwd, stdout, isStop}) {
|
|
|
194
197
|
}
|
|
195
198
|
|
|
196
199
|
module.exports._filesCount = filesCount;
|
|
197
|
-
|
package/lib/diff.mjs
CHANGED
package/lib/exit-codes.js
CHANGED
package/lib/format.js
CHANGED
package/lib/formatter/harness.js
CHANGED
package/lib/formatter/index.js
CHANGED
package/lib/help.js
CHANGED
|
@@ -3,10 +3,7 @@
|
|
|
3
3
|
module.exports.help = () => {
|
|
4
4
|
const bin = require('../help.json');
|
|
5
5
|
const usage = 'Usage: supertape [options] [path]';
|
|
6
|
-
const result = [
|
|
7
|
-
usage,
|
|
8
|
-
'Options',
|
|
9
|
-
];
|
|
6
|
+
const result = [usage, 'Options'];
|
|
10
7
|
|
|
11
8
|
for (const name of Object.keys(bin)) {
|
|
12
9
|
result.push(` ${name} ${bin[name]}`);
|
|
@@ -14,4 +11,3 @@ module.exports.help = () => {
|
|
|
14
11
|
|
|
15
12
|
return result.join('\n') + '\n';
|
|
16
13
|
};
|
|
17
|
-
|
package/lib/is-debug.js
CHANGED
package/lib/operators.mjs
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import deepEqualCheck from 'deep-equal';
|
|
2
|
-
|
|
3
2
|
import diff from './diff.mjs';
|
|
4
3
|
import {
|
|
5
4
|
formatOutput,
|
|
@@ -139,7 +138,9 @@ const notDeepEqual = (result, expected, message = 'should not deep equal') => {
|
|
|
139
138
|
};
|
|
140
139
|
|
|
141
140
|
const comment = ({formatter}) => (message) => {
|
|
142
|
-
const messages = message
|
|
141
|
+
const messages = message
|
|
142
|
+
.trim()
|
|
143
|
+
.split('\n');
|
|
143
144
|
|
|
144
145
|
for (const current of messages) {
|
|
145
146
|
const line = current
|
|
@@ -211,11 +212,7 @@ function validateEnd({name, operators, runnerState}) {
|
|
|
211
212
|
} = runnerState;
|
|
212
213
|
|
|
213
214
|
if (name === 'end' && isEnded())
|
|
214
|
-
return [INVALID, run(
|
|
215
|
-
'fail',
|
|
216
|
-
runnerState,
|
|
217
|
-
operators.fail(`Cannot use a couple 't.end()' operators in one test`),
|
|
218
|
-
)];
|
|
215
|
+
return [INVALID, run('fail', runnerState, operators.fail(`Cannot use a couple 't.end()' operators in one test`))];
|
|
219
216
|
|
|
220
217
|
if (name === 'end') {
|
|
221
218
|
isEnded(true);
|
|
@@ -225,11 +222,7 @@ function validateEnd({name, operators, runnerState}) {
|
|
|
225
222
|
incAssertionsCount();
|
|
226
223
|
|
|
227
224
|
if (isEnded()) {
|
|
228
|
-
return [INVALID, run(
|
|
229
|
-
'fail',
|
|
230
|
-
runnerState,
|
|
231
|
-
operators.fail(`Cannot run assertions after 't.end()' called`),
|
|
232
|
-
)];
|
|
225
|
+
return [INVALID, run('fail', runnerState, operators.fail(`Cannot run assertions after 't.end()' called`))];
|
|
233
226
|
}
|
|
234
227
|
|
|
235
228
|
return [VALID];
|
|
@@ -280,7 +273,9 @@ function run(name, {formatter, count, incCount, incPassed, incFailed}, testState
|
|
|
280
273
|
expected,
|
|
281
274
|
output,
|
|
282
275
|
errorStack: formatOutput(errorStack),
|
|
283
|
-
at: at || parseAt(errorStack, {
|
|
276
|
+
at: at || parseAt(errorStack, {
|
|
277
|
+
reason,
|
|
278
|
+
}),
|
|
284
279
|
});
|
|
285
280
|
}
|
|
286
281
|
|
|
@@ -311,7 +306,9 @@ export const initOperators = ({formatter, count, incCount, incPassed, incFailed,
|
|
|
311
306
|
notOk: operator('notOk'),
|
|
312
307
|
pass: operator('pass'),
|
|
313
308
|
fail: operator('fail'),
|
|
314
|
-
comment: comment({
|
|
309
|
+
comment: comment({
|
|
310
|
+
formatter,
|
|
311
|
+
}),
|
|
315
312
|
match: operator('match'),
|
|
316
313
|
notMatch: operator('notMatch'),
|
|
317
314
|
end: operator('end'),
|
|
@@ -319,4 +316,3 @@ export const initOperators = ({formatter, count, incCount, incPassed, incFailed,
|
|
|
319
316
|
...extendedOperators,
|
|
320
317
|
};
|
|
321
318
|
};
|
|
322
|
-
|
package/lib/run-tests.js
CHANGED
|
@@ -14,9 +14,7 @@ const notSkip = ({skip}) => !skip;
|
|
|
14
14
|
|
|
15
15
|
const getInitOperators = async () => await import('./operators.mjs');
|
|
16
16
|
|
|
17
|
-
const {
|
|
18
|
-
SUPERTAPE_TIMEOUT = 3000,
|
|
19
|
-
} = process.env;
|
|
17
|
+
const {SUPERTAPE_TIMEOUT = 3000} = process.env;
|
|
20
18
|
|
|
21
19
|
const DEBUG_TIME = 3000 * 1000;
|
|
22
20
|
|
package/lib/supertape.d.ts
CHANGED
|
@@ -1,22 +1,19 @@
|
|
|
1
1
|
import {OperatorStub} from '@supertape/operator-stub';
|
|
2
|
-
|
|
3
2
|
import {
|
|
4
3
|
stub,
|
|
5
4
|
Stub,
|
|
6
5
|
} from '@cloudcmd/stub';
|
|
7
6
|
|
|
8
7
|
type OperationResult = {
|
|
9
|
-
is: boolean
|
|
10
|
-
expected: unknown
|
|
11
|
-
result: unknown
|
|
12
|
-
message: string
|
|
13
|
-
output: string
|
|
8
|
+
is: boolean;
|
|
9
|
+
expected: unknown;
|
|
10
|
+
result: unknown;
|
|
11
|
+
message: string;
|
|
12
|
+
output: string;
|
|
14
13
|
};
|
|
15
|
-
|
|
16
14
|
type Operator = {
|
|
17
15
|
[index: string]: (...args: any[]) => OperationResult;
|
|
18
16
|
};
|
|
19
|
-
|
|
20
17
|
type Test = Operator & OperatorStub & {
|
|
21
18
|
equal: (result: unknown, expected: unknown, message?: string) => OperationResult;
|
|
22
19
|
notEqual: (result: unknown, expected: unknown, message?: string) => OperationResult;
|
|
@@ -31,11 +28,10 @@ type Test = Operator & OperatorStub & {
|
|
|
31
28
|
notMatch: (result: string, pattern: string | RegExp, message?: string) => OperationResult;
|
|
32
29
|
end: () => void;
|
|
33
30
|
};
|
|
34
|
-
|
|
35
31
|
type TestOptions = {
|
|
36
|
-
checkAssertionsCount?: boolean
|
|
37
|
-
checkScopes?: boolean
|
|
38
|
-
checkDuplicates?: boolean
|
|
32
|
+
checkAssertionsCount?: boolean;
|
|
33
|
+
checkScopes?: boolean;
|
|
34
|
+
checkDuplicates?: boolean;
|
|
39
35
|
};
|
|
40
36
|
|
|
41
37
|
declare function test(message: string, fn: (t: Test) => void, options?: TestOptions): void;
|
|
@@ -52,11 +48,10 @@ declare namespace test {
|
|
|
52
48
|
export default test;
|
|
53
49
|
|
|
54
50
|
type CustomOperator = {
|
|
55
|
-
[index: string]: (operator: Operator) => (...args: any[]) => OperationResult
|
|
51
|
+
[index: string]: (operator: Operator) => (...args: any[]) => OperationResult;
|
|
56
52
|
};
|
|
57
53
|
|
|
58
54
|
declare function extend(customOperator: CustomOperator): typeof test;
|
|
59
|
-
|
|
60
55
|
export {
|
|
61
56
|
test,
|
|
62
57
|
Test,
|
|
@@ -64,4 +59,3 @@ export {
|
|
|
64
59
|
Stub,
|
|
65
60
|
extend,
|
|
66
61
|
};
|
|
67
|
-
|
package/lib/supertape.js
CHANGED
|
@@ -71,6 +71,7 @@ function _createEmitter({quiet, stream = stdout, format, getOperators, isStop, r
|
|
|
71
71
|
harness.pipe(stream);
|
|
72
72
|
|
|
73
73
|
const operators = await getOperators();
|
|
74
|
+
|
|
74
75
|
const result = await runTests(tests, {
|
|
75
76
|
formatter,
|
|
76
77
|
operators,
|
|
@@ -237,7 +238,6 @@ const loop = once(({emitter, tests}) => {
|
|
|
237
238
|
}
|
|
238
239
|
|
|
239
240
|
previousCount = tests.length;
|
|
240
|
-
|
|
241
241
|
// 5ms ought to be enough for anybody
|
|
242
242
|
setTimeout(loop, 5);
|
|
243
243
|
})();
|
|
@@ -264,4 +264,3 @@ function fakeEmitter() {
|
|
|
264
264
|
|
|
265
265
|
return emitter;
|
|
266
266
|
}
|
|
267
|
-
|
package/lib/validator.js
CHANGED
|
@@ -4,7 +4,11 @@ const once = require('once');
|
|
|
4
4
|
const StackTracey = require('stacktracey');
|
|
5
5
|
const getDuplicatesMessage = ([, a]) => a;
|
|
6
6
|
|
|
7
|
-
const getMessage = ({message, at, validations}) => [
|
|
7
|
+
const getMessage = ({message, at, validations}) => [
|
|
8
|
+
message,
|
|
9
|
+
at,
|
|
10
|
+
validations,
|
|
11
|
+
];
|
|
8
12
|
|
|
9
13
|
const getMessagesList = (tests) => tests.map(getMessage);
|
|
10
14
|
const compareMessage = (a) => ([b]) => a === b;
|
|
@@ -31,9 +35,8 @@ const {
|
|
|
31
35
|
|
|
32
36
|
const findByMessage = (msg, tests) => {
|
|
33
37
|
const getMessages = once(getMessagesList);
|
|
34
|
-
const filtered = getMessages(tests).filter(compareMessage(msg));
|
|
35
38
|
|
|
36
|
-
return
|
|
39
|
+
return getMessages(tests).filter(compareMessage(msg));
|
|
37
40
|
};
|
|
38
41
|
|
|
39
42
|
module.exports.setValidations = ({checkDuplicates, checkScopes, checkAssertionsCount}) => {
|
|
@@ -93,10 +96,16 @@ function checkAssertionsCount(msg, filtered, options) {
|
|
|
93
96
|
return [];
|
|
94
97
|
|
|
95
98
|
if (assertionsCount > 1)
|
|
96
|
-
return [
|
|
99
|
+
return [
|
|
100
|
+
`Only one assertion per test allowed, looks like you have more`,
|
|
101
|
+
at,
|
|
102
|
+
];
|
|
97
103
|
|
|
98
104
|
if (!assertionsCount)
|
|
99
|
-
return [
|
|
105
|
+
return [
|
|
106
|
+
`Only one assertion per test allowed, looks like you have none`,
|
|
107
|
+
at,
|
|
108
|
+
];
|
|
100
109
|
|
|
101
110
|
return [];
|
|
102
111
|
}
|
|
@@ -105,13 +114,16 @@ function checkScopes(msg, filtered) {
|
|
|
105
114
|
const [message, at] = filtered[0];
|
|
106
115
|
|
|
107
116
|
if (!SCOPE_DEFINED.test(message))
|
|
108
|
-
return [
|
|
117
|
+
return [
|
|
118
|
+
`Scope should be defined before first colon: 'scope: subject', received: '${message}'`,
|
|
119
|
+
at,
|
|
120
|
+
];
|
|
109
121
|
|
|
110
122
|
return [];
|
|
111
123
|
}
|
|
112
124
|
|
|
113
125
|
const isEnabled = (tests, name) => {
|
|
114
|
-
for (const [
|
|
126
|
+
for (const [, , validations] of tests) {
|
|
115
127
|
if (!validations[name]) {
|
|
116
128
|
return false;
|
|
117
129
|
}
|
|
@@ -133,6 +145,8 @@ function checkDuplicates(msg, filtered) {
|
|
|
133
145
|
return [];
|
|
134
146
|
|
|
135
147
|
processedList.add(first);
|
|
136
|
-
return [
|
|
148
|
+
return [
|
|
149
|
+
`Duplicate ${first}`,
|
|
150
|
+
second,
|
|
151
|
+
];
|
|
137
152
|
}
|
|
138
|
-
|
package/package.json
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "supertape",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.4.1",
|
|
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",
|
|
7
7
|
"main": "./lib/supertape.js",
|
|
8
|
-
"commitType": "colon",
|
|
9
8
|
"exports": {
|
|
10
9
|
".": {
|
|
11
10
|
"node": {
|
|
@@ -76,21 +75,21 @@
|
|
|
76
75
|
"devDependencies": {
|
|
77
76
|
"@babel/core": "^7.12.9",
|
|
78
77
|
"@iocmd/wait": "^2.1.0",
|
|
79
|
-
"c8": "^
|
|
80
|
-
"check-dts": "^0.
|
|
78
|
+
"c8": "^8.0.0",
|
|
79
|
+
"check-dts": "^0.7.0",
|
|
81
80
|
"eslint": "^8.0.0",
|
|
82
|
-
"eslint-plugin-n": "^
|
|
83
|
-
"eslint-plugin-putout": "^
|
|
81
|
+
"eslint-plugin-n": "^16.0.1",
|
|
82
|
+
"eslint-plugin-putout": "^19.0.3",
|
|
84
83
|
"find-up": "^6.3.0",
|
|
85
84
|
"madrun": "^9.0.0",
|
|
86
85
|
"mock-require": "^3.0.2",
|
|
87
86
|
"montag": "^1.0.0",
|
|
88
|
-
"nodemon": "^
|
|
87
|
+
"nodemon": "^3.0.1",
|
|
89
88
|
"pullout": "^4.0.0",
|
|
90
|
-
"putout": "^
|
|
89
|
+
"putout": "^31.0.3",
|
|
91
90
|
"runsome": "^1.0.0",
|
|
92
91
|
"try-catch": "^3.0.0",
|
|
93
|
-
"typescript": "^
|
|
92
|
+
"typescript": "^5.1.6"
|
|
94
93
|
},
|
|
95
94
|
"license": "MIT",
|
|
96
95
|
"engines": {
|
package/supertape.json
CHANGED