-
Notifications
You must be signed in to change notification settings - Fork 3.2k
/
cypress.d.ts
6593 lines (6249 loc) · 255 KB
/
cypress.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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/* eslint-disable @typescript-eslint/no-unused-vars */
/// <reference path="./cypress-npm-api.d.ts" />
/// <reference path="./cypress-eventemitter.d.ts" />
/// <reference path="./cypress-type-helpers.d.ts" />
declare namespace Cypress {
type FileContents = string | any[] | object
type HistoryDirection = 'back' | 'forward'
type HttpMethod = string
type RequestBody = string | object | boolean | null
type ViewportOrientation = 'portrait' | 'landscape'
type PrevSubject = keyof PrevSubjectMap
type TestingType = 'e2e' | 'component'
type PluginConfig = (on: PluginEvents, config: PluginConfigOptions) => void | ConfigOptions | Promise<ConfigOptions>
interface JQueryWithSelector<TElement = HTMLElement> extends JQuery<TElement> {
selector?: string | null
}
interface PrevSubjectMap<O = unknown> {
optional: O
element: JQueryWithSelector
document: Document
window: Window
}
interface CommandOptions {
prevSubject: boolean | PrevSubject | PrevSubject[]
}
interface CommandFn<T extends keyof ChainableMethods> {
(this: Mocha.Context, ...args: Parameters<ChainableMethods[T]>): ReturnType<ChainableMethods[T]> | void
}
interface CommandFns {
[name: string]: (this: Mocha.Context, ...args: any) => any
}
interface CommandFnWithSubject<T extends keyof ChainableMethods, S> {
(this: Mocha.Context, prevSubject: S, ...args: Parameters<ChainableMethods[T]>): ReturnType<ChainableMethods[T]> | void
}
interface CommandFnsWithSubject<S> {
[name: string]: (this: Mocha.Context, prevSubject: S, ...args: any) => any
}
interface CommandOriginalFn<T extends keyof ChainableMethods> extends CallableFunction {
(...args: Parameters<ChainableMethods[T]>): ReturnType<ChainableMethods[T]>
}
interface CommandOriginalFnWithSubject<T extends keyof ChainableMethods, S> extends CallableFunction {
(prevSubject: S, ...args: Parameters<ChainableMethods[T]>): ReturnType<ChainableMethods[T]>
}
interface CommandFnWithOriginalFn<T extends keyof Chainable> {
(this: Mocha.Context, originalFn: CommandOriginalFn<T>, ...args: Parameters<ChainableMethods[T]>): ReturnType<ChainableMethods[T]> | void
}
interface CommandFnWithOriginalFnAndSubject<T extends keyof Chainable, S> {
(this: Mocha.Context, originalFn: CommandOriginalFnWithSubject<T, S>, prevSubject: S, ...args: Parameters<ChainableMethods[T]>): ReturnType<ChainableMethods[T]> | void
}
interface QueryFn<T extends keyof ChainableMethods> {
(this: Command, ...args: Parameters<ChainableMethods[T]>): (subject: any) => any
}
interface QueryFnWithOriginalFn<T extends keyof Chainable> {
(this: Command, originalFn: QueryFn<T>, ...args: Parameters<ChainableMethods[T]>): (subject: any) => any
}
interface ObjectLike {
[key: string]: any
}
interface Auth {
username: string
password: string
}
interface RemoteState {
auth?: Auth
domainName: string
strategy: 'file' | 'http'
origin: string
fileServer: string | null
props: Record<string, any>
visiting: string
}
interface Backend {
/**
* Firefox only: Force Cypress to run garbage collection routines.
* No-op if not running in Firefox.
*
* @see https://on.cypress.io/firefox-gc-issue
*/
(task: 'firefox:force:gc'): Promise<void>
(task: 'net', eventName: string, frame: any): Promise<void>
}
type BrowserName = 'electron' | 'chrome' | 'chromium' | 'firefox' | 'edge' | string
type BrowserChannel = 'stable' | 'canary' | 'beta' | 'dev' | 'nightly' | string
type BrowserFamily = 'chromium' | 'firefox' | 'webkit'
/**
* Describes a browser Cypress can control
*/
interface Browser {
/**
* Short browser name.
*/
name: BrowserName
/**
* The underlying engine for this browser.
*/
family: BrowserFamily
/**
* The release channel of the browser.
*/
channel: BrowserChannel
/**
* Human-readable browser name.
*/
displayName: string
version: string
majorVersion: number | string
path: string
isHeaded: boolean
isHeadless: boolean
/**
* Informational text to accompany this browser. Shown in desktop-gui.
*/
info?: string
/**
* Warning text to accompany this browser. Shown in desktop-gui.
*/
warning?: string
/**
* The minimum majorVersion of this browser supported by Cypress.
*/
minSupportedVersion?: number
/**
* If `true`, this browser is too old to be supported by Cypress.
*/
unsupportedVersion?: boolean
}
/**
* Browser that's exposed in public APIs
*/
interface PublicBrowser {
channel: BrowserChannel
displayName: string
family: string
majorVersion?: string | number | null
name: BrowserName
path: string
version: string
}
interface Ensure {
/**
* Throws an error if `subject` is not one of the passed in `type`s.
*/
isType(subject: any, type: PrevSubject[], commandName: string, cy: Chainable): void
/**
* Throws an error if `subject` is not a DOM element.
*/
isElement(subject: any, commandName: string, cy: Chainable): void
/**
* Throws an error if `subject` is not a `document`.
*/
isDocument(subject: any, commandName: string, cy: Chainable): void
/**
* Throws an error if `subject` is not a `window`.
*/
isWindow(subject: any, commandName: string, cy: Chainable): void
/**
* Throws an error if `subject` is not a DOM element attached to the application under test.
*/
isAttached(subject: any, commandName: string, cy: Chainable, onFail?: Log): void
/**
* Throws an error if `subject` is a disabled DOM element.
*/
isNotDisabled(subject: any, commandName: string, onFail?: Log): void
/**
* Throws an error if `subject` is a DOM element hidden by any of its parent elements.
*/
isNotHiddenByAncestors(subject: any, commandName: string, onFail?: Log): void
/**
* Throws an error if `subject` is a read-only form element.
*/
isNotReadonly(subject: any, commandName: string, onFail?: Log): void
/**
* Throws an error if `subject` is a read-only form element.
*/
isScrollable(subject: any, commandName: string, onFail?: Log): void
/**
* Throws an error if `subject` is not a DOM element visible in the AUT.
*/
isVisible(subject: any, commandName: string, onFail?: Log): void
}
interface LocalStorage {
/**
* Called internally to clear `localStorage` in two situations.
*
* 1. Before every test, this is called with no argument to clear all keys.
* 2. On `cy.clearLocalStorage(keys)` this is called with `keys` as an argument.
*
* You should not call this method directly to clear `localStorage`; instead, use `cy.clearLocalStorage(key)`.
*
* @see https://on.cypress.io/clearlocalstorage
*/
clear: (keys?: string[]) => void
}
// TODO: raise minimum required TypeScript version to 3.7
// and make this recursive
// https://github.com/cypress-io/cypress/issues/24875
type Storable =
| string
| number
| boolean
| null
| StorableObject
| StorableArray
interface StorableObject {
[key: string]: Storable
}
interface StorableArray extends Array<Storable> { }
type StorableRecord = Record<string, Storable>
interface OriginStorage {
origin: string
value: StorableRecord
}
interface Storages {
localStorage: OriginStorage[]
sessionStorage: OriginStorage[]
}
interface StorageByOrigin {
[key: string]: StorableRecord
}
type IsBrowserMatcher = BrowserName | Partial<Browser> | Array<BrowserName | Partial<Browser>>
interface ViewportPosition extends WindowPosition {
right: number
bottom: number
}
interface WindowPosition {
top: number
left: number
topCenter: number
leftCenter: number
}
interface ElementPositioning {
scrollTop: number
scrollLeft: number
width: number
height: number
fromElViewport: ViewportPosition
fromElWindow: WindowPosition
fromAutWindow: WindowPosition
}
interface ElementCoordinates {
width: number
height: number
fromElViewport: ViewportPosition & { x: number, y: number }
fromElWindow: WindowPosition & { x: number, y: number }
fromAutWindow: WindowPosition & { x: number, y: number }
}
/**
* Spec type for the given test. "integration" is the default, but
* tests run using `open --component` will be "component"
*
* @see https://on.cypress.io/experiments
*/
type CypressSpecType = 'integration' | 'component'
/**
* A Cypress spec.
*/
interface Spec {
name: string // "config_passing_spec.js"
relative: string // "cypress/e2e/config_passing_spec.cy.js" or "__all" if clicked all specs button
absolute: string // "/Users/janelane/app/cypress/e2e/config_passing_spec.cy.js"
specFilter?: string // optional spec filter used by the user
specType?: CypressSpecType
baseName?: string // "config_passing_spec.cy.js"
fileExtension?: string // ".js"
fileName?: string // "config_passing_spec.cy"
id?: string // "U3BlYzovVXNlcnMvamFuZWxhbmUvYXBwL2N5cHJlc3MvZTJlL2NvbmZpZ19wYXNzaW5nX3NwZWMuY3kuanM="
}
/**
* Window type for Application Under Test(AUT)
*/
type AUTWindow = Window & typeof globalThis & ApplicationWindow
/**
* The interface for user-defined properties in Window object under test.
*/
interface ApplicationWindow { } // tslint:disable-line
/**
* The configuration for Cypress.
*/
type Config = ResolvedConfigOptions & RuntimeConfigOptions & RuntimeServerConfigOptions
/**
* Several libraries are bundled with Cypress by default.
*
* @see https://on.cypress.io/api
*/
interface Cypress {
/**
* Lodash library
*
* @see https://on.cypress.io/_
* @example
* Cypress._.keys(obj)
*/
_: _.LoDashStatic
/**
* jQuery library
*
* @see https://on.cypress.io/$
* @example
* Cypress.$('p')
*/
$: JQueryStatic
/**
* Cypress automatically includes a Blob library and exposes it as Cypress.Blob.
*
* @see https://on.cypress.io/blob
* @see https://github.com/nolanlawson/blob-util
* @example
* Cypress.Blob.method()
*/
Blob: BlobUtil.BlobUtilStatic
/**
* Cypress automatically includes a Buffer library and exposes it as Cypress.Buffer.
*
* @see https://on.cypress.io/buffer
* @see https://github.com/feross/buffer
* @example
* Cypress.Buffer.method()
*/
Buffer: BufferType
/**
* Cypress automatically includes minimatch and exposes it as Cypress.minimatch.
*
* @see https://on.cypress.io/minimatch
*/
minimatch: typeof Minimatch.minimatch
/**
* Cypress automatically includes Bluebird and exposes it as Cypress.Promise.
*
* @see https://on.cypress.io/promise
* @see https://github.com/petkaantonov/bluebird
* @example
* new Cypress.Promise((resolve, reject) => { ... })
*/
Promise: Bluebird.BluebirdStatic
/**
* Cypress includes Sinon.js library used in `cy.spy` and `cy.stub`.
*
* @see https://sinonjs.org/
* @see https://on.cypress.io/stubs-spies-and-clocks
* @see https://example.cypress.io/commands/spies-stubs-clocks
*/
sinon: sinon.SinonStatic
/**
* Utility functions for ensuring various properties about a subject.
* @see https://on.cypress.io/api/custom-queries
*/
ensure: Ensure
/**
* Cypress version string. i.e. "1.1.2"
* @see https://on.cypress.io/version
* @example
```
expect(Cypress.version).to.be.a('string')
if (Cypress.version === '1.2.0') {
// test something specific
}
```
*/
version: string
/**
* OS platform name, from Node `os.platform()`
*
* @see https://nodejs.org/api/os.html#os_os_platform
* @example
* Cypress.platform // "darwin"
*/
platform: string
/**
* CPU architecture, from Node `os.arch()`
*
* @see https://nodejs.org/api/os.html#os_os_arch
* @example
* Cypress.arch // "x64"
*/
arch: string
/**
* Currently executing spec file.
* @example
* ```
* Cypress.spec
* // {
* // name: "config_passing_spec.coffee",
* // relative: "cypress/integration/config_passing_spec.coffee",
* // absolute: "/users/smith/projects/web/cypress/integration/config_passing_spec.coffee"
* // specType: "integration"
* // }
* ```
*/
spec: Spec
/**
* Currently executing test runnable instance.
*/
currentTest: {
title: string
titlePath: string[]
}
/**
* Information about current test retry
*/
currentRetry: number
/**
* Information about the browser currently running the tests
*/
browser: Browser
/**
* Internal class for LocalStorage management.
*/
LocalStorage: LocalStorage
/**
* Internal class for session management.
*/
session: Session
/**
* Current testing type, determined by the Test Runner chosen to run.
*/
testingType: TestingType
/**
* Fire automation:request event for internal use.
*/
automation(eventName: string, ...args: any[]): Bluebird.Promise<any>
/**
* Promise wrapper for certain internal tasks.
*/
backend: Backend
/**
* Returns all configuration objects.
* @see https://on.cypress.io/config
* @example
```
Cypress.config()
// {defaultCommandTimeout: 10000, pageLoadTimeout: 30000, ...}
```
*/
config(): Config
/**
* Returns one configuration value.
* @see https://on.cypress.io/config
* @example
```
Cypress.config('pageLoadTimeout')
// 60000
```
*/
config<K extends keyof Config>(key: K): Config[K]
/**
* Sets one configuration value.
* @see https://on.cypress.io/config
* @example
```
Cypress.config('viewportWidth', 800)
```
*/
config<K extends keyof TestConfigOverrides>(key: K, value: TestConfigOverrides[K]): void
/**
* Sets multiple configuration values at once.
* @see https://on.cypress.io/config
* @example
```
Cypress.config({
defaultCommandTimeout: 10000,
viewportHeight: 900
})
```
*/
config(Object: TestConfigOverrides): void
// no real way to type without generics
/**
* Returns all environment variables set with CYPRESS_ prefix or in "env" object in "cypress.config.{js,ts,mjs,cjs}"
*
* @see https://on.cypress.io/env
*/
env(): ObjectLike
/**
* Returns specific environment variable or undefined
* @see https://on.cypress.io/env
* @example
* // cypress.config.js
* { "env": { "foo": "bar" } }
* Cypress.env("foo") // => bar
*/
env(key: string): any
/**
* Set value for a variable.
* Any value you change will be permanently changed for the remainder of your tests.
* @see https://on.cypress.io/env
* @example
* Cypress.env("host", "http://server.dev.local")
*/
env(key: string, value: any): void
/**
* Set values for multiple variables at once. Values are merged with existing values.
* @see https://on.cypress.io/env
* @example
* Cypress.env({ host: "http://server.dev.local", foo: "foo" })
*/
env(object: ObjectLike): void
/**
* @returns the number of test retries currently enabled for the run
*/
getTestRetries(): number | null
/**
* Checks if a variable is a valid instance of `cy` or a `cy` chainable.
*
* @see https://on.cypress.io/iscy
* @example
* Cypress.isCy(cy) // => true
*/
isCy<TSubject = any>(obj: Chainable<TSubject>): obj is Chainable<TSubject>
isCy(obj: any): obj is Chainable
/**
* Returns true if currently running the supplied browser name or matcher object. Also accepts an array of matchers.
* @example isBrowser('chrome') will be true for the browser 'chrome:canary' and 'chrome:stable'
* @example isBrowser({ name: 'firefox', channel: 'dev' }) will be true only for the browser 'firefox:dev' (Firefox Developer Edition)
* @example isBrowser(['firefox', 'edge']) will be true only for the browsers 'firefox' and 'edge'
* @example isBrowser('!firefox') will be true for every browser other than 'firefox'
* @example isBrowser({ family: '!chromium'}) will be true for every browser not matching { family: 'chromium' }
* @param matcher browser name or matcher object to check.
*/
isBrowser(name: IsBrowserMatcher): boolean
/**
* Internal options for "cy.log" used in custom commands.
*
* @see https://on.cypress.io/cypress-log
*/
log(options: Partial<LogConfig>): Log
Commands: {
/**
* Add a custom command
* @see https://on.cypress.io/api/commands
*/
add<T extends keyof Chainable>(name: T, fn: CommandFn<T>): void
/**
* Add a custom parent command
* @see https://on.cypress.io/api/commands#Parent-Commands
*/
add<T extends keyof Chainable>(name: T, options: CommandOptions & { prevSubject: false }, fn: CommandFn<T>): void
/**
* Add a custom child command
* @see https://on.cypress.io/api/commands#Child-Commands
*/
add<T extends keyof Chainable, S = any>(name: T, options: CommandOptions & { prevSubject: true }, fn: CommandFnWithSubject<T, S>): void
/**
* Add a custom child or dual command
* @see https://on.cypress.io/api/commands#Validations
*/
add<T extends keyof Chainable, S extends PrevSubject>(
name: T, options: CommandOptions & { prevSubject: S | ['optional'] }, fn: CommandFnWithSubject<T, PrevSubjectMap[S]>,
): void
/**
* Add a custom command that allows multiple types as the prevSubject
* @see https://on.cypress.io/api/commands#Validations#Allow-Multiple-Types
*/
add<T extends keyof Chainable, S extends PrevSubject>(
name: T, options: CommandOptions & { prevSubject: S[] }, fn: CommandFnWithSubject<T, PrevSubjectMap<void>[S]>,
): void
/**
* Add one or more custom commands
* @see https://on.cypress.io/api/commands
*/
addAll<T extends keyof Chainable>(fns: CommandFns): void
/**
* Add one or more custom parent commands
* @see https://on.cypress.io/api/commands#Parent-Commands
*/
addAll<T extends keyof Chainable>(options: CommandOptions & { prevSubject: false }, fns: CommandFns): void
/**
* Add one or more custom child commands
* @see https://on.cypress.io/api/commands#Child-Commands
*/
addAll<T extends keyof Chainable, S = any>(options: CommandOptions & { prevSubject: true }, fns: CommandFnsWithSubject<S>): void
/**
* Add one or more custom commands that validate their prevSubject
* @see https://on.cypress.io/api/commands#Validations
*/
addAll<T extends keyof Chainable, S extends PrevSubject>(
options: CommandOptions & { prevSubject: S | ['optional'] }, fns: CommandFnsWithSubject<PrevSubjectMap[S]>,
): void
/**
* Add one or more custom commands that allow multiple types as their prevSubject
* @see https://on.cypress.io/api/commands#Allow-Multiple-Types
*/
addAll<T extends keyof Chainable, S extends PrevSubject>(
options: CommandOptions & { prevSubject: S[] }, fns: CommandFnsWithSubject<PrevSubjectMap<void>[S]>,
): void
/**
* Overwrite an existing Cypress command with a new implementation
* @see https://on.cypress.io/api/commands#Overwrite-Existing-Commands
*/
overwrite<T extends keyof Chainable>(name: T, fn: CommandFnWithOriginalFn<T>): void
/**
* Overwrite an existing Cypress command with a new implementation
* @see https://on.cypress.io/api/commands#Overwrite-Existing-Commands
*/
overwrite<T extends keyof Chainable, S extends PrevSubject>(name: T, fn: CommandFnWithOriginalFnAndSubject<T, PrevSubjectMap[S]>): void
/**
* Add a custom query
* @see https://on.cypress.io/api/custom-queries
*/
addQuery<T extends keyof Chainable>(name: T, fn: QueryFn<T>): void
/**
* Overwrite an existing Cypress query with a new implementation
* @see https://on.cypress.io/api/custom-queries
*/
overwriteQuery<T extends keyof Chainable>(name: T, fn: QueryFnWithOriginalFn<T>): void
}
/**
* @see https://on.cypress.io/cookies
*/
Cookies: {
debug(enabled: boolean, options?: Partial<DebugOptions>): void
}
/**
* @see https://on.cypress.io/dom
*/
dom: {
/**
* Returns a jQuery object obtained by wrapping an object in jQuery.
*/
wrap(wrappingElement_function: JQuery.Selector | JQuery.htmlString | Element | JQuery | ((index: number) => string | JQuery)): JQuery
query(selector: JQuery.Selector, context?: Element | JQuery): JQuery
/**
* Returns an array of raw elements pulled out from a jQuery object.
*/
unwrap(obj: any): any
/**
* Returns a boolean indicating whether an object is a DOM object.
*/
isDom(obj: any): boolean
isType(element: JQuery | HTMLElement, type: string): boolean
/**
* Returns a boolean indicating whether an element is visible.
*/
isVisible(element: JQuery | HTMLElement): boolean
/**
* Returns a boolean indicating whether an element is hidden.
*/
isHidden(element: JQuery | HTMLElement, methodName?: string, options?: object): boolean
/**
* Returns a boolean indicating whether an element can receive focus.
*/
isFocusable(element: JQuery | HTMLElement): boolean
isTextLike(element: JQuery | HTMLElement): boolean
/**
* Returns a boolean indicating whether an element is scrollable.
*/
isScrollable(element: Window | JQuery | HTMLElement): boolean
/**
* Returns a boolean indicating whether an element currently has focus.
*/
isFocused(element: JQuery | HTMLElement): boolean
/**
* Returns a boolean indicating whether an element is detached from the DOM.
*/
isDetached(element: JQuery | HTMLElement): boolean
/**
* Returns a boolean indicating whether an element is attached to the DOM.
*/
isAttached(element: JQuery | HTMLElement | Window | Document): boolean
isSelector(element: JQuery | HTMLElement, selector: JQuery.Selector): boolean
/**
* Returns a boolean indicating whether an element is a descendent of another element.
*/
isDescendent(element1: JQuery | HTMLElement, element2: JQuery | HTMLElement): boolean
/**
* Returns a boolean indicating whether object is undefined or html, body, or document.
*/
isUndefinedOrHTMLBodyDoc(obj: any): boolean
/**
* Returns a boolean indicating whether an object is a DOM element.
*/
isElement(obj: any): boolean
/**
* Returns a boolean indicating whether a node is of document type.
*/
isDocument(obj: any): boolean
/**
* Returns a boolean indicating whether an object is a window object.
*/
isWindow(obj: any): obj is Window
/**
* Returns a boolean indicating whether an object is a jQuery object.
*/
isJquery(obj: any): obj is JQuery
isInputType(element: JQuery | HTMLElement, type: string | string[]): boolean
stringify(element: JQuery | HTMLElement, form: string): string
getElements(element: JQuery): JQuery | HTMLElement[]
getContainsSelector(text: string, filter?: string, options?: CaseMatchable): JQuery.Selector
getFirstDeepestElement(elements: HTMLElement[], index?: number): HTMLElement
getWindowByElement(element: JQuery | HTMLElement): JQuery | HTMLElement
getReasonIsHidden(element: JQuery | HTMLElement, options?: object): string
getFirstScrollableParent(element: JQuery | HTMLElement): JQuery | HTMLElement
getFirstFixedOrStickyPositionParent(element: JQuery | HTMLElement): JQuery | HTMLElement
getFirstStickyPositionParent(element: JQuery | HTMLElement): JQuery | HTMLElement
getCoordsByPosition(left: number, top: number, xPosition?: string, yPosition?: string): number
getElementPositioning(element: JQuery | HTMLElement): ElementPositioning
getElementAtPointFromViewport(doc: Document, x: number, y: number): Element | null
getElementCoordinatesByPosition(element: JQuery | HTMLElement, position: string): ElementCoordinates
getElementCoordinatesByPositionRelativeToXY(element: JQuery | HTMLElement, x: number, y: number): ElementPositioning
}
/**
* @see https://on.cypress.io/keyboard-api
*/
Keyboard: {
defaults(options: Partial<KeyboardDefaultsOptions>): void
}
/**
* @see https://on.cypress.io/screenshot-api
*/
Screenshot: {
defaults(options: Partial<ScreenshotDefaultsOptions>): void
}
/**
* @see https://on.cypress.io/selector-playground-api
*/
SelectorPlayground: {
defaults(options: Partial<SelectorPlaygroundDefaultsOptions>): void
getSelector($el: JQuery): JQuery.Selector
}
/**
* These events come from Cypress as it issues commands and reacts to their state. These are all useful to listen to for debugging purposes.
* @see https://on.cypress.io/catalog-of-events#App-Events
*/
on: Actions
/**
* These events come from Cypress as it issues commands and reacts to their state. These are all useful to listen to for debugging purposes.
* @see https://on.cypress.io/catalog-of-events#App-Events
*/
once: Actions
/**
* These events come from Cypress as it issues commands and reacts to their state. These are all useful to listen to for debugging purposes.
* @see https://on.cypress.io/catalog-of-events#App-Events
*/
off: Actions
/**
* Used to include dependencies within the cy.origin() callback
* @see https://on.cypress.io/origin
*/
require: <T = any>(id: string) => T
/**
* Trigger action
* @private
*/
action: <T = (any[] | void) >(action: string, ...args: any[]) => T
/**
* Load files
* @private
*/
onSpecWindow: (window: Window, specList: string[] | Array<() => Promise<void>>) => void
}
type CanReturnChainable = void | Chainable | Promise<unknown>
type ThenReturn<S, R> =
R extends void ? Chainable<S> :
R extends R | undefined ? Chainable<S | Exclude<R, undefined>> :
Chainable<S>
/**
* Chainable interface for non-array Subjects
*/
interface Chainable<Subject = any> {
/**
* Create an assertion. Assertions are automatically retried until they pass or time out.
*
* @alias should
* @see https://on.cypress.io/and
*/
and: Chainer<Subject>
/**
* Assign an alias for later use. Reference the alias later within a
* [cy.get()](https://on.cypress.io/get) or
* [cy.wait()](https://on.cypress.io/wait) command with a `@` prefix.
* You can alias DOM elements, routes, stubs and spies.
*
* @see https://on.cypress.io/as
* @see https://on.cypress.io/variables-and-aliases
* @see https://on.cypress.io/get
* @example
* // Get the aliased 'todos' elements
* cy.get('ul#todos').as('todos')
*
* // later retrieve the todos
* cy.get('@todos')
*/
as(alias: string, options?: Partial<AsOptions>): Chainable<Subject>
/**
* Blur a focused element. This element must currently be in focus.
* If you want to ensure an element is focused before blurring,
* try using .focus() before .blur().
*
* @see https://on.cypress.io/blur
*/
blur(options?: Partial<BlurOptions>): Chainable<Subject>
/**
* Check checkbox(es) or radio(s). This element must be an `<input>` with type `checkbox` or `radio`.
*
* @see https://on.cypress.io/check
* @example
* // Check checkbox element
* cy.get('[type="checkbox"]').check()
* // Check first radio element
* cy.get('[type="radio"]').first().check()
*/
check(options?: Partial<CheckOptions>): Chainable<Subject>
/**
* Check checkbox(es) or radio(s). This element must be an `<input>` with type `checkbox` or `radio`.
*
* @see https://on.cypress.io/check
* @example
* // Select the radio with the value of 'US'
* cy.get('[type="radio"]').check('US')
* // Check the checkboxes with the values 'ga' and 'ca'
* cy.get('[type="checkbox"]').check(['ga', 'ca'])
*/
check(value: string | string[], options?: Partial<CheckOptions>): Chainable<Subject>
/**
* Get the children of each DOM element within a set of DOM elements.
*
* @see https://on.cypress.io/children
*/
children<E extends Node = HTMLElement>(options?: Partial<Loggable & Timeoutable>): Chainable<JQuery<E>>
children<K extends keyof HTMLElementTagNameMap>(selector: K, options?: Partial<Loggable & Timeoutable>): Chainable<JQuery<HTMLElementTagNameMap[K]>>
children<E extends Node = HTMLElement>(selector: string, options?: Partial<Loggable & Timeoutable>): Chainable<JQuery<E>>
/**
* Clear the value of an `input` or `textarea`.
* An alias for `.type({selectall}{del})`
*
* @see https://on.cypress.io/clear
*/
clear(options?: Partial<ClearOptions>): Chainable<Subject>
/**
* Clear a specific browser cookie for a domain.
*
* Cypress automatically clears all cookies _before_ each test to prevent
* state from being shared across tests when test isolation is enabled.
* You shouldn't need to use this command unless you're using it to clear
* a specific cookie inside a single test or test isolation is disabled.
*
* @see https://on.cypress.io/clearcookie
*/
clearCookie(name: string, options?: CookieOptions): Chainable<null>
/**
* Clear browser cookies for a domain.
*
* Cypress automatically clears all cookies _before_ each test to prevent
* state from being shared across tests when test isolation is enabled.
* You shouldn't need to use this command unless you're using it to clear
* specific cookies inside a single test or test isolation is disabled.
*
* @see https://on.cypress.io/clearcookies
*/
clearCookies(options?: CookieOptions): Chainable<null>
/**
* Clear all browser cookies.
*
* Cypress automatically clears all cookies _before_ each test to prevent
* state from being shared across tests when test isolation is enabled.
* You shouldn't need to use this command unless you're using it to clear
* all cookie inside a single test or test isolation is disabled.
*
* @see https://on.cypress.io/clearallcookies
*/
clearAllCookies(options?: Partial<Loggable & Timeoutable>): Chainable<null>
/**
* Get local storage for all origins.
*
* @see https://on.cypress.io/getalllocalstorage
*/
getAllLocalStorage(options?: Partial<Loggable>): Chainable<StorageByOrigin>
/**
* Clear local storage for all origins.
*
* Cypress automatically clears all local storage _before_ each test to
* prevent state from being shared across tests when test isolation
* is enabled. You shouldn't need to use this command unless you're using it
* to clear localStorage inside a single test or test isolation is disabled.
*
* @see https://on.cypress.io/clearalllocalstorage
*/
clearAllLocalStorage(options?: Partial<Loggable>): Chainable<null>
/**
* Get session storage for all origins.
*
* @see https://on.cypress.io/getallsessionstorage
*/
getAllSessionStorage(options?: Partial<Loggable>): Chainable<StorageByOrigin>
/**
* Clear session storage for all origins.
*
* @see https://on.cypress.io/clearallsessionstorage
*/
clearAllSessionStorage(options?: Partial<Loggable>): Chainable<null>
/**
* Clear data in local storage for the current origin.
*
* Cypress automatically clears all local storage _before_ each test to
* prevent state from being shared across tests when test isolation
* is enabled. You shouldn't need to use this command unless you're using it
* to clear localStorage inside a single test or test isolation is disabled.
*
* @see https://on.cypress.io/clearlocalstorage
* @param {string} [key] - name of a particular item to remove (optional).
* @example
```
// Removes all local storage keys