@@ -61,31 +61,33 @@ export async function getDocument(context?: Page): Promise<ElementHandle> {
61
61
return document
62
62
}
63
63
64
- export function extendObjectWithTestingUtils ( object : any , contextFn ?: ContextFn ) : void {
65
- object . queryByPlaceholderText = createDelegateFor ( 'queryByPlaceholderText' , contextFn )
66
- object . queryAllByPlaceholderText = createDelegateFor ( 'queryAllByPlaceholderText' , contextFn )
67
- object . getByPlaceholderText = createDelegateFor ( 'getByPlaceholderText' , contextFn )
68
- object . getAllByPlaceholderText = createDelegateFor ( 'getAllByPlaceholderText' , contextFn )
69
- object . queryByText = createDelegateFor ( 'queryByText' , contextFn )
70
- object . queryAllByText = createDelegateFor ( 'queryAllByText' , contextFn )
71
- object . getByText = createDelegateFor ( 'getByText' , contextFn )
72
- object . getAllByText = createDelegateFor ( 'getAllByText' , contextFn )
73
- object . queryByLabelText = createDelegateFor ( 'queryByLabelText' , contextFn )
74
- object . queryAllByLabelText = createDelegateFor ( 'queryAllByLabelText' , contextFn )
75
- object . getByLabelText = createDelegateFor ( 'getByLabelText' , contextFn )
76
- object . getAllByLabelText = createDelegateFor ( 'getAllByLabelText' , contextFn )
77
- object . queryByAltText = createDelegateFor ( 'queryByAltText' , contextFn )
78
- object . queryAllByAltText = createDelegateFor ( 'queryAllByAltText' , contextFn )
79
- object . getByAltText = createDelegateFor ( 'getByAltText' , contextFn )
80
- object . getAllByAltText = createDelegateFor ( 'getAllByAltText' , contextFn )
81
- object . queryByTestId = createDelegateFor ( 'queryByTestId' , contextFn )
82
- object . queryAllByTestId = createDelegateFor ( 'queryAllByTestId' , contextFn )
83
- object . getByTestId = createDelegateFor ( 'getByTestId' , contextFn )
84
- object . getAllByTestId = createDelegateFor ( 'getAllByTestId' , contextFn )
85
- object . queryByTitle = createDelegateFor ( 'queryByTitle' , contextFn )
86
- object . queryAllByTitle = createDelegateFor ( 'queryAllByTitle' , contextFn )
87
- object . getByTitle = createDelegateFor ( 'getByTitle' , contextFn )
88
- object . getAllByTitle = createDelegateFor ( 'getAllByTitle' , contextFn )
64
+ export function extendObjectWithTestingUtils < T > ( object : T , contextFn ?: ContextFn ) : T & ITestUtils {
65
+ const o = object as any
66
+ o . queryByPlaceholderText = createDelegateFor ( 'queryByPlaceholderText' , contextFn )
67
+ o . queryAllByPlaceholderText = createDelegateFor ( 'queryAllByPlaceholderText' , contextFn )
68
+ o . getByPlaceholderText = createDelegateFor ( 'getByPlaceholderText' , contextFn )
69
+ o . getAllByPlaceholderText = createDelegateFor ( 'getAllByPlaceholderText' , contextFn )
70
+ o . queryByText = createDelegateFor ( 'queryByText' , contextFn )
71
+ o . queryAllByText = createDelegateFor ( 'queryAllByText' , contextFn )
72
+ o . getByText = createDelegateFor ( 'getByText' , contextFn )
73
+ o . getAllByText = createDelegateFor ( 'getAllByText' , contextFn )
74
+ o . queryByLabelText = createDelegateFor ( 'queryByLabelText' , contextFn )
75
+ o . queryAllByLabelText = createDelegateFor ( 'queryAllByLabelText' , contextFn )
76
+ o . getByLabelText = createDelegateFor ( 'getByLabelText' , contextFn )
77
+ o . getAllByLabelText = createDelegateFor ( 'getAllByLabelText' , contextFn )
78
+ o . queryByAltText = createDelegateFor ( 'queryByAltText' , contextFn )
79
+ o . queryAllByAltText = createDelegateFor ( 'queryAllByAltText' , contextFn )
80
+ o . getByAltText = createDelegateFor ( 'getByAltText' , contextFn )
81
+ o . getAllByAltText = createDelegateFor ( 'getAllByAltText' , contextFn )
82
+ o . queryByTestId = createDelegateFor ( 'queryByTestId' , contextFn )
83
+ o . queryAllByTestId = createDelegateFor ( 'queryAllByTestId' , contextFn )
84
+ o . getByTestId = createDelegateFor ( 'getByTestId' , contextFn )
85
+ o . getAllByTestId = createDelegateFor ( 'getAllByTestId' , contextFn )
86
+ o . queryByTitle = createDelegateFor ( 'queryByTitle' , contextFn )
87
+ o . queryAllByTitle = createDelegateFor ( 'queryAllByTitle' , contextFn )
88
+ o . getByTitle = createDelegateFor ( 'getByTitle' , contextFn )
89
+ o . getAllByTitle = createDelegateFor ( 'getAllByTitle' , contextFn )
90
+ return o
89
91
}
90
92
91
93
// @ts -ignore
0 commit comments