Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support trace method request #4

Merged
merged 1 commit into from
Jan 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@
"superagent": "^9.0.1"
},
"devDependencies": {
"@arethetypeswrong/cli": "^0.17.1",
"@arethetypeswrong/cli": "^0.17.3",
"@eggjs/bin": "7",
"@eggjs/tsconfig": "1",
"@types/body-parser": "^1.19.5",
"@types/cookie-parser": "^1.4.8",
Expand All @@ -37,7 +38,6 @@
"@types/node": "22",
"body-parser": "^1.20.3",
"cookie-parser": "^1.4.6",
"egg-bin": "6",
"eslint": "8",
"eslint-config-egg": "14",
"express": "^4.18.2",
Expand Down
3 changes: 3 additions & 0 deletions src/agent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ export class TestAgent extends Agent {
options(url: string) {
return this._testRequest('options', url);
}
trace(url: string) {
return this._testRequest('trace', url);
}
}

// allow keep use by `agent()`
Expand Down
3 changes: 3 additions & 0 deletions src/request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,7 @@ export class Request {
options(url: string) {
return this._testRequest('options', url);
}
trace(url: string) {
return this._testRequest('trace', url);
}
}
23 changes: 23 additions & 0 deletions test/supertest.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,18 @@ describe('request(app)', function() {
.expect('Hello', done);
});

it('should work on trace method', function(done) {
const app = express();

app.trace('/', function(_req, res) {
res.end('Hello');
});

request(app)
.trace('/')
.expect('Hello', done);
});

it('should default redirects to 0', function(done) {
const app = express();

Expand Down Expand Up @@ -1078,6 +1090,11 @@ describe('request.agent(app)', function() {
res.send();
});

app.trace('/', function(_req, res) {
res.cookie('cookie', 'hey');
res.send('trace method');
});

app.get('/return_cookies', function(req, res) {
if (req.cookies.cookie) res.send(req.cookies.cookie);
else res.send(':(');
Expand Down Expand Up @@ -1105,6 +1122,12 @@ describe('request.agent(app)', function() {
.get('/return_headers')
.expect('hey', done);
});

it('should trace method work', function(done) {
agent
.trace('/')
.expect('trace method', done);
});
});

describe('agent.host(host)', function() {
Expand Down
Loading