From 0cf9cf082997259f2dd6ff45f38a3cff52acdf24 Mon Sep 17 00:00:00 2001 From: Joel Einbinder Date: Mon, 19 Jul 2021 11:59:53 -0500 Subject: [PATCH] fix(test-runner): set expand: false for expect. (#7722) --- src/test/expect.ts | 1 + tests/playwright-test/expect.spec.ts | 17 +++++++++++++++++ 2 files changed, 18 insertions(+) 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, 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