testingchild_process.exec导致flakeytesting…为什么?
Flakeytesting
我正在编写一个黄瓜世界模块的unit testing。 该模块似乎正在工作,它作为一个child_process启动快速应用程序,并通过杀死subprocess停止应用程序。
问题是这个模块的摩卡testing是flakey,它每隔一段时间都会通过,而且每隔一段时间都会失败。 我似乎无法弄清楚为什么。
我怎样才能为每一次通过的世界文件写一个testing?
黄瓜世界文件
var zombie = require('zombie'); var cp = require('child_process'); var World = function World(callback) { this.browser = new zombie(); callback(this); }; World.prototype.start = function (callback) { console.log("Starting Express App"); this.app = cp.exec('node ./bin/www'); console.log("Express App Started"); if (callback) callback(); }; World.prototype.stop = function (callback) { this.app.on('close', function () { console.log("Stopped Express App"); if (callback) callback(); }); this.app.kill('SIGHUP'); }; World.prototype.visit = function (url, callback) { this.browser.visit(url, callback); }; module.exports = World;
世界模块的Flakeytesting
var assert = require('assert'), http = require('http'), World = require('../features/support/world'); describe("Cucumber World", function () { var world; beforeEach(function(done) { world = new World(function (world) { world.start(done); }); }); it('should start the web app', function (done) { http.get("http://localhost:3000", function (res) { assert.ok(res, "A successful response was made"); assert.equal(res.statusCode, 200, "200 success status received"); world.stop(done); }); }); });
- 节点JS摩卡testing用例没有运行
- 如何在node.js + Express.js + mongodb应用程序上asynchronous启动摩卡testing
- 在使用承诺调用方法的方法的摩卡testing环境中无法调用sinon间谍
- 如何撰写asynchronous瀑布的摩卡testing
- 在JavaScript中整合了代码覆盖率报告
- 在运行摩卡unit testing时,如何避免在NodeJScallback式API中调用两次Q promise catch块?
- 如何在nodejs中模拟请求和响应来testing中间件/控制器?
- 我怎样才能得到摩卡独立运行我的testing?
- 使用SailsJS / Node,Mocha,Supertest进行authentication的会话存储