Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
TypeScript automationchromechromiume2e-testingelectronend-to-end-testingfirefoxjavascriptplaywrighttesttest-automationtestingtesting-toolswebwebkit
test: add failing test for eval with overridden Array.toJSON (#6766)
Yury Semikhatsky3b220e50ee72
diff --git a/tests/page/page-evaluate.spec.ts b/tests/page/page-evaluate.spec.tsindex 942ef5308e..842621c8e8 100644--- a/tests/page/page-evaluate.spec.ts+++ b/tests/page/page-evaluate.spec.ts@@ -550,6 +550,15 @@ it('should not use toJSON when evaluating', async ({ page }) => {expect(result).toEqual({ data: 'data', toJSON: {} });});+it('should not use Array.prototype.toJSON when evaluating', async ({ page, browserName }) => {+ it.fixme(browserName === 'firefox', 'https://github.com/microsoft/playwright/issues/6750');+ const result = await page.evaluate(() => {+ (Array.prototype as any).toJSON = () => 'busted';+ return [1, 2, 3];+ });+ expect(result).toEqual([1,2,3]);+});+it('should not use toJSON in jsonValue', async ({ page }) => {const resultHandle = await page.evaluateHandle(() => ({ toJSON: () => 'string', data: 'data' }));expect(await resultHandle.jsonValue()).toEqual({ data: 'data', toJSON: {} });