Skip to Main Content
Truffle Quick Start Guide
book

Truffle Quick Start Guide

by Nikhil Bhaskar
June 2018
Beginner to intermediate content levelBeginner to intermediate
170 pages
3h 46m
English
Packt Publishing
Content preview from Truffle Quick Start Guide

Writing unit tests with JavaScript

Inside the contracts folder, create a .js file that will house our tests; call it test-task-master.js.

Again, stick to the same practice of prepending our contract name with the word test so that it's clear that it's a test file.  I prefer JavaScript file names to be snake case, but if you prefer camelCase file names, that is fine too.

Inside the test-task-master.js file, let's import our contract so we can make use of it in our tests:

const TaskMaster = artifacts.require("../contracts/TaskMaster.sol");

artifacts is automatically injected by Truffle inside our test environment, and it allows us to instantiate our contract easily for the purpose of testing.

Next, let's define a function where we will place ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Cryptosocial

Cryptosocial

Allen Taylor
Step into the Metaverse

Step into the Metaverse

Mark van Rijmenam

Publisher Resources

ISBN: 9781789132540Supplemental Content