escover 2.1.2 โ†’ 2.3.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 CHANGED
@@ -1,3 +1,21 @@
1
+ 2022.07.01, v2.3.0
2
+
3
+ feature:
4
+ - escover: mark: add support of UpdateExpression: inc/dec
5
+
6
+
7
+ 2022.05.30, v2.2.0
8
+
9
+ feature:
10
+ - escover: add support of ESCOVER_SUCCESS_EXIT_CODE
11
+
12
+
13
+ 2022.05.29, v2.1.3
14
+
15
+ fix:
16
+ - escover: formatters: lines: add #
17
+
18
+
1
19
  2022.05.09, v2.1.2
2
20
 
3
21
  feature:
@@ -334,14 +352,14 @@ feature:
334
352
  2022.01.08, v1.0.3
335
353
 
336
354
  feature:
337
- - escover: plugin-mark: add support ot ThrowStatement
355
+ - escover: plugin-mark: add support of ThrowStatement
338
356
  - escover: add merger
339
357
 
340
358
 
341
359
  2022.01.08, v1.0.2
342
360
 
343
361
  fix:
344
- - escover: impove support of AssignmentPattern
362
+ - escover: improve support of AssignmentPattern
345
363
 
346
364
  feature:
347
365
  - escover: plugin-mark-line -> plugin-mark
package/README.md CHANGED
@@ -26,7 +26,7 @@ you have a couple problems to solve.
26
26
 
27
27
  ### ๐Ÿคทโ€ How to get coverage when `nyc` doesn't supported?
28
28
 
29
- โ˜๏ธ `c8` could help, but [no](https://github.com/coderaiser/c8-reproduce) it supports no `query paramters`
29
+ โ˜๏ธ `c8` could help, but [no](https://github.com/coderaiser/c8-reproduce) it supports no `query parameters`
30
30
  which are needed to load module again, and apply mocks.
31
31
 
32
32
  ### ๐Ÿคทโ€ How to get coverage when mocks are used?
@@ -35,7 +35,7 @@ which are needed to load module again, and apply mocks.
35
35
 
36
36
  ### ๐Ÿคทโ€ What with [`coveralls`](https://coveralls.io/)? Does [`lcov`](https://github.com/StevenLooman/mocha-lcov-reporter) supported?
37
37
 
38
- โ˜๏ธ Sure! `coverage/lcov.info` is main coverage file for ๐ŸŽฉ`ESCover`.
38
+ โ˜๏ธ Sure! `coverage/lcov.info` is main coverage file for ๐ŸŽฉ**ESCover**.
39
39
 
40
40
  ## Install
41
41
 
@@ -49,6 +49,26 @@ Run to collect and show coverage:
49
49
  escover npm test
50
50
  ```
51
51
 
52
+ ## Comparison with `c8`
53
+
54
+ Check out the real example from [wisdom](https://github.com/coderaiser/wisdom). There is next uncovered code:
55
+
56
+ ```js
57
+ import jessy from 'jessy';
58
+
59
+ export default (info) => typeof jessy('publishConfig.access', info) === 'undefined';
60
+ ```
61
+
62
+ `c8` shows three columns with 100% and one with 0%.
63
+
64
+ <img width="584" alt="image" src="https://user-images.githubusercontent.com/1573141/169064257-579d6770-095e-475b-a7bc-8275849c8dc2.png">
65
+
66
+ And here is what you will see with ๐ŸŽฉ**ESCover**:
67
+
68
+ <img width="403" alt="image" src="https://user-images.githubusercontent.com/1573141/169064550-62aa2398-b370-496f-8c8b-418d0d2d6004.png">
69
+
70
+ So if you need more accurate code with no bullshit green 100%, use ๐ŸŽฉ**ESCover** ๐Ÿ˜‰.
71
+
52
72
  ## Config
53
73
 
54
74
  `exclude` section of configuration file `.nyrc.json` supported.
@@ -75,18 +95,40 @@ Experimental `loaders` supports only one, for now. So [zenload](https://github.c
75
95
  Install it with:
76
96
 
77
97
  ```sh
78
- npm i escover mock-import zenload
98
+ npm i escover
79
99
  ```
80
100
 
81
101
  Then run:
82
102
 
103
+ ```sh
104
+ escover npm test
105
+ ```
106
+
107
+ This is the same as:
108
+
83
109
  ```sh
84
110
  NODE_OPTIONS="'--loader zenlend'" ZENLOAD='escover,mock-import' escover npm test
85
111
  ```
86
112
 
87
- ## What you should know about `lcov`
113
+ ## Env
114
+
115
+ If you want to disable coverage on status code without erroring, use `ESCOVER_SUCCESS_EXIT_CODE`:
116
+
117
+ ```js
118
+ import {SKIPPED} from 'supertape/exit-codes';
119
+
120
+ const env = {
121
+ ESCOVER_SUCCESS_EXIT_CODE: SKIPPED,
122
+ };
123
+
124
+ export default {
125
+ test: () => [env, `escover tape 'test/**/*.js' 'lib/**/*.spec.js'`],
126
+ };
127
+ ```
128
+
129
+ ## What should I know about `lcov`?
88
130
 
89
- Format used by ๐ŸŽฉ`ESCover` located in `coverage/lcov.info`.
131
+ Format used by ๐ŸŽฉ**ESCover** located in `coverage/lcov.info`.
90
132
 
91
133
  - โ˜๏ธ *[`lcov`](https://github.com/linux-test-project/lcov) was created in `2002`, twenty years ago.*
92
134
  - โ˜๏ธ *Linux kernel developers created it to know what is going on with the coverage.*
@@ -122,7 +164,7 @@ Where:
122
164
 
123
165
  - `SF` - is path to source;
124
166
  - `DA` - is line number, and count of running;
125
- - `end_of_record` latest recored for current file entry;
167
+ - `end_of_record` latest recorded for current file entry;
126
168
 
127
169
  The only thing that is differ from `lcov`: counters are `0` or `1`, if you have a reason to use "real" counters [create an issue](https://github.com/coderaiser/escover/issues/new).
128
170
 
package/lib/cli/cli.js CHANGED
@@ -48,6 +48,8 @@ export const cli = ({argv, exit, readCoverage}) => {
48
48
  process.stdout.write(output);
49
49
  };
50
50
 
51
+ export const isSuccess = (error) => error?.status === Number(process.env.ESCOVER_SUCCESS_EXIT_CODE);
52
+
51
53
  function execute(cmd, exit) {
52
54
  const [error] = tryCatch(execSync, cmd, {
53
55
  stdio: [0, 1, 2],
@@ -58,6 +60,9 @@ function execute(cmd, exit) {
58
60
  },
59
61
  });
60
62
 
63
+ if (isSuccess(error))
64
+ return exit(0);
65
+
61
66
  if (error) {
62
67
  console.error(error.message);
63
68
  return exit(1);
package/lib/config.js CHANGED
@@ -36,6 +36,7 @@ export const readConfig = () => {
36
36
  return defaults;
37
37
 
38
38
  const data = readFileSync(name, 'utf8');
39
+
39
40
  return {
40
41
  ...defaults,
41
42
  ...parse(data),
@@ -58,6 +58,7 @@ export function formatLines(array) {
58
58
  return lines;
59
59
 
60
60
  const latest = array.at(-1);
61
+
61
62
  return `${lines}..${latest}`;
62
63
  }
63
64
 
@@ -61,7 +61,7 @@ export default (coverageFile) => {
61
61
  out('');
62
62
 
63
63
  if (!coverage.uncoveredCount)
64
- out('#๏ธ ๐ŸŒด ok');
64
+ out('# ๐ŸŒด ok');
65
65
 
66
66
  if (coverage.uncoveredCount)
67
67
  out(`# ๐Ÿงจ fail: ${coverage.uncoveredCount}`);
@@ -19,6 +19,7 @@ export const instrument = (url, source) => {
19
19
  };
20
20
 
21
21
  const ast = parse(source);
22
+
22
23
  transform(ast, source, options);
23
24
  const {code} = generate(ast);
24
25
 
@@ -60,6 +60,7 @@ export const fix = (path, {options}) => {
60
60
  lineNode.expression,
61
61
  node,
62
62
  ]));
63
+
63
64
  return;
64
65
  }
65
66
 
@@ -97,6 +98,7 @@ export const fix = (path, {options}) => {
97
98
  lineNode.expression,
98
99
  node,
99
100
  ]));
101
+
100
102
  return;
101
103
  }
102
104
 
@@ -183,6 +185,13 @@ export const traverse = ({push}) => ({
183
185
  push(expPath);
184
186
  }
185
187
  },
188
+ UpdateExpression(path) {
189
+ if (compare(path, `(${LINE}, __z)`)) {
190
+ return;
191
+ }
192
+
193
+ push(path);
194
+ },
186
195
  'IfStatement|ConditionalExpression'(path) {
187
196
  const consequentPath = path.get('consequent');
188
197
  const alternatePath = path.get('alternate');
package/lib/merge.js CHANGED
@@ -5,13 +5,12 @@ export const merge = (files) => {
5
5
 
6
6
  for (const {rawName, rawLines} of files) {
7
7
  const name = cutQuery(rawName);
8
- const lines = applyCoverage({
8
+
9
+ deduplicator[name] = applyCoverage({
9
10
  name,
10
11
  rawLines,
11
12
  deduplicator,
12
13
  });
13
-
14
- deduplicator[name] = lines;
15
14
  }
16
15
 
17
16
  const list = [];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "escover",
3
- "version": "2.1.2",
3
+ "version": "2.3.0",
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",