Skip to content

Commit 8ea15e6

Browse files
committed
Added response time measuring interceptors to the test fixtures.
Signed-off-by: Vilem Obratil <[email protected]>
1 parent 01eaca4 commit 8ea15e6

File tree

3 files changed

+35
-0
lines changed

3 files changed

+35
-0
lines changed

e2e/README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,12 @@
2525
npm run test
2626
```
2727

28+
- Run a set of tests marked with a tag:
29+
30+
```
31+
npx playwright test --grep @performance
32+
```
33+
2834
- For other methods and operating systems, see [Developing tests](DEVELOPING.md)
2935

3036
## Environment Variables
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { test } from "../fixtures";
2+
3+
// test.beforeEach()
4+
5+
test("@performance Delete / Large SBOMs", async ({ axios }) => {
6+
7+
8+
});

e2e/tests/api/fixtures.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ const initAxiosInstance = async (
9595
access_token = tokenResponse.access_token;
9696

9797
// Intercept Requests
98+
// Add access token
9899
axiosInstance.interceptors.request.use(
99100
(config) => {
100101
config.headers.Authorization = `Bearer ${access_token}`;
@@ -106,7 +107,16 @@ const initAxiosInstance = async (
106107
},
107108
);
108109

110+
// Measure request start time
111+
axiosInstance.interceptors.request.use(
112+
(config) => {
113+
config.headers['request-startTime'] = new Date().getTime();
114+
return config
115+
}
116+
);
117+
109118
// Intercept Responses
119+
// Retry
110120
axiosInstance.interceptors.response.use(
111121
(response) => {
112122
return response;
@@ -137,6 +147,17 @@ const initAxiosInstance = async (
137147
return Promise.reject(error);
138148
},
139149
);
150+
151+
// Measure response reception time
152+
axiosInstance.interceptors.response.use(
153+
(response) => {
154+
const currentTime = new Date().getTime()
155+
const startTime = response.config.headers['request-startTime']
156+
157+
response.headers['request-duration'] = currentTime - startTime
158+
159+
return response
160+
})
140161
};
141162

142163
// Declare the types of your fixtures.

0 commit comments

Comments
 (0)