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 🙏

© 2026 – Pkg Stats / Ryan Hefner

truffle-test-helpers

v0.2.2

Published

Zeppelin-solidity inspired test helpers for truffle framework

Downloads

96

Readme

Truffle test helpers

Inspired by Zeppelin solidity this package provides a number of test helpers to used in truffle javascript tests.

Installation

npm install truffle-test-helpers

Usage

import {
  advanceBlock,
  advanceToBlock,
  increaseTime,
  increaseTimeTo,
  duration,
  revert,
  latestTime
} from 'truffle-test-helpers';
  • duration useful to create durations for contracts that require time to be provided as one of their function arguments. Usage:
const time1 = duration.seconds(1);
const time2 = duration.minutes(1);
const time3 = duration.hours(1);
const time4 = duration.days(1);
const time5 = duration.weeks(1);
const time6 = duration.years(1); 
  • latestTime gets the current time of blockchain. Async since v 0.1.0

  • advanceBlock is mostly used in a generic before each contract:

contract('MyContract', function() {
  before(async function() {
    // Advance to the next block to correctly read time in the solidity "now" function interpreted by ganache
    await advanceBlock();
  });
});
  • increaseTimeTo advances to specified block in time. Example:
contract('MyContract', function() {
 before(async function() {
   // Advance to the next block to correctly read time in the solidity "now" function interpreted by ganache
   await advanceBlock();
 });
 
 beforeEach(function() {
   this.startTime = latestTime();
   this.endTime = this.startTime + duration.minutes(2);
 });
 
 it('some test', async function() {
   await advanceToBlock(this.endTime);
 });
});
  • increaseTime advances on some duration. Used under the hood by increaseTimeTo.

  • advanceBlock step to next block by mining.

  • advanceToBlock advances to specified block in time. Uses advanceBlock under the hood.

Changelog

v 0.2.0:

  • Added compatibility for [email protected] for increaseTime and advanceBlock methods. They would now use sendPayload instead of send on web3 current provider if it exists as in recent web3 versions api of send has been changed to accept just json-rpc method instead of payload object.

v 0.1.1:

  • Added setWeb3 interface which can be used like so:
import { setWeb3 } from 'truffle-test-helpers';
import Web3 from 'web3';

const myWeb3Instance = new Web3(
  new Web3.providers.HttpProvider('http://localhost:8545')
);

setWeb3(myWeb3Instance);

This code would enable injecting web3 into this library and allow to use it outside truffle test context i.e. in development with ganache. By default we still check the presence of web3 in global context and use it as default web3 instance to keep compatibility with truffle standard behaviour.

v 0.1.0:

  • Updated to support both truffle v4 and v5 beta. Truffle v5 is based on web3 1.0 which has methods incompatible with this library. This lib should support both legacy web3 0.22 and web3 1.0

  • const time = await latestTime() is now async which is a breaking change