Skip to content

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

fix(test-runner): set expand: false for expect. (#7722)

Joel Einbinder0cf9cf082997
diff --git a/src/test/expect.ts b/src/test/expect.ts
index dd15c1316b..744ebafd39 100644
--- a/src/test/expect.ts
+++ b/src/test/expect.ts
@@ -58,3 +58,4 @@ function toMatchSnapshot(this: ReturnType<Expect['getState']>, received: Buffer
}
expectLibrary.extend({ toMatchSnapshot });
+expectLibrary.setState({ expand: false });
\ No newline at end of file
diff --git a/tests/playwright-test/expect.spec.ts b/tests/playwright-test/expect.spec.ts
index 8b5d06124a..4727e287bc 100644
--- a/tests/playwright-test/expect.spec.ts
+++ b/tests/playwright-test/expect.spec.ts
@@ -125,3 +125,20 @@ test('should work with custom PlaywrightTest namespace', async ({runTSC}) => {
});
expect(result.exitCode).toBe(0);
});
+
+test('should not expand huge arrays', async ({runInlineTest}) => {
+ const result = await runInlineTest({
+ 'expect-test.spec.ts': `
+ const { test } = pwt;
+ test('numeric ranges', () => {
+ const a1 = Array(100000).fill(1);
+ const a2 = Array(100000).fill(1);
+ a2[500] = 2;
+ test.expect(a1).toEqual(a2);
+ });
+ `
+ });
+ expect(result.exitCode).toBe(1);
+ expect(result.passed).toBe(0);
+ expect(result.output.length).toBeLessThan(100000);
+});
\ No newline at end of file