0

私は API を構築しており、モカとスーパーテストでテストしようとしています。

私はこのコードで POST 呼び出しを正しくテストしています:

it("Should generate a PDF based on the given data using API", function(done) {

    request(app)
    .post("/api/document/print")
    .send({tplName: "default", tplData: { title: "Testee", p1: "paragraph"}})
    .expect(200, done);

});

しかし、このコードで GET リクエストをテストしようとすると:

it("Should get HTML of the selected template", function(done) {

    request(app)
    .get("/api/template/default/html")
    .expect(200, done);

});

アプリを実行して Chrome で試してみると、正しい応答 (200) が得られます。

私は何を間違っていますか?

4

1 に答える 1

0

これらのテストは同じファイルにありますか? 同じ記述ブロック内ですか? おそらくあなたはこれを試すことができます:

.expect(200) .end(function(err, res){ if (err) return done(err); done() });

于 2014-07-11T20:21:54.827 に答える