Introduction to Unit Testing

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?

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