用mocha.jstestingCLI应用程序
我想testingCLI应用程序,并希望在testing运行时接收用户input,因为mocha.js具有200ms限制testing失败。 所以我想知道如何在脚本获得input时暂停testing,并在获得input后恢复。
你可以像这样增加testing超时
describe('increased timeout', function(){ it('should not timeout', function(done){ this.timeout(2000); setTimout(done, 1500); }); });
但我不build议你这样做。 您可以使用nexpect或stream – 期望模拟用户input。 这样你可以写很多自动化testing。
stream-expect的示例用法
你应该做你的testingasynchronous。 添加done
参数并在完成后调用它。 http://visionmedia.github.io/mocha/ – 检查示例的asynchronous代码部分。