Tag: 茉莉花

Sails.js:哪些模块用于unit testing?

我是sails.js和node.js的新手 我试图弄清楚设置unit testing的最佳方法是什么。 例如,在Kraken.js中,生成时已经有一个testing/文件夹设置,它看起来像使用摩卡。 但是,没有像这样预先包装sails.js。 我想知道什么是最好的方式来构build它,我需要添加依赖关系(我应该使用业力,茉莉花,摩卡,量angular器,…),以及如何自动化一切(即运行所有testing使用“grunttesting”我想,或者我应该在每个“npm start”运行testing…?) 你如何在你的sails.js环境中设置unit testing?

testing一个Node.js函数,它的返回值可以根据执行asynchronous操作的时间而改变

我正在为node-redis模块编写一个模拟器,并使用Jasmine来testing它。 我为Redis命令的各个方面编写testing,我的意图是能够对原始Redis模块运行testing。 我的问题是: 如果我正确理解node-redis , node-redis的asynchronous函数的返回值是不同的,这取决于命令发送到Redis或排队等待稍后发送(例如,在连接完成后发送)。 但是我也想testing返回值,如果我写一个如下所示的testing: it("should update value", function () { var client = redis.createClient(); client.set("key", "1st"); var value = client.get("key", function (err, data) { expect(err).toBeNull(); expect(data).toBe("1st"); }); expect(value).toBe(true); }); 如果使用真正的Redis模块,它将不会通过,因为没有足够的时间连接到数据库。 有没有办法等待asynchronous请求被执行以继续testing代码? (对这个问题采取不同的解决方法也是受欢迎的。)

茉莉花节点导致jenkins完成后挂起

我有一些问题,让我的CI服务器打好。 我正在运行Jenkins来执行我的unit testing中使用的Jasmine-Node二进制文件 node_modules/jasmine-node/bin/jasmine-node tests/ –junitreport 从jenkins的输出控制台,我可以看到我的testing正在成功执行。 npm info ok + node_modules/jasmine-node/bin/jasmine-node tests/ –junitreport [32m.[0m[32m.[0m Finished in 0.33 seconds [32m2 tests, 9 assertions, 0 failures, 0 skipped [0m 虽然jenkins从未继续任何进一步的步骤,并无限期地挂起。 任何想法如何callbackjenkins,并告诉它继续? 我不会认为这是必要的,但显然我没有做正确的事情。 任何帮助,将不胜感激。

咕噜+手表+茉莉花一次,失败第二

这是我的Grumodule.exports =函数(grunt){ grunt.initConfig({ pkg: grunt.file.readJSON('package.json'), watch: { serve: { files: ['server.js', 'src/**/*.coffee'], tasks: ['coffee', 'develop', 'jasmine'], options: { nospawn: true } }, test: { files: ['tests/*.spec.js', 'src/**/*.coffee'], tasks: ['coffee', 'jasmine_node'], options: { nospawn: true } } }, jasmine_node: { options: { forceExit: true, match: '.', matchall: false, extensions: 'js', specNameMatcher: 'spec', jUnit: { useDotNotation: true, […]

强制npmtesting来创build新的\新的input副本

test/ ├── TestOne.js └── TestTwo.js 说, TestOne.js是: 这个testing用例从InputOne.json文件中读取, InputOne.json已有3条logging的对象添加一条logging。 describe('Add Items', function () { it('Should add items', function () { var input = require('./data/InputOne'); var obj = new Department(); var result = obj.AddDept(input); result.should.have.length(4); }); }); 说, TestTwo.js是: 这个testing用例从文件InputOne.json读取并计算元素的数量 describe('Count Items', function () { it('Should count items length', function () { var input = require('./data/InputOne'); […]

AngularJS:在业力testingmodule.exports:模块没有定义

我试图写一个外部模块来处理我的服务使用module.exports我的业力testing,但我不断收到 未捕获的ReferenceError:模块未定义 这是我的karma.conf.js文件: // Karma configuration // Generated on Fri Nov 07 2014 11:32:23 GMT-0600 (CST) module.exports = function(config) { config.set({ // base path that will be used to resolve all patterns (eg. files, exclude) basePath: '', // frameworks to use // available frameworks: https://npmjs.org/browse/keyword/karma-adapter frameworks: ['jasmine'], // list of files / patterns to load […]

在Jasmine中使用createSpy来testing模块内部的setInterval

在一个nodejs类中,我有一个called _timerEvent的内部函数,它将从setInterval中调用。 调用有两个方法,第一个方法调用的startInterval和stopInterval this._timerForInterval = setInterval(this._timerEvent, this._interval * 1000); 调用stopIntervall调用 clearInterval(this._timerForInterval); 现在我想用茉莉花testing如果this._timerEvent被调用: var spyTimerEvent = null; controller._timerEvent = jasmine.createSpy('spyTimerEvent'); jasmine.clock().install(); controller.setInterval(60); controller.startInterval(); expect(spyTimerEvent).not.toHaveBeenCalled(); jasmine.Clock().tick(61); expect(spyTimerEvent).toHaveBeenCalled(); jasmine.clock().uninstall(); 我得到的错误: "Expected a spy, but got null" 我尝试了几种方法,但我认为如果使用jasmine.clock,我没有这个概念。 任何人都可以用正确的方式暗示我吗?

量angular器停止工作。 你能明白为什么吗?

Protractor对我来说运行良好,testingChrome和Firefox 。 然后Chrometesting开始失败。 然后Protractor根本不运行。 然后Protractor根本找不到。 然后我无法更新或安装它或其他任何东西。 我是新来的,我真的不知道我在做什么。 几天前,我的经理让我在我的电脑上install Norton AV 。 莫名其妙地干扰吗? 如果是这样的话,我能做些什么? 当我试图再次install Protractor (在pipe理员模式下运行时,我尝试了进出pipe理员),这里是一个来自NodeJS的示例错误日志: 0 info it worked if it ends with ok 1 verbose cli [ 'C:\\Program Files\\nodejs\\node.exe', 1 verbose cli 'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js', 1 verbose cli 'install', 1 verbose cli '-g', 1 verbose cli 'protractor' ] 2 info using npm@2.14.4 3 info […]

茉莉花节点没有显示testing结果

我正在使用jasmine-node为我的node.js应用程序运行testing。 问题是,如果我运行指定文件( jasmine-node spec/file.spec.js )一个接一个的testing – 那么一切看起来不错 – 我得到(作为一个例子)的输出,如Finished in 0.049 seconds 4 tests, 19 assertions, 1 failure, 0 skipped 。 但是,如果我只是通过input命令jasmine-node spec/运行testing,我没有得到如上所述的结果,我看不到哪些testing失败或成功。 有谁知道如何解决这个问题? (我使用node.js版本0.12.7和茉莉花节点1.14.3)

为什么fs-extra的步行stream不能和茉莉花一起工作

我不知道为什么这不起作用。 我想使用伟大的fs-extra模块的walkfunction/stream。 我完全无法称之为茉莉花。 我已经尝试过beforeEach或beforeAll,就像它在文档中描述的那样。 我的茉莉花版本是2.3.2 我猜这个事件不会被调用。 因为溪stream里的一切都不在茉莉花环境里工作。 我做了一个小testing例子: fs = require("fs-extra"); console.log("console log output"); fs.walk(__dirname) .on("data", function (item) { console.log (item.path); }) 通过node spec/testSpec.js调用该部分一切正常。 通过使用jasmine的输出只是控制台日志输出 那么为什么这些stream不工作? 有解决scheme吗? 还是我需要使用另一个工具来testing代码与stream?