playwright 1.57.0-alpha-2025-10-30 → 1.57.0-alpha-1761929702000
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 +2 -2
- package/ThirdPartyNotices.txt +202 -282
- package/lib/common/expectBundle.js +0 -9
- package/lib/common/expectBundleImpl.js +267 -249
- package/lib/index.js +1 -1
- package/lib/matchers/expect.js +2 -0
- package/lib/mcp/browser/response.js +16 -7
- package/lib/mcp/browser/tab.js +6 -3
- package/lib/mcp/sdk/server.js +6 -1
- package/lib/mcp/test/browserBackend.js +1 -1
- package/package.json +2 -2
- package/types/test.d.ts +22 -0
package/lib/index.js
CHANGED
|
@@ -586,7 +586,7 @@ class ArtifactsRecorder {
|
|
|
586
586
|
return;
|
|
587
587
|
try {
|
|
588
588
|
await page._wrapApiCall(async () => {
|
|
589
|
-
this._pageSnapshot = await page._snapshotForAI({ timeout: 5e3 });
|
|
589
|
+
this._pageSnapshot = (await page._snapshotForAI({ timeout: 5e3 })).full;
|
|
590
590
|
}, { internal: true });
|
|
591
591
|
} catch {
|
|
592
592
|
}
|
package/lib/matchers/expect.js
CHANGED
|
@@ -190,6 +190,8 @@ class ExpectMetaInfoProxyHandler {
|
|
|
190
190
|
this._prefix = prefix;
|
|
191
191
|
}
|
|
192
192
|
get(target, matcherName, receiver) {
|
|
193
|
+
if (matcherName === "toThrowError")
|
|
194
|
+
matcherName = "toThrow";
|
|
193
195
|
let matcher = Reflect.get(target, matcherName, receiver);
|
|
194
196
|
if (typeof matcherName !== "string")
|
|
195
197
|
return matcher;
|
|
@@ -70,7 +70,7 @@ class Response {
|
|
|
70
70
|
}
|
|
71
71
|
async finish() {
|
|
72
72
|
if (this._includeSnapshot !== "none" && this._context.currentTab())
|
|
73
|
-
this._tabSnapshot = await this._context.currentTabOrDie().captureSnapshot(
|
|
73
|
+
this._tabSnapshot = await this._context.currentTabOrDie().captureSnapshot();
|
|
74
74
|
for (const tab of this._context.tabs())
|
|
75
75
|
await tab.updateTitle();
|
|
76
76
|
}
|
|
@@ -105,7 +105,8 @@ ${this._code.join("\n")}
|
|
|
105
105
|
response.push(...(0, import_tab.renderModalStates)(this._context, this._tabSnapshot.modalStates));
|
|
106
106
|
response.push("");
|
|
107
107
|
} else if (this._tabSnapshot) {
|
|
108
|
-
|
|
108
|
+
const includeSnapshot = options.omitSnapshot ? "none" : this._includeSnapshot;
|
|
109
|
+
response.push(renderTabSnapshot(this._tabSnapshot, includeSnapshot));
|
|
109
110
|
response.push("");
|
|
110
111
|
}
|
|
111
112
|
const content = [
|
|
@@ -129,7 +130,7 @@ ${this._code.join("\n")}
|
|
|
129
130
|
}
|
|
130
131
|
}
|
|
131
132
|
}
|
|
132
|
-
function renderTabSnapshot(tabSnapshot,
|
|
133
|
+
function renderTabSnapshot(tabSnapshot, includeSnapshot) {
|
|
133
134
|
const lines = [];
|
|
134
135
|
if (tabSnapshot.consoleMessages.length) {
|
|
135
136
|
lines.push(`### New console messages`);
|
|
@@ -147,13 +148,21 @@ function renderTabSnapshot(tabSnapshot, options = {}) {
|
|
|
147
148
|
}
|
|
148
149
|
lines.push("");
|
|
149
150
|
}
|
|
151
|
+
if (includeSnapshot === "incremental" && tabSnapshot.ariaSnapshotDiff === "") {
|
|
152
|
+
return lines.join("\n");
|
|
153
|
+
}
|
|
150
154
|
lines.push(`### Page state`);
|
|
151
155
|
lines.push(`- Page URL: ${tabSnapshot.url}`);
|
|
152
156
|
lines.push(`- Page Title: ${tabSnapshot.title}`);
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
+
if (includeSnapshot !== "none") {
|
|
158
|
+
lines.push(`- Page Snapshot:`);
|
|
159
|
+
lines.push("```yaml");
|
|
160
|
+
if (includeSnapshot === "incremental" && tabSnapshot.ariaSnapshotDiff !== void 0)
|
|
161
|
+
lines.push(tabSnapshot.ariaSnapshotDiff);
|
|
162
|
+
else
|
|
163
|
+
lines.push(tabSnapshot.ariaSnapshot);
|
|
164
|
+
lines.push("```");
|
|
165
|
+
}
|
|
157
166
|
return lines.join("\n");
|
|
158
167
|
}
|
|
159
168
|
function renderTabsMarkdown(tabs, force = false) {
|
package/lib/mcp/browser/tab.js
CHANGED
|
@@ -41,6 +41,7 @@ class Tab extends import_events.EventEmitter {
|
|
|
41
41
|
this._requests = /* @__PURE__ */ new Set();
|
|
42
42
|
this._modalStates = [];
|
|
43
43
|
this._downloads = [];
|
|
44
|
+
this._needsFullSnapshot = false;
|
|
44
45
|
this.context = context;
|
|
45
46
|
this.page = page;
|
|
46
47
|
this._onPageClose = onPageClose;
|
|
@@ -172,14 +173,15 @@ class Tab extends import_events.EventEmitter {
|
|
|
172
173
|
await this._initializedPromise;
|
|
173
174
|
return this._requests;
|
|
174
175
|
}
|
|
175
|
-
async captureSnapshot(
|
|
176
|
+
async captureSnapshot() {
|
|
176
177
|
let tabSnapshot;
|
|
177
178
|
const modalStates = await this._raceAgainstModalStates(async () => {
|
|
178
|
-
const snapshot = await this.page._snapshotForAI({
|
|
179
|
+
const snapshot = await this.page._snapshotForAI({ track: "response" });
|
|
179
180
|
tabSnapshot = {
|
|
180
181
|
url: this.page.url(),
|
|
181
182
|
title: await this.page.title(),
|
|
182
|
-
ariaSnapshot: snapshot,
|
|
183
|
+
ariaSnapshot: snapshot.full,
|
|
184
|
+
ariaSnapshotDiff: this._needsFullSnapshot ? void 0 : snapshot.incremental,
|
|
183
185
|
modalStates: [],
|
|
184
186
|
consoleMessages: [],
|
|
185
187
|
downloads: this._downloads
|
|
@@ -189,6 +191,7 @@ class Tab extends import_events.EventEmitter {
|
|
|
189
191
|
tabSnapshot.consoleMessages = this._recentConsoleMessages;
|
|
190
192
|
this._recentConsoleMessages = [];
|
|
191
193
|
}
|
|
194
|
+
this._needsFullSnapshot = !tabSnapshot;
|
|
192
195
|
return tabSnapshot ?? {
|
|
193
196
|
url: this.page.url(),
|
|
194
197
|
title: "",
|
package/lib/mcp/sdk/server.js
CHANGED
|
@@ -156,7 +156,12 @@ function firstRootPath(clientInfo) {
|
|
|
156
156
|
return void 0;
|
|
157
157
|
const firstRootUri = clientInfo.roots[0]?.uri;
|
|
158
158
|
const url = firstRootUri ? new URL(firstRootUri) : void 0;
|
|
159
|
-
|
|
159
|
+
try {
|
|
160
|
+
return url ? (0, import_url.fileURLToPath)(url) : void 0;
|
|
161
|
+
} catch (error) {
|
|
162
|
+
serverDebug(error);
|
|
163
|
+
return void 0;
|
|
164
|
+
}
|
|
160
165
|
}
|
|
161
166
|
function mergeTextParts(result) {
|
|
162
167
|
const content = [];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "playwright",
|
|
3
|
-
"version": "1.57.0-alpha-
|
|
3
|
+
"version": "1.57.0-alpha-1761929702000",
|
|
4
4
|
"description": "A high-level API to automate web browsers",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
},
|
|
65
65
|
"license": "Apache-2.0",
|
|
66
66
|
"dependencies": {
|
|
67
|
-
"playwright-core": "1.57.0-alpha-
|
|
67
|
+
"playwright-core": "1.57.0-alpha-1761929702000"
|
|
68
68
|
},
|
|
69
69
|
"optionalDependencies": {
|
|
70
70
|
"fsevents": "2.3.2"
|
package/types/test.d.ts
CHANGED
|
@@ -7728,6 +7728,27 @@ interface AsymmetricMatchers {
|
|
|
7728
7728
|
* @param expected Expected array that is a subset of the received value.
|
|
7729
7729
|
*/
|
|
7730
7730
|
arrayContaining(sample: Array<unknown>): AsymmetricMatcher;
|
|
7731
|
+
/**
|
|
7732
|
+
* `expect.arrayOf()` matches array of objects created from the
|
|
7733
|
+
* [`constructor`](https://playwright.dev/docs/api/class-genericassertions#generic-assertions-array-of-option-constructor)
|
|
7734
|
+
* or a corresponding primitive type. Use it inside
|
|
7735
|
+
* [expect(value).toEqual(expected)](https://playwright.dev/docs/api/class-genericassertions#generic-assertions-to-equal)
|
|
7736
|
+
* to perform pattern matching.
|
|
7737
|
+
*
|
|
7738
|
+
* **Usage**
|
|
7739
|
+
*
|
|
7740
|
+
* ```js
|
|
7741
|
+
* // Match instance of a class.
|
|
7742
|
+
* class Example {}
|
|
7743
|
+
* expect([new Example(), new Example()]).toEqual(expect.arrayOf(Example));
|
|
7744
|
+
*
|
|
7745
|
+
* // Match any string.
|
|
7746
|
+
* expect(['a', 'b', 'c']).toEqual(expect.arrayOf(String));
|
|
7747
|
+
* ```
|
|
7748
|
+
*
|
|
7749
|
+
* @param constructor Constructor of the expected object like `ExampleClass`, or a primitive boxed type like `Number`.
|
|
7750
|
+
*/
|
|
7751
|
+
arrayOf(sample: unknown): AsymmetricMatcher;
|
|
7731
7752
|
/**
|
|
7732
7753
|
* Compares floating point numbers for approximate equality. Use this method inside
|
|
7733
7754
|
* [expect(value).toEqual(expected)](https://playwright.dev/docs/api/class-genericassertions#generic-assertions-to-equal)
|
|
@@ -8111,6 +8132,7 @@ interface GenericAssertions<R> {
|
|
|
8111
8132
|
* - [expect(value).any(constructor)](https://playwright.dev/docs/api/class-genericassertions#generic-assertions-any)
|
|
8112
8133
|
* - [expect(value).anything()](https://playwright.dev/docs/api/class-genericassertions#generic-assertions-anything)
|
|
8113
8134
|
* - [expect(value).arrayContaining(expected)](https://playwright.dev/docs/api/class-genericassertions#generic-assertions-array-containing)
|
|
8135
|
+
* - [expect(value).arrayOf(constructor)](https://playwright.dev/docs/api/class-genericassertions#generic-assertions-array-of)
|
|
8114
8136
|
* - [expect(value).closeTo(expected[, numDigits])](https://playwright.dev/docs/api/class-genericassertions#generic-assertions-close-to)
|
|
8115
8137
|
* - [expect(value).objectContaining(expected)](https://playwright.dev/docs/api/class-genericassertions#generic-assertions-object-containing)
|
|
8116
8138
|
* - [expect(value).stringContaining(expected)](https://playwright.dev/docs/api/class-genericassertions#generic-assertions-string-containing)
|