I'm using running hardhat tests. When I add console logs to the test cases, nothing actually gets outputted to console. Why's that?

  • 1
    Hi! console.log should be outputting text to the console the tests are running in. Could you edit the question to post the output of your tests, and maybe a code block from the tests with a console.log in it?
    – Linum Labs
    Apr 25, 2021 at 6:46

2 Answers 2


When people report this, 99% the time it means that they are running npx hardhat node in one terminal and npx hardhat test --network localhost in the other, and they expect to see the logs in the second terminal, but it's actually shown in the first one. This happens because the output of console.log is shown in the process where the Hardhat Network is running.

This doesn't happen when you run npx hardhat test (without a --network param), because that uses the in-process hardhat network. That is, the test task and the network run in the same process, and therefore the output is shown in the same terminal.

I have an explainer about this that goes more in-depth about what happens in these different scenarios, and others, under the hood.


In case anyone else happens to come across this, I happened to run across this because I was using ganache for my network instead of hardhat node. Switching my localhost network to hardhat node instead of using ganache-cli revealed the console.logs

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.