本文整理汇总了TypeScript中supertest-as-promised类的典型用法代码示例。如果您正苦于以下问题:TypeScript supertest-as-promised类的具体用法?TypeScript supertest-as-promised怎么用?TypeScript supertest-as-promised使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了supertest-as-promised类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: supertest
test('honors the cache max evicting least recently used', async() => {
await supertest(app).get('/components/test-component/test.html');
assert(babelCompileCache.has(uncompiledHtml));
const originalMax = babelCompileCache['max'];
babelCompileCache['max'] = babelCompileCache.length;
try {
await supertest(app).get('/components/test-component/test.js');
assert(!babelCompileCache.has(uncompiledHtml), 'cached html evicted');
} finally {
babelCompileCache['max'] = originalMax;
}
});
示例2: beforeEach
beforeEach((done: DoneFn) => {
request(server.getApp())
.get("/api/user/1/address/2")
.expect(200)
.then(() => done())
.catch((error: any) => done.fail(error));
});
示例3: setUpProxy
test('rewrites directory with proxy', async() => {
await setUpProxy('normally-non-existing-path');
await supertest(proxyServer)
.get(
'/normally-non-existing-path/bower_components/test-component/test-file.txt')
.expect(200, 'TEST COMPONENT\n');
});
示例4: beforeEach
beforeEach((done: DoneFn) => {
app
.use("/user/info", (err: any, req: any, res: any, next: any) => {
err.$handlers.push("info error handler");
next(err);
})
.use("/user", (err: any, req: any, res: any, next: any) => {
err.$handlers.push("user error handler");
next(err);
})
.use((err: any, req: any, res: any, next: any) => {
err.$handlers.push("app error handler");
res.status(500).send(err.$handlers);
});
spyOn(controller, "fn").and.callFake((req, res, next) => {
next({ $handlers: [] });
});
request(app)
.get("/user/info")
.expect(500)
.then((res: request.Response) => {
response = res;
done();
})
.catch((error) => done.fail(error));
});
示例5: async
test("isLogged:Error", async(t) => {
const res = await request(app)
.post("/test/api/user/isLogged")
.set("authorization", "nope");
t.is(res.status, 401);
t.falsy(res.body.isSuccess);
});
示例6: beforeEach
beforeEach((done: DoneFn) => {
spyOn(server.getDependency<ControllerClass>(ControllerClass), "read").and.callThrough();
request(expressApp)
.get("/controllers")
.expect(200)
.then(() => done())
.catch((error) => done.fail(error));
});
示例7: supertest
test('serves index.html, not 404', async() => {
const app = getApp({root});
await supertest(app).get('/foo').expect(200).expect((res: any) => {
if (!res.text.includes('INDEX')) {
throw new Error('Expected body to contain INDEX');
}
});
});