Introduction to Unit Testing

Welcome to the forum discussion for this section. Here you can ask questions or post feedback.

1 Like

Hey guys,

I’m experiencing a problem as I try to run the first unit test - file compilation is fine though. I get the following error:

Any recommendations are welcome! Thanks!

10 Likes

Problem solved. Had to delete some lines of code in runner.js file - one of the files in truffle documentation.

Read this blog post for more info: https://github.com/mochajs/mocha/issues/4009

7 Likes

Awesome! I’m glad you solved it :slight_smile: Let me know if you have more issues.

1 Like

Hi. Can you please be more specific on how to solve this issue? I tried the link you attached, but I can`t find the solution. :thinking:

Thanx.
Ivo

2 Likes

Hey,

You have to find runner.js file (mocha library file) and delete 3 lines of code. The code is either at the given lines, or further on at line 900 smth.

:

.

Hope that helps!

13 Likes

Hi @ivga80,

I had the same error. “TypeError [ERR_INVALID_REPL_INPUT]: Listeners for uncaughtException…”
If the changes in the runner.js file does not help you to run mocha test, like in my case. You can also consider to downgrade Node if you already have the new Node version 12.
It looks like that there is still a problem with the current Node version 12.14 and the mocha/truffle setup. It helped me to uninstall the current Node version and reinstall Node version 10.18. https://nodejs.org/download/release/v10.18.0/
This works fine for me.
image

Hope you can get it to run in one or the other way. :slight_smile:

5 Likes

Hi @Paultier Thank you very much!
I just fixed the problem by downloading the msi file in the link you provided!

3 Likes

I can confirm node v12.14.1 still produces the above error and as Paultier pointed out v10.18.0 works dandy. These kind of node version related errors are common. I finally broke down and installed Node Version Manager (NVM). This allows you to install multiple versions of node and switch between them with a command line call:

NVM Windows:

NVM (Mac/Linux):

EDIT: note you’ll need to reinstall truffle after using NVM as the global utilities are linked to specific versions of node after doing this.

4 Likes

Hi @ivga80,
could you solve your problem? I just had similar troubles.

I have node.js 12 installed.

When calling truffle test i got the following error:

TypeError [ERR_INVALID_REPL_INPUT]: Listeners for `uncaughtException` cannot be used in the REPL

For me the solution was:

npm un -g truffle
npm i -g truffle@nodeLTS

see: https://github.com/trufflesuite/truffle/issues/2070#issuecomment-573198692

5 Likes

worked for me too! thanks guys

2 Likes

such a blessing to get the problem, struggle a bit, look up at the forum and thats the first thing to see that is beeing solved :smiley: Thanks guys, its now working for me too

4 Likes

@filip

Hi Filip, i’m getting the same error over and over again at my first test. Could you help me out? See code i run below;

truffle(ganache)> test
Using network ‘ganache’.

Compiling your contracts…

Everything is up to date, there is nothing to compile.

⠋ Saving migration to chain.Success

TypeError [ERR_INVALID_REPL_INPUT]: Listeners for uncaughtException cannot be used in the REPL
at process. (repl.js:227:15)
at process.emit (events.js:215:7)
at process.emit (C:\Users\Daniel\AppData\Roaming\npm\node_modules\truffle\build\webpack:~\source-map-support\source-map-support.js:465:1)
at processEmit [as emit] (C:\Users\Daniel\AppData\Roaming\npm\node_modules\truffle\build\webpack:~\signal-exit\index.js:155:1)
at _addListener (events.js:236:14)
at process.addListener (events.js:284:10)
at Runner.run (C:\Users\Daniel\AppData\Roaming\npm\node_modules\truffle\node_modules\mocha\lib\runner.js:868:11)
at Mocha.run (C:\Users\Daniel\AppData\Roaming\npm\node_modules\truffle\node_modules\mocha\lib\mocha.js:612:17)
at C:\Users\Daniel\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\core\lib\test.js:128:1
at new Promise ()
at Object.run (C:\Users\Daniel\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\core\lib\test.js:127:1)
at processTicksAndRejections (internal/process/task_queues.js:93:5)

I’m getting this when i want to install it;

C:\Users\Daniel>npm un -g truffle
removed 27 packages in 0.453s

C:\Users\Daniel>npm i -g truffle@nodeLTS
npm ERR! code ENOENT
npm ERR! syscall spawn git
npm ERR! path git
npm ERR! errno ENOENT
npm ERR! enoent Error while executing:
npm ERR! enoent undefined ls-remote -h -t https://github.com/trufflesuite/mocha.git
npm ERR! enoent
npm ERR! enoent
npm ERR! enoent spawn git ENOENT
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent

npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Daniel\AppData\Roaming\npm-cache_logs\2020-02-24T22_04_38_693Z-debug.log

Hi @Dskeur91

You need to make sure you have git installed and properly in your PATH

https://git-scm.com/book/en/v2/Getting-Started-Installing-Git

1 Like

Thanks for your help! Getting this again:

truffle(ganache)> test
Using network ‘ganache’.

Compiling your contracts…

Everything is up to date, there is nothing to compile.

⠋ Saving migration to chain.Success

TypeError [ERR_INVALID_REPL_INPUT]: Listeners for uncaughtException cannot be used in the REPL
at process. (repl.js:227:15)
at process.emit (events.js:215:7)
at process.emit (C:\Users\Daniel\AppData\Roaming\npm\node_modules\truffle\build\webpack:~\source-map-support\source-map-support.js:465:1)
at processEmit [as emit] (C:\Users\Daniel\AppData\Roaming\npm\node_modules\truffle\build\webpack:~\signal-exit\index.js:155:1)
at _addListener (events.js:236:14)
at process.addListener (events.js:284:10)
at Runner.run (C:\Users\Daniel\AppData\Roaming\npm\node_modules\truffle\node_modules\mocha\lib\runner.js:868:11)
at Mocha.run (C:\Users\Daniel\AppData\Roaming\npm\node_modules\truffle\node_modules\mocha\lib\mocha.js:612:17)
at C:\Users\Daniel\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\core\lib\test.js:128:1
at new Promise ()
at Object.run (C:\Users\Daniel\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\core\lib\test.js:127:1)
at processTicksAndRejections (internal/process/task_queues.js:93:5)

@gabba see message above

Hi Dskeur91.
Have you edited the Runner.js as described earlier in this post? If you edit the runner.js and restart your computer the REPL error when testing should be gone.
Ivo

3 Likes

@ivga80 just edited the Runner.js, deleted the 3 lines. Now getting the same REPL error again. Other solutions?

Did you restart he computer?