NodeJS teams - anyone got input/output tests working with prompt or prompt-sync

Have anyone managed to get prompt or prompt-sync to work with input/output tests? In tests, the function either time out or returns junk values, causing the test case to failed.

Here’s the code I am using; it’s as simple as it can be:

firstNumber = prompt("")
secondNumber = prompt("")
console.log(firstNumber * secondNumber)

I’m late to this party but hoping I can help. The output to the console includes colour and font information - that’s why it looks like junk. @LenaAtReplit gave me a work-around to clean the output.

  1. Add a .replit file to the student’s work. Literally a file called “.replit”
  2. Put this in the file: run = "node index.js | cat"

That tells replit to pipe the output from node through the concatenate tool which does a bunch of stuff but ultimately cleans the text of any extra ‘stuff’.

Hoping this fixes your issue.

1 Like