Skip to content

Commit 2277b25

Browse files
committed
test: add more observability in the debug mode
1 parent 7d75493 commit 2277b25

File tree

1 file changed

+52
-0
lines changed

1 file changed

+52
-0
lines changed

tests/Setup/api.ts

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,58 @@ export class Api {
2929
},
3030
headers: { authorization: `api-key ${options.apiKey}` }
3131
});
32+
33+
this.client.interceptors.request.use((request) => {
34+
// eslint-disable-next-line no-console
35+
console.log('Request:', {
36+
method: request.method,
37+
url: request.url,
38+
headers: request.headers,
39+
body: request.data
40+
});
41+
42+
return request;
43+
});
44+
45+
this.client.interceptors.response.use(
46+
(response) => {
47+
// eslint-disable-next-line no-console
48+
console.log('Response:', {
49+
status: response.status,
50+
statusText: response.statusText,
51+
headers: response.headers,
52+
body: response.data
53+
});
54+
55+
return response;
56+
},
57+
(error) => {
58+
if (axios.isAxiosError(error)) {
59+
if (error.response) {
60+
// eslint-disable-next-line no-console
61+
console.log('Response:', {
62+
status: error.response.status,
63+
statusText: error.response.statusText,
64+
headers: error.response.headers,
65+
body: error.response.data
66+
});
67+
}
68+
} else {
69+
// eslint-disable-next-line no-console
70+
console.log('Response Error:', error);
71+
}
72+
73+
return Promise.reject(error);
74+
}
75+
);
76+
77+
const isGithubRunnerDebugMode =
78+
process.env.ACTIONS_STEP_DEBUG === 'true' ||
79+
process.env.ACTIONS_RUNNER_DEBUG === 'true';
80+
81+
if (!isGithubRunnerDebugMode) {
82+
this.client.interceptors.request.clear();
83+
}
3284
}
3385

3486
public async getScanEntryPointsConnectivity(scanId: string) {

0 commit comments

Comments
 (0)