Skip to content

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.

chore: do not capture aria snapshot for passing expects (#41163)

Dmitry Gozman749d0ef6983c
diff --git a/packages/injected/src/injectedScript.ts b/packages/injected/src/injectedScript.ts
index c07b844f97..f91fdbed3b 100644
--- a/packages/injected/src/injectedScript.ts
+++ b/packages/injected/src/injectedScript.ts
@@ -1446,7 +1446,7 @@ export class InjectedScript {
async expect(element: Element | undefined, options: FrameExpectParams, elements: Element[]): Promise<{ matches: boolean, received?: ExpectReceived, missingReceived?: boolean }> {
const core = await this._expectCore(element, options, elements);
- const ariaSnapshot = this._ariaSnapshotForExpect(element, options);
+ const ariaSnapshot = core.matches !== options.isNot ? undefined : this._ariaSnapshotForExpect(element, options);
if (core.received === undefined && ariaSnapshot === undefined)
return { matches: core.matches, missingReceived: core.missingReceived };
return { matches: core.matches, received: { value: core.received, ariaSnapshot }, missingReceived: core.missingReceived };