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 🙏

© 2024 – Pkg Stats / Ryan Hefner

@dexon-foundation/remix-tests

v0.0.30

Published

Tests for the Ethereum tool suite Remix

Downloads

39

Readme

Remix-Tests

Tests for the Ethereum tool suite Remix

Installation

npm -g install remix-tests

Test structure

Example test file:

pragma solidity ^0.4.7;
import "remix_tests.sol"; // injected by remix-tests
import "./simple_storage.sol";

contract MyTest {
  SimpleStorage foo;
  uint i = 0;

  function beforeAll() {
    foo = new SimpleStorage();
  }

  function beforeEach() {
    if (i == 1) {
      foo.set(200);
    }
    i += 1;
  }

  function initialValueShouldBe100() public {
    Assert.equal(foo.get(), 100, "initial value is not correct");
  }

  function initialValueShouldBe200() public constant returns {
    return Assert.equal(foo.get(), 200, "initial value is not correct");
  }

}

See also: example Su Squares contract and [https://travis-ci.org/su-squares/ethereum-contract/builds/446186067](Travis build) that uses remix-tests for continuous integration testing.

Available special functions:

  • beforeEach() - runs before each test
  • beforeAll() - runs before all tests

Assert library

| Available functions | Supported types | | ------------- | ------------- | | Assert.ok() | bool | | Assert.equal() | uint, int, bool, address, bytes32, string | | Assert.notEqual() | uint, int, bool, address, bytes32, string | | Assert.greaterThan() | uint, int | | Assert.lesserThan() | uint, int |

Command Line

Remix-Tests will assume the tests will files whose name end with "_test.sol". e.g simple_storage_test.sol

Usage:

  • A directory with tests files remix-tests examples/
  • A test file remix-tests examples/simple_storage_test.sol

Library

Importing the library:

const RemixTests = require('@dexon-foundation/remix-tests');

Running a single test object:

remixTests.runTest(contractName, contractObj, testCallback, resultsCallback)

params: testName - string name of the test testObj - web3.js 1.0 contract instance of the test testCallback(object) - called each time there is a test event. 3 possible type of objects:

  • { type: 'contract', value: '<TestName>', filename: '<test_filename.sol>' }
  • { type: 'testPass', value: '<name of testing function>', time: <time taken>, context: '<TestName>'}
  • { type: 'testFailure', value: '<name of testing function>', time: <time taken>, context: '<TestName>', errMsg: '<message in the Assert>' }

resultsCallback(object)

  • passingNum - number of passing tests
  • failureNum - number of failing tests
  • timePassed - time it took for all the tests to run (in seconds)

Running a set of tests given the sourcecode:

remixTests.runTestSources(contractSources, testCallback, resultCallback, finalCallback, importFileCb);

params: contractSources - object -> filename => { content: source } testCallback(object) - called each time there is a test event. 3 possible type of objects:

  • { type: 'contract', value: '<TestName>', filename: '<test_filename.sol>' }
  • { type: 'testPass', value: '<name of testing function>', time: <time taken>, context: '<TestName>'}
  • { type: 'testFailure', value: '<name of testing function>', time: <time taken>, context: '<TestName>', errMsg: '<message in the Assert>' }

resultCallback(err, object)

  • passingNum - number of passing tests
  • failureNum - number of failing tests
  • timePassed - time it took for all the tests to run (in seconds)

finalCallback(err) - called when all tests finish running. importCb(url, cb)

Contribute

Please feel free! Open an issue or a pull request. Please conform to standard for code styles, and make sure that you add any relevant tests.

License

MIT © 2018 Remix Team