Search code examples
mocha.jsmochawesome

Can't view test output in file and console output together using mocha and mochawesome


I'm using latest node, mocha to run UI tests and mochaawesome for reporting. I would like to get output of mocha test command in console output and text file both.

Test works fine but user can't see console output promptly if output is redirected and if i don't redirect then report text file is not created. mochawesome report doesn't create text file, default behavior is html file. I need both kind of output, any alternative using mochawesome report or any other solution to have this facility?

config:

npm install mocha mochaawesome

report.txt:

mocha create-event.js -f Smoke > report.txt

enter image description here

enter image description here

console output:

mocha create-event.js -f Smoke

enter image description here


Solution

  • Please use tee command to view console output and redirecting output to file together. Please use powershell especially for windows (doesn't work via normal cmd) and bash/sh for linux.

    mocha create-event.js -f Smoke | tee report.txt