Tag: tdd

摩卡是如何做没有幻影的DOMtesting

我似乎可以用Mocha做DOMtesting。 我以为我需要像PhantomJS这样的无头浏览器。 然后用Mocha来使用PhantomJS有什么好处? (我在使用Yeoman。)

Sinon – 何时使用间谍/嘲笑/存根或只是简单的断言?

我试图理解Sinon在一个节点项目中是如何正确使用的。 我已经通过例子和文档,但我还没有得到它。 我已经build立了一个具有以下结构的目录来尝试通过各种Sinonfunction来了解它们的适用位置 |–lib |–index.js |–test |–test.js index.js是 var myFuncs = {}; myFuncs.func1 = function () { myFuncs.func2(); return 200; }; myFuncs.func2 = function(data) { }; module.exports = myFuncs; test.js从以下开始 var assert = require('assert'); var sinon = require('sinon'); var myFuncs = require('../lib/index.js'); var spyFunc1 = sinon.spy(myFuncs.func1); var spyFunc2 = sinon.spy(myFuncs.func2); 诚然,这是非常人为的,但现在我想testing任何调用func1导致func2被调用,所以我会用 describe('Function 2', function(){ it('should […]

如何组织我的规格文件?

我正在使用摩卡来testing我的node.js应用程序。 我注意到,随着时间的推移,我的规格文件变得越来越大。 是否有任何模式来组织testing文件(例如每个testing一个规格文件)? 还是有其他框架摩卡顶部帮助我构buildtesting? 或者你是否因为这个原因而提供其他testing框架?

Node.js:我应该使用Vows还是Expresso或者NodeUnit或者Zombie.js或者All?

开发node.js应用程序时应该使用什么?

在suback / tape中使用“plan”和“end”的目的是什么?

substack的磁带testing模块允许您使用plan方法提前指定断言的数量,然后它会自动为您调用end 。 为什么不把testing结束呢? 使用plan和end什么区别?

testing未导出模块的节点方法

这是一个正常的节点模块。 有些function不是全部导出,但需要testing var foo1 = function () { console.log("Foo1"); } var foo2 = function () { console.log("Foo2"); } var foo3 = function () { console.log("Foo3"); } module.exports = { foo1: foo1, foo2: foo2 } 任何人都知道如何testingfoo3? 通常我用节点沙箱模块testing模块。 但是只能模拟给模块的东西,但是我不能改变方法的范围。 带有节点沙箱模块的testing模块示例: var SandboxedModule = require('sandboxed-module'); var user = SandboxedModule.require('./user', { requires: {'mysql': {fake: 'mysql module'}}, globals: {myGlobal: 'variable'}, […]

nodejs,当文件改变时自动运行testing

有没有办法自动运行testing,当应用程序中的文件更改? 在铁路上有一个叫做守卫的gem。 如何在nodejs中实现相同的function?

如何在Node.js中构buildTDD?

我有我的文件夹结构如下: backend |-Process1 |-Process2 |-app |-config |-controllers |-models public |-css |-js 我应该在哪里放置我的unit testing文件夹?

在Node.js / Express应用程序中testing环境

我刚刚开始使用Node,并且一直在跟随各种教程。 我创build了一个Express应用程序,并设置了Mongoose和Jasmine。 如何configuration我的规格,以便我可以: 创build模型,在每个规范之后自动清理它们 使用不同的数据库来创buildtesting对象(比如myapp_test) 以尽可能干的方式做到这一点,即不要为每个描述块的拆卸创build一个之前/之后的块 ?

ERROR :

我使用业力和茉莉花进行一些unit testing。 我想要一个html输出,而不是检查控制台/terminal,并发现这个: https : //www.npmjs.org/package/karma-htmlfile-reporter这是完美的我的要求。 当我运行它时,我得到一个错误: `ERROR [karma]: [TypeError: Cannot call method 'push' of undefined] TypeError: Cannot call method 'push' of undefined at onBrowserStart (/usr/local/lib/node_modules/karma/lib/reporters/base.js:14:20) at null.<anonymous> (/usr/local/lib/node_modules/karma/lib/events.js:15:22) at EventEmitter.emit (events.js:117:20) at onStart (/usr/local/lib/node_modules/karma/lib/browser.js:128:13) at Socket.<anonymous> (/usr/local/lib/node_modules/karma/lib/events.js:15:22) at Socket.EventEmitter.emit [as $emit] (events.js:117:20) at SocketNamespace.handlePacket (/usr/local/lib/node_modules/karma/node_modules/socket.io/lib/namespace.js:335:22) at Manager.onClientMessage (/usr/local/lib/node_modules/karma/node_modules/socket.io/lib/manager.js:488:38) at WebSocket.Transport.onMessage (/usr/local/lib/node_modules/karma/node_modules/socket.io/lib/transport.js:387:20) at Parser.<anonymous> (/usr/local/lib/node_modules/karma/node_modules/socket.io/lib/transports/websocket/hybi-16.js:39:10) […]