I'm using running hardhat tests. When I add console logs to the test cases, nothing actually gets outputted to console. Why's that?
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.