1

I am following an online tutorial, doing almost exactly like the instructor.

I have the following error every time I try to run 'truffle test' enter image description here

my truffle-config file:


module.exports = {
  // See <http://truffleframework.com/docs/advanced/configuration>
  // to customize your Truffle configuration!
  contracts_build_directory: path.join(__dirname, "client/src/contracts"),
  networks: {
    development: {
      host: "127.0.0.1",
      port: 7545,
      network_id: "*", // match any network
      websockets: true
    }
  },
  contracts_directory: "./client/src/contracts/",
  contracts_build_directory: "./client/src/abis/"
};

I tried migrate with --reset.

3

Just found out that my test code had wrong brackets placement: it was

contract("Marketplace"), accounts => {
  //all tests go inside here

  let marketplace;
  before(async () => {
    marketplace = await Marketplace.deployed();
  });

  //describe comes from Mocha framework
  describe("deployment", async () => {
    it("deploys successfully", async () => {
      const address = await marketplace.address;
      assert.notEqual(address, 0x0);
      assert.notEqual(address, "");
      assert.notEqual(address, null);
      assert.notEqual(address, undefined);
    });

it should be

contract("Marketplace", accounts => {
  //all tests go inside here

  let marketplace;
  before(async () => {
    marketplace = await Marketplace.deployed(); //this will get the deployed copy of the contract
  });

  //describe comes from Mocha framework
  describe("deployment", async () => {
    it("deploys successfully", async () => {
      const address = await marketplace.address;
      assert.notEqual(address, 0x0);
      assert.notEqual(address, "");
      assert.notEqual(address, null);
      assert.notEqual(address, undefined);
    });

notice the bracket after"marketplace" changes everything, the compiler won't complain since in the end of the file I had an extra bracket.

| improve this answer | |
  • The snippets of code are identical. Are you sure you pasted the incorrect code? Both are missing several closing brackets });. – Ismael Mar 19 at 14:31
  • 1
    The first one has a bracket after contract("Marketplace" – elGreato Mar 19 at 14:47
  • cool. it works for me – True Eye Sep 25 at 12:19

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.