From d882720c7b58d50f44de43e68de6739e9e0be51d Mon Sep 17 00:00:00 2001 From: Hansanto Date: Thu, 28 Mar 2024 10:34:43 +0100 Subject: [PATCH] test: Implements intervals config tests --- tests/playwright-test/expect-to-pass.spec.ts | 24 ++++++++++++-------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/tests/playwright-test/expect-to-pass.spec.ts b/tests/playwright-test/expect-to-pass.spec.ts index a0b6c01136..c3d16639db 100644 --- a/tests/playwright-test/expect-to-pass.spec.ts +++ b/tests/playwright-test/expect-to-pass.spec.ts @@ -263,32 +263,38 @@ test('should give priority to timeout parameter over timeout in config file', as test('should respect intervals in config file when intervals parameter is not passed', async ({ runInlineTest }) => { const result = await runInlineTest({ - 'playwright.config.js': `module.exports = { expect: { toPass: { intervals: [100, 200] } } }`, + 'playwright.config.js': `module.exports = { expect: { toPass: { timeout: 2000, intervals: [100, 1000] } } }`, 'a.spec.ts': ` import { test, expect } from '@playwright/test'; test('should fail', async () => { + let attempt = 0; await test.expect(() => { - expect(1).toBe(2); + expect(++attempt).toBe(-1); }).toPass(); }); ` }); - expect(result.exitCode).toBe('TODO'); - // TODO + expect(result.exitCode).toBe(1); + expect(result.output).toContain('Error: expect(received).toBe(expected) // Object.is equality'); + expect(result.output).toContain('Expected: -1'); + expect(result.output).toContain('Received: 3'); }); test('should give priority to intervals parameter over intervals in config file', async ({ runInlineTest }) => { const result = await runInlineTest({ - 'playwright.config.js': `module.exports = { expect: { toPass: { intervals: [100, 200] } } }`, + 'playwright.config.js': `module.exports = { expect: { toPass: { timeout: 2000, intervals: [100] } } }`, 'a.spec.ts': ` import { test, expect } from '@playwright/test'; test('should fail', async () => { + let attempt = 0; await test.expect(() => { - expect(1).toBe(2); - }).toPass({ intervals: [500] }); + expect(++attempt).toBe(-1); + }).toPass({ intervals: [100, 1000] }); }); ` }); - expect(result.exitCode).toBe('TODO'); - // TODO + expect(result.exitCode).toBe(1); + expect(result.output).toContain('Error: expect(received).toBe(expected) // Object.is equality'); + expect(result.output).toContain('Expected: -1'); + expect(result.output).toContain('Received: 3'); });