0

I just started seeing solidity and truffle. I created a new project with the truffle init command and try this test code to verify the deployment of a contract.

const GreeterContract = artifacts.require("Greeter");

contract("Greeter", () => {       
  it("has been deployed successfully", async () => {
    const greeter = await GreeterContract.deployed();
    assert(greeter, "contract was not deployed");
  });
});

But the truffle test command does nothing and the terminal stands still as if waiting for something. Instead truffle compile command works.

The anomaly occurs on both linux and windows. I also tried other test codes from the net or to write whatever, always the same result. Is it a bug?

Truffle version installed at the moment is the latest, 5.1.44

EDIT This is the folder structure created by truffle init.The Greeter contract is missing to fail the test. However, I also tried to add it and nothing changes.

5
  • Put your Greeter.test.js file to the test folder. NOTE: Your example is missing a trailing curly brace.
    – MentatX
    Sep 17 '20 at 10:24
  • The file is located in the test folder of the project (I updated the post with the structure that the init command created for me). The missing parenthesis was my distraction in the post.
    – Hatta
    Sep 17 '20 at 14:42
  • If you try with an empty test folder does it work?
    – Ismael
    Sep 17 '20 at 16:54
  • Did you try file name like greeter.test.js?
    – MentatX
    Sep 18 '20 at 8:36
  • I get the same result both with empty test folder and renaming the file greeter.test.js. I'm starting to think it's a problem on Ubuntu, Windows 10 and also with WSL2 because, not knowing what to do anymore, I try it on a PC with Fedora 32 and it works. It is really weird. It is as if it does not understand the test command because if I write something wrong, like tesst I have the same problem, the terminal is waiting
    – Hatta
    Sep 18 '20 at 17:21
0

After quite some time, I realized that the problem was the nodejs version. Truffle is incompatible with nodejs 14, I downgraded to nodejs 12 and it works on all operating systems.

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.