I have written javascript tests that run fine with truffle test ./test/Token.js

However, when I have the following:

var UTO = artifacts.require("./uto.sol");

module.exports = function(deployer) {

Then I get the following error:

UTO contract constructor expected 6 arguments, received 0

The error itself is fine, it needs arguments. However, I am wondering why this is happening, because my test script sets these arguments:

before(async function() {

      // deploy contract with parameters for testing
      contract = await C.new(company, _token_eth, _name, _symbol, _decimals, _percentToHold);

I can comment out the deployer and everything works fine.. so why is the truffle command triggering the deploy outside of the test script?



Migrations scripts are always run before each unit test it doesn't matter if you already deploy the contracts before each test.

One option is to have separate 'network' in your truffle.js and decide what to do in the script using the network parameter.

var UTO = artifacts.require("./uto.sol");

module.exports = function(deployer, network, accounts) {
  if (network === 'development') {
    deployer.deploy(UTO, "dummy", 1000, ...); // <-- dummy params
  } else if (network === 'unittest') {
    // Do not deploy contracts, each test should deploy them by itself

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.