test-proxy-recorder 0.3.4 → 0.3.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +334 -483
- package/dist/{index-BlBWqSE4.d.cts → index-BloXCw69.d.cts} +4 -0
- package/dist/{index-BlBWqSE4.d.ts → index-BloXCw69.d.ts} +4 -0
- package/dist/index.cjs +551 -445
- package/dist/index.d.cts +15 -43
- package/dist/index.d.ts +15 -43
- package/dist/index.mjs +549 -443
- package/dist/playwright/index.cjs +15 -8
- package/dist/playwright/index.d.cts +1 -1
- package/dist/playwright/index.d.ts +1 -1
- package/dist/playwright/index.mjs +15 -8
- package/dist/proxy.js +560 -450
- package/package.json +14 -12
- package/skills/nextjs-ssr/SKILL.md +377 -0
- package/skills/proxy-setup/SKILL.md +458 -0
|
@@ -17,6 +17,7 @@ var Modes = {
|
|
|
17
17
|
};
|
|
18
18
|
|
|
19
19
|
// src/playwright/index.ts
|
|
20
|
+
var registeredContexts = /* @__PURE__ */ new WeakSet();
|
|
20
21
|
function getProxyPort() {
|
|
21
22
|
const envPort = process.env.TEST_PROXY_RECORDER_PORT;
|
|
22
23
|
if (envPort) {
|
|
@@ -35,7 +36,7 @@ async function setProxyMode(mode, sessionId, timeout) {
|
|
|
35
36
|
id: sessionId,
|
|
36
37
|
...timeout && { timeout }
|
|
37
38
|
};
|
|
38
|
-
const response = await fetch(`http://
|
|
39
|
+
const response = await fetch(`http://localhost:${proxyPort}/__control`, {
|
|
39
40
|
method: "POST",
|
|
40
41
|
headers: { "Content-Type": "application/json" },
|
|
41
42
|
body: JSON.stringify(body)
|
|
@@ -58,7 +59,7 @@ async function cleanupSession(sessionId) {
|
|
|
58
59
|
cleanup: true,
|
|
59
60
|
id: sessionId
|
|
60
61
|
};
|
|
61
|
-
const response = await fetch(`http://
|
|
62
|
+
const response = await fetch(`http://localhost:${proxyPort}/__control`, {
|
|
62
63
|
method: "POST",
|
|
63
64
|
headers: { "Content-Type": "application/json" },
|
|
64
65
|
body: JSON.stringify(body)
|
|
@@ -122,7 +123,7 @@ async function getRecordingsDir() {
|
|
|
122
123
|
}
|
|
123
124
|
const proxyPort = getProxyPort();
|
|
124
125
|
try {
|
|
125
|
-
const response = await fetch(`http://
|
|
126
|
+
const response = await fetch(`http://localhost:${proxyPort}/__control`);
|
|
126
127
|
if (response.ok) {
|
|
127
128
|
const data = await response.json();
|
|
128
129
|
if (data.recordingsDir) {
|
|
@@ -175,6 +176,14 @@ var playwrightProxy = {
|
|
|
175
176
|
await page.setExtraHTTPHeaders({
|
|
176
177
|
[RECORDING_ID_HEADER]: sessionId
|
|
177
178
|
});
|
|
179
|
+
const fallbackProxyPort = getProxyPort();
|
|
180
|
+
await page.context().addCookies([
|
|
181
|
+
{
|
|
182
|
+
name: "proxy-recording-id",
|
|
183
|
+
value: encodeURIComponent(sessionId),
|
|
184
|
+
url: `http://localhost:${fallbackProxyPort}`
|
|
185
|
+
}
|
|
186
|
+
]);
|
|
178
187
|
await setProxyMode(mode, sessionId, timeout);
|
|
179
188
|
if (clientSideOptions?.url) {
|
|
180
189
|
await setupClientSideRecording(
|
|
@@ -209,10 +218,8 @@ var playwrightProxy = {
|
|
|
209
218
|
// Ensure the handler applies to all matching requests
|
|
210
219
|
);
|
|
211
220
|
const context = page.context();
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
if (!globalThis[handlerKey]) {
|
|
215
|
-
globalThis[handlerKey] = true;
|
|
221
|
+
if (!registeredContexts.has(context)) {
|
|
222
|
+
registeredContexts.add(context);
|
|
216
223
|
context.on("close", async () => {
|
|
217
224
|
try {
|
|
218
225
|
await cleanupSession(sessionId);
|
|
@@ -222,7 +229,7 @@ var playwrightProxy = {
|
|
|
222
229
|
error
|
|
223
230
|
);
|
|
224
231
|
} finally {
|
|
225
|
-
delete
|
|
232
|
+
registeredContexts.delete(context);
|
|
226
233
|
}
|
|
227
234
|
});
|
|
228
235
|
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import '@playwright/test';
|
|
2
|
-
export { f as ClientSideRecordingOptions, P as PlaywrightTestInfo, e as cleanupSession, g as generateSessionId, p as playwrightProxy, s as setProxyMode, b as startRecording, c as startReplay, d as stopProxy } from '../index-
|
|
2
|
+
export { f as ClientSideRecordingOptions, P as PlaywrightTestInfo, e as cleanupSession, g as generateSessionId, p as playwrightProxy, s as setProxyMode, b as startRecording, c as startReplay, d as stopProxy } from '../index-BloXCw69.cjs';
|
|
3
3
|
import 'node:http';
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import '@playwright/test';
|
|
2
|
-
export { f as ClientSideRecordingOptions, P as PlaywrightTestInfo, e as cleanupSession, g as generateSessionId, p as playwrightProxy, s as setProxyMode, b as startRecording, c as startReplay, d as stopProxy } from '../index-
|
|
2
|
+
export { f as ClientSideRecordingOptions, P as PlaywrightTestInfo, e as cleanupSession, g as generateSessionId, p as playwrightProxy, s as setProxyMode, b as startRecording, c as startReplay, d as stopProxy } from '../index-BloXCw69.js';
|
|
3
3
|
import 'node:http';
|
|
@@ -11,6 +11,7 @@ var Modes = {
|
|
|
11
11
|
};
|
|
12
12
|
|
|
13
13
|
// src/playwright/index.ts
|
|
14
|
+
var registeredContexts = /* @__PURE__ */ new WeakSet();
|
|
14
15
|
function getProxyPort() {
|
|
15
16
|
const envPort = process.env.TEST_PROXY_RECORDER_PORT;
|
|
16
17
|
if (envPort) {
|
|
@@ -29,7 +30,7 @@ async function setProxyMode(mode, sessionId, timeout) {
|
|
|
29
30
|
id: sessionId,
|
|
30
31
|
...timeout && { timeout }
|
|
31
32
|
};
|
|
32
|
-
const response = await fetch(`http://
|
|
33
|
+
const response = await fetch(`http://localhost:${proxyPort}/__control`, {
|
|
33
34
|
method: "POST",
|
|
34
35
|
headers: { "Content-Type": "application/json" },
|
|
35
36
|
body: JSON.stringify(body)
|
|
@@ -52,7 +53,7 @@ async function cleanupSession(sessionId) {
|
|
|
52
53
|
cleanup: true,
|
|
53
54
|
id: sessionId
|
|
54
55
|
};
|
|
55
|
-
const response = await fetch(`http://
|
|
56
|
+
const response = await fetch(`http://localhost:${proxyPort}/__control`, {
|
|
56
57
|
method: "POST",
|
|
57
58
|
headers: { "Content-Type": "application/json" },
|
|
58
59
|
body: JSON.stringify(body)
|
|
@@ -116,7 +117,7 @@ async function getRecordingsDir() {
|
|
|
116
117
|
}
|
|
117
118
|
const proxyPort = getProxyPort();
|
|
118
119
|
try {
|
|
119
|
-
const response = await fetch(`http://
|
|
120
|
+
const response = await fetch(`http://localhost:${proxyPort}/__control`);
|
|
120
121
|
if (response.ok) {
|
|
121
122
|
const data = await response.json();
|
|
122
123
|
if (data.recordingsDir) {
|
|
@@ -169,6 +170,14 @@ var playwrightProxy = {
|
|
|
169
170
|
await page.setExtraHTTPHeaders({
|
|
170
171
|
[RECORDING_ID_HEADER]: sessionId
|
|
171
172
|
});
|
|
173
|
+
const fallbackProxyPort = getProxyPort();
|
|
174
|
+
await page.context().addCookies([
|
|
175
|
+
{
|
|
176
|
+
name: "proxy-recording-id",
|
|
177
|
+
value: encodeURIComponent(sessionId),
|
|
178
|
+
url: `http://localhost:${fallbackProxyPort}`
|
|
179
|
+
}
|
|
180
|
+
]);
|
|
172
181
|
await setProxyMode(mode, sessionId, timeout);
|
|
173
182
|
if (clientSideOptions?.url) {
|
|
174
183
|
await setupClientSideRecording(
|
|
@@ -203,10 +212,8 @@ var playwrightProxy = {
|
|
|
203
212
|
// Ensure the handler applies to all matching requests
|
|
204
213
|
);
|
|
205
214
|
const context = page.context();
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
if (!globalThis[handlerKey]) {
|
|
209
|
-
globalThis[handlerKey] = true;
|
|
215
|
+
if (!registeredContexts.has(context)) {
|
|
216
|
+
registeredContexts.add(context);
|
|
210
217
|
context.on("close", async () => {
|
|
211
218
|
try {
|
|
212
219
|
await cleanupSession(sessionId);
|
|
@@ -216,7 +223,7 @@ var playwrightProxy = {
|
|
|
216
223
|
error
|
|
217
224
|
);
|
|
218
225
|
} finally {
|
|
219
|
-
delete
|
|
226
|
+
registeredContexts.delete(context);
|
|
220
227
|
}
|
|
221
228
|
});
|
|
222
229
|
}
|