【发布时间】:2012-08-19 01:58:02
【问题描述】:
所以我正在尝试为我的 REST API(基于 Express 和 Mongoose 构建)编写测试,但遇到了一些麻烦。
我遵循了很多示例和教程,这表明我下面的解决方案应该可以工作,但事实并非如此 - 我收到了 Error: global leak detected: path
似乎导致它的行是.post( '/api/invoices' ) - 但我不知道为什么。
var app = require("../app").app,
request = require("supertest");
describe("Invoice API", function() {
it( "GET /api/invoices should return 200", function (done) {
request(app)
.get( '/api/invoices' )
.expect( 200, done );
});
it( "GET /api/invoices/_wrong_id should return 500", function (done) {
request(app)
.get( '/api/invoices/_wrong_id' )
.expect( 500, done );
});
it( "POST /api/invoices should return 200", function (done) {
request(app)
.post( '/api/invoices' )
.set( 'Content-Type', 'application/json' )
.send( { number: "200" } )
.expect( 200, done );
});
});
【问题讨论】:
标签: node.js express mongoose mocha.js