|
1 | | -// I hope to get types and docs from functions imported from ./index one day |
2 | | -// but for now have to document methods in both places |
3 | | -// like this: import {mount} from './index' |
4 | | - |
5 | | -interface ReactModule { |
6 | | - name: string |
7 | | - type: string |
8 | | - location: string |
9 | | - source: string |
10 | | -} |
11 | | - |
12 | | -/** |
13 | | - * The `type` property from the transpiled JSX object. |
14 | | - * @example |
15 | | - * const { type } = React.createElement('div', null, 'Hello') |
16 | | - * const { type } = <div>Hello</div> |
17 | | - */ |
18 | | -interface JSX extends Function { |
19 | | - displayName: string |
20 | | -} |
21 | | - |
22 | | -declare namespace Cypress { |
23 | | - interface Cypress { |
24 | | - stylesCache: any |
25 | | - React: string |
26 | | - ReactDOM: string |
27 | | - Styles: string |
28 | | - modules: ReactModule[] |
29 | | - } |
30 | | - |
31 | | - // NOTE: By default, avoiding React.Component/Element typings |
32 | | - // for many cases, we don't want to import @types/react |
33 | | - interface Chainable<Subject> { |
34 | | - state: (key) => any, |
35 | | - injectReactDOM: () => Chainable<void> |
36 | | - copyComponentStyles: (component: Symbol) => Chainable<void> |
37 | | - /** |
38 | | - * Mount a React component in a blank document; register it as an alias |
39 | | - * To access: use an alias or original component reference |
40 | | - * @function cy.mount |
41 | | - * @param {Object} jsx - component to mount |
42 | | - * @param {string} [Component] - alias to use later |
43 | | - * @example |
44 | | - ``` |
45 | | - import Hello from './hello.jsx' |
46 | | - // mount and access by alias |
47 | | - cy.mount(<Hello />, 'Hello') |
48 | | - // using default alias |
49 | | - cy.get('@Component') |
50 | | - // using specified alias |
51 | | - cy.get('@Hello').its('state').should(...) |
52 | | - // using original component |
53 | | - cy.get(Hello) |
54 | | - ``` |
55 | | - **/ |
56 | | - mount: (component: Symbol, alias?: string) => Chainable<void> |
57 | | - get<S = any>(alias: string | symbol | Function, options?: Partial<Loggable & Timeoutable>): Chainable<any> |
58 | | - } |
59 | | -} |
| 1 | +// I hope to get types and docs from functions imported from ./index one day |
| 2 | +// but for now have to document methods in both places |
| 3 | +// like this: import {mount} from './index' |
| 4 | + |
| 5 | +interface ReactModule { |
| 6 | + name: string |
| 7 | + type: string |
| 8 | + location: string |
| 9 | + source: string |
| 10 | +} |
| 11 | + |
| 12 | +/** |
| 13 | + * The `type` property from the transpiled JSX object. |
| 14 | + * @example |
| 15 | + * const { type } = React.createElement('div', null, 'Hello') |
| 16 | + * const { type } = <div>Hello</div> |
| 17 | + */ |
| 18 | +interface JSX extends Function { |
| 19 | + displayName: string |
| 20 | +} |
| 21 | + |
| 22 | +interface JSXElement { |
| 23 | + type: JSX |
| 24 | + props: object |
| 25 | +} |
| 26 | + |
| 27 | +declare namespace Cypress { |
| 28 | + interface Cypress { |
| 29 | + stylesCache: any |
| 30 | + React: string |
| 31 | + ReactDOM: string |
| 32 | + Styles: string |
| 33 | + modules: ReactModule[] |
| 34 | + } |
| 35 | + |
| 36 | + // NOTE: By default, avoiding React.Component/Element typings |
| 37 | + // for many cases, we don't want to import @types/react |
| 38 | + interface Chainable<Subject> { |
| 39 | + state: (key: any) => any, |
| 40 | + injectReactDOM: () => Chainable<void> |
| 41 | + copyComponentStyles: (component: JSXElement) => Chainable<void> |
| 42 | + /** |
| 43 | + * Mount a React component in a blank document; register it as an alias |
| 44 | + * To access: use an alias or original component reference |
| 45 | + * @function cy.mount |
| 46 | + * @param {Object} jsx - component to mount |
| 47 | + * @param {string} [Component] - alias to use later |
| 48 | + * @example |
| 49 | + ``` |
| 50 | + import Hello from './hello.jsx' |
| 51 | + // mount and access by alias |
| 52 | + cy.mount(<Hello />, 'Hello') |
| 53 | + // using default alias |
| 54 | + cy.get('@Component') |
| 55 | + // using specified alias |
| 56 | + cy.get('@Hello').its('state').should(...) |
| 57 | + // using original component |
| 58 | + cy.get(Hello) |
| 59 | + ``` |
| 60 | + **/ |
| 61 | + mount: (component: JSXElement, alias?: string) => Chainable<void> |
| 62 | + get<S = any>(alias: string | symbol | Function, options?: Partial<Loggable & Timeoutable>): Chainable<any> |
| 63 | + } |
| 64 | +} |
0 commit comments