0
的相关问题Cant test DELETE method using mocha and supertest和当前两个答案没有解决我的问题:(不能测试选项方法和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
@robertklep感谢您的评论,它对于检测问题非常有用。 – diosney