Mocha newbie... Advice on idiomatic ways to keep extra logs/state of failed tests

25 views
Skip to first unread message

Oliver Mattos

unread,
Jun 1, 2020, 3:47:00 PM6/1/20
to Mocha
Say some of my tests have side effects/logs/state.   I don't care about the state if the tests pass, but if they fail I want to be able to see it.


Is there some way to:

 * Get some identifier for a specific test run, preferably human readable, so it could be used in a log filename, database entry, or whatever other state the thing being tested might leave behind?
 * Run cleanup code dependant on if the test passed?
 * Output a string to the console on a failure to assist whoever is fixing the test?  For example:

  > mocha

   screenshots are correct
    test page
      1) /view1
          Screenshots differ from expected!  See /tmp/test5512/screenshots_are_correct_test_page_view1/expected.png and actual.png.  For help fixing this issue, see http://wiki/ScreenshotMismatch


  0 passing (2s)
  1 failing

 
Reply all
Reply to author
Forward
0 new messages