Skip to content
One-line setup for a blazing-fast smart contracts tests
TypeScript JavaScript
Branch: master
Clone or download
Latest commit 21daea2 Jan 20, 2020
Type Name Latest commit message Commit time
Failed to load latest commit information.
.circleci Review integration tests setup (#30) Dec 17, 2019
scripts Review integration tests setup (#30) Dec 17, 2019
src Upgrade to contract-loader 0.6.1.rc-0, add new config options Jan 17, 2020
test-integration Review integration tests setup (#30) Dec 17, 2019
.eslintignore initial Oct 26, 2019
.gitignore Review integration tests setup (#30) Dec 17, 2019
LICENSE initial Oct 26, 2019 Update Jan 20, 2020
tsconfig.json Publish types for TypeScript users (#33) Dec 22, 2019

OpenZeppelin Test Environment

NPM Package Build Status

Blazing fast smart contract testing. One-line setup for an awesome testing experience.

  • Near-instant start up: have your code running in under 2s after typing npm test.
  • Test runner agnostic – from the familiarity of Mocha, to parallel tests using Jest or Ava!
  • Non-opinionated: use either @truffle/contract or web3-eth-contract as you see fit.
  • First class support for the OpenZeppelin Test Helpers.
  • Highly configurable: from gas limit and initial balance, to complex custom web3 providers.
  • No global variables, no hacks.

test-environment is the result of our learnings while developing the OpenZeppelin Contracts, combining best practices and the tools we've come to rely on over the years. We think you'll love it!



npm install --save-dev @openzeppelin/test-environment


By including require('@openzeppelin/test-environment') in your test files, a local ganache-powered blockchain with unlocked accounts will be spun up, and all tools configured to work with it.

Here's a quick sample of how using test-environment in a Mocha + Chai setup looks like.

const { accounts, contract } = require('@openzeppelin/test-environment');
const [ owner ] = accounts;

const { expect } = require('chai');

const MyContract = contract.fromArtifact('MyContract'); // Loads a compiled contract

describe('MyContract', function () {
  it('deployer is owner', async function () {
    const myContract = await{ from: owner });
    expect(await myContract.owner()).to.equal(owner);

If you're used to truffle test, this probably looks very familiar. Follow our guide on migrating from Truffle to have your project running with test-environment in a breeze!

Note: if you'd rather not rely on truffle contracts and use web3 contract types directly, worry not: you can configure test-environment to use the web3-eth-contract abstraction.

Learn More


Released under the MIT License.

You can’t perform that action at this time.