Skip to main content
Version: 2.0.0

Merge Unit Test Coverage Data

To get the coverage report, first make sure all the requirements are met and then run Keploy test as usual with your application command:

keploy test -c "your_application_command"

After successful execution of this command, A coverage report would be generated inside the test-run folder of keploy/reports.

keploy
├── reports
│ └── test-run-0
│ ├── coverage.yaml
│ └── test-set-0-report.yaml
└── test-set-0
├── mocks.yaml
└── tests
├── test-1.yaml
└── test-2.yaml

🛠️ Language Specific Requirements

Programming LanguagePrerequisites
javascriptnyc

Usage

Update package file

Update the package.json file that runs the application:

  "scripts": {
//other scripts
"test": "jest --coverage --collectCoverageFrom='src/**/*.{js,jsx}'",
"coverage:merge": "mkdir -p ./coverage && nyc merge ./coverage .nyc_output/out.json",
"coverage:report": "nyc report --reporter=lcov --reporter=text",
//other scripts
}

In test script, --coverage flag would trigger the report generation for jest. For report generation in other testing frameworks like mocha, intern, tap, refer https://istanbul.js.org/docs/tutorials/

To generate coverage report for your unit tests, Run:

npm test

To merge coverage data of unit tests with keploy tests, Run:

npm run coverage:merge

To get coverage related information for merged coverage data, Run:

npm run coverage:report