Introduction to Unit Testing

Yes i restarted the pc. Just installed Node version 10.18.0 and now it all runs fine.
Thanks for the help!

1 Like

@Karolis_Abramavicius, thank you very much!!! I tried to run the test since yesterday and it was not working.
But your solution is perfect.
Works even with Node.js v13.9.0
Thank you!

1 Like

Here is my file helloworldtest.js ::

I execute the test command (Ganache) and the following is displayed (why?) ::

Hi.
Sure, You can find the answer to this in this post many many times.
I think this topic might have all the possible solutions for this issue posted.
So good luck, my friend! :hugs:

2 Likes

Yes - I commented out the following line (line #868) in the MOCHA library file runner.js ::

//process.on(‘uncaughtException’, uncaught);

Thanks …

1 Like

I cant get passed this error; please help. I get in response to running truffle test:

1 Like

Hi, I cant get past this error. I tried setting network ID to 5777 in the truffle config file but that didint work. Also I realize the Ownable contract failed to deploy after running migrate --reset. Please help

my test file contents below:
const People = artifacts.require(“People”);
const truffleAssert =require(“truffle-assertions”);

contract(“People”, async function() {
it(“shouldn’t create a person of age ove 150”, async function(){
let instance = await People.deployed();
await truffleAssert.fails(instance.createPerson(“Bob”, 100, 6, {value: web3.utils.toWei(“1”, “ether”)}));
})
})

1 Like

Hi Guys,

PLEASE HELP! Haven’t been able to test yet as I keep getting this error in CMD. Moving onto the project now so I was hoping to resolve this issue.

1 Like

Hi.
You can look at the link posted below.

You will find multiple solutions to that issue. :wink::+1:
Good luck.

Ivo

1 Like

Thanks for the quick reply!

1 Like

anyone can help with my post above?

guys how do I get rid of this error. I’m stuck and cant proceed with testing

1 Like

if anyone comes across this problem I was able to resolve it by updating the truffle-config.js as below: be sure to match the port to rpc server on your ganache

1 Like

Hi, @tical.

Thanks for sharing your solution the this issue. :+1:

Ivo

this worked for me, Thanks @mawize

1 Like

Thank you very much, this worked for me…I guess…the more I know, the more I understand that I have no WHATSOEVER IDEA of wtf am I touching in the fucking computer…sorry for the french.

2 Likes

@filip When you write a complex contract. Is it better to write the tests as you go? Or would you write all the tests after you have finished writing the contract?
Thanks :smiley:

1 Like

Hi.
When I learned python in school, I learned that we should write our tests as we go.

You write the function - then you write the unit test to test it.

Good luck.

Ivo

Had a feeling it was that way. Thanks for confirming :+1:t2: :grinning:

1 Like

For everyone having poblems with: ERR_INVALID_REPL_INPUT

  1. Uninstall/Install truffle
npm un -g truffle
npm i -g truffle@nodeLTS
  1. Remove build directory via console/or remove manually
rm build
  1. Migrate again to re-create build directory
truffle console
migrate
10 Likes