diff --git a/docs/src/release-notes-csharp.md b/docs/src/release-notes-csharp.md index 400b3c0104..5d28afaf0f 100644 --- a/docs/src/release-notes-csharp.md +++ b/docs/src/release-notes-csharp.md @@ -327,7 +327,7 @@ Playwright Trace Viewer is now **available online** at https://trace.playwright. ![image](https://user-images.githubusercontent.com/746130/141877402-e486643d-72c7-4db3-8844-ed2072c5d676.png) -## Ubuntu ARM64 support + more +### Ubuntu ARM64 support + more - Playwright now supports **Ubuntu 20.04 ARM64**. You can now run Playwright tests inside Docker on Apple M1 and on Raspberry Pi. - You can now use Playwright to install stable version of Edge on Linux: diff --git a/packages/playwright-test/types/test.d.ts b/packages/playwright-test/types/test.d.ts index b231ec13cd..3f61e29531 100644 --- a/packages/playwright-test/types/test.d.ts +++ b/packages/playwright-test/types/test.d.ts @@ -3029,6 +3029,23 @@ import type { Suite } from '@playwright/test/types/testReporter'; type AsymmetricMatcher = Record; +type AsymmetricMatchers = { + any(sample: unknown): AsymmetricMatcher; + anything(): AsymmetricMatcher; + arrayContaining(sample: Array): AsymmetricMatcher; + closeTo(sample: number, precision?: number): AsymmetricMatcher; + objectContaining(sample: Record): AsymmetricMatcher; + stringContaining(sample: string): AsymmetricMatcher; + stringMatching(sample: string | RegExp): AsymmetricMatcher; +} + +type Inverse = { + /** + * Inverse next matcher. If you know how to test something, `.not` lets you test its opposite. + */ + not: Matchers; +}; + type IfAny = 0 extends (1 & T) ? Y : N; type ExtraMatchers = T extends Type ? Matchers : IfAny; @@ -3054,6 +3071,16 @@ type MakeMatchers = BaseMatchers & { ExtraMatchers & ExtraMatchers; +type BaseExpect = { + // Removed following methods because they rely on a test-runner integration from Jest which we don't support: + // assertions(numberOfAssertions: number): void; + // extractExpectedAssertionsErrors(): ExpectedAssertionsErrors; + // hasAssertions(): void; + extend(matchers: any): void; + getState(): expectType.MatcherState; + setState(state: Partial): void; +} + export type Expect = { (actual: T, messageOrOptions?: string | { message?: string }): MakeMatchers; soft: (actual: T, messageOrOptions?: string | { message?: string }) => MakeMatchers; @@ -3063,23 +3090,9 @@ export type Expect = { */ not: BaseMatchers, T>; }; - - extend(arg0: any): void; - getState(): expectType.MatcherState; - setState(state: Partial): void; - any(expectedObject: any): AsymmetricMatcher; - anything(): AsymmetricMatcher; - arrayContaining(sample: Array): AsymmetricMatcher; - objectContaining(sample: Record): AsymmetricMatcher; - stringContaining(expected: string): AsymmetricMatcher; - stringMatching(expected: string | RegExp): AsymmetricMatcher; - /** - * Removed following methods because they rely on a test-runner integration from Jest which we don't support: - * - assertions() - * - extractExpectedAssertionsErrors() - * – hasAssertions() - */ -}; +} & BaseExpect & + AsymmetricMatchers & + Inverse>; type Awaited = T extends PromiseLike ? U : T; diff --git a/tests/playwright-test/expect.spec.ts b/tests/playwright-test/expect.spec.ts index 4c7051ce88..dd21af5a49 100644 --- a/tests/playwright-test/expect.spec.ts +++ b/tests/playwright-test/expect.spec.ts @@ -114,6 +114,7 @@ test('should work with default expect prototype functions', async ({ runTSC, run ); expect('foo').toEqual(expect.any(String)); expect('foo').toEqual(expect.anything()); + expect('hello world').toEqual(expect.not.stringContaining('text')); }); `; { diff --git a/utils/generate_types/index.js b/utils/generate_types/index.js index 2211f04753..a0219a5283 100644 --- a/utils/generate_types/index.js +++ b/utils/generate_types/index.js @@ -99,7 +99,6 @@ class TypesGenerator { return this.writeComment(docClass.comment) + '\n'; }, (className, methodName, overloadIndex) => { if (className === 'SuiteFunction' && methodName === '__call') { - console.log(className, methodName, overloadIndex); const cls = this.documentation.classes.get('Test'); const method = cls.membersArray.find(m => m.alias === 'describe' && m.overloadIndex === overloadIndex); return this.memberJSDOC(method, ' ').trimLeft(); diff --git a/utils/generate_types/overrides-test.d.ts b/utils/generate_types/overrides-test.d.ts index 44c584ecd3..ca0bb5f9ca 100644 --- a/utils/generate_types/overrides-test.d.ts +++ b/utils/generate_types/overrides-test.d.ts @@ -256,6 +256,23 @@ import type { Suite } from '@playwright/test/types/testReporter'; type AsymmetricMatcher = Record; +type AsymmetricMatchers = { + any(sample: unknown): AsymmetricMatcher; + anything(): AsymmetricMatcher; + arrayContaining(sample: Array): AsymmetricMatcher; + closeTo(sample: number, precision?: number): AsymmetricMatcher; + objectContaining(sample: Record): AsymmetricMatcher; + stringContaining(sample: string): AsymmetricMatcher; + stringMatching(sample: string | RegExp): AsymmetricMatcher; +} + +type Inverse = { + /** + * Inverse next matcher. If you know how to test something, `.not` lets you test its opposite. + */ + not: Matchers; +}; + type IfAny = 0 extends (1 & T) ? Y : N; type ExtraMatchers = T extends Type ? Matchers : IfAny; @@ -281,6 +298,16 @@ type MakeMatchers = BaseMatchers & { ExtraMatchers & ExtraMatchers; +type BaseExpect = { + // Removed following methods because they rely on a test-runner integration from Jest which we don't support: + // assertions(numberOfAssertions: number): void; + // extractExpectedAssertionsErrors(): ExpectedAssertionsErrors; + // hasAssertions(): void; + extend(matchers: any): void; + getState(): expectType.MatcherState; + setState(state: Partial): void; +} + export type Expect = { (actual: T, messageOrOptions?: string | { message?: string }): MakeMatchers; soft: (actual: T, messageOrOptions?: string | { message?: string }) => MakeMatchers; @@ -290,23 +317,9 @@ export type Expect = { */ not: BaseMatchers, T>; }; - - extend(arg0: any): void; - getState(): expectType.MatcherState; - setState(state: Partial): void; - any(expectedObject: any): AsymmetricMatcher; - anything(): AsymmetricMatcher; - arrayContaining(sample: Array): AsymmetricMatcher; - objectContaining(sample: Record): AsymmetricMatcher; - stringContaining(expected: string): AsymmetricMatcher; - stringMatching(expected: string | RegExp): AsymmetricMatcher; - /** - * Removed following methods because they rely on a test-runner integration from Jest which we don't support: - * - assertions() - * - extractExpectedAssertionsErrors() - * – hasAssertions() - */ -}; +} & BaseExpect & + AsymmetricMatchers & + Inverse>; type Awaited = T extends PromiseLike ? U : T;