npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@cartesi/solidity-coverage

v0.7.16-patch-2

Published

[![Gitter chat](https://badges.gitter.im/sc-forks/solidity-coverage.svg)][18] ![npm (tag)](https://img.shields.io/npm/v/solidity-coverage/latest) [![CircleCI](https://circleci.com/gh/sc-forks/solidity-coverage.svg?style=svg)][20] [![codecov](https://codec

Downloads

9

Readme

solidity-coverage

Gitter chat npm (tag) CircleCI codecov buidler

Code coverage for Solidity testing

coverage example

Install

$ npm install --save-dev solidity-coverage

Resources:

Truffle V5

Add this package to your plugins array in truffle-config.js (Truffle docs)

module.exports = {
  networks: {...},
  plugins: ["solidity-coverage"]
}

Run

truffle run coverage [command-options]

Hardhat

Beginning with v0.7.12, this tool supports Hardhat and runs directly on HardhatEVM.

Require the plugin in hardhat.config.js (Hardhat docs)

require('solidity-coverage')

Run

npx hardhat coverage [command-options]

(Additional Hardhat-specific info can be found here)

Buidler [Deprecated]

Add the plugin in buidler.config.js (Buidler docs)

usePlugin('solidity-coverage')

module.exports = {
  networks: {
    coverage: {
      url: 'http://localhost:8555'
    }
  },
}

Run

npx buidler coverage --network coverage [command-options]

Buidler Project Examples:

@openzeppelin/test-environment

OpenZeppelin have written their own coverage generation scripts for test-environment using the solidity-coverage API. A working example can be found at openzeppelin-contracts, here.

Usage notes:

  • Coverage runs tests a little more slowly.
  • Coverage launches its own in-process ganache server.
  • You can set ganache options using the providerOptions key in your .solcover.js config.
  • Coverage distorts gas consumption. Tests that check exact gas consumption should be skipped.
  • :warning: Contracts are compiled without optimization. Please report unexpected compilation faults to issue 417

Command Options

| Option | Example | Description | |--------------|------------------------------------|--------------------------------| | file | --file="test/registry/*.js" | (Truffle) Filename or glob describing a subset of tests to run. (Globs must be enclosed by quotes and use globby matching patterns)| | testfiles | --testfiles "test/registry/*.ts" | (Buidler) Test file(s) to run. (Globs must be enclosed by quotes and use globby matching patterns)| | solcoverjs | --solcoverjs ./../.solcover.js | Relative path from working directory to config. Useful for monorepo packages that share settings. (Path must be "./" prefixed) | | network | --network development | Use network settings defined in the Truffle or Buidler config | | temp* | --temp build | :warning: Caution :warning: Path to a disposable folder to store compilation artifacts in. Useful when your test setup scripts include hard-coded paths to a build directory. More... |

* Advanced use

Config Options

Additional options can be specified in a .solcover.js config file located in the root directory of your project.

Example:

module.exports = {
  skipFiles: ['Routers/EtherRouter.sol']
};

| Option | Type | Default | Description | | ------ | ---- | ------- | ----------- | | silent | Boolean | false | Suppress logging output | | client | Object | require("ganache-core") | Useful if you need a specific ganache version. | | providerOptions | Object | { } | ganache-core options | | skipFiles | Array | ['Migrations.sol'] | Array of contracts or folders (with paths expressed relative to the contracts directory) that should be skipped when doing instrumentation. | | measureStatementCoverage | boolean | true | Computes statement (in addition to line) coverage. More... | | measureFunctionCoverage | boolean | true | Computes function coverage. More... | | istanbulFolder | String | ./coverage | Folder location for Istanbul coverage reports. | | istanbulReporter | Array | ['html', 'lcov', 'text', 'json'] | Istanbul coverage reporters | | mocha | Object | { } | Mocha options to merge into existing mocha config. grep and invert are useful for skipping certain tests under coverage using tags in the test descriptions.| | 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. More... | | onCompileComplete* | Function | | Hook run after compilation completes, before tests are run. Useful if you have secondary compilation steps or need to modify built artifacts. More...| | onTestsComplete* | Function | | Hook run after the tests complete, before Istanbul reports are generated. More...| | 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. More...|

* Advanced use

API

Solidity-coverage's core methods and many utilities are available as an API.

const CoverageAPI = require('solidity-coverage/api');

Documentation available here.

FAQ

Common problems & questions:

Example reports

Contribution Guidelines

Contributions are welcome! If you're opening a PR that adds features or options please consider writing full unit tests for them. (We've built simple fixtures for almost everything and are happy to add some for your case if necessary).

Set up the development environment with:

$ git clone https://github.com/sc-forks/solidity-coverage.git
$ yarn

Contributors