Skip to content

Commit 235e2f3

Browse files
fix: use correct wording for HTTP status codes
1 parent 49c7ac4 commit 235e2f3

File tree

4 files changed

+18
-11
lines changed

4 files changed

+18
-11
lines changed

src/formatters/NetworkFormatter.ts

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -171,17 +171,24 @@ export class NetworkFormatter {
171171
const httpResponse = request.response();
172172
const failure = request.failure();
173173
let status: string;
174-
if (httpResponse) {
175-
const responseStatus = httpResponse.status();
176-
status =
177-
responseStatus >= 200 && responseStatus <= 299
178-
? `[success - ${responseStatus}]`
179-
: `[failed - ${responseStatus}]`;
180-
} else if (failure) {
174+
if (failure) {
181175
status = `[failed - ${failure.errorText}]`;
176+
} else if (httpResponse) {
177+
const responseStatus = httpResponse.status();
178+
179+
if (responseStatus >= 100 && responseStatus <= 199) {
180+
status = `[info - ${responseStatus}]`;
181+
} else if (responseStatus >= 200 && responseStatus <= 299) {
182+
status = `[success - ${responseStatus}]`;
183+
} else if (responseStatus >= 300 && responseStatus <= 399) {
184+
status = `[redirect - ${responseStatus}]`;
185+
} else {
186+
status = `[failed - ${responseStatus}]`;
187+
}
182188
} else {
183189
status = '[pending]';
184190
}
191+
185192
return status;
186193
}
187194

tests/formatters/NetworkFormatter.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ describe('NetworkFormatter', () => {
4949

5050
assert.equal(
5151
formatter.toString(),
52-
'reqid=1 GET http://example.com [failed - 199]',
52+
'reqid=1 GET http://example.com [info - 199]',
5353
);
5454
});
5555
it('shows correct status for request with response code above 200', async () => {
@@ -61,7 +61,7 @@ describe('NetworkFormatter', () => {
6161

6262
assert.equal(
6363
formatter.toString(),
64-
'reqid=1 GET http://example.com [failed - 300]',
64+
'reqid=1 GET http://example.com [redirect - 300]',
6565
);
6666
});
6767
it('shows correct status for request that failed', async () => {

tests/tools/network.test.js.snapshot

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ exports[`network > network_list_requests > list requests from previous navigatio
4747
# list_request response
4848
## Network requests
4949
Showing 1-3 of 3 (Page 1 of 1).
50-
reqid=1 GET http://localhost:<port>/redirect [failed - 302]
50+
reqid=1 GET http://localhost:<port>/redirect [redirect - 302]
5151
reqid=2 GET http://localhost:<port>/redirected [success - 200]
5252
reqid=3 GET http://localhost:<port>/redirected-page [success - 200]
5353
`;

tests/tools/performance.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ describe('performance', () => {
140140
});
141141
});
142142

143-
it.only('supports filePath', async () => {
143+
it('supports filePath', async () => {
144144
const rawData = loadTraceAsBuffer('basic-trace.json.gz');
145145
// rawData is the decompressed buffer (based on loadTraceAsBuffer implementation).
146146
// We want to simulate saving it as a .gz file, so the tool should compress it.

0 commit comments

Comments
 (0)