Tag: 压力testing

使用PhantomJS和Travis CI运行实习生testing

语境: 我正在使用Intern框架运行一些unit testing。 由于我testing的代码是我在NPM上发布的一个包,我想将它与Travis CI集成。 在我的本地,所有的testing运行良好。 但是,使用Travis CI,testing因为启动PhantomJSnetworking服务器而停滞不前。 这是我的Travis CI文件: language: node_js node_js: – "4" env: – CXX=g++-4.8 addons: apt: sources: – ubuntu-toolchain-r-test packages: – g++-4.8 before_script: – bower install – npm install grunt-cli -g – grunt installation – phantomjs –webdriver=4444 因为phantomjs命令启动了一个web服务器,所以它永远不会运行npm test 。 它只是暂停在networking服务器上。 题: 启动PhantomJS后,如何进行npm test ? 有什么方法可以将该过程移到后台,还是启动另一个过程来运行我的testing? 还是有一种方式调用phantomjs –webddriver=444和intern-runner config=tests/intern在同一时间?

摩卡/ Should.js使用asynchronousfunction

我是JavaScripttesting框架的新手。 我想做一点优化,但遇到一些问题。 该项目正在使用should.js 这里是我原来的testing用例的简化版本: describe('Simple', function() { describe('Test', function() { it('should do something', function(done) { somePromise.then(function(data) { data.should.above(100); done(); }); } it('should do something else but alike', function(done) { somePromise.then(function(data) { data.should.above(100); done(); }); } } }); 我试图这样做: var testFunc = function(data) { it('should do something', function(done) { data.should.above(100); done(); }); } describe('Simple', function() { […]

如何触发电子自动更新事件用于testing目的?

例如: autoUpdater.on('update-available', function() { console.log("update-available"); }); 我想要触发更新可用事件,而不必将应用程序的状态恢复到更新可用的位置。 谢谢! PS我会使用autoUpdater标签在这篇文章中,如果我有1.5K代表,对不起:/

如何使用sinon来模拟作为函数导出的节点模块的函数/属性?

我有一个作为function导出的服务模块。 我需要传递一些东西,像一个configuration对象,所以它需要保留这个结构。 我正在尝试从服务中删除一个函数,但无法弄清楚。 在我的应用程序,我有一个函数,使testing期间有问题的API调用,所以我想存根。 (我知道我必须写我的testing不同来处理asynchronous问题) // myService.js module.exports = function(config) { function foo() { returns 'bar'; } return { foo: foo }; }; // test.js var config = require('../../config'); var request = require('supertest'); var chai = require('chai'); var expect = chai.expect; var sinon = require('sinon'); var myService = require('./myService.js')(config); describe('Simple test', function(done) { it('should expect […]

如何增加REDIS CPU使用率

嗨,我在nodejs中使用redis ,并尝试使用Jmeter执行redis命令。 CPU使用率不超过5%,我也试图增加负载,然后CPU使用率也不超过5%。 当我试图使用默认基准testing,然后CPU使用率达到50%。 你能帮我做redis最大的CPU利用率 这是我的jmx文件 jmx文件 这是我的nodejs程序var express = require('express'); var app = express(); var redis = require("redis"), //client = redis.createClient(6379,"10.96.82.163"); client = redis.createClient(6379,"10.96.82.175"); app.get('/', function (req, res) { res.send("HEY Nodejs runnning on 10.96.82.175:4000"); }); app.put('/set/:arg1/:arg2', function (req, res) { client.set( req.params.arg1,req.params.arg2,function (err, reply) { if (reply==null) { res.send("null"); } else { res.send(reply.toString()); } […]

如何使用Node.js执行集成testing?

我正在编写一个充当GraphQL服务器的Node.js应用程序。 我想testingGraphQL是否给我正确的结果。 我的猜测是在每个testing中向服务器发出请求,然后观察是否正确。 但是我不确定如何设置它,如何在所有testing完成之前运行服务器并清理数据库并closures它。 我之前使用Ruby on Rails与rspec一起工作过,所以我想在Node.js中做类似rspec事情。 有没有办法使用Jest来完成它? 如果没有,我怎么能做一些相似的事情?

在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头数据,我不知道如何设置这个。 任何帮助将不胜感激

如何在运行testing之前从摩卡文件读取数据?

我目前正在API上运行testing – 使用Mocha运行时没有问题。 testing数组存储在一个variables – “testing”在文件的顶部。 我想从文本文件中读取testing信息,并在运行testing(一次)之前将信息parsing成variables。 我试图使用before()同步和asynchronous(下面) //Synchronously describe("API Tests", function (done) { before(function(){ tests = fs.readFileSync('./json.txt', 'utf8'); tests = JSON.parse(tests); }); for (var i = 0; i < tests.length; i++) { runTest(tests[i]); } done(); }); //Asynchronously describe("API Tests", function () { var tests = ""; before(function(){ fs.readFile('./json.txt', 'utf8', function(err, fileContents) { if (err) […]

Travis CI没有使用正确的node.js版本

我正在写ES6代码,使用class和const ,但特拉维斯CI是说我的构build失败,因为它正在运行我的testing脚本与node.js版本0.10.48 。 这里是失败的版本的链接: https : //travis-ci.org/javacoolme/google-sign-in/builds/205586193 。

unit testing查询数据库的方法

所以我创build了一个接受ID的函数,通过数据库从数据库内部查询数据库,根据不同的场景返回数据,然后我们返回数据。 我将如何unit testing这个function? 我会存根据我的存储库层查找方法返回数据,所以我不依赖于连接数据库?