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
fix(types): accept string in expect().toMatch() (#21454)
Max Schmittc9eac69f2bfb
diff --git a/docs/src/api/class-genericassertions.md b/docs/src/api/class-genericassertions.mdindex f93970bc25..0fe46efd31 100644--- a/docs/src/api/class-genericassertions.md+++ b/docs/src/api/class-genericassertions.md@@ -418,7 +418,7 @@ expect(value).toMatch(/Is \d+ enough/);### param: GenericAssertions.toMatch.expected* since: v1.9-- `expected` <[RegExp]>+- `expected` <[RegExp]|[string]>Regular expression to match against.diff --git a/packages/playwright-test/types/test.d.ts b/packages/playwright-test/types/test.d.tsindex edc5acb3ab..93cb1ab7a9 100644--- a/packages/playwright-test/types/test.d.ts+++ b/packages/playwright-test/types/test.d.ts@@ -4149,7 +4149,7 @@ interface GenericAssertions<R> {** @param expected Regular expression to match against.*/- toMatch(expected: RegExp): R;+ toMatch(expected: RegExp | string): R;/*** Compares contents of the value with contents of `expected`, performing "deep equality" check. Allows extra* properties to be present in the value, unlikediff --git a/tests/playwright-test/expect.spec.ts b/tests/playwright-test/expect.spec.tsindex 52af2e462c..34c2aec8c8 100644--- a/tests/playwright-test/expect.spec.ts+++ b/tests/playwright-test/expect.spec.ts@@ -157,6 +157,7 @@ test('should work with generic matchers', async ({ runTSC }) => {expect({}).toEqual({});expect([1, 2]).toHaveLength(2);expect('abc').toMatch(/a.?c/);+ expect('abc').toMatch('abc');expect({ a: 1, b: 2 }).toMatchObject({ a: 1 });expect({}).toStrictEqual({});expect(() => { throw new Error('Something bad'); }).toThrow('something');diff --git a/utils/generate_types/overrides-test.d.ts b/utils/generate_types/overrides-test.d.tsindex 5e5eeb3b3b..d441b59594 100644--- a/utils/generate_types/overrides-test.d.ts+++ b/utils/generate_types/overrides-test.d.ts@@ -302,7 +302,7 @@ interface GenericAssertions<R> {toEqual(expected: unknown): R;toHaveLength(expected: number): R;toHaveProperty(keyPath: string | Array<string>, value?: unknown): R;- toMatch(expected: RegExp): R;+ toMatch(expected: RegExp | string): R;toMatchObject(expected: Record<string, unknown> | Array<unknown>): R;toStrictEqual(expected: unknown): R;toThrow(error?: unknown): R;