I want to get a combined coverage of both unit-test and integration-test.
I have seperate folders for both unit-test and integration-test. In my pipeline ci i have a seperate stage for unit-test and integration-test becasue the integration-test requires a dependency.
package.json
{
"unit-test": "nyc mocha --timeout 5000000 -r ts-node/register --project tsconfig.json test/unit/*.test.ts --exit",
"integration-test": "nyc mocha --timeout 5000000 -r ts-node/register --project tsconfig.json test/integration/*.test.ts --exit",
}
Right now i get coverage report for both of them seperatly, but what i can see is that its not a true reflection of all the coverage.
Is there someway i can combine the coverage summary. It might mean that i would need to combine the 2 stages in my pipeline?
There is a nyc merge
feature, that is able to merge multiple coverage reports that are produced by different test runs. You can read about it in the nyc docs.
Other way is to run both tests in same command (as mocha is able to handle multiple input paths), like following:
"test": "nyc mocha --timeout 5000000 -r ts-node/register --project tsconfig.json 'test/unit/*.test.ts' 'test/integration/*.test.ts' --exit"