mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-07-01 15:50:13 +00:00
chai-http: Add methods keepOpen() and close() to the agent (#27153)
keepOpen() and close() are available both on the base request and on the agent for controlling the lifetime of the server.
This commit is contained in:
committed by
Ryan Cavanaugh
parent
83f67fa71c
commit
ffbf9da05f
@@ -84,6 +84,10 @@ chai.request(app)
|
||||
.then((res: ChaiHttp.Response) => chai.expect(res).to.have.status(200))
|
||||
.catch((err: any) => { throw err; });
|
||||
|
||||
chai.request(app)
|
||||
.keepOpen()
|
||||
.close((err: any) => { throw err; });
|
||||
|
||||
const agent = chai.request.agent(app);
|
||||
|
||||
agent
|
||||
@@ -97,6 +101,8 @@ agent
|
||||
.then((res: ChaiHttp.Response) => chai.expect(res).to.have.status(200));
|
||||
});
|
||||
|
||||
agent.close((err: any) => { throw err; });
|
||||
|
||||
function test1() {
|
||||
const req = chai.request(app).get('/');
|
||||
req.then((res: ChaiHttp.Response) => {
|
||||
|
||||
2
types/chai-http/index.d.ts
vendored
2
types/chai-http/index.d.ts
vendored
@@ -64,6 +64,8 @@ declare global {
|
||||
del(url: string, callback?: (err: any, res: Response) => void): request.Request;
|
||||
options(url: string, callback?: (err: any, res: Response) => void): request.Request;
|
||||
patch(url: string, callback?: (err: any, res: Response) => void): request.Request;
|
||||
keepOpen(): Agent;
|
||||
close(callback?: (err: any) => void): Agent;
|
||||
}
|
||||
|
||||
interface TypeComparison {
|
||||
|
||||
Reference in New Issue
Block a user