@ -20,38 +20,32 @@ find discrepancies between the coverage report and your suite's behavior, please
$ npm install --save-dev solidity-coverage
$ npm install --save-dev solidity-coverage
```
```
### Usage notes:
### Usage notes:
+ For pragma solidity >=0.4.22 <0.6.0/Petersburg
+ Coverage runs tests a little more slowly.
+ Coverage runs tests a little more slowly.
+ Coverage distorts gas consumption.
+ Coverage distorts gas consumption. Tests that check exact gas consumption should be skipped.
+ Coverage launches its own in-process ganache instance. You can
+ Coverage launches its own in-process ganache server. [ganache options](https://github.com/trufflesuite/ganache-core#options) via the `providerOptions` key in your `.solcover.js` config file.
set [ganache options](https://github.com/trufflesuite/ganache-core#options) via
the `providerOptions` key in your `.solcover.js` config file.
### Truffle V5
### Truffle V5
Add "solidity-coverage" to your plugins array in `truffle-config.js`
**Add** "solidity-coverage" to your plugins array in `truffle-config.js`
```javascript
```javascript
module.exports = {
module.exports = {
networks: {...},
networks: {...},
plugins: ["solidity-coverage"]
plugins: ["solidity-coverage"]
}
}
```
```
Run
**Run**
```
```
truffle run coverage [options]
truffle run coverage [options]
```
```
### Command Options
### Command Options
| Option | Example | Description |
| Option <imgwidth=200/> | Example <imgwidth=700/>| Description <imgwidth=1000/> |
| `--file` | `--file="test/registry/*.js"` | Filename or glob describing a subset of JS tests to run. (Globs must be enclosed by quotes.)|
| file | `--file="test/registry/*.js"` | Filename or glob describing a subset of JS tests to run. (Globs must be enclosed by quotes.)|
| `--solcoverjs` | `--solcoverjs ./../.solcover.js` | Relative path from working directory to config. Useful for monorepo packages that share settings. (Path must be "./" prefixed) |
| solcoverjs | `--solcoverjs ./../.solcover.js` | Relative path from working directory to config. Useful for monorepo packages that share settings. (Path must be "./" prefixed) |
| `--useGlobalTruffle` | | Force use of truffle library module from globally installed truffle. (Default: false)|
| version | | Version info |
| `--usePluginTruffle` | | Force use of truffle library module from plugin provided copy (Truffle v5.0.31.) Requires you have locally installed Truffle V5 <= 5.0.30 (Default: false)|
| providerOptions | *Object* | {} | ganache-core options (ex: `network_id: 55`). Complete list of options [here](https://github.com/trufflesuite/ganache-core#options). |
| client | *Object* | `require("ganache-core")` | Useful if you need a specific ganache version. |
| skipFiles | *Array* | `['Migrations.sol']` | Array of contracts or folders (with paths expressed relative to the `contracts` directory) that should be skipped when doing instrumentation. `Migrations.sol` is skipped by default, and does not need to be added to this configuration option if it is used. |
| istanbulReporter | *Array* | ['html', 'lcov', 'text'] | Coverage reporters for Istanbul. Optional reporter replaces the default reporters. |
| skipFiles | *Array* | `['Migrations.sol']` | Array of contracts or folders (with paths expressed relative to the `contracts` directory) that should be skipped when doing instrumentation. |
| onServerReady | *Function* | `async (config) => {}` | Function run when server is ready to receive calls, but before the tests execute. Useful if you need to launch the Oraclize/Provable bridge or have preparatory scripts which rely on the server's availability |
| mocha | *Object* | `{ }` | [Mocha options](https://mochajs.org/api/mocha) to merge into existing mocha config. `grep` and `invert` are useful for skipping certain tests under coverage using tags in the test descriptions.|
| onTestsComplete | *Function* | `async (config) => {}` | Function run immediately after the tests
| onServerReady | *Function* | | Hook run *after* server is launched, *before* the tests execute. Useful if you need to use the Oraclize bridge or have setup scripts which rely on the server's availability |
complete, but before Istanbul reports are generated. |
| onTestsComplete | *Function* | | Hook run *after* the tests complete, *before* Istanbul reports are generated. |
| onIstanbulComplete | *Function* | `async (config) => {}` | Function run immediately after the Istanbul reports are generated, but before the ganache server is shut down. Useful if you need to clean resources up. |
| onIstanbulComplete | *Function* | | Hook run *after* the Istanbul reports are generated, *before* the ganache server is shut down. Useful if you need to clean resources up. |