sc-forks / solidity-coverage

Code coverage for Solidity smart-contracts
MIT License
977 stars 264 forks source link

Can I use this to run test coverage for non-Solidity files too? #670

Closed PaulRBerg closed 3 years ago

PaulRBerg commented 3 years ago

I have a repo in which I am testing both Solidity and TypeScript files. Can I use solidity-coverage to generate a coverage report for both?

PaulRBerg commented 3 years ago

It looks the answer is "no". When I run my tests which do cover both .sol and .ts files, solidity-coverage includes only the former in the coverage report.

Instrumenting for coverage...
=============================

> IPRBProxy.sol
> IPRBProxyFactory.sol
> IPRBProxyRegistry.sol
> PRBProxy.sol
> PRBProxyFactory.sol
> PRBProxyRegistry.sol
PaulRBerg commented 3 years ago

Can you recommend a solution, @cgewecke? Should I run coverage with nyc, then merge the two reports?

cgewecke commented 3 years ago

@paulrberg Yes, I think that's only possibility. One issue is that solidity-coverage is using Istanbul under the hood and you may have to do something to extract its coverage.json and process it with nyc before using nyc to merge everything.

Another strategy (if you're mostly consuming coverage via CI) could be to have two services report - e.g Coveralls for solidity and Codecov for TS.

PaulRBerg commented 3 years ago

Thanks for the tips! I found a third solution - that is to use the Coveralls GitHub Action and upload the coverage reports in parallel.

cgewecke commented 3 years ago

Oh cool!