Beautifying Your Smart Contract Tests With JavaScript

Photo by Kelly Sikkema
npm install --only=dev --save chai
npm install --only=dev --save chai-as-promised
npm install --only=dev --save chai-bignumber
const BigNumber = web3.BigNumberconst should = require('chai')
.use(require('chai-as-promised'))
.use(require('chai-bignumber')(BigNumber))
.should()
const EVMThrow = 'invalid opcode'module.exports = { should, EVMThrow }
const FundRaise = artifacts.require('./FundRaise.sol')
const { should } = require('./helpers')
contract('FundRaise', function ([owner, donor]) {... it('has an owner', async function () {
const fundRaiseOwner = await fundRaise.owner()
fundRaiseOwner.should.be.equal(owner)
})
...
const { should } = require('./helpers')
it('has an owner', async function () {
const fundRaiseOwner = await fundRaise.owner()
fundRaiseOwner.should.be.equal(owner)
})

--

--

A curious mind, joie de vivre practitioner

Love podcasts or audiobooks? Learn on the go with our new app.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Gustavo (Gus) Guimaraes

Gustavo (Gus) Guimaraes

A curious mind, joie de vivre practitioner