-
-
Notifications
You must be signed in to change notification settings - Fork 28
/
index.d.ts
106 lines (99 loc) · 2.64 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
/// <reference types="cypress" />
declare namespace Cypress {
interface RESQNode {
name: string;
node: HTMLElement | null;
isFragment: boolean;
state: string | boolean | any[] | {};
props: {};
children: RESQNode[];
}
interface reactOpts {
props: {};
state: {};
root: string;
}
interface Chainable {
/**
* Wait until the React's component tree is loaded. Call `cy.waitForReact()` in your test's `before` hook.
* @example
* before(() => {
* cy.visit('http://localhost:3000/myApp');
* cy.waitForReact();
* });
*
* @param timeout
* @param reactRoot
* @param resqModulePath
*/
waitForReact(
timeout?: number,
reactRoot?: string,
resqModulePath?: string
): void;
/**
* Get react elements by component, props and states
* @see https://github.com/abhinaba-ghosh/cypress-react-selector/blob/master/cypress/integration/react-selector.spec.js
* @example
* cy.react(`MyComponent`).should('have.length', 10)
* cy.react('MyComponent',{name:'Bill'}).should('have.length', 1)
*/
react<E extends Node = HTMLElement>(
component: string,
reactOpts?: {
props?: object;
state?: object;
exact?: boolean;
root?: string;
options?: Partial<Loggable & Timeoutable>;
}
): Chainable<JQuery<E>>;
/**
* Get React Node by component, props and state
*
* @example
* cy.getReact('MyComponent')
* cy.getReact('MyComponent',{name:'Bill'})
* @param component
* @param props
* @param state
*/
getReact(
component: string,
reactOpts?: {
props?: object;
state?: object;
exact?: boolean;
root?: string;
options?: Partial<Loggable & Timeoutable>;
}
): Chainable<RESQNode>;
/**
* Get prop value from React Node.
* @note
* This method should always be used with getReact() method
* @param propName
*
* @example
* cy.getReact('MyForm',{name:'email'}).getProps('value').should('eq','[email protected]')
*
* to get all props
* cy.getReact('MyForm',{name:'email'}).getProps()
*/
getProps(propName?: string): Chainable<any>;
/**
* Get current state from React Node.
* @note
* This method should always be used with getReact() method
*/
getCurrentState(): Chainable<any>;
/**
* Get the nthNode using index
* @param index
*
* @example
* cy.getReact('Product').nthNode(0).getProps('name').should('eq', 'First item');
*/
nthNode(index: number): Chainable<any>;
}
}