monocart-coverage-reports 2.7.10 → 2.8.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 CHANGED
@@ -6,7 +6,9 @@
6
6
  ![](https://img.shields.io/github/license/cenfun/monocart-coverage-reports)
7
7
  ![](https://img.shields.io/github/actions/workflow/status/cenfun/monocart-coverage-reports/static.yml)
8
8
 
9
- > A code coverage tool to generate native [V8](https://v8.dev/blog/javascript-code-coverage) reports or [Istanbul](https://istanbul.js.org/) reports.
9
+ 🌐 English | [įŽ€äŊ“中文](README.zh-Hans.md)
10
+
11
+ > A JavaScript code coverage tool to generate native [V8](https://v8.dev/blog/javascript-code-coverage) reports or [Istanbul](https://istanbul.js.org/) reports.
10
12
 
11
13
  * [Usage](#usage)
12
14
  * [Options](#options)
@@ -37,10 +39,11 @@
37
39
  * [Integration with Any Testing Framework](#integration-with-any-testing-framework)
38
40
  * [Integration Examples](#integration-examples)
39
41
  - [Playwright](#playwright)
42
+ - [CodeceptJS](#codeceptjs)
40
43
  - [Jest](#jest)
41
44
  - [Vitest](#vitest)
45
+ - [Puppeteer](#puppeteer)
42
46
  - [Cypress](#cypress)
43
- - [CodeceptJS](#codeceptjs)
44
47
  - [WebdriverIO](#webdriverio)
45
48
  - [Storybook Test Runner](#storybook-test-runner)
46
49
  - [TestCafe](#testcafe)
@@ -202,6 +205,8 @@ const mcr = MCR(coverageOptions);
202
205
  ```
203
206
 
204
207
  ## Compare Reports
208
+ > If the V8 data format is used for Istanbul reports, it will be automatically converted from V8 to Istanbul.
209
+
205
210
  | | Istanbul | V8 | V8 to Istanbul |
206
211
  | :--------------| :------ | :------ | :---------------------- |
207
212
  | Coverage data | [Istanbul](https://github.com/gotwarlost/istanbul/blob/master/coverage.json.md) (Object) | [V8](#v8-coverage-data-format) (Array) | [V8](#v8-coverage-data-format) (Array) |
@@ -698,32 +703,7 @@ npx mcr node ./test/specs/node.test.js -r v8,console-details --lcov
698
703
  ```
699
704
 
700
705
  - CLI Options
701
- ```sh
702
- Usage: mcr [options] [command]
703
-
704
- CLI to generate coverage reports
705
-
706
- Arguments:
707
- command command to execute
708
-
709
- Options:
710
- -v, --version output the current version
711
- -c, --config <path> custom config file path
712
- -l, --logging <logging> off, error, info, debug
713
- -n, --name <name> report name for title
714
- -r, --reports <name[,name]> coverage reports to use
715
- -o, --outputDir <dir> output dir for reports
716
- -i, --inputDir <dir> input dir for merging raw files
717
- --entryFilter <pattern> entry url filter
718
- --sourceFilter <pattern> source path filter
719
- --outputFile <path> output file for v8 report
720
- --inline inline html for v8 report
721
- --assetsPath <path> assets path if not inline
722
- --lcov generate lcov.info file
723
- --import <module> preload module at startup
724
- --require <module> preload module at startup
725
- -h, --help display help for command
726
- ```
706
+ see all options with running `mcr` or `mcr --help`
727
707
 
728
708
  - Use `--` to separate sub CLI args
729
709
  ```sh
@@ -746,24 +726,24 @@ Loading config file by priority:
746
726
  - `mcr.config.mjs`
747
727
  - `mcr.config.json` - json format
748
728
  - `mcr.config.ts` (requires preloading the ts execution module)
749
- - `.mcrrc.js`
750
- - `.mcrrc` - json format
751
729
 
752
730
  ## Merge Coverage Reports
753
731
  The following usage scenarios may require merging coverage reports:
754
- - When the code is executed in different environments, like Node.js server side and browser client side (Next.js for instance). Each environment may generate its own coverage report. Merging them can give a more comprehensive view of the test coverage.
755
- - When the code is subjected to different kinds of testing. For example, unit tests with Jest might cover certain parts of the code, while end-to-end tests with Playwright might cover other parts. Merging these different coverage reports can provide a holistic view of what code has been tested.
732
+ - When the code is executed in different environments, like Node.js `server side` and browser `client side` (`Next.js` for instance). Each environment may generate its own coverage report. Merging them can give a more comprehensive view of the test coverage.
733
+ - When the code is subjected to different kinds of testing. For example, `unit tests` with `Jest` might cover certain parts of the code, while `end-to-end tests` with `Playwright` might cover other parts. Merging these different coverage reports can provide a holistic view of what code has been tested.
756
734
  - When tests are run on different machines or containers, each might produce its own coverage report. Merging these can give a complete picture of the test coverage across all machines or shards.
757
735
 
758
736
  ### Automatic Merging
759
- - `MCR` will automatically merge all the added coverage data when executing `generate()`. And it supports adding coverage data asynchronously across processes, see [Multiprocessing Support](#multiprocessing-support)
760
- - For Next.js, it can actually add coverage data including both server side and client side before executing `generate()`, see example [nextjs-with-playwright](https://github.com/cenfun/nextjs-with-playwright)
761
- - Use Codecov, a popular online code coverage service, which supports automatic merging of reports. Please use report `codecov`, it will generate report file `codecov.json`. If multiple `codecov.json` files are generated, upload all these files, they will be automatically merged. see [Codecov](#codecov) and [merging reports](https://docs.codecov.com/docs/merging-reports)
737
+ - The `MCR` will automatically merge all the added coverage data when executing `generate()`. And it supports adding coverage data asynchronously across processes, see [Multiprocessing Support](#multiprocessing-support)
738
+ - For `Next.js`, it can actually add coverage data including both server side and client side before executing `generate()`, see example [nextjs-with-playwright](https://github.com/cenfun/nextjs-with-playwright)
739
+ - Using `Codecov`, a popular online code coverage service, which supports automatic merging of reports. Please use report `codecov`, it will generate report file `codecov.json`. If multiple `codecov.json` files are generated, upload all these files, they will be automatically merged. see [Codecov](#codecov) and [merging reports](https://docs.codecov.com/docs/merging-reports)
762
740
 
763
741
  ### Manual Merging
764
- If the reports cannot be merged automatically, then here is how to manually merge the reports.
742
+ If the reports cannot be merged automatically, then here is how to manually merge the reports.
765
743
  First, using the `raw` report to export the original coverage data to the specified directory.
766
- - For example, we have `raw` coverage data from unit tests, which is output to `./coverage-reports/unit/raw`
744
+ - For example, we have `raw` coverage data from `unit test`, which is output to `./coverage-reports/unit/raw`. Unit test examples:
745
+ - `Jest` + [jest-monocart-coverage](https://github.com/cenfun/jest-monocart-coverage)
746
+ - `Vitest` + [vitest-monocart-coverage](https://github.com/cenfun/vitest-monocart-coverage)
767
747
  ```js
768
748
  const coverageOptions = {
769
749
  name: 'My Unit Test Coverage Report',
@@ -779,8 +759,13 @@ const coverageOptions = {
779
759
  ]
780
760
  };
781
761
  ```
782
- - We also have `raw` coverage data from e2e tests, which is output to `./coverage-reports/e2e/raw`
783
- - Create a script `merge-coverage.js` to generate a merged report with option `inputDir`. After all the tests are completed, running script `node path/to/merge-coverage.js`
762
+
763
+ - We also have `raw` coverage data from `e2e test`, which is output to `./coverage-reports/e2e/raw`. E2E test examples:
764
+ - `Playwright` + [monocart-reporter](https://github.com/cenfun/monocart-reporter) with coverage API
765
+ - `Playwright` + `MCR`, see [playwright-coverage](https://github.com/cenfun/playwright-coverage)
766
+ - see more [Integration Examples](#integration-examples)
767
+
768
+ - Then create a script `merge-coverage.js` to generate a merged report with option `inputDir`.
784
769
  ```js
785
770
  // merge-coverage.js
786
771
  const fs = require('fs');
@@ -830,7 +815,7 @@ const coverageOptions = {
830
815
  };
831
816
  await new CoverageReport(coverageOptions).generate();
832
817
  ```
833
- - All the command scripts are probably like following:
818
+ - Running script `node path/to/merge-coverage.js` after all the tests are completed. All the command scripts are probably like following:
834
819
  ```json
835
820
  {
836
821
  "scripts": {
@@ -909,42 +894,46 @@ When `logging` is `debug`, the raw report data will be preserved in `[outputDir]
909
894
  ## Integration Examples
910
895
 
911
896
  ### [Playwright](https://github.com/microsoft/playwright)
912
- - [playwright-coverage](https://github.com/cenfun/playwright-coverage) - A Example for Playwright Coverage Reports
913
- - [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)
914
- - Coverage for component testing:
897
+ - [playwright-coverage](https://github.com/cenfun/playwright-coverage) - Example for Playwright coverage reports
898
+ - [playwright-bdd-coverage](https://github.com/cenfun/playwright-bdd-coverage) - Example for Playwright BDD coverage reports
899
+ - [monocart-reporter](https://github.com/cenfun/monocart-reporter) - Playwright custom reporter, supports generating [Code coverage report](https://github.com/cenfun/monocart-reporter?#code-coverage-report)
900
+ - Coverage for component testing with `monocart-reporter`:
915
901
  - [playwright-ct-vue](https://github.com/cenfun/playwright-ct-vue)
916
902
  - [playwright-ct-react](https://github.com/cenfun/playwright-ct-react)
917
903
  - [playwright-ct-svelte](https://github.com/cenfun/playwright-ct-svelte)
918
904
  - Coverage for Next.js, both server side and client side:
919
905
  - [nextjs-with-playwright](https://github.com/cenfun/nextjs-with-playwright)
920
906
  - [nextjs-with-playwright-istanbul](https://github.com/cenfun/nextjs-with-playwright-istanbul)
907
+ - see [Collecting V8 Coverage Data with Playwright](#collecting-v8-coverage-data-with-playwright)
908
+
909
+ ### [CodeceptJS](https://github.com/codeceptjs/CodeceptJS)
910
+ - CodeceptJS is a [BDD](https://codecept.io/bdd/) + [AI](https://codecept.io/ai/) testing framework for e2e testing, it has integrated `MCR` since [v3.5.15](https://github.com/codeceptjs/CodeceptJS/releases/tag/3.5.15), see [plugins/coverage](https://codecept.io/plugins/#coverage). There's no need to use ~~[codeceptjs-monocart-coverage](https://github.com/cenfun/codeceptjs-monocart-coverage)~~ anymore.
921
911
 
922
912
  ### [Jest](https://github.com/jestjs/jest/)
923
- - [jest-monocart-coverage](https://github.com/cenfun/jest-monocart-coverage) - A Jest custom reporter for coverage reports
924
- - [jest-puppeteer-coverage](https://github.com/cenfun/jest-puppeteer-coverage) - A Jest Puppeteer Coverage Example
925
- - Example for Jest (unit) + Puppeteer (e2e) + Codecov: [maplibre-gl-js](https://github.com/maplibre/maplibre-gl-js)
913
+ - [jest-monocart-coverage](https://github.com/cenfun/jest-monocart-coverage) - Jest custom reporter for coverage reports
926
914
 
927
915
  ### [Vitest](https://github.com/vitest-dev/vitest)
928
- - [vitest-monocart-coverage](https://github.com/cenfun/vitest-monocart-coverage) - A Vitest custom provider module for coverage reports
916
+ - [vitest-monocart-coverage](https://github.com/cenfun/vitest-monocart-coverage) - Vitest custom provider module for coverage reports
929
917
 
930
- ### [Cypress](https://github.com/cypress-io/cypress)
931
- - [cypress-monocart-coverage](https://github.com/cenfun/cypress-monocart-coverage) - A Cypress plugin for coverage reports
918
+ ### [Puppeteer](https://github.com/puppeteer/puppeteer/)
919
+ - [jest-puppeteer-coverage](https://github.com/cenfun/jest-puppeteer-coverage) - Example for Jest puppeteer coverage
920
+ - [maplibre-gl-js](https://github.com/maplibre/maplibre-gl-js) - Example for Jest (unit) + Puppeteer (e2e) + Codecov
921
+ - see [Collecting Raw V8 Coverage Data with Puppeteer](#collecting-raw-v8-coverage-data-with-puppeteer)
932
922
 
933
- ### [CodeceptJS](https://github.com/codeceptjs/CodeceptJS)
934
- - CodeceptJS has integrated MCR from version [3.5.15](https://github.com/codeceptjs/CodeceptJS/releases/tag/3.5.15)
935
- - [codeceptjs-monocart-coverage](https://github.com/cenfun/codeceptjs-monocart-coverage) - A CodeceptJS plugin for coverage reports
923
+ ### [Cypress](https://github.com/cypress-io/cypress)
924
+ - [cypress-monocart-coverage](https://github.com/cenfun/cypress-monocart-coverage) - Cypress plugin for coverage reports
936
925
 
937
926
  ### [WebdriverIO](https://github.com/webdriverio/webdriverio)
938
- - [wdio-monocart-service](https://github.com/cenfun/wdio-monocart-service) - A WebdriverIO service for coverage reports
927
+ - [wdio-monocart-service](https://github.com/cenfun/wdio-monocart-service) - WebdriverIO service for coverage reports
939
928
 
940
929
  ### [Storybook Test Runner](https://github.com/storybookjs/test-runner)
941
- - [storybook-monocart-coverage](https://github.com/cenfun/storybook-monocart-coverage) - Storybook V8 Coverage Example
930
+ - [storybook-monocart-coverage](https://github.com/cenfun/storybook-monocart-coverage) - Example for Storybook V8 coverage reports
942
931
 
943
932
  ### [TestCafe](https://github.com/DevExpress/testcafe)
944
- - [testcafe-reporter-coverage](https://github.com/cenfun/testcafe-reporter-coverage) - A TestCafe custom reporter for coverage reports
933
+ - [testcafe-reporter-coverage](https://github.com/cenfun/testcafe-reporter-coverage) - TestCafe custom reporter for coverage reports
945
934
 
946
935
  ### [Selenium Webdriver](https://github.com/seleniumhq/selenium)
947
- - [selenium-webdriver-coverage](https://github.com/cenfun/selenium-webdriver-coverage) - Selenium Webdriver V8 Coverage Example
936
+ - [selenium-webdriver-coverage](https://github.com/cenfun/selenium-webdriver-coverage) - Example for Selenium Webdriver V8 coverage reports
948
937
 
949
938
  ### [Mocha](https://github.com/mochajs/mocha)
950
939
  ```sh