-
-
Notifications
You must be signed in to change notification settings - Fork 177
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: 🏷️ Use generic return type for all jest matchers (#655)
This better aligns with jest documentation: https://archive.jestjs.io/docs/en/23.x/expect#expectextendmatchers and ensures that types can work properly with other jest extension libraries like jest-chain.
- Loading branch information
Showing
1 changed file
with
28 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,59 +1,59 @@ | ||
declare namespace jest { | ||
interface Matchers<R> { | ||
toExist(): boolean; | ||
toExist(): R; | ||
|
||
toHaveLength(expected: number): boolean; | ||
toHaveLength(expected: number): R; | ||
|
||
toHaveId(id: string | number): boolean; | ||
toHaveId(id: string | number): R; | ||
|
||
toHaveClass(className: string | string[], options?: { strict: boolean }): boolean; | ||
toHaveClass(className: string | string[], options?: { strict: boolean }): R; | ||
|
||
toHaveAttribute(attr: string | object, val?: string): boolean; | ||
toHaveAttribute(attr: string | object, val?: string): R; | ||
|
||
toHaveProperty(prop: string | object, val?: string | boolean): boolean; | ||
toHaveProperty(prop: string | object, val?: string | boolean): R; | ||
|
||
toContainProperty(prop: string | object, val?: string): boolean; | ||
toContainProperty(prop: string | object, val?: string): R; | ||
|
||
toHaveText(text: string | string[] | ((text: string) => boolean), exact?: boolean): boolean; | ||
toHaveText(text: string | string[] | ((text: string) => boolean), exact?: boolean): R; | ||
|
||
toContainText(text: string | string[] | ((text: string) => boolean), exact?: boolean): boolean; | ||
toContainText(text: string | string[] | ((text: string) => boolean), exact?: boolean): R; | ||
|
||
toHaveExactText(text: string | string[] | ((text: string) => boolean), options?: { trim: boolean }): boolean; | ||
toHaveExactText(text: string | string[] | ((text: string) => boolean), options?: { trim: boolean }): R; | ||
|
||
toHaveExactTrimmedText(text: string | string[] | ((text: string) => boolean)): boolean; | ||
toHaveExactTrimmedText(text: string | string[] | ((text: string) => boolean)): R; | ||
|
||
toHaveValue(value: string | string[]): boolean; | ||
toHaveValue(value: string | string[]): R; | ||
|
||
toContainValue(value: string | string[]): boolean; | ||
toContainValue(value: string | string[]): R; | ||
|
||
toHaveStyle(style: { [styleKey: string]: any }): boolean; | ||
toHaveStyle(style: { [styleKey: string]: any }): R; | ||
|
||
toHaveData({ data, val }: { data: string; val: string }): boolean; | ||
toHaveData({ data, val }: { data: string; val: string }): R; | ||
|
||
toBeChecked(): boolean; | ||
toBeChecked(): R; | ||
|
||
toBeIndeterminate(): boolean; | ||
toBeIndeterminate(): R; | ||
|
||
toBeDisabled(): boolean; | ||
toBeDisabled(): R; | ||
|
||
toBeEmpty(): boolean; | ||
toBeEmpty(): R; | ||
|
||
toBePartial(partial: object): boolean; | ||
toBePartial(partial: object): R; | ||
|
||
toBeHidden(): boolean; | ||
toBeHidden(): R; | ||
|
||
toBeSelected(): boolean; | ||
toBeSelected(): R; | ||
|
||
toBeVisible(): boolean; | ||
toBeVisible(): R; | ||
|
||
toBeFocused(): boolean; | ||
toBeFocused(): R; | ||
|
||
toBeMatchedBy(selector: string | Element): boolean; | ||
toBeMatchedBy(selector: string | Element): R; | ||
|
||
toHaveDescendant(selector: string | Element): boolean; | ||
toHaveDescendant(selector: string | Element): R; | ||
|
||
toHaveDescendantWithText({ selector, text }: { selector: string; text: string }): boolean; | ||
toHaveDescendantWithText({ selector, text }: { selector: string; text: string }): R; | ||
|
||
toHaveSelectedOptions(expected: string | string[] | HTMLOptionElement | HTMLOptionElement[]): boolean; | ||
toHaveSelectedOptions(expected: string | string[] | HTMLOptionElement | HTMLOptionElement[]): R; | ||
} | ||
} |