escover 1.7.1 → 1.9.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,31 @@
1
+ 2022.01.19, v1.9.0
2
+
3
+ feature:
4
+ - escover: formatters: files: add ability to cut lines, when count more then 10
5
+ - escover: formatters returning a string
6
+
7
+
8
+ 2022.01.19, v1.8.1
9
+
10
+ fix:
11
+ - npmignore: add example
12
+
13
+
14
+ 2022.01.19, v1.8.0
15
+
16
+ fix:
17
+ - chore: instrument: rm useless fixture
18
+
19
+ feature:
20
+ - escover: when one of expressions lin line not covered - line not covered
21
+
22
+
23
+ 2022.01.18, v1.7.2
24
+
25
+ feature:
26
+ - escover: config: isExclude: add ability to drop stars
27
+
28
+
1
29
  2022.01.17, v1.7.1
2
30
 
3
31
  fix:
package/README.md CHANGED
@@ -47,17 +47,13 @@ escover npm test
47
47
 
48
48
  ## Config
49
49
 
50
- `exclude` section of configuration file `.nyrc.json` supported.
50
+ `exclude` section of configuration file `.nyrc.json` supported.
51
51
 
52
52
  ## How it looks like?
53
53
 
54
54
  When everything is covered:
55
55
 
56
- ![image](https://user-images.githubusercontent.com/1573141/147943954-ef708577-2856-4de0-9397-dead487b8c08.png)
57
-
58
- When some lines missing coverage:
59
-
60
- ![image](https://user-images.githubusercontent.com/1573141/147944130-9b901646-05ff-4a76-86c9-30631b0a0dd4.png)
56
+ ![image](https://user-images.githubusercontent.com/1573141/149822261-ff9bc3b4-6ee4-452c-9ada-3cc922b630ec.png)
61
57
 
62
58
  ## What if I want to use 🎩`ESCover` with `mock-import`?
63
59
 
package/lib/cli/cli.js CHANGED
@@ -38,10 +38,14 @@ export const cli = ({argv, exit, read}) => {
38
38
 
39
39
  const coverage = read();
40
40
 
41
+ let output = '';
42
+
41
43
  if (args.format === 'lines')
42
- return reportLines(coverage);
44
+ output = reportLines(coverage);
45
+ else
46
+ output = reportFiles(coverage);
43
47
 
44
- reportFiles(coverage);
48
+ process.stdout.write(output);
45
49
  };
46
50
 
47
51
  function execute(cmd, exit) {
package/lib/config.js CHANGED
@@ -4,8 +4,20 @@ import {findUpSync} from 'find-up';
4
4
 
5
5
  const {parse} = JSON;
6
6
 
7
+ const addStars = (patterns) => {
8
+ const result = [];
9
+ for (const pattern of patterns) {
10
+ result.push(...[
11
+ `**/${pattern}/**`,
12
+ pattern,
13
+ ]);
14
+ }
15
+
16
+ return result;
17
+ };
18
+
7
19
  export const isExclude = (name, patterns) => {
8
- const isMatch = picomatch(patterns, {
20
+ const isMatch = picomatch(addStars(patterns), {
9
21
  dot: true,
10
22
  });
11
23
 
@@ -19,7 +19,7 @@ export default (coverageFile) => {
19
19
  ];
20
20
 
21
21
  for (const {filename, covered, lines, percentLines} of files) {
22
- const uncoveredLines = lines.join(', ');
22
+ const uncoveredLines = formatLines(lines);
23
23
 
24
24
  if (covered) {
25
25
  tableData.push([chalk.green(filename), chalk.green(percentLines), '']);
@@ -29,7 +29,7 @@ export default (coverageFile) => {
29
29
  tableData.push([chalk.red(filename), chalk.red(percentLines), chalk.red(uncoveredLines)]);
30
30
  }
31
31
 
32
- process.stdout.write(table(tableData, {
32
+ return table(tableData, {
33
33
  drawHorizontalLine: (raw) => {
34
34
  return !raw || raw === 1 || raw === files.length + 1;
35
35
  },
@@ -46,9 +46,19 @@ export default (coverageFile) => {
46
46
  joinJoin: '|',
47
47
  bodyJoin: '|',
48
48
  },
49
- }));
49
+ });
50
50
  };
51
51
 
52
+ export function formatLines(array) {
53
+ console.log(array);
54
+ const lines = array.slice(0, 10).join(', ');
55
+
56
+ if (array.length <= 10)
57
+ return lines;
58
+
59
+ return `${lines}...`;
60
+ }
61
+
52
62
  function parseUncoveredLines(lines) {
53
63
  const uncoveredLines = [];
54
64
 
@@ -1,7 +1,10 @@
1
1
  import chalk from 'chalk';
2
2
  const {entries} = Object;
3
3
 
4
+ const createOut = (output) => (a) => output.push(a);
4
5
  export default (coverageFile) => {
6
+ const output = [];
7
+ const out = createOut(output);
5
8
  const files = [];
6
9
  const coverage = {
7
10
  files,
@@ -9,8 +12,8 @@ export default (coverageFile) => {
9
12
  uncoveredCount: 0,
10
13
  };
11
14
 
12
- console.log('# CAP version 13');
13
- console.log('');
15
+ out('# CAP version 13');
16
+ out('');
14
17
 
15
18
  for (const {name, lines} of coverageFile) {
16
19
  const uncoveredLines = [];
@@ -39,31 +42,33 @@ export default (coverageFile) => {
39
42
 
40
43
  for (const {name, covered, uncoveredLines} of files) {
41
44
  if (!covered) {
42
- console.log(`# ${name}`);
43
- console.log('🧨 should be covered');
44
- console.log('---');
45
- console.log(`lines:`);
45
+ out(`# ${name}`);
46
+ out('🧨 should be covered');
47
+ out('---');
48
+ out(`lines:`);
46
49
  for (const line of uncoveredLines) {
47
- console.log(`️- ${chalk.red(line)} at file://${name}:${line}`);
50
+ out(`️- ${chalk.red(line)} at file://${name}:${line}`);
48
51
  }
49
- console.log('');
52
+ out('');
50
53
  }
51
54
  }
52
55
 
53
- console.log(`1..${files.length}`);
54
- console.log(`# files: ${files.length}`);
55
- console.log(`# covered: ${coverage.coveredCount}`);
56
+ out(`1..${files.length}`);
57
+ out(`# files: ${files.length}`);
58
+ out(`# covered: ${coverage.coveredCount}`);
56
59
 
57
- console.log('');
60
+ out('');
58
61
 
59
62
  if (!coverage.uncoveredCount) {
60
- console.log('#️ 🌴 ok');
63
+ out('#️ 🌴 ok');
61
64
  }
62
65
 
63
66
  if (coverage.uncoveredCount) {
64
- console.log(`# 🧨 fail: ${coverage.uncoveredCount}`);
67
+ out(`# 🧨 fail: ${coverage.uncoveredCount}`);
65
68
  }
66
69
 
67
- console.log('');
70
+ out('');
71
+
72
+ return output.join('\n');
68
73
  };
69
74
 
package/lib/transform.js CHANGED
@@ -1,17 +1,13 @@
1
1
  const sort = (a) => new Map(Array.from(a.entries()).sort());
2
2
 
3
+ const isBool = (a) => typeof a === 'boolean';
4
+
3
5
  export const transform = (files) => {
4
6
  const result = [];
5
7
  const sorted = sort(files);
6
8
 
7
9
  for (const [rawName, places] of sorted.entries()) {
8
- const rawLines = {};
9
-
10
- for (const [place, covered] of places.entries()) {
11
- const [line] = place.split(':');
12
-
13
- rawLines[line] = covered;
14
- }
10
+ const rawLines = mergeLines(places);
15
11
 
16
12
  result.push({
17
13
  rawName,
@@ -22,3 +18,20 @@ export const transform = (files) => {
22
18
  return result;
23
19
  };
24
20
 
21
+ function mergeLines(places) {
22
+ const result = {};
23
+
24
+ for (const [place, covered] of places.entries()) {
25
+ const [line] = place.split(':');
26
+
27
+ if (isBool(result[line])) {
28
+ result[line] &= covered;
29
+ continue;
30
+ }
31
+
32
+ result[line] = covered;
33
+ }
34
+
35
+ return result;
36
+ }
37
+
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "escover",
3
- "version": "1.7.1",
3
+ "version": "1.9.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",
@@ -19,21 +19,17 @@
19
19
  "loader"
20
20
  ],
21
21
  "scripts": {
22
- "loader": "madrun loader",
23
22
  "test": "madrun test",
24
- "test:only": "madrun test:only",
25
23
  "coverage": "madrun coverage",
26
- "c4": "madrun c4",
27
24
  "lint": "madrun lint",
28
25
  "fresh:lint": "madrun fresh:lint",
29
26
  "lint:fresh": "madrun lint:fresh",
30
27
  "fix:lint": "madrun fix:lint",
31
28
  "report": "madrun report",
32
29
  "watcher": "madrun watcher",
33
- "watch:test": "madrun watch:test",
34
30
  "watch:lint": "madrun watch:lint",
35
31
  "watch:tape": "madrun watch:tape",
36
- "watch:coverage": "madrun watch:coverage"
32
+ "prewisdom": "madrun prewisdom"
37
33
  },
38
34
  "dependencies": {
39
35
  "chalk": "^5.0.0",
@@ -1,4 +0,0 @@
1
- export const sum = (a, b) => a + b;
2
-
3
- // export const mul = (a, b) => a * b;
4
-