-
11 votesanswersviews
使用超级,摩卡和模型进行环回测试
在Google groups post on deprecating loopback-testing上有一个问题,询问提供一个如何在没有环回测试的情况下实现测试的正确示例 . 该线程谈到使用supertest而不是 . 下面是我尝试将Mocha,supertest和模型(from app.js)结合起来的尝试 . 当我自己运行文件时,结果非常好 . 但是,如果我有另一个测试文件(比如test-t... -
6 votesanswersviews
如何避免摩卡测试用例超时?
这里我附加了我的代码,我传递完成回调并使用supertest请求 . 由于我在request.end块中的testcase中使用assert / expect,为什么我需要担心超时?我在这里犯的是什么错误 . it('should get battle results ', function(done) { request(url) .post('/compare?vf_id=... -
2 votesanswersviews
带有Mocha的节点Supertest:未捕获错误:读取ECONNRESET
我开始为应用程序编写一些测试,使用Mocha,Chai和supertest 我正在测试一些表格的模糊测试,以验证正确的响应 . 现在,我的整个测试看起来像这样: const app_config = require('../config/mainConfigs'); const request = require('supertest'); const nock = require('nock')... -
3 votesanswersviews
未处理的Promise拒绝警告:TypeError:第一个参数必须是字符串或缓冲区
问题似乎是重复的,但我一直在努力解决这个问题 . 基本上我正在使用 supertest 和 mocha 来测试我的API . 我无法理解哪个承诺没有得到解决 . app.post('/todos', (req, res) => { var todo = new Todo({ text : req.body.text }); todo.save().then( (doc) => {... -
1 votesanswersviews
使用supertest和mocha进行测试无法解决问题
我正在使用promises测试我的休息应用程序(使用hapi on node)和mocha(3.2)以及supertest(3.0) . 它在超时后停止并返回错误: 错误:超出2000ms的超时 . 对于异步测试和钩子,确保调用“done()”;如果返回Promise,请确保它已解决 . 我已经尝试增加超时但它没有用 . 如果我添加一个 done() 电话我得到: 分辨率方法过于规范 . 指... -
5 votesanswersviews
Mocha supertest断言:测试失败时打印响应体
我正在使用mocha,supertest和assert来测试我的Express应用程序 . My Express应用程序在开发模式下运行,因此只要请求失败,它就会以JSON形式返回有用的调试信息 . 我想在我的测试套件中打印这些数据,但仅在测试失败时才打印 . 我的一个测试的例子(在CoffeeScript中): assert = require "assert" re... -
0 votesanswersviews
nodeJS Supertest,mocha失败错误:超出2000ms超时
我的"/todos"路由工作,实际上我可以在 end 回调中的if语句之后调用done()并且它'll update the database, but when I add a my mongodb query to verfiy it has been added, it doesn' t更新我的数据库它给了我 错误:超过2000毫秒的超时 . 确保在此测试中调用done(... -
1 votesanswersviews
在Mocha Supertest中进行404测试时出现'Body Parse'错误
我正在尝试编写测试以确保我的Express API正确地为各种方案返回正确的HTTP状态代码 . 我在测试中使用Mocha和Supertest来请求API . 现在我得到了非常意外的结果,详情如下 . 使用:Express,body-parser,Sequelize,Mocha,Supertest GET / users /:id models.User.find(req.params.id).c... -
0 votesanswersviews
使用supertest-as-promised和mocha测试promise时出现超时错误
所以我试图测试一个功能如下 function generateJwt(){ var deferred = Q.defer(); deferred.resolve({ message: 'user created', token: signedJwt, userId: user.userId }); ... -
0 votesanswersviews
测试请求(摩卡柴,超级) . 我不知所措
I'm a noob with Node.js, mocha,chai, sinon and supertest. This is the function I have and need to test. It is in .js file that has const request = require('request'); at the beginning and exports mod...