Skip to content

Commit 0056ca2

Browse files
committed
feat: support trace method request
1 parent 732b13c commit 0056ca2

File tree

4 files changed

+31
-2
lines changed

4 files changed

+31
-2
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@
2828
"superagent": "^9.0.1"
2929
},
3030
"devDependencies": {
31-
"@arethetypeswrong/cli": "^0.17.1",
31+
"@arethetypeswrong/cli": "^0.17.3",
32+
"@eggjs/bin": "7",
3233
"@eggjs/tsconfig": "1",
3334
"@types/body-parser": "^1.19.5",
3435
"@types/cookie-parser": "^1.4.8",
@@ -37,7 +38,6 @@
3738
"@types/node": "22",
3839
"body-parser": "^1.20.3",
3940
"cookie-parser": "^1.4.6",
40-
"egg-bin": "6",
4141
"eslint": "8",
4242
"eslint-config-egg": "14",
4343
"express": "^4.18.2",

src/agent.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,9 @@ export class TestAgent extends Agent {
8383
options(url: string) {
8484
return this._testRequest('options', url);
8585
}
86+
trace(url: string) {
87+
return this._testRequest('trace', url);
88+
}
8689
}
8790

8891
// allow keep use by `agent()`

src/request.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,4 +56,7 @@ export class Request {
5656
options(url: string) {
5757
return this._testRequest('options', url);
5858
}
59+
trace(url: string) {
60+
return this._testRequest('trace', url);
61+
}
5962
}

test/supertest.test.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,18 @@ describe('request(app)', function() {
204204
.expect('Hello', done);
205205
});
206206

207+
it('should work on trace method', function(done) {
208+
const app = express();
209+
210+
app.trace('/', function(_req, res) {
211+
res.end('Hello');
212+
});
213+
214+
request(app)
215+
.trace('/')
216+
.expect('Hello', done);
217+
});
218+
207219
it('should default redirects to 0', function(done) {
208220
const app = express();
209221

@@ -1078,6 +1090,11 @@ describe('request.agent(app)', function() {
10781090
res.send();
10791091
});
10801092

1093+
app.trace('/', function(_req, res) {
1094+
res.cookie('cookie', 'hey');
1095+
res.send('trace method');
1096+
});
1097+
10811098
app.get('/return_cookies', function(req, res) {
10821099
if (req.cookies.cookie) res.send(req.cookies.cookie);
10831100
else res.send(':(');
@@ -1105,6 +1122,12 @@ describe('request.agent(app)', function() {
11051122
.get('/return_headers')
11061123
.expect('hey', done);
11071124
});
1125+
1126+
it('should trace method work', function(done) {
1127+
agent
1128+
.trace('/')
1129+
.expect('trace method', done);
1130+
});
11081131
});
11091132

11101133
describe('agent.host(host)', function() {

0 commit comments

Comments
 (0)