diff --git a/tests/playwright-test/expect.spec.ts b/tests/playwright-test/expect.spec.ts index 1886651f95..8db86f2041 100644 --- a/tests/playwright-test/expect.spec.ts +++ b/tests/playwright-test/expect.spec.ts @@ -1139,3 +1139,77 @@ test('custom asymmetric matchers should work with expect.extend', async ({ runIn expect(result.passed).toBe(1); expect(result.output).not.toContain('should not run'); }); + +test('should check types of overloaded toMatchObject with generic parameter', async ({ runTSC }) => { + const result = await runTSC({ + 'playwright.config.ts': ` + import { defineConfig } from '@playwright/test'; + + export default defineConfig({ + }); + `, + 'a.spec.ts': ` + import { test, expect } from '@playwright/test'; + test('my test', async () => { + const value = { a: 1, b: 'foo', c: { d: 2, e: 'bar' } }; + + expect.soft(value).toMatchObject({}); + expect.soft(value).toMatchObject({ a: 1 }); + expect.soft(value).toMatchObject({ a: 1, c: { e: 'bar' } }); + expect.soft([value]).toMatchObject([{ a: 1 }]); + expect.soft([value]).toMatchObject([{ a: 1, c: { e: 'bar' } }]); + + // @ts-expect-error + expect.soft(value).toMatchObject({ a: 'a' }); + + // @ts-expect-error + expect.soft(value).toMatchObject({ c: { e: 2 } }); + + // @ts-expect-error + expect.soft([value]).toMatchObject([{ a: 'a' }]); + + // @ts-expect-error + expect.soft([value]).toMatchObject([{ c: { e: 2 } }]); + }); + ` + }); + expect(result.exitCode).toBe(0); +}); + +test('should check types of overloaded toStrictEqual with generic parameter', async ({ runTSC }) => { + const result = await runTSC({ + 'playwright.config.ts': ` + import { defineConfig } from '@playwright/test'; + + export default defineConfig({ + }); + `, + 'a.spec.ts': ` + import { test, expect } from '@playwright/test'; + test('my test', async () => { + const value = { a: 1, b: 'foo', c: { d: 2, e: 'bar' } }; + + expect.soft(value).toStrictEqual({ a: 1, b: 'foo', c: { d: 2, e: 'bar' } }); + expect.soft([value]).toStrictEqual>([{ a: 1, b: 'foo', c: { d: 2, e: 'bar' } }]); + + expect.soft(new Date()).toStrictEqual(new Date()); + + // @ts-expect-error + expect.soft(value).toStrictEqual({ a: 1 }); + + // @ts-expect-error + expect.soft(value).toStrictEqual({ a: 'a' }); + + // @ts-expect-error + expect.soft(value).toStrictEqual({ c: { e: 2 } }); + + // @ts-expect-error + expect.soft([value]).toStrictEqual([{ a: 'a' }]); + + // @ts-expect-error + expect.soft([value]).toStrictEqual([{ c: { e: 2 } }]); + }); + ` + }); + expect(result.exitCode).toBe(0); +}); \ No newline at end of file diff --git a/tests/playwright-test/types.spec.ts b/tests/playwright-test/types.spec.ts index 6e19bbe305..c34c586f7a 100644 --- a/tests/playwright-test/types.spec.ts +++ b/tests/playwright-test/types.spec.ts @@ -324,77 +324,3 @@ test('config should allow void/empty options', async ({ runTSC }) => { }); expect(result.exitCode).toBe(0); }); - -test.fixme('should check types of overloaded toMatchObject with generic parameter', async ({ runTSC }) => { - const result = await runTSC({ - 'playwright.config.ts': ` - import { defineConfig } from '@playwright/test'; - - export default defineConfig({ - }); - `, - 'a.spec.ts': ` - import { test, expect } from '@playwright/test'; - test('my test', async () => { - const value = { a: 1, b: 'foo', c: { d: 2, e: 'bar' } }; - - expect.soft(value).toMatchObject({}); - expect.soft(value).toMatchObject({ a: 1 }); - expect.soft(value).toMatchObject({ a: 1, c: { e: 'bar' } }); - expect.soft([value]).toMatchObject([{ a: 1 }]); - expect.soft([value]).toMatchObject([{ a: 1, c: { e: 'bar' } }]); - - // @ts-expect-error - expect.soft(value).toMatchObject({ a: 'a' }); - - // @ts-expect-error - expect.soft(value).toMatchObject({ c: { e: 2 } }); - - // @ts-expect-error - expect.soft([value]).toMatchObject([{ a: 'a' }]); - - // @ts-expect-error - expect.soft([value]).toMatchObject([{ c: { e: 2 } }]); - }); - ` - }); - expect(result.exitCode).toBe(0); -}); - -test.fixme('should check types of overloaded toStrictEqual with generic parameter', async ({ runTSC }) => { - const result = await runTSC({ - 'playwright.config.ts': ` - import { defineConfig } from '@playwright/test'; - - export default defineConfig({ - }); - `, - 'a.spec.ts': ` - import { test, expect } from '@playwright/test'; - test('my test', async () => { - const value = { a: 1, b: 'foo', c: { d: 2, e: 'bar' } }; - - expect.soft(value).toStrictEqual({ a: 1, b: 'foo', c: { d: 2, e: 'bar' } }); - expect.soft([value]).toStrictEqual>([{ a: 1, b: 'foo', c: { d: 2, e: 'bar' } }]); - - expect.soft(new Date()).toStrictEqual(new Date()); - - // @ts-expect-error - expect.soft(value).toStrictEqual({ a: 1 }); - - // @ts-expect-error - expect.soft(value).toStrictEqual({ a: 'a' }); - - // @ts-expect-error - expect.soft(value).toStrictEqual({ c: { e: 2 } }); - - // @ts-expect-error - expect.soft([value]).toStrictEqual([{ a: 'a' }]); - - // @ts-expect-error - expect.soft([value]).toStrictEqual([{ c: { e: 2 } }]); - }); - ` - }); - expect(result.exitCode).toBe(0); -}); \ No newline at end of file