# OpenZeppelin Test Helpers 0.5

**URL:** <https://forum.openzeppelin.com/t/openzeppelin-test-helpers-0-5/1600>\
**Category:** Announcements\
**Tags:** release\
**Created:** [October 23, 2019, 12:05am UTC](https://forum.openzeppelin.com/t/openzeppelin-test-helpers-0-5/1600 "2019-10-23T00:05:52Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![frangio](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.openzeppelin.com/frangio/32/15251_2.png) [@frangio](https://forum.openzeppelin.com/u/frangio)\
**Post date:** [October 23, 2019, 12:05am UTC](https://forum.openzeppelin.com/t/openzeppelin-test-helpers-0-5/1600/1 "2019-10-23T00:05:52Z")

</div>

![Test Helpers 0.5](https://us1.discourse-cdn.com/flex022/uploads/zeppelin/original/2X/0/071394c6e6c9716a5e54ecbed71c36b58ee93ef9.png)

[OpenZeppelin Test Helpers](https://github.com/OpenZeppelin/openzeppelin-test-helpers) is a library of functions that come in handy when writing tests for smart contracts.

We’ve recently released a shiny new version. Here’s all the details!

### Support for plain Web3.js workflows

The main change introduced in 0.5 is support for plain Web3.js workflows, without the need for a Truffle environment. This essentially means that the helpers that use or return contract abstractions (`expectEvent` and `singletons`) now also support instances of `web3.eth.Contract`. There may still be some small warts in this feature, so please let us know if you run into any issues!

```javascript
const myContract = new web3.eth.Contract(abi, address);

await expectRevert(myContract.methods.fails().send(), 'Failed for reasons');

```

This should also open the door to using Test Helpers with other frameworks. If you have a favorite framework that you would like to see supported please [let us know](https://github.com/OpenZeppelin/openzeppelin-test-helpers/issues/new)!

### Revamped `expectEvent`

To support instances of `web3.eth.Contract` we’ve revamped the `expectEvent` helper. The previous `expectEvent.inLogs` is still available but has been deprecated. We recommend migrating to the new helper `expectEvent(receipt, eventName, eventArgs)` which will, quite magically ✨, work with both Web3.js and Truffle receipts. _(Note: a “receipt” is what’s contained in the Promise returned by contract function calls.)_

```javascript
const web3Receipt = await MyWeb3Contract.methods.foo('bar').send();
expectEvent(web3Receipt, 'Foo', { value: 'bar' });

const truffleReceipt = await MyTruffleContract.foo('bar');
expectEvent(truffleReceipt, 'Foo', { value: 'bar' });

```

### Balance units

An additional new goodie included in this release is the possibility of reading an account’s balance in any unit. Whereas before these helpers always returned amounts in wei, you can now ask for amounts in ether, gwei, or anything supported by web3.js.

```javascript
// Web3.js
new BN(web3.utils.fromWei(await web3.eth.getBalance(account), 'ether'))

// Test Helpers
await balance.current(account, 'ether')

```

Note that this also applies to the cool [`balance.tracker`](https://github.com/OpenZeppelin/openzeppelin-test-helpers#balance-tracker). If you’ve never heard about this one, it’s a great moment to check it out, since for this release we’ve improved its documentation.

### Chai is now optional

As a small quality-of-life improvement, it is no longer necessary to install Chai side by side with Test Helpers. If you want to use it, you can install it, but it will no longer cause an error if it’s not present.

## Upgrading

We have released this version under the new `@openzeppelin` npm scope, like the rest of the packages in the OpenZeppelin suite. So you will need to reinstall the package as `@openzeppelin/test-helpers`.

If you are using 0.4, we have a short [upgrade guide](https://github.com/OpenZeppelin/openzeppelin-test-helpers/blob/master/CHANGELOG.md#how-to-upgrade-from-04) that you can follow. It should be very simple.

All of this is already in use in the [Contracts test suite](https://github.com/OpenZeppelin/openzeppelin-contracts/tree/master/test), so feel free to use that as a reference. Also remember to use the documentation in [the readme](https://github.com/OpenZeppelin/openzeppelin-test-helpers#readme)! We will be migrating it to our [official docs site](https://docs.openzeppelin.com) soon.

---

<div class="post-metadata">

**Author:** ![ylv-io](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.openzeppelin.com/ylv-io/32/331_2.png) [@ylv-io](https://forum.openzeppelin.com/u/ylv-io)\
**Post date:** [October 23, 2019, 1:08pm UTC](https://forum.openzeppelin.com/t/openzeppelin-test-helpers-0-5/1600/2 "2019-10-23T13:08:15Z")

</div>

Amazing work! Dying to use. Would be cool if we could run smart contracts on any test framework like `jest`!😍

---

<div class="post-metadata">

**Author:** ![abcoathup](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.openzeppelin.com/abcoathup/32/415_2.png) [@abcoathup](https://forum.openzeppelin.com/u/abcoathup)\
**Post date:** [October 24, 2019, 5:33am UTC](https://forum.openzeppelin.com/t/openzeppelin-test-helpers-0-5/1600/3 "2019-10-24T05:33:38Z")

</div>

I ❤ the Test Helpers. (I am biased 😄).

I upgraded my tests for [https://github.com/abcoathup/Simple777Token](https://github.com/abcoathup/Simple777Token) and got the following error which had me stumped. Similar tests worked on [https://github.com/OpenZeppelin/openzeppelin-contracts](https://github.com/OpenZeppelin/openzeppelin-contracts).

```auto
TypeError: this.erc1820.setInterfaceImplementer is not a function

```

I had forgotten that migrations were run as part of `truffle test` (even though in my tests I create new contract instances in `beforeEach`).

As per [how to upgrade from 0.4](https://github.com/OpenZeppelin/openzeppelin-test-helpers/blob/master/CHANGELOG.md#how-to-upgrade-from-04) I needed to change in my migrations (`2_deploy.js`)

```auto
require('@openzeppelin/test-helpers/configure')({ web3 });

```

to

```auto
require('@openzeppelin/test-helpers/configure')({ provider: web3.currentProvider, environment: 'truffle' });

```

---

<div class="post-metadata">

**Author:** ![tinchoabbate](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.openzeppelin.com/tinchoabbate/32/57_2.png) [@tinchoabbate](https://forum.openzeppelin.com/u/tinchoabbate)\
**Post date:** [October 24, 2019, 6:17pm UTC](https://forum.openzeppelin.com/t/openzeppelin-test-helpers-0-5/1600/4 "2019-10-24T18:17:12Z")

</div>

wohoooo! Great work @frangio @nventuro

---

<div class="post-metadata">

**Author:** ![abcoathup](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.openzeppelin.com/abcoathup/32/415_2.png) [@abcoathup](https://forum.openzeppelin.com/u/abcoathup)\
**Post date:** [December 16, 2019, 2:09am UTC](https://forum.openzeppelin.com/t/openzeppelin-test-helpers-0-5/1600/5 "2019-12-16T02:09:36Z")

</div>

A post was split to a new topic: [Has anyone used the OpenZeppelin Test Helpers with OZ SDK?](https://forum.openzeppelin.com/t/has-anyone-used-the-openzeppelin-test-helpers-with-oz-sdk/1940)
