Tag: 茉莉花节点

为什么不是这个茉莉节点testing失败?

我正在使用Express.js和Jasmine-node进行testing。 这是我的服务器代码: var express = require('express'); var app = express(); app.get('/', function (request, response) { response.send("Bonjour!"); }); module.exports = app; 这是testing: var request = require('http'); var app = require('../src/app'); var server; describe('textreader', function(){ beforeEach(function(done){ server = app.listen(3333, function (err, result) { if (err) { done(err); } else { done(); } }); }); afterEach(function(){ server.close(); }); […]

使用jasmine.any,预期和实际的SEEM匹配

我试图testing一个快速路由是在我的节点应用程序中使用茉莉花(以及茉莉花给予和茉莉花隐形)。 我在做循环,但比较的要点是(顺便说一句,在咖啡文件中): route = app.stack.shift() expect(route).toEqual route: '' handle: jasmine.any(Function) 我在这个特定的testing上使用jasmine.any,因为句柄函数来自一个明确的内部函数(如express.static(/*stuff*/) )。 当我用grunt运行testing时,出现以下消息: Message: Expected { route : '', handle : Function } to equal { route : '', handle : Function }. 那些看起来和我一样。 我错过了什么?

为什么我的茉莉花unit testing不等待“完成”?

我在我的节点应用程序中testing… it('will call done', function(done) { myObj.fn(function(){ done(); } }); 和代码…. myObj.fn = function(success){ setTimeout(2000000000,success); } 当我运行testing时,我在输出中得到这个… -MacBook-Pro:torus-pqdata user$ npm test > torus-pqdata@0.0.0 test /Stuff/code bases/2015/torus-pqdata > jasmine-node specs/ 但是,正如你所看到的unit testing只是退出没有失败,但我需要它超时(我试图模拟悬挂的东西)。 我如何让它超时?

Jasmine-node Body未定义

我是新来的茉莉花,并试图进行基本testing,但我不断收到错误。 我的testing如下 var request = require('request'); var base_url = 'http://localhost:8080' var getdata = require('../modules/getdata.js') var index = require('../index.js') describe("GetData Test",function(){ describe("Get /", function() { it("returns statusCode 200", function(done) { request.get(base_url, function(error, response, body){ expect(response.statusCode).toBe(200); done(); }); }); it("returns Api is Online", function(done) { request.get('base_url', function(error, response, body){ console.log(request.body) expect(body).toBe("Api is online"); index.closeServer(); done(); }); }); […]

茉莉花未能在async.waterfall块内调用函数

我有一个node.js应用程序,使用asynchronous实用程序来打破嵌套的callback。 而且我试图在我的茉莉花规格中窥探async.waterfall封装的函数,但总是失败。 下面的代码可以重现错误: async = require 'async' app = hi: -> fn = -> # app.hi() # works async.waterfall [ (cb) -> app.hi() # doesn't work cb null ], (err) -> describe 'jasmine', -> beforeEach -> spyOn app, 'hi' it 'test async.waterfall', -> spyOn app, 'hi' fn() expect(app.hi).toHaveBeenCalled() 失败消息: Failures: 1) jasmine test async.waterfall Message: […]

茉莉花节点asynchronous不明白代码错误

我正在尝试与asynchronous茉莉节点: it('should not be dumb', function(done){ Promise.resolve(0).then(function(){ console.log('dumb'); expect(2).toEqual(2); done(); }); }); 返回: dumb . Finished in 0.026 seconds 1 test, 1 assertion, 0 failures, 0 skipped 但不知何故,如果我在我的代码中有一个错误: it('should not be dumb', function(done){ Promise.resolve(0).then(function(result){ console.log('dumb'); expect(2,toEqual(2)); done(); }, function (err){console.log(err); done()}); }); 它只是坐在那里,直到它超时,没有任何有用的输出: dumb Pairing user stories – 7816 ms should not be dumb – […]

在Jasmine中设置基本身份validation头以testingNodeJS Api

我目前正在为我正在编写的API编写testing套件,但是我无法确定如何设置基本身份validation标题来testing某些路由。 我可以testing正常的路线,如下所示: describe('Get /', function() { it('returns statusCode 200', function(done) { request.get(base_url, function(error, response){ expect(response.statusCode).toBe(SuccessCode) done() }) 然而,许多亩路线需要从基本的auth头数据,我不知道如何设置这个。 任何帮助将不胜感激

jasmin-node不能在Windows中工作

我试图从Windows cmd运行茉莉花节点没有成功。 我的package.json位于我的项目的顶层,具体如下 { "devDependencies": { "jasmine-node": "" } } 我在我的项目的顶层运行这个。 npm install 然后呢 node_modules/jasmine-node/bin/jasmine-node spec/greetSpec.js 这是结果 'node_modules' is not recognized as an internal or external command, operable program or batch file. 安装jasmin-node出了什么问题? 什么是在Windows中这样做的正确方法?

frisbyjs对象数组

我的nodejs服务器响应一个包含这样的对象数组的对象: { error: false message: "get dispatchers successful" data: [1] 0: { id: 1 first_name: "Brenth Andrew J." last_name: "Miras" contact_number: null email: "brenthmiras2@gmail.com" address: null image: null password: "bajmiras" created: "2014-09-12T10:24:06.000Z" } } 现在我想testing数组的所有元素的数据的属性的types。 我的弗里斯比testing看起来像这样: //expect these types of response .expectJSONTypes('*', { error: Boolean, message: String, data: { id: Number, first_name: String, last_name: String, […]

自动e2etesting – WebDriverJS,茉莉花

我正在按照这个教程http://engineering.wingify.com/posts/e2e-testing-with-webdriverjs-jasmine/ 第一部分要求创buildtestfile.js var webdriver = require('selenium-webdriver'); var driver = new webdriver.Builder(). withCapabilities(webdriver.Capabilities.chrome()). build(); driver.get('http://www.wingify.com'); 当我运行node testfile.js时,我能够运行浏览器 我创build了testfile.js $ cat testfile.js var webdriver = require('selenium-webdriver'); var driver = new webdriver.Builder(). withCapabilities(webdriver.Capabilities.chrome()). build(); describe('basic test', function () { it('should be on correct page', function () { driver.get('http://www.wingify.com'); driver.getTitle().then(function(title) { expect(title).toBe('Wingify'); }); }); }); 我到了你运行jasmine-node的地方 $ jasmine-node testfile.js […]