Tag: 压力testing

如何确保testing对象属性的更改不会传播到其他testing用例?

这是foo.js : var Foo; Foo = function () { var foo = {}; foo.get = function (url) { // [..] return Foo.get(url); }; return foo; }; Foo.get = function (url) {}; module.exports = Foo; 这是foo.js一个testing用例: var expect = require('chai').expect, sinon = require('sinon'); describe('foo', function () { var Foo, foo; beforeEach(function () { Foo = require('foo.js'); […]

如何运行browser-perf的Node APItesting

我正在尝试configurationbrowser-perf来测量浏览器性能指标。 我可以通过使用命令行来运行它 browser-perf –selenium=http://localhost:4444/wd/hub http://yourwebsite.com 但是,我想为browser-perfconfiguration节点模块API 。 以下是问题: 1.我无法find执行节点API browser-perftesting的命令。 另外,我在哪里打电话给browserPerf() – 在configuration或规格? 如果有人可以提供Node API设置的步骤,那真的很有帮助! PS:我发现protractor-perf conf.js命令用于量angular器 – 性能testing。 只是无法find类似的浏览器性能!

在查询mongodb之前,我是否应该关心在id中过滤$ nin ID?

所以我有一个node.js代码,它有一个$ in和$ nin id的mongodb。 “$ nin”的列表实际上比“$ in”列表大。 在“我的实现”我做了“简单的方法”,通过将两个ID列表传递给mongodb: query = { _id: { $in: in_list, $nin: not_in_list } } 然后我的同事过来,从“$ in”列表中删除了所有“$ nin”id,只是查询$ in_list = _.difference in_list, not_in_list query = { _id: { $in: in_list } } 我的假设是,mongodb足够聪明,能够比node.js更快地处理这个问题,但是我实际上并不知道这个差异是否是实际可测量的和/或显着的。 任何input?

NodeJS和supertest:用npm命令开始testing

我用supertest 。 我想在testing目录中启动所有testing。 我的/tests/tests.js文件: var request = require('supertest'); var app = require('express.io')(); //add good url with http:// and redirection request(app) .post('/add/') .expect(201) .send({url: 'http://www.google.fr'}) .end(function(err, res){ console.log(res.body.url); if (err) throw err; request(app) .get('/redirect/' + res.body.url.generatedid) .expect(302) .end(function(err, res){ if (err) throw err; }); }); //add good url with www. and redirection request(app) .post('/add/') .expect(201) .send({url: […]

用MochatestingExpress和Mongoose

我正在尝试使用Mocha和Chai来testing我的REST API端点处理程序,该应用程序是使用Express和Mongoose构build的。 我的处理程序主要是这样的forms: var handler = function (req, res, next) { // Process the request, prepare the variables // Call a Mongoose function Model.operation({'search': 'items'}, function(err, results) { // Process the results, send call next(err) if necessary // Return the object or objects return res.send(results) } } 例如: auth.getUser = function (req, res, next) { […]

允许chai / mochatesting将错误冒泡到process.on

我正在编写一个捕获顶级未捕获错误的节点模块,并希望为其编写一些testing。 不幸的是,我最喜欢的框架似乎有意识地抛出和捕获未捕获的exception的问题。 如果我抛出exception,那么错误,然后testing失败。 如果我抛出并捕获错误,它不会冒泡process.on('uncaughtException') 代码atm不起作用 it('Catches errors and return the user and line number', function(done) { blame.init(function (res) { console.log('\n\n', res, '\n\n'); expect(true).should.equal(true); done(); }); expect(function () { undefinedFunction(); }).to.throw('undefinedFunction is not defined'); });

黄瓜testing通过没有function存在

我已经开始为Cucumber创build一个Meteor应用程序的testing套件( http://joshowens.me/cucumber-js-and-meteor-the-why-and-how-of-it/ )。 一些testing通过时没有任何function。 例如,testing文件login.feature包含Feature: Allow users to login , Scenario: A user can login with valid information When I click on sign in link 它在文件loginSteps.js被支持: this.When(/^I click on sign in link$/, function (callback) { helper.world.browser. waitForExist('.at-signup', 7000). waitForVisible('.at-signup'). click('.at-signup'). call(callback); }); loginbutton实际上有class="btn btn-default navbar-btn" ,但Velocity说testing通过了858ms。 另一个testing通过url(helper.world.cucumber.mirror.rootUrl + "event/1")虽然没有这样的url。 其他testing失败,但是,如: getText('.user-menu .dropdown-top-level', function (err, username) […]

使用mocha.js在node.js中testing外部API调用

我正在尝试为我的npm模块编写testing,该模块负责与后端api进行通信。 这个模块将坐在一个cordova的Android应用程序,并会照顾任何API调用。 我所遇到的问题似乎是对摩卡的理解,但是我已经在互联网上看了一遍,也找不到解决办法,所以我转向群众。 作为一个例子,我有一个像这样的function test: function() { request.get({ url: defaultHost, headers: { } }, function(err, httpResponse, body) { if(err) { return err; } else { console.log(body); return body; } }); } 这个作品会的。 我现在正在尝试在摩卡中为它创buildtesting。 我得到的问题是,我不知道如何从.get调用返回到摩卡testing函数。 api返回json,所以我知道我将不得不做一个平等的比较,但是目前我甚至不能打印结果。 我认为问题在于,用我的其他摩卡testing,我可以工作,他们都有一个论点,你通过的地方,因为这不是。 我目前的testing代码是这样的。 describe('#test', function() { it('tests api reachability;', function() { var test = new test(); }); }); 如果有人可以解释什么是必要的,甚至只是指向我在谷歌的正确方向,这将是很棒的。 我通常在谷歌相当好,但没有find方向在这一个。

用Sinon嘲笑require()函数

我试图在使用Sinon的testing中嘲讽request-promise 。 据我所知,Sinon嘲笑对象的方法,但request-promise只是返回一个函数。 有没有什么办法来模拟一个必需的function? var rp = require('request-promise'); var User = require('../../models/user'); // this works sinon.stub(User, 'message', function() {}); // This is what I'd like to do to request-promise sinon.stub(rp, function() {}); 我也研究过mockrequire和proxyquire,但我认为他们都遇到类似的问题。

如何使用Selenium Webdriver Nodejs为一个configuration文件运行两个Chrome驱动程序?

我写testing,并为了速度,我想,该用户已被authentication(加载本地存储数据)。 import * as webdriver from 'selenium-webdriver'; import * as Chrome from 'selenium-webdriver/chrome'; var options = new Chrome.Options(); options.addArguments('–user-data-dir=C:\\profilepath'); var driver = new webdriver.Builder().withCapabilities(options.toCapabilities()).build(); driver.get("http://site.ru/").then(() => { console.log('Opened'); }, (err) => { console.log('Err', err); }); var driver2 = new webdriver.Builder().withCapabilities(options.toCapabilities()).build(); driver2.get("http://site.ru/").then(() => { console.log('Opened'); }, (err) => { console.log('Error', err); }); 第一个驱动程序工作正常,打开页面,第二个只是挂起初始屏幕没有任何错误。 同样的启动他们在不同的过程中…