Tag: jasmine

Node.js上Geddy MVC的unit testing框架

我正在Heroku上的Node.js上运行Geddy MVC框架,并使用Postgres数据库。 我似乎无法find任何支持Geddy的node.js的unit testing框架。 我试过nodeunit,茉莉花和其他一些,但似乎没有与geddy(说它是未定义的 – 我想是因为它不知道如何导入所有必需的文件)。 我知道Geddy提供了他们的杰克testing工具,但它似乎也不工作。 它给了我这个输出: ReferenceError: geddy is not defined 任何帮助将不胜感激。 也在寻找一个代码覆盖的工具,将与我开始工作的unit testing框架一起工作。 谢谢! 编辑:我的testing都开始这个头来导入所需的模块: var assert = require('assert') , tests , Activity = geddy.model.Activity; 而Activity的导入失败,上面的ReferenceError,所以它甚至从来没有尝试我的testing。 这是我写的一个nodeunittesting var tests , User = geddy.model.User; exports['addUser1'] = function (test) { var user = User.create({username: 'Greg', password: 'MyPassword!', confirmPassword: 'MyPassword!', familyName: 'LastName1', givenName: 'FirstName1', […]

茉莉花穿梭在咕噜噜唧唧喳喳的失败

我为我的插件创build了一些茉莉花testing。 他们都通过浏览器(铬),但由于某种原因,当我在我的terminal使用“grunt-contrib-jasmine”任务,他们大多失败。 这里是一个例子: it("scroll to the correct floor", function() { // return and instance of my plugin (ascensor) var ascensor = getInstanceOfAscensor({}); var floorArray; // Triggered when 'next' is triggered ascensor.on("scrollStart", function(event, floor) { // floor look like {from:0, to:1} floorArray = floor; }); // trigger an 'next' event which // trigger a 'scrollStart' // […]

Webstorm中运行茉莉花testing停止跟踪与退出码0

我通过grunt在我的node.js应用程序中运行jasminetesting。 我已经将Grunt grunt test添加到了Webstorm的运行configuration中。 在“运行/debuggingconfiguration”中,“Grunt Test”具有以下属性:节点解释器( node.exe中的node.exe ),工作目录(项目位置),JavaScript文件(grunt binary)以及应用程序参数名称)。 configuration正常工作,但停止打印完整的茉莉花输出。 有时在打印任何输出之前,大多数情况下经过茉莉花日志的某个部分之后,而是在testing总结或错误细节之前。 总是输出的最后一行是 Process finished with exit code 0 当我使用Webstorm命令并在控制台中手动运行它时,它工作正常,并且始终打印完整输出: "C:\Program Files\nodejs\node.exe" C:\…\node_modules\grunt-cli\bin\grunt test 我的testing包括asynchronous的情况下,所以大约需要20秒来运行它们。 我注意到,每个尝试通过Webstorm运行testing打印一点点输出。 第一次尝试结束没有任何,但十后进一步我得到完整的输出与testing总结。

使用Jasmine-Node进行testing时,Mongoose模型自定义函数中消失的值

我试图在我的Mongoose模型上testing我的自定义方法,但是我在testing模型中设置的值消失,并使testing失败。 testing看起来像这样: it('should get the friend id', function(){ var conversation = new Conversation({ 'users': [new ObjectId('0'), new ObjectId('1')] }); expect(conversation.getFriendId('0')).toEqual(new ObjectId('1')); }); 我的模型声明包含这个: var mongoose = require('mongoose'); var ObjectId = mongoose.Schema.Types.ObjectId; var ConversationSchema = new mongoose.Schema({ 'users': [{'type': ObjectId, 'ref': 'User'}] }); ConversationSchema.methods.getFriendId = function(userId) { return this.users; //return this.users[0] === new ObjectId(userId) // ? […]

AngularJS:Karma + Jasmine用_real_后端进行testing

去运行Karma + Jasmine来testing带有真实后端的angularjs客户端。 由于Karma使用自己的express但我需要访问与DB和其他的东西真正的nodejs后端,我想添加拦截器到$httpProvider.interceptors ,只是将我的电话/api和redirect到真正的后端位置。 有没有更好的办法?

NPM开始抛出错误

嗨,我正在尝试安装并运行angular-phonecat项目。 从github安装git(windows) 打开git shell.cloned的问题。 我有节点已经安装,所以我打开节点控制台和types节点 – 版本。我得到v0.10.9 回到git shell。 做npm安装在angular-phonecat目录(安装所有的依赖关系,如angular度js在这里build议: https ://docs.angularjs.org/tutorial 我得到以下错误,然后: npm ERR! Error: No compatible version found: karma-chrome-launcher@'^0.1.4' npm ERR! Valid install targets: npm ERR! ["0.0.1","0.0.2","0.1.0","0.1.1","0.1.2","0.1.3","0.1.4","0.1.5"] npm ERR! at installTargetsError (C:\Program Files (x86)\nodejs\node_modules\ npm\lib\cache.js:709:10) npm ERR! at C:\Program Files (x86)\nodejs\node_modules\npm\lib\cache.js:631: 10 npm ERR! at saved (C:\Program Files (x86)\nodejs\node_modules\npm\node_modul es\npm-registry-client\lib\get.js:138:7) npm ERR! at […]

如何启动与咕噜茉莉testing?

我想创build一个咕task任务,当代码改变时自动运行茉莉花testing。 对于AMD的支持,我安装了grunt-template-jasmine-requirejs 。 我将这些行添加到我的gruntfile中: connect: { test : { port : 8000 } }, jasmine: { jasmine_tests: { src: 'src/**/*.js', options: { specs: 'spec/*Spec.js', helpers: 'spec/*Helper.js', host: 'http://127.0.0.1:8000/', template: require('grunt-template-jasmine-requirejs'), templateOptions: { requireConfigFile: 'public/js/app/config/config.js' } } } }, 现在我尝试通过inputgrunt jasmine开始我的testing。 但我得到的是这样的: 运行“jasmine:jasmine_tests”(茉莉花)任务 通过PhantomJStesting茉莉花规格 警告:PhantomJS无法加载您的网页。 使用–force继续。 由于警告而中止。 那里有什么可能是错的? 我的目录结构: – website3 – .grunt + grunt-contrib-jasmine + […]

如何从Jasmine获得更好的terminal输出?

当我运行我的testing时,我在terminal输出中得到的是红色和绿色的点,我想看看所有规格的清单,以及他们是否通过或失败类似于摩卡和柴。 任何想法如何从茉莉花得到这个期望的输出?

node.jsunit testing模拟依赖

我有一个关于使用proxyquire(或任何其他build议如何testing下面的代码) 如果我有以下文件来testing: var path = require('path'); module.exports = function (conf) { var exported = {}; exported.getIssue = function (issueId, done) { … … }; return exported; }; 如何在使用proxyquire模拟path时传递'conf'variables; VAR? 有没有其他的方式来做到这一点,如果不使用proxyquire?

运行用TypeScript编写的Jasminetesting

我有一个TypeScript + Node + Angular2 + Electron应用程序,目前正在尝试运行节点类的testing,也写在Typescript中。 为了构build应用程序并在电子内运行,我使用下面的tsconfig: "compilerOptions": { "module": "system", "target": "es6", … } 正如你所看到的,它使用了systemjs并将TS编译成JS-es6。 它工作正常,应用程序本身正在工作。 现在我需要茉莉花来join 我安装了这个npm包,更新了我的gulp任务,运行gulp-jasmine只有一个文件: gulp.task('jasmine', function() { gulp.src('./test/test.js') .pipe(jasmine()) }); 这是我的test.js的样子: System.register(["./models-src/app/models/pathWatch/pathWatch"], function(exports_1, context_1) { "use strict"; var __moduleName = context_1 && context_1.id; var pathWatch_1; return { setters:[ function (pathWatch_1_1) { pathWatch_1 = pathWatch_1_1; }], execute: function() { describe("Run […]