本文整理匯總了TypeScript中@tsed/testing.TestContext.bootstrap方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript TestContext.bootstrap方法的具體用法?TypeScript TestContext.bootstrap怎麽用?TypeScript TestContext.bootstrap使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類@tsed/testing.TestContext
的用法示例。
在下文中一共展示了TestContext.bootstrap方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: describe
describe("Calendars", () => {
// bootstrap your expressApplication in first
before(TestContext.bootstrap(Server));
before(TestContext.inject([ExpressApplication], (expressApplication: ExpressApplication) => {
this.app = expressApplication;
}));
after(TestContext.reset);
// then run your test
describe("GET /rest/calendars", () => {
it("should return all calendars", (done) => {
SuperTest(this.app)
.get("/rest/calendars")
.expect(200)
.end((err, response: any) => {
if (err) {
throw (err);
}
let obj = JSON.parse(response.text);
expect(obj).to.be.an("array");
done();
});
});
});
});
示例2: describe
describe("Upload", () => {
// bootstrap the express application
before(TestContext.bootstrap(Server));
before(TestContext.inject([ExpressApplication], (expressApplication: ExpressApplication) => {
this.app = expressApplication;
}));
after(TestContext.reset);
describe("PUT /rest/upload", () => { // work if you enable the MultipartFileMiddlewareOverrided ;)
it("should return 400", (done) => {
SuperTest(this.app)
.put("/rest/upload")
.attach("file", Path.join(__dirname, "/test.txt"))
.expect(400)
.end((err, res: any) => {
if (err) {
throw (err);
}
expect(res.text).to.eq("This should be thrown and seen on the test failure.");
done();
});
});
});
});