escover 1.1.1 → 1.1.5
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 +25 -0
- package/README.md +12 -14
- package/lib/cli/cli.js +25 -0
- package/package.json +7 -6
package/ChangeLog
CHANGED
|
@@ -1,3 +1,28 @@
|
|
|
1
|
+
2022.01.14, v1.1.5
|
|
2
|
+
|
|
3
|
+
fix:
|
|
4
|
+
- escover: set zenload as dependency
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
2022.01.13, v1.1.4
|
|
8
|
+
|
|
9
|
+
feature:
|
|
10
|
+
- (package) eslint-plugin-putout v13.0.1
|
|
11
|
+
- (package) putout v24.0.2
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
2022.01.11, v1.1.3
|
|
15
|
+
|
|
16
|
+
fix:
|
|
17
|
+
- escover: rm unused
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
2022.01.11, v1.1.2
|
|
21
|
+
|
|
22
|
+
fix:
|
|
23
|
+
- escover: get back running support
|
|
24
|
+
|
|
25
|
+
|
|
1
26
|
2022.01.11, v1.1.1
|
|
2
27
|
|
|
3
28
|
feature:
|
package/README.md
CHANGED
|
@@ -11,22 +11,26 @@
|
|
|
11
11
|
|
|
12
12
|
Coverage for EcmaScript Modules based on 🐊[`Putout`](https://github.com/coderaiser/putout) and [loaders](https://nodejs.org/dist/latest-v16.x/docs/api/esm.html#loaders).
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
## Why another coverage tool?
|
|
15
15
|
|
|
16
16
|
When you want to use `ESM` in `Node.js` without transpiling to `CommonJS` (that's what `jest`, `ava`, `tap` does),
|
|
17
17
|
you have a couple problems to solve.
|
|
18
18
|
|
|
19
|
-
🤷 What test runner does no transpiling to `CommonJS`?
|
|
19
|
+
### 🤷 What test runner does no transpiling to `CommonJS`?
|
|
20
|
+
|
|
20
21
|
☝️ that's easy! 📼 [`Supertape`](https://github.com/coderaiser/supertape) supports `ESM` from the box;
|
|
21
22
|
|
|
22
|
-
🤷 How to mock modules without [mock-require](https://github.com/boblauer/mock-require) (we in `ESM`!);
|
|
23
|
+
### 🤷 How to mock modules without [mock-require](https://github.com/boblauer/mock-require) (we in `ESM`!);
|
|
24
|
+
|
|
23
25
|
☝️ that's solved! [`mock-import`](https://github.com/coderaiser/mock-import) does the thing using `loaders`;
|
|
24
26
|
|
|
25
|
-
🤷
|
|
27
|
+
### 🤷 How to get coverage when `nyc` doesn't supported?
|
|
28
|
+
|
|
26
29
|
☝️ `c8` could help, but [no](https://github.com/coderaiser/c8-reproduce) it supports no `query paramters`
|
|
27
30
|
which are needed to load module again, and apply mocks.
|
|
28
31
|
|
|
29
|
-
🤷 How to get coverage when mocks are used?
|
|
32
|
+
### 🤷 How to get coverage when mocks are used?
|
|
33
|
+
|
|
30
34
|
☝️ Use 🎩 `ESCover`! It supports loaders, `ESM` and collects coverage as a loader!
|
|
31
35
|
|
|
32
36
|
## Install
|
|
@@ -35,16 +39,10 @@ which are needed to load module again, and apply mocks.
|
|
|
35
39
|
npm i escover -D
|
|
36
40
|
```
|
|
37
41
|
|
|
38
|
-
Run to collect coverage:
|
|
39
|
-
|
|
40
|
-
```sh
|
|
41
|
-
NODE_OPTIONS="'--loader escover'" escover npm test
|
|
42
|
-
```
|
|
43
|
-
|
|
44
|
-
Run to show coverage report:
|
|
42
|
+
Run to collect and show coverage:
|
|
45
43
|
|
|
46
44
|
```sh
|
|
47
|
-
escover
|
|
45
|
+
escover npm test
|
|
48
46
|
```
|
|
49
47
|
|
|
50
48
|
## How it looks like?
|
|
@@ -57,7 +55,7 @@ When some lines missing coverage:
|
|
|
57
55
|
|
|
58
56
|

|
|
59
57
|
|
|
60
|
-
## What if I want to use with `mock-import`?
|
|
58
|
+
## What if I want to use 🎩`ESCover` with `mock-import`?
|
|
61
59
|
|
|
62
60
|
Experimental `loaders` supports only one, for now. So [zenload](https://github.com/coderaiser/zenload) should be used.
|
|
63
61
|
|
package/lib/cli/cli.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import {execSync} from 'child_process';
|
|
2
|
+
import tryCatch from 'try-catch';
|
|
1
3
|
import yargsParser from 'yargs-parser';
|
|
2
4
|
|
|
3
5
|
import {version} from './version.js';
|
|
@@ -19,6 +21,29 @@ export const cli = ({argv, exit, read}) => {
|
|
|
19
21
|
return exit();
|
|
20
22
|
}
|
|
21
23
|
|
|
24
|
+
const cmd = argv.slice(2);
|
|
25
|
+
|
|
26
|
+
if (cmd.length) {
|
|
27
|
+
execute('"' + cmd.join(`" "`) + '"', exit);
|
|
28
|
+
}
|
|
29
|
+
|
|
22
30
|
const coverage = read();
|
|
31
|
+
|
|
23
32
|
report(coverage);
|
|
24
33
|
};
|
|
34
|
+
|
|
35
|
+
function execute(cmd, exit) {
|
|
36
|
+
const [error] = tryCatch(execSync, cmd, {
|
|
37
|
+
stdio: [0, 1, 2],
|
|
38
|
+
env: {
|
|
39
|
+
...process.env,
|
|
40
|
+
NODE_OPTIONS: '--no-warnings --loader zenload',
|
|
41
|
+
ZENLOAD: 'escover,mock-import',
|
|
42
|
+
},
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
if (error) {
|
|
46
|
+
console.error(error.message);
|
|
47
|
+
return exit(1);
|
|
48
|
+
}
|
|
49
|
+
}
|
package/package.json
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "escover",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.5",
|
|
4
4
|
"author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
|
|
5
5
|
"description": "Coverage for EcmaScript Modules",
|
|
6
6
|
"main": "lib/escover.js",
|
|
7
7
|
"type": "module",
|
|
8
|
+
"commitType": "colon",
|
|
8
9
|
"bin": {
|
|
9
10
|
"escover": "bin/escover.js"
|
|
10
11
|
},
|
|
@@ -40,9 +41,10 @@
|
|
|
40
41
|
"find-up": "^6.2.0",
|
|
41
42
|
"montag": "^1.2.1",
|
|
42
43
|
"once": "^1.4.0",
|
|
43
|
-
"putout": "^
|
|
44
|
+
"putout": "^24.0.2",
|
|
44
45
|
"try-catch": "^3.0.0",
|
|
45
|
-
"yargs-parser": "^21.0.0"
|
|
46
|
+
"yargs-parser": "^21.0.0",
|
|
47
|
+
"zenload": "^1.4.0"
|
|
46
48
|
},
|
|
47
49
|
"engines": {
|
|
48
50
|
"node": ">=14"
|
|
@@ -54,10 +56,9 @@
|
|
|
54
56
|
"escover": ".",
|
|
55
57
|
"eslint": "^8.3.0",
|
|
56
58
|
"eslint-plugin-node": "^11.1.0",
|
|
57
|
-
"eslint-plugin-putout": "^
|
|
59
|
+
"eslint-plugin-putout": "^13.0.1",
|
|
58
60
|
"madrun": "^8.8.1",
|
|
59
61
|
"mock-import": "^2.0.0",
|
|
60
|
-
"supertape": "^6.0.5"
|
|
61
|
-
"zenload": "^1.0.0"
|
|
62
|
+
"supertape": "^6.0.5"
|
|
62
63
|
}
|
|
63
64
|
}
|