can I turn off Mocha's watching watching watch

2019-08-31 04:43发布

问题:

I like Mocha so far but I'm not fond of this when I'm doing continous testing:

   watching    
   watching    
   watching    
   watching    
   watching    
   watching
   [repeat many times]

If I haven't run a test for a while and I want to see the output of the last test it's scroll scroll scroll. It quickly swamps my console buffer. Can I change this behavior without changing mocha's source code?

EDIT: this has been fixed and pulled into master.

回答1:

Per https://github.com/visionmedia/mocha/blob/master/bin/_mocha#L287-303, the mocha command gives the test runner a callback that prints a series of strings to the console, and there aren't any cmd line flags that would affect that behavior.

The root of the problem seems that the animation's control characters might be failing in your terminal, though, as it's supposed to do a pretty-looking spinning symbol at the beginning, and then do a character return (not line feed) to rewrite the line after every printout.

If you're really dead-set on changing that behavior without modifying mocha's source, you could make a copy the bin/_mocha file, and just replace the play() function with one that suits your needs. Make sure to fix up all the relative paths.



标签: mocha