Skip to content
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
1 change: 1 addition & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ jobs:
run: npm run cover
env:
HTTPBIN_BASEURL: http://localhost
SUPERAGENT_VERSION: ${{ matrix.superagent-version }}

- name: Install lcov
uses: awalsh128/cache-apt-pkgs-action@latest
Expand Down
15 changes: 8 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
"puppeteer": "^24.3.0",
"rollup": "^4.34.9",
"rollup-plugin-istanbul": "^5.0.0",
"superagent": "^10.1.1",
"superagent": "^10.2.0",
"superagent-prefix": "^0.0.2",
"typescript": "^5.8.2"
}
Expand Down
17 changes: 12 additions & 5 deletions test/integration.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,18 @@ import superagent from 'chai-superagent';

use(superagent());

// https://github.com/ladjs/superagent/pull/1805
// https://github.com/ladjs/superagent/pull/1829
const { SUPERAGENT_VERSION } = env;
const BASEURL = env.HTTPBIN_BASEURL ?? 'https://httpbin.org';

const normalizeAddress = ({ address, family, port }) => `http://${(SUPERAGENT_VERSION === '9'
? address.replace('::', 'localhost')
: (family === 'IPv6'
? `[${address}]`
: address
))}:${port}/`;

describe('superagent', () => {
const isNode = typeof process === 'object';
// eslint-disable-next-line unicorn/prefer-global-this
Expand Down Expand Up @@ -128,10 +138,8 @@ describe('superagent', () => {
});

server.listen(0, () => {
const { address, port } = server.address();

request
.get(`http://${address.replace('::', 'localhost')}:${port}/`)
.get(normalizeAddress(server.address()))
.set('X-API-Key', 'test2')
.end((err, res) => {
expect(res).to.have.status(200);
Expand All @@ -150,8 +158,7 @@ describe('superagent', () => {
});

server.listen(0, () => {
const { address, port } = server.address();
const agent = request.agent().use(prefix(`http://${address.replace('::', 'localhost')}:${port}`));
const agent = request.agent().use(prefix(normalizeAddress(server.address())));

agent
.get('/')
Expand Down