【发布时间】:2015-08-21 19:26:01
【问题描述】:
相关问题Cant test DELETE method using mocha and supertest 及其当前的两个答案并没有解决我的问题:(
以下是测试定义:
api = supertest(url);
describe('when OPTIONS', function () {
it('should return only method GET', function (done) {
api
.options('/')
.expect('Allow', 'GET')
.expect(200, done);
});
});
它一直触发以下错误:
Uncaught TypeError: Cannot read property 'header' of undefined
at _stream_readable.js:944:16
以及何时:
api
.options('/')
.end(function(error,res){
if (error) return done(error);
done()
});
上面写着:
SyntaxError: Unexpected token G
at Object.parse (native)
at _stream_readable.js:944:16
我已经尝试了很多东西但无法完成这项工作。
我正在使用 supertest ^1.0.1,它在版本 ~0.13.0 上运行良好。
https://github.com/visionmedia/supertest/issues/272的相关问题
谢谢
【问题讨论】:
-
我无法复制。您确定您的 API 的响应有效吗?
-
@robertklep 感谢您的评论,这对于检测问题非常有用。
标签: javascript node.js testing mocha.js supertest