- Edit
package.json
Jest configuration as shown below. The big points are to ensure you have ajson
reporter and to ensure your coverage is stored in a unique directory for unit tests (in this config itscoverage/unit
. Also, add the development dependencies shown as they are required for the merge script. - Edit your e2e configuration (
test/jest-e2e.json
) as shown below. The required "trick" was to ensure thatrootDir
's subtree includes paths for the e2e tests as well as an source you want to generate coverage for. Using the parent directory includes bothtest
andsrc
so this works. I tried many other methods, like settingcollectCoverageFrom
to../src
, none of them worked. It appears you must use the parent directory and exclude everything you don't want. Note that it also uses a unique directory for its generated coverage data (coverage/e2e
). - Add
merge-coverage.ts
shown below to your project and run it after you've ran both test sets generating coverage.