使用--watch时可以关闭Mocha的观看观看行为吗? [英] can I turn off Mocha's watching watching watching behavior when using --watch?

查看:71
本文介绍了使用--watch时可以关闭Mocha的观看观看行为吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

到目前为止,我一直喜欢Mocha,但是在进行连续测试时我并不喜欢它:

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]

如果我有一段时间没有进行测试了,并且想查看上一个测试的输出,则为滚动滚动滚动.它很快淹没了我的控制台缓冲区.我可以在不更改Mocha源代码的情况下更改此行为吗?

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?

此问题已解决,已被拉入母版.

this has been fixed and pulled into master.

推荐答案

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.

如果您真的对改变行为无动于衷,而无需修改mocha的源代码,则可以复制bin/_mocha文件,而只需将play()函数替换为适合您需求的函数即可.确保修正所有相对路径.

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.

这篇关于使用--watch时可以关闭Mocha的观看观看行为吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆