monocart-coverage-reports 2.5.0 → 2.5.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 +71 -60
- package/lib/default/options.js +3 -0
- package/lib/index.d.ts +3 -0
- package/lib/index.js +9 -7
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -33,7 +33,14 @@
|
|
|
33
33
|
- [Using `v8-to-istanbul`](#using-v8-to-istanbul)
|
|
34
34
|
- [How Monocart Works](#how-monocart-works)
|
|
35
35
|
* [Debug for Coverage and Sourcemap](#debug-for-coverage-and-sourcemap)
|
|
36
|
-
* [Integration](#integration)
|
|
36
|
+
* [Integration](#integration)
|
|
37
|
+
- [Playwright](#playwright)
|
|
38
|
+
- [Jest](#jest)
|
|
39
|
+
- [Vitest](#vitest)
|
|
40
|
+
- [Codecov](#codecov)
|
|
41
|
+
- [Coveralls](#coveralls)
|
|
42
|
+
- [Sonar Cloud](#sonar-cloud)
|
|
43
|
+
- [Integration with Any Testing Framework](#integration-with-any-testing-framework)
|
|
37
44
|
* [Thanks](#thanks)
|
|
38
45
|
|
|
39
46
|
## Usage
|
|
@@ -645,65 +652,69 @@ When `logging` is `debug`, the raw report data will be preserved in `[outputDir]
|
|
|
645
652
|

|
|
646
653
|
|
|
647
654
|
## Integration
|
|
648
|
-
|
|
649
|
-
- [
|
|
650
|
-
|
|
651
|
-
- [
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
655
|
+
### [Playwright](https://github.com/microsoft/playwright)
|
|
656
|
+
- [monocart-reporter](https://github.com/cenfun/monocart-reporter) - A Playwright custom reporter, supports generating [Code Coverage Report](https://github.com/cenfun/monocart-reporter?#code-coverage-report)
|
|
657
|
+
### [Jest](https://github.com/jestjs/jest/)
|
|
658
|
+
- [jest-monocart-coverage](https://github.com/cenfun/jest-monocart-coverage) - A Jest custom reporter for coverage reports
|
|
659
|
+
### [Vitest](https://github.com/vitest-dev/vitest)
|
|
660
|
+
- [vitest-monocart-coverage](https://github.com/cenfun/vitest-monocart-coverage) - A Vitest custom provider module for coverage reports
|
|
661
|
+
### [Codecov](https://codecov.com/)
|
|
662
|
+
[](https://codecov.io/gh/cenfun/monocart-coverage-reports)
|
|
663
|
+
- Supports native `codecov` built-in report ([specification](https://docs.codecov.com/docs/codecov-custom-coverage-format))
|
|
664
|
+
```js
|
|
665
|
+
const coverageOptions = {
|
|
666
|
+
outputDir: "./coverage-reports",
|
|
667
|
+
reports: [
|
|
668
|
+
['codecov']
|
|
669
|
+
]
|
|
670
|
+
};
|
|
671
|
+
```
|
|
672
|
+
- Github actions example:
|
|
673
|
+
```yml
|
|
674
|
+
- name: Codecov
|
|
675
|
+
uses: codecov/codecov-action@v3
|
|
676
|
+
with:
|
|
677
|
+
files: ./coverage-reports/codecov.json
|
|
678
|
+
```
|
|
679
|
+
### [Coveralls](https://coveralls.io/)
|
|
680
|
+
[](https://coveralls.io/github/cenfun/monocart-coverage-reports?branch=main)
|
|
681
|
+
- Using `lcov` report:
|
|
682
|
+
```js
|
|
683
|
+
const coverageOptions = {
|
|
684
|
+
outputDir: "./coverage-reports",
|
|
685
|
+
lcov: true
|
|
686
|
+
};
|
|
687
|
+
```
|
|
688
|
+
- Github actions example:
|
|
689
|
+
```yml
|
|
690
|
+
- name: Coveralls
|
|
691
|
+
uses: coverallsapp/github-action@v2
|
|
692
|
+
with:
|
|
693
|
+
files: ./coverage-reports/lcov.info
|
|
694
|
+
```
|
|
695
|
+
### [Sonar Cloud](https://sonarcloud.io/)
|
|
696
|
+
[](https://sonarcloud.io/summary/new_code?id=monocart-coverage-reports)
|
|
697
|
+
- Using `lcov` report. Github actions example:
|
|
698
|
+
```yml
|
|
699
|
+
- name: Analyze with SonarCloud
|
|
700
|
+
uses: sonarsource/sonarcloud-github-action@master
|
|
701
|
+
env:
|
|
702
|
+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
|
|
703
|
+
with:
|
|
704
|
+
projectBaseDir: ./
|
|
705
|
+
args: >
|
|
706
|
+
-Dsonar.organization=cenfun
|
|
707
|
+
-Dsonar.projectKey=monocart-coverage-reports
|
|
708
|
+
-Dsonar.projectName=monocart-coverage-reports
|
|
709
|
+
-Dsonar.javascript.lcov.reportPaths=docs/mcr/lcov.info
|
|
710
|
+
-Dsonar.sources=lib
|
|
711
|
+
-Dsonar.tests=test
|
|
712
|
+
-Dsonar.exclusions=dist/*,packages/*
|
|
713
|
+
```
|
|
714
|
+
### Integration with Any Testing Framework
|
|
715
|
+
- Collecting coverage data when any stage of the test is completed, and adding the coverage data to the coverage reporter.
|
|
716
|
+
- Generating the coverage reports after the completion of all tests.
|
|
717
|
+
- see [Multiprocessing Support](#multiprocessing-support)
|
|
707
718
|
|
|
708
719
|
## Thanks
|
|
709
720
|
- Special thanks to [@edumserrano](https://github.com/edumserrano)
|
package/lib/default/options.js
CHANGED
|
@@ -65,6 +65,9 @@ module.exports = {
|
|
|
65
65
|
// {object} { bytes:[50,80], statements:[50,80], branches:[50,80], functions:[50,80], lines:[50,80] }
|
|
66
66
|
watermarks: [50, 80],
|
|
67
67
|
|
|
68
|
+
// {boolean} clean previous files in output dir before generating report. Defaults to true.
|
|
69
|
+
clean: true,
|
|
70
|
+
|
|
68
71
|
// {function} onEnd hook
|
|
69
72
|
// onEnd: async (reportData) => {}
|
|
70
73
|
onEnd: null
|
package/lib/index.d.ts
CHANGED
|
@@ -237,6 +237,9 @@ declare namespace MCR {
|
|
|
237
237
|
* {object} { bytes:[50,80], statements:[50,80], branches:[50,80], functions:[50,80], lines:[50,80] } */
|
|
238
238
|
watermarks?: Watermarks;
|
|
239
239
|
|
|
240
|
+
/** {boolean} clean previous files in output dir before generating report. Defaults to true. */
|
|
241
|
+
clean?: boolean;
|
|
242
|
+
|
|
240
243
|
/** {function} onEnd hook */
|
|
241
244
|
onEnd?: (reportData: CoverageResults) => Promise<void>;
|
|
242
245
|
}
|
package/lib/index.js
CHANGED
|
@@ -112,13 +112,15 @@ class CoverageReport {
|
|
|
112
112
|
const outputDir = this.options.outputDir;
|
|
113
113
|
|
|
114
114
|
if (fs.existsSync(outputDir)) {
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
115
|
+
// if assets dir is out of output dir will be ignore
|
|
116
|
+
if (this.options.clean) {
|
|
117
|
+
fs.readdirSync(outputDir).forEach((itemName) => {
|
|
118
|
+
if (itemName === this.cacheDirName) {
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
Util.rmSync(path.resolve(outputDir, itemName));
|
|
122
|
+
});
|
|
123
|
+
}
|
|
122
124
|
} else {
|
|
123
125
|
fs.mkdirSync(outputDir, {
|
|
124
126
|
recursive: true
|