@putout/test 15.9.2 → 15.10.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/README.md CHANGED
@@ -23,6 +23,14 @@ UPDATE=1 tape test/*.js
23
23
 
24
24
  When you need to override extension use `UPDATE_EXTENSION`, for example `UPDATE_EXTENSION=abc` will create files with extension 'abc'.
25
25
 
26
+ ## `PUTOUT_INSTRUMENT`
27
+
28
+ When you want to check coverage of [type checkers](https://github.com/coderaiser/putout/tree/master/packages/operator-type-checker#readme) use:
29
+
30
+ ```
31
+ PUTOUT_INSTRUMENT=1 putout-test 'lib/**/*.spec.js`
32
+ ```
33
+
26
34
  ## Plugins API
27
35
 
28
36
  🐊**Putout** can be used in all IDE's supported by`ESLint` as [`eslint-plugin-putout`](https://github.com/coderaiser/putout/tree/packages/eslint-plugin-putout).
package/bin/test.js CHANGED
@@ -1,7 +1,10 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- import 'supertape/bin/supertape';
4
- import {callWhenTestsEnds} from 'supertape';
5
- import {whenTestsEnds} from '@putout/printer/type-checker/when-tests-ends';
3
+ import process from 'node:process';
6
4
 
7
- callWhenTestsEnds('PUTOUT_INSTRUMENT', whenTestsEnds);
5
+ const hook = new URL('./type-check-coverage.js', import.meta.url);
6
+
7
+ // supertape runs tests in a worker, so the hook has to be loaded there
8
+ process.argv.splice(2, 0, '-r', hook.href);
9
+
10
+ await import('supertape/bin/supertape');
@@ -0,0 +1,4 @@
1
+ import {callWhenTestsEnds} from 'supertape';
2
+ import {whenTestsEnds} from '../lib/type-check-coverage/index.js';
3
+
4
+ callWhenTestsEnds('PUTOUT_INSTRUMENT', whenTestsEnds);
@@ -0,0 +1,28 @@
1
+ import {pathToFileURL} from 'node:url';
2
+ import {cwd as _cwd} from 'node:process';
3
+ import {whenTestsEnds as _whenTestsEnds} from '@putout/printer/type-checker/when-tests-ends';
4
+ import {getCoverage as _getCoverage} from '@putout/printer/type-checker/instrument';
5
+
6
+ export const createGetCoverage = (overrides = {}) => {
7
+ const {
8
+ cwd = _cwd(),
9
+ getCoverage = _getCoverage,
10
+ } = overrides;
11
+
12
+ const {href} = pathToFileURL(cwd);
13
+ const isOwn = ([name]) => name.includes(href);
14
+
15
+ return () => new Map(Array
16
+ .from(getCoverage())
17
+ .filter(isOwn));
18
+ };
19
+
20
+ export const whenTestsEnds = (overrides = {}) => {
21
+ const {
22
+ whenTestsEnds = _whenTestsEnds,
23
+ } = overrides;
24
+
25
+ return whenTestsEnds({
26
+ getCoverage: createGetCoverage(overrides),
27
+ });
28
+ };
package/package.json CHANGED
@@ -1,13 +1,14 @@
1
1
  {
2
2
  "name": "@putout/test",
3
- "version": "15.9.2",
3
+ "version": "15.10.1",
4
4
  "type": "module",
5
5
  "author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
6
6
  "description": "Test runner for 🐊Putout plugins ",
7
7
  "homepage": "https://github.com/coderaiser/putout/tree/master/packages/test#readme",
8
8
  "main": "lib/test.js",
9
9
  "bin": {
10
- "tape": "bin/test.js"
10
+ "tape": "bin/test.js",
11
+ "putout-test": "bin/test.js"
11
12
  },
12
13
  "exports": {
13
14
  ".": "./lib/test.js",