0
그래서 REST API (Express 및 Mongoose 위에 구축 된)에 대한 테스트를 작성하려고하는데 몇 가지 문제가 있습니다.Supertest/mocha Error : 전역 누설이 발견되었습니다 : 경로
내 솔루션은 아래 작업을해야하는 것이 좋습니다 예제와 자습서를 많이 따랐지만, 그것을하지 않습니다 - 나는 점점 오전 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);
});
});
예! 비록 그다지 분명한 것은 아니지만 사실 그 것이었다. 나는 for..in 루프를'for (object in path) ... '와 같이 가지고 있는데, 문제는 루프 앞에'var path'를 선언하지 않았다는 것입니다. 감사! – ragulka
다음 위치에 ... 감사합니다. –