supertape 12.8.0 → 12.10.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 +10 -0
- package/README.md +39 -0
- package/lib/call-when-tests-ends.js +23 -0
- package/lib/is-only-tests.js +1 -1
- package/lib/is-skip-tests.js +3 -0
- package/lib/run-tests.js +10 -2
- package/lib/supertape.d.ts +2 -0
- package/lib/supertape.js +2 -0
- package/package.json +1 -1
package/ChangeLog
CHANGED
package/README.md
CHANGED
|
@@ -239,6 +239,13 @@ Here is Possible `options` similar to [Environment Variables](#environment-varia
|
|
|
239
239
|
- `checkAssertionsCount`;
|
|
240
240
|
- `timeout`;
|
|
241
241
|
|
|
242
|
+
```js
|
|
243
|
+
test('hello: world', (t) => {
|
|
244
|
+
t.equal('hello', 'world');
|
|
245
|
+
t.end();
|
|
246
|
+
});
|
|
247
|
+
```
|
|
248
|
+
|
|
242
249
|
### test.only(message, fn, options?)
|
|
243
250
|
|
|
244
251
|
Like `test(name, cb)` except if you use `.only` this is the only test case
|
|
@@ -273,6 +280,38 @@ test('assertion', (t) => {
|
|
|
273
280
|
});
|
|
274
281
|
```
|
|
275
282
|
|
|
283
|
+
### `isSkiptTests`
|
|
284
|
+
|
|
285
|
+
When you need to know if there was `only` tests use:
|
|
286
|
+
|
|
287
|
+
```js
|
|
288
|
+
import {isOnlyTests} from 'supertape';
|
|
289
|
+
|
|
290
|
+
isOnlyTests();
|
|
291
|
+
```
|
|
292
|
+
|
|
293
|
+
### `isOnlyTests`
|
|
294
|
+
|
|
295
|
+
When you need to know if there was `skip` tests use:
|
|
296
|
+
|
|
297
|
+
```js
|
|
298
|
+
import {isSkipTests} from 'supertape';
|
|
299
|
+
|
|
300
|
+
isSkipTests();
|
|
301
|
+
```
|
|
302
|
+
|
|
303
|
+
### `callWhenTestsEnds`
|
|
304
|
+
|
|
305
|
+
Call your function when tests ends (usually on 'process.exit')
|
|
306
|
+
|
|
307
|
+
```js
|
|
308
|
+
import {callWhenTestsEnds} from 'supertape';
|
|
309
|
+
|
|
310
|
+
callWhenTestsEnds('TYPE_CHECK', () => {
|
|
311
|
+
console.log(`tests ends without 'skip' and 'only'`);
|
|
312
|
+
});
|
|
313
|
+
```
|
|
314
|
+
|
|
276
315
|
## Example
|
|
277
316
|
|
|
278
317
|
```js
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import _process from 'node:process';
|
|
2
|
+
import {isOnlyTests as _isOnlyTests} from './is-only-tests.js';
|
|
3
|
+
import {isSkipTests as _isSkipTests} from './is-skip-tests.js';
|
|
4
|
+
|
|
5
|
+
export function callWhenTestsEnds(name, fn, overrides = {}) {
|
|
6
|
+
const {
|
|
7
|
+
process = _process,
|
|
8
|
+
isOnlyTests = _isOnlyTests,
|
|
9
|
+
isSkipTests = _isSkipTests,
|
|
10
|
+
} = overrides;
|
|
11
|
+
|
|
12
|
+
if (!process.env[name])
|
|
13
|
+
return;
|
|
14
|
+
|
|
15
|
+
const runner = () => {
|
|
16
|
+
if (isOnlyTests() || isSkipTests())
|
|
17
|
+
return;
|
|
18
|
+
|
|
19
|
+
process.exitCode = fn() || 0;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
process.once('exit', runner);
|
|
23
|
+
}
|
package/lib/is-only-tests.js
CHANGED
package/lib/run-tests.js
CHANGED
|
@@ -4,6 +4,7 @@ import {tryToCatch} from 'try-to-catch';
|
|
|
4
4
|
import _isDebug from './is-debug.js';
|
|
5
5
|
import {createValidator} from './validator.js';
|
|
6
6
|
import {isOnlyTests} from './is-only-tests.js';
|
|
7
|
+
import {isSkipTests} from './is-skip-tests.js';
|
|
7
8
|
|
|
8
9
|
const inc = wraptile((store) => store(store() + 1));
|
|
9
10
|
const isOnly = ({only}) => only;
|
|
@@ -41,11 +42,16 @@ export default async (tests, overrides = {}) => {
|
|
|
41
42
|
const onlyTests = tests.filter(isOnly);
|
|
42
43
|
|
|
43
44
|
if (onlyTests.length) {
|
|
44
|
-
isOnlyTests(
|
|
45
|
+
isOnlyTests(onlyTests.length);
|
|
46
|
+
|
|
47
|
+
const skipped = tests.length - onlyTests.length;
|
|
48
|
+
|
|
49
|
+
isSkipTests(skipped);
|
|
50
|
+
|
|
45
51
|
return await runTests(onlyTests, {
|
|
46
52
|
formatter,
|
|
47
53
|
operators,
|
|
48
|
-
skipped
|
|
54
|
+
skipped,
|
|
49
55
|
isStop,
|
|
50
56
|
isDebug,
|
|
51
57
|
});
|
|
@@ -54,6 +60,8 @@ export default async (tests, overrides = {}) => {
|
|
|
54
60
|
const notSkippedTests = tests.filter(notSkip);
|
|
55
61
|
const skipped = tests.filter(isSkip).length;
|
|
56
62
|
|
|
63
|
+
isSkipTests(skipped);
|
|
64
|
+
|
|
57
65
|
return await runTests(notSkippedTests, {
|
|
58
66
|
formatter,
|
|
59
67
|
operators,
|
package/lib/supertape.d.ts
CHANGED
|
@@ -54,3 +54,5 @@ export type CustomOperator = Record<string, OperatorFactory>;
|
|
|
54
54
|
export declare function extend(operators: CustomOperator): TestFunction;
|
|
55
55
|
|
|
56
56
|
export let isOnlyTests: () => boolean;
|
|
57
|
+
export let isSkipTests: () => boolean;
|
|
58
|
+
export let callWhenTestsEnds: (name: string, fn: () => number | void) => void;
|
package/lib/supertape.js
CHANGED
|
@@ -12,6 +12,8 @@ import {createEmitter as _createEmitter} from './emitter.js';
|
|
|
12
12
|
import {createFormatter as _createFormatter} from './formatter/index.js';
|
|
13
13
|
|
|
14
14
|
export {isOnlyTests} from './is-only-tests.js';
|
|
15
|
+
export {isSkipTests} from './is-skip-tests.js';
|
|
16
|
+
export {callWhenTestsEnds} from './call-when-tests-ends.js';
|
|
15
17
|
|
|
16
18
|
const createOnly = (test) => (message, fn, options) => {
|
|
17
19
|
return test(message, fn, {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "supertape",
|
|
3
|
-
"version": "12.
|
|
3
|
+
"version": "12.10.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",
|