@putout/test 15.10.0 → 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/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,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/test",
3
- "version": "15.10.0",
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 ",