@msw/playwright 0.4.1 → 0.4.2
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/build/index.d.ts +1 -0
- package/build/index.js +6 -2
- package/package.json +8 -4
- package/src/index.ts +18 -5
package/build/index.d.ts
CHANGED
package/build/index.js
CHANGED
|
@@ -48,7 +48,7 @@ var NetworkFixture = class extends SetupApi {
|
|
|
48
48
|
});
|
|
49
49
|
const response = await getResponse(this.handlersController.currentHandlers().filter((handler) => {
|
|
50
50
|
return handler instanceof RequestHandler;
|
|
51
|
-
}), fetchRequest);
|
|
51
|
+
}), fetchRequest, { baseUrl: this.getPageUrl() });
|
|
52
52
|
if (response) {
|
|
53
53
|
if (response.status === 0) {
|
|
54
54
|
route.abort();
|
|
@@ -77,13 +77,17 @@ var NetworkFixture = class extends SetupApi {
|
|
|
77
77
|
client,
|
|
78
78
|
server,
|
|
79
79
|
info: { protocols: [] }
|
|
80
|
-
});
|
|
80
|
+
}, { baseUrl: this.getPageUrl() });
|
|
81
81
|
});
|
|
82
82
|
}
|
|
83
83
|
async stop() {
|
|
84
84
|
super.dispose();
|
|
85
85
|
await this.#page.unroute(/.+/);
|
|
86
86
|
}
|
|
87
|
+
getPageUrl() {
|
|
88
|
+
const url = this.#page.url();
|
|
89
|
+
return url !== "about:blank" ? url : void 0;
|
|
90
|
+
}
|
|
87
91
|
};
|
|
88
92
|
var PlaywrightWebSocketClientConnection = class {
|
|
89
93
|
id;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"type": "module",
|
|
3
3
|
"name": "@msw/playwright",
|
|
4
|
-
"version": "0.4.
|
|
4
|
+
"version": "0.4.2",
|
|
5
5
|
"description": "Mock Service Worker binding for Playwright",
|
|
6
6
|
"main": "./build/index.js",
|
|
7
7
|
"types": "./build/index.d.ts",
|
|
@@ -34,16 +34,17 @@
|
|
|
34
34
|
"node": ">=20.0.0"
|
|
35
35
|
},
|
|
36
36
|
"peerDependencies": {
|
|
37
|
-
"msw": "^2.10.
|
|
37
|
+
"msw": "^2.10.3"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
40
|
"@epic-web/test-server": "^0.1.6",
|
|
41
41
|
"@ossjs/release": "^0.8.1",
|
|
42
42
|
"@playwright/test": "^1.52.0",
|
|
43
43
|
"@types/node": "^22.15.29",
|
|
44
|
-
"msw": "^2.10.
|
|
44
|
+
"msw": "^2.10.3",
|
|
45
45
|
"tsdown": "^0.12.7",
|
|
46
|
-
"typescript": "^5.8.3"
|
|
46
|
+
"typescript": "^5.8.3",
|
|
47
|
+
"vite": "^7.0.2"
|
|
47
48
|
},
|
|
48
49
|
"dependencies": {
|
|
49
50
|
"@mswjs/interceptors": "^0.39.2",
|
|
@@ -52,6 +53,9 @@
|
|
|
52
53
|
"scripts": {
|
|
53
54
|
"dev": "tsdown --watch",
|
|
54
55
|
"test": "playwright test",
|
|
56
|
+
"app:dev": "vite dev",
|
|
57
|
+
"app:build": "vite build",
|
|
58
|
+
"app:start": "vite",
|
|
55
59
|
"build": "tsdown",
|
|
56
60
|
"release": "release publish"
|
|
57
61
|
}
|
package/src/index.ts
CHANGED
|
@@ -93,6 +93,9 @@ export class NetworkFixture extends SetupApi<LifeCycleEventsMap> {
|
|
|
93
93
|
return handler instanceof RequestHandler
|
|
94
94
|
}),
|
|
95
95
|
fetchRequest,
|
|
96
|
+
{
|
|
97
|
+
baseUrl: this.getPageUrl(),
|
|
98
|
+
},
|
|
96
99
|
)
|
|
97
100
|
|
|
98
101
|
if (response) {
|
|
@@ -131,11 +134,16 @@ export class NetworkFixture extends SetupApi<LifeCycleEventsMap> {
|
|
|
131
134
|
const server = new PlaywrightWebSocketServerConnection(ws)
|
|
132
135
|
|
|
133
136
|
for (const handler of allWebSocketHandlers) {
|
|
134
|
-
await handler.run(
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
137
|
+
await handler.run(
|
|
138
|
+
{
|
|
139
|
+
client,
|
|
140
|
+
server,
|
|
141
|
+
info: { protocols: [] },
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
baseUrl: this.getPageUrl(),
|
|
145
|
+
},
|
|
146
|
+
)
|
|
139
147
|
}
|
|
140
148
|
})
|
|
141
149
|
}
|
|
@@ -144,6 +152,11 @@ export class NetworkFixture extends SetupApi<LifeCycleEventsMap> {
|
|
|
144
152
|
super.dispose()
|
|
145
153
|
await this.#page.unroute(/.+/)
|
|
146
154
|
}
|
|
155
|
+
|
|
156
|
+
private getPageUrl(): string | undefined {
|
|
157
|
+
const url = this.#page.url()
|
|
158
|
+
return url !== 'about:blank' ? url : undefined
|
|
159
|
+
}
|
|
147
160
|
}
|
|
148
161
|
|
|
149
162
|
class PlaywrightWebSocketClientConnection
|