forked from cypress-io/cypress
/
cypress-tests.ts
833 lines (737 loc) · 24.5 KB
/
cypress-tests.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
namespace CypressLodashTests {
Cypress._ // $ExpectType LoDashStatic
Cypress._.each([1], item => {
item // $ExpectType number
})
}
namespace CypressSinonTests {
Cypress.sinon // $ExpectType SinonStatic
const stub = cy.stub()
stub(2, 'foo')
expect(stub).to.have.been.calledWith(Cypress.sinon.match.number, Cypress.sinon.match('foo'))
const stub2 = Cypress.sinon.stub()
stub2(2, 'foo')
expect(stub2).to.have.been.calledWith(Cypress.sinon.match.number, Cypress.sinon.match('foo'))
}
namespace CypressJqueryTests {
Cypress.$ // $ExpectType JQueryStatic
Cypress.$('selector') // $ExpectType JQuery<HTMLElement>
Cypress.$('selector').click() // $ExpectType JQuery<HTMLElement>
}
namespace CypressAutomationTests {
Cypress.automation('hello') // $ExpectType Promise<any>
}
namespace CypressConfigTests {
// getters
Cypress.config('baseUrl') // $ExpectType string | null
Cypress.config().baseUrl // $ExpectType string | null
// setters
Cypress.config('baseUrl', '.') // $ExpectType void
Cypress.config('baseUrl', null) // $ExpectType void
Cypress.config({ baseUrl: '.', }) // $ExpectType void
Cypress.config('taskTimeout') // $ExpectType number
Cypress.config('includeShadowDom') // $ExpectType boolean
}
namespace CypressEnvTests {
// Just making sure these are valid - no real type safety
Cypress.env('foo')
Cypress.env('foo', 'bar')
Cypress.env().foo
Cypress.env({
foo: 'bar'
})
}
namespace CypressIsCyTests {
Cypress.isCy(cy) // $ExpectType boolean
Cypress.isCy(undefined) // $ExpectType boolean
const chainer = cy.wrap("foo").then(function() {
if (Cypress.isCy(chainer)) {
chainer // $ExpectType Chainable<string>
}
})
}
declare namespace Cypress {
interface Chainable {
newCommand: (arg: string) => Chainable<number>
}
}
namespace CypressCommandsTests {
Cypress.Commands.add('newCommand', (arg) => {
// $ExpectType string
arg
return
})
Cypress.Commands.add('newCommand', (arg) => {
// $ExpectType string
arg
})
Cypress.Commands.add('newCommand', function(arg) {
this // $ExpectType Context
arg // $ExpectType string
})
Cypress.Commands.add('newCommand', { prevSubject: true }, (subject, arg) => {
subject // $ExpectType JQuerySelector
subject.selector // $ExpectType string
arg // $ExpectType string
return
})
Cypress.Commands.add('newCommand', { prevSubject: false }, (arg) => {
arg // $ExpectType string
return
})
Cypress.Commands.add('newCommand', { prevSubject: 'optional' }, (subject, arg) => {
subject // $ExpectType unknown
arg // $ExpectType string
return
})
Cypress.Commands.add('newCommand', { prevSubject: 'optional' }, (subject, arg) => {
subject // $ExpectType unknown
arg // $ExpectType string
})
Cypress.Commands.add('newCommand', { prevSubject: ['optional'] }, (subject, arg) => {
subject // $ExpectType unknown
arg // $ExpectType string
})
Cypress.Commands.add('newCommand', { prevSubject: 'document' }, (subject, arg) => {
subject // $ExpectType Document
arg // $ExpectType string
})
Cypress.Commands.add('newCommand', { prevSubject: 'window' }, (subject, arg) => {
subject // $ExpectType Window
arg // $ExpectType string
})
Cypress.Commands.add('newCommand', { prevSubject: 'element' }, (subject, arg) => {
subject // $ExpectType JQuerySelector
subject.selector // $ExpectType string
arg // $ExpectType string
})
Cypress.Commands.add('newCommand', { prevSubject: ['element'] }, (subject, arg) => {
subject // $ExpectType JQuerySelector
subject.selector // $ExpectType string
arg // $ExpectType string
})
Cypress.Commands.add('newCommand', { prevSubject: ['element', 'document', 'window'] }, (subject, arg) => {
if (subject instanceof Window) {
subject // $ExpectType Window
} else if (subject instanceof Document) {
subject // $ExpectType Document
} else {
subject // $ExpectType JQuerySelector
subject.selector // $ExpectType string
}
arg // $ExpectType string
})
Cypress.Commands.add('newCommand', { prevSubject: ['window', 'document', 'optional', 'element'] }, (subject, arg) => {
if (subject instanceof Window) {
subject // $ExpectType Window
} else if (subject instanceof Document) {
subject // $ExpectType Document
} else if (subject) {
subject // $ExpectType JQuerySelector
} else {
subject // $ExpectType void
}
arg // $ExpectType string
})
Cypress.Commands.add('newCommand', (arg) => {
// $ExpectType string
arg
return cy.wrap(new Promise<number>((resolve) => { resolve(5) }))
})
Cypress.Commands.overwrite('newCommand', (originalFn, arg) => {
arg // $ExpectType string
originalFn // $ExpectedType Chainable['newCommand']
originalFn(arg) // $ExpectType Chainable<number>
})
Cypress.Commands.overwrite('newCommand', function(originalFn, arg) {
this // $ExpectType Context
arg // $ExpectType string
originalFn // $ExpectedType Chainable['newCommand']
originalFn.apply(this, [arg]) // $ExpectType Chainable<number>
})
Cypress.Commands.overwrite<'type', 'element'>('type', (originalFn, element, text, options?: Partial<Cypress.TypeOptions & {sensitive: boolean}>) => {
element // $ExpectType JQuery<HTMLElement>
text // $ExpectType string
if (options && options.sensitive) {
// turn off original log
options.log = false
// create our own log with masked message
Cypress.log({
$el: element,
name: 'type',
message: '*'.repeat(text.length),
})
}
return originalFn(element, text, options)
})
}
namespace CypressLogsTest {
const log = Cypress.log({
$el: Cypress.$('body'),
name: 'MyCommand',
displayName: 'My Command',
message: ['foo', 'bar'],
consoleProps: () => {
return {
foo: 'bar',
}
},
})
.set('$el', Cypress.$('body'))
.set({ name: 'MyCommand' })
.snapshot()
.snapshot('before')
.snapshot('before', { next: 'after' })
log.get() // $ExpectType LogConfig
log.get('name') // $ExpectType string
log.get('$el') // $ExpectType JQuery<HTMLElement>
}
namespace CypressLocalStorageTest {
Cypress.LocalStorage.clear = function(keys) {
keys // $ExpectType string[] | undefined
}
}
namespace CypressItsTests {
cy.wrap({ foo: [1, 2, 3] })
.its('foo')
.each((s: number) => {
s
})
cy.wrap({foo: 'bar'}).its('foo') // $ExpectType Chainable<string>
cy.wrap([1, 2]).its(1) // $ExpectType Chainable<number>
cy.wrap(['foo', 'bar']).its(1) // $ExpectType Chainable<string>
.then((s: string) => {
s
})
cy.wrap({baz: { quux: '2' }}).its('baz.quux') // $ExpectType Chainable<any>
cy.wrap({foo: 'bar'}).its('foo', { log: true }) // $ExpectType Chainable<string>
cy.wrap({foo: 'bar'}).its('foo', { timeout: 100 }) // $ExpectType Chainable<string>
cy.wrap({foo: 'bar'}).its('foo', { log: true, timeout: 100 }) // $ExpectType Chainable<string>
}
namespace CypressInvokeTests {
const returnsString = () => 'foo'
const returnsNumber = () => 42
cy.wrap({ a: returnsString }).invoke('a') // $ExpectType Chainable<string>
cy.wrap({ b: returnsNumber }).invoke('b') // $ExpectType Chainable<number>
cy.wrap({ b: returnsNumber }).invoke({ log: true }, 'b') // $ExpectType Chainable<number>
cy.wrap({ b: returnsNumber }).invoke({ timeout: 100 }, 'b') // $ExpectType Chainable<number>
cy.wrap({ b: returnsNumber }).invoke({ log: true, timeout: 100 }, 'b') // $ExpectType Chainable<number>
// challenging to define a more precise return type than string | number here
cy.wrap([returnsString, returnsNumber]).invoke(1) // $ExpectType Chainable<string | number>
// invoke through property path results in any
cy.wrap({ a: { fn: (x: number) => x * x }}).invoke('a.fn', 4) // $ExpectType Chainable<any>
// examples below are from previous attempt at typing `invoke`
// (see https://github.com/cypress-io/cypress/issues/4022)
// call methods on arbitrary objects with reasonable return types
cy.wrap({ fn: () => ({a: 1})}).invoke("fn") // $ExpectType Chainable<{ a: number; }>
// call methods on dom elements with reasonable return types
cy.get('.trigger-input-range').invoke('val', 25) // $ExpectType Chainable<string | number | string[] | undefined>
}
cy.wrap({ foo: ['bar', 'baz'] })
.its('foo')
.then(([first, second]) => {
first // $ExpectType string
})
.spread((first: string, second: string) => {
first // $ExpectType string
// return first as string
})
.each((s: string) => {
s // $ExpectType string
})
.then(s => {
s // $ExpectType string[]
})
cy.get('.someSelector')
.each(($el, index, list) => {
$el // $ExpectType JQuery<HTMLElement>
index // $ExpectType number
list // $ExpectType HTMLElement[]
})
cy.wrap(['bar', 'baz'])
.spread((first, second) => {
first // $ExpectType any
})
describe('then', () => {
// https://github.com/cypress-io/cypress/issues/5575
it('should respect the return type of callback', () => {
// Expected type is verbose here because the function below matches 2 declarations.
// * then<S extends object | any[] | string | number | boolean>(fn: (this: ObjectLike, currentSubject: Subject) => S): Chainable<S>
// * then<S>(fn: (this: ObjectLike, currentSubject: Subject) => S): ThenReturn<Subject, S>
// For our purpose, it doesn't matter.
const result = cy.get('foo').then(el => el.attr('foo'))
result // $ExpectType Chainable<JQuery<HTMLElement>> | Chainable<string | JQuery<HTMLElement>>
const result2 = cy.get('foo').then(el => `${el}`)
result2 // $ExpectType Chainable<string>
const result3 = cy.get('foo').then({ timeout: 1234 }, el => el.attr('foo'))
result3 // $ExpectType Chainable<JQuery<HTMLElement>> | Chainable<string | JQuery<HTMLElement>>
const result4 = cy.get('foo').then({ timeout: 1234 }, el => `${el}`)
result4 // $ExpectType Chainable<string>
})
it('should have the correct type signature', () => {
cy.wrap({ foo: 'bar' })
.then(s => {
s // $ExpectType { foo: string; }
return s
})
.then(s => {
s // $ExpectType { foo: string; }
})
.then(s => s.foo)
.then(s => {
s // $ExpectType string
})
})
it('should have the correct type signature with options', () => {
cy.wrap({ foo: 'bar' })
.then({ timeout: 5000 }, s => {
s // $ExpectType { foo: string; }
return s
})
.then({ timeout: 5000 }, s => {
s // $ExpectType { foo: string; }
})
.then({ timeout: 5000 }, s => s.foo)
.then({ timeout: 5000 }, s => {
s // $ExpectType string
})
})
it('HTMLElement', () => {
cy.get('div')
.then(($div) => {
$div // $ExpectType JQuery<HTMLDivElement>
return $div[0]
})
.then(($div) => {
$div // $ExpectType JQuery<HTMLDivElement>
})
cy.get('div')
.then(($div) => {
$div // $ExpectType JQuery<HTMLDivElement>
return [$div[0]]
})
.then(($div) => {
$div // $ExpectType JQuery<HTMLDivElement>
})
cy.get('p')
.then(($p) => {
$p // $ExpectType JQuery<HTMLParagraphElement>
return $p[0]
})
.then({timeout: 3000}, ($p) => {
$p // $ExpectType JQuery<HTMLParagraphElement>
})
})
// https://github.com/cypress-io/cypress/issues/16669
it('any as default', () => {
cy.get('body')
.then(() => ({} as any))
.then(v => {
v // $ExpectType any
})
})
})
cy.wait(['@foo', '@bar'])
.then(([first, second]) => {
first // $ExpectType Interception
})
cy.wait(1234) // $ExpectType Chainable<undefined>
cy.wrap('foo').wait(1234) // $ExpectType Chainable<string>
cy.wrap([{ foo: 'bar' }, { foo: 'baz' }])
.then(subject => {
subject // $ExpectType { foo: string; }[]
})
.then(([first, second]) => {
first // $ExpectType { foo: string; }
})
.then(subject => {
subject // $ExpectType { foo: string; }[]
})
.then(([first, second]) => {
return first.foo + second.foo
})
.then(subject => {
subject // $ExpectType string
})
cy.wrap([1, 2, 3]).each((num: number, i, array) => {
return new Cypress.Promise((resolve) => {
setTimeout(() => {
resolve()
}, num * 100)
})
})
cy.get('something').should('have.length', 1)
cy.stub().withArgs('').log(false).as('foo')
cy.spy().withArgs('').log(false).as('foo')
cy.wrap('foo').then(subject => {
subject // $ExpectType string
return cy.wrap(subject)
}).then(subject => {
subject // $ExpectType string
})
cy.wrap('foo').then(subject => {
subject // $ExpectType string
return Cypress.Promise.resolve(subject)
}).then(subject => {
subject // $ExpectType string
})
cy.get('body').within(body => {
body // $ExpectType JQuery<HTMLBodyElement>
})
cy.get('body').within({ log: false }, body => {
body // $ExpectType JQuery<HTMLBodyElement>
})
cy.get('body').within(() => {
cy.get('body', { withinSubject: null }).then(body => {
body // $ExpectType JQuery<HTMLBodyElement>
})
})
cy
.get('body')
.then(() => {
return cy.wrap(undefined)
})
.then(subject => {
subject // $ExpectType undefined
})
namespace CypressAUTWindowTests {
cy.go(2).then((win) => {
win // $ExpectType AUTWindow
})
cy.reload().then((win) => {
win // $ExpectType AUTWindow
})
cy.visit('https://google.com').then(win => {
win // $ExpectType AUTWindow
})
cy.window().then(win => {
win // $ExpectType AUTWindow
})
}
namespace CypressOnTests {
Cypress.on('uncaught:exception', (error, runnable, promise) => {
error // $ExpectType Error
runnable // $ExpectType Runnable
promise // $ExpectType Promise<any> | undefined
})
cy.on('uncaught:exception', (error, runnable, promise) => {
error // $ExpectType Error
runnable // $ExpectType Runnable
promise // $ExpectType Promise<any> | undefined
})
// you can chain multiple callbacks
Cypress
.on('test:before:run', () => { })
.on('test:after:run', () => { })
.on('test:before:run:async', () => { })
cy
.on('window:before:load', () => { })
.on('command:start', () => { })
}
namespace CypressOnceTests {
Cypress.once('uncaught:exception', (error, runnable) => {
error // $ExpectType Error
runnable // $ExpectType Runnable
})
cy.once('uncaught:exception', (error, runnable) => {
error // $ExpectType Error
runnable // $ExpectType Runnable
})
}
namespace CypressOffTests {
Cypress.off('uncaught:exception', (error, runnable) => {
error // $ExpectType Error
runnable // $ExpectType Runnable
})
cy.off('uncaught:exception', (error, runnable) => {
error // $ExpectType Error
runnable // $ExpectType Runnable
})
}
namespace CypressFilterTests {
cy.get<HTMLDivElement>('#id')
.filter((index: number, element: HTMLDivElement) => {
index // $ExpectType number
element // $ExpectType HTMLDivElement
return true
})
}
namespace CypressScreenshotTests {
cy.screenshot('example-name')
cy.screenshot('example', { log: false })
cy.screenshot({ log: false })
cy.screenshot({
log: true,
blackout: []
})
cy.screenshot('example', {
log: true,
blackout: []
})
}
namespace CypressShadowDomTests {
cy.get('my-component').shadow()
}
namespace CypressTriggerTests {
cy.get('something')
.trigger('click') // .trigger(eventName)
.trigger('click', 'center') // .trigger(eventName, position)
.trigger('click', { // .trigger(eventName, options)
arbitraryProperty: 0
})
.trigger('click', 0, 0) // .trigger(eventName, x, y)
.trigger('click', 'center', { // .trigger(eventName, position, options)
arbitraryProperty: 0
})
.trigger('click', 0, 0, { // .trigger(eventName, x, y, options)
arbitraryProperty: 0
})
}
namespace CypressClockTests {
// timestamp
cy.clock(new Date(2019, 3, 2).getTime(), ['Date'])
// timestamp shortcut
cy.clock(+ new Date(), ['Date'])
// Date object
cy.clock(new Date(2019, 3, 2))
// restoring the clock
cy.clock().then(clock => {
clock.restore()
})
// restoring the clock shortcut
cy.clock().invoke('restore')
}
namespace CypressContainsTests {
cy.contains('#app')
cy.contains('my text to find')
cy.contains('#app', 'my text to find')
cy.contains('#app', 'my text to find', { log: false, timeout: 100, matchCase: false, includeShadowDom: true })
cy.contains('my text to find', { log: false, timeout: 100, matchCase: false, includeShadowDom: true })
}
// https://github.com/cypress-io/cypress/pull/5574
namespace CypressLocationTests {
cy.location('path') // $ExpectError
cy.location('pathname') // $ExpectType Chainable<string>
}
// https://github.com/cypress-io/cypress/issues/17399
namespace CypressUrlTests {
cy.url({decode: true}).should('contain', '사랑')
}
namespace CypressBrowserTests {
Cypress.isBrowser('chrome')// $ExpectType boolean
Cypress.isBrowser('firefox')// $ExpectType boolean
Cypress.isBrowser('edge')// $ExpectType boolean
Cypress.isBrowser('brave')// $ExpectType boolean
// does not error to allow for user supplied browsers
Cypress.isBrowser('safari')// $ExpectType boolean
Cypress.isBrowser({channel: 'stable'})// $ExpectType boolean
Cypress.isBrowser({family: 'chromium'})// $ExpectType boolean
Cypress.isBrowser({name: 'chrome'})// $ExpectType boolean
Cypress.isBrowser({family: 'foo'}) // $ExpectError
Cypress.isBrowser() // $ExpectError
}
namespace CypressDomTests {
const obj: any = {}
const el = {} as any as HTMLElement
const jel = {} as any as JQuery
const doc = {} as any as Document
Cypress.dom.wrap((x: number) => 'a') // $ExpectType JQuery<HTMLElement>
Cypress.dom.query('foo', el) // $ExpectType JQuery<HTMLElement>
Cypress.dom.unwrap(obj) // $ExpectType any
Cypress.dom.isDom(obj) // $ExpectType boolean
Cypress.dom.isType(el, 'foo') // $ExpectType boolean
Cypress.dom.isVisible(el) // $ExpectType boolean
Cypress.dom.isHidden(el) // $ExpectType boolean
Cypress.dom.isFocusable(el) // $ExpectType boolean
Cypress.dom.isTextLike(el) // $ExpectType boolean
Cypress.dom.isScrollable(el) // $ExpectType boolean
Cypress.dom.isFocused(el) // $ExpectType boolean
Cypress.dom.isDetached(el) // $ExpectType boolean
Cypress.dom.isAttached(el) // $ExpectType boolean
Cypress.dom.isSelector(el, 'foo') // $ExpectType boolean
Cypress.dom.isDescendent(el, el) // $ExpectType boolean
Cypress.dom.isElement(obj) // $ExpectType boolean
Cypress.dom.isDocument(obj) // $ExpectType boolean
Cypress.dom.isWindow(obj) // $ExpectType boolean
Cypress.dom.isJquery(obj) // $ExpectType boolean
Cypress.dom.isInputType(el, 'number') // $ExpectType boolean
Cypress.dom.stringify(el, 'foo') // $ExpectType string
Cypress.dom.getElements(jel) // $ExpectType JQuery<HTMLElement> | HTMLElement[]
Cypress.dom.getContainsSelector('foo', 'bar') // $ExpectType string
Cypress.dom.getFirstDeepestElement([el], 1) // $ExpectType HTMLElement
Cypress.dom.getWindowByElement(el) // $ExpectType HTMLElement | JQuery<HTMLElement>
Cypress.dom.getReasonIsHidden(el) // $ExpectType string
Cypress.dom.getFirstScrollableParent(el) // $ExpectType HTMLElement | JQuery<HTMLElement>
Cypress.dom.getFirstFixedOrStickyPositionParent(el) // $ExpectType HTMLElement | JQuery<HTMLElement>
Cypress.dom.getFirstStickyPositionParent(el) // $ExpectType HTMLElement | JQuery<HTMLElement>
Cypress.dom.getCoordsByPosition(1, 2) // $ExpectType number
Cypress.dom.getElementPositioning(el) // $ExpectType ElementPositioning
Cypress.dom.getElementAtPointFromViewport(doc, 1, 2) // $ExpectType Element | null
Cypress.dom.getElementCoordinatesByPosition(el, 'top') // $ExpectType ElementCoordinates
Cypress.dom.getElementCoordinatesByPositionRelativeToXY(el, 1, 2) // $ExpectType ElementPositioning
Cypress.dom.wrap() // $ExpectError
Cypress.dom.query(el, 'foo') // $ExpectError
Cypress.dom.unwrap() // $ExpectError
Cypress.dom.isDom() // $ExpectError
Cypress.dom.isType(el) // $ExpectError
Cypress.dom.isVisible('') // $ExpectError
Cypress.dom.isHidden('') // $ExpectError
Cypress.dom.isFocusable('') // $ExpectError
Cypress.dom.isTextLike('') // $ExpectError
Cypress.dom.isScrollable('') // $ExpectError
Cypress.dom.isFocused('') // $ExpectError
Cypress.dom.isDetached('') // $ExpectError
Cypress.dom.isAttached('') // $ExpectError
Cypress.dom.isSelector('', 'foo') // $ExpectError
Cypress.dom.isDescendent('', '') // $ExpectError
Cypress.dom.isElement() // $ExpectError
Cypress.dom.isDocument() // $ExpectError
Cypress.dom.isWindow() // $ExpectError
Cypress.dom.isJquery() // $ExpectError
Cypress.dom.isInputType('', 'number') // $ExpectError
Cypress.dom.stringify('', 'foo') // $ExpectError
Cypress.dom.getElements(el) // $ExpectError
Cypress.dom.getContainsSelector(el, 'bar') // $ExpectError
Cypress.dom.getFirstDeepestElement(el, 1) // $ExpectError
Cypress.dom.getWindowByElement('') // $ExpectError
Cypress.dom.getReasonIsHidden('') // $ExpectError
Cypress.dom.getFirstScrollableParent('') // $ExpectError
Cypress.dom.getFirstFixedOrStickyPositionParent('') // $ExpectError
Cypress.dom.getFirstStickyPositionParent('') // $ExpectError
Cypress.dom.getCoordsByPosition(1) // $ExpectError
Cypress.dom.getElementPositioning('') // $ExpectError
Cypress.dom.getElementAtPointFromViewport(el, 1, 2) // $ExpectError
Cypress.dom.getElementCoordinatesByPosition(doc, 'top') // $ExpectError
Cypress.dom.getElementCoordinatesByPositionRelativeToXY(doc, 1, 2) // $ExpectError
}
namespace CypressTestConfigOverridesTests {
// set config on a per-test basis
it('test', {
animationDistanceThreshold: 10,
baseUrl: 'www.foobar.com',
defaultCommandTimeout: 6000,
env: {},
execTimeout: 6000,
includeShadowDom: true,
requestTimeout: 6000,
responseTimeout: 6000,
scrollBehavior: 'center',
taskTimeout: 6000,
viewportHeight: 200,
viewportWidth: 200,
waitForAnimations: false
}, () => { })
it('test', {
browser: {name: 'firefox'}
}, () => {})
it('test', {
browser: [{name: 'firefox'}, {name: 'chrome'}]
}, () => {})
it('test', {
browser: 'firefox',
keystrokeDelay: 0
}, () => {})
it('test', {
browser: {foo: 'bar'}, // $ExpectError
}, () => {})
it('test', {
retries: null,
keystrokeDelay: 0
}, () => { })
it('test', {
retries: 3,
keystrokeDelay: false, // $ExpectError
}, () => { })
it('test', {
retries: {
runMode: 3,
openMode: null
}
}, () => { })
it('test', {
retries: {
runMode: 3,
}
}, () => { })
it('test', {
retries: { run: 3 } // $ExpectError
}, () => { })
it.skip('test', {}, () => {})
it.only('test', {}, () => {})
xit('test', {}, () => {})
specify('test', {}, () => {})
specify.only('test', {}, () => {})
specify.skip('test', {}, () => {})
xspecify('test', {}, () => {})
// set config on a per-suite basis
describe('suite', {
browser: {family: 'firefox'},
baseUrl: 'www.example.com',
keystrokeDelay: 0
}, () => {})
context('suite', {}, () => {})
describe('suite', {
browser: {family: 'firefox'},
baseUrl: 'www.example.com',
keystrokeDelay: false // $ExpectError
foo: 'foo' // $ExpectError
}, () => {})
describe.only('suite', {}, () => {})
describe.skip('suite', {}, () => {})
xdescribe('suite', {}, () => {})
}
namespace CypressShadowTests {
cy
.get('.foo')
.shadow()
.find('.bar')
.click()
cy.get('.foo', { includeShadowDom: true }).click()
cy
.get('.foo')
.find('.bar', {includeShadowDom: true})
}
namespace CypressTaskTests {
cy.task<number>('foo') // $ExpectType Chainable<number>
cy.task<number>('foo').then((val) => {
val // $ExpectType number
})
cy.task('foo') // $ExpectType Chainable<unknown>
cy.task('foo').then((val) => {
val // $ExpectType unknown
})
}
namespace CypressSessionsTests {
Cypress.config('experimentalSessionSupport') // $ExpectType boolean
cy.session('user')
cy.session('user', () => {})
cy.session({ name: 'bob' }, () => {})
cy.session('user', () => {}, {})
cy.session('user', () => {}, {
validate: () => {}
})
cy.session() // $ExpectError
cy.session(null) // $ExpectError
cy.session('user', () => {}, {
validate: { foo: true } // $ExpectError
})
}
namespace CypressCurrentTest {
Cypress.currentTest.title // $ExpectType string
Cypress.currentTest.titlePath // $ExpectType string[]
Cypress.currentTest() // $ExpectError
}
namespace CypressKeyboardTests {
Cypress.Keyboard.defaults({
keystrokeDelay: 0
})
Cypress.Keyboard.defaults({
keystrokeDelay: 500
})
Cypress.Keyboard.defaults({
keystrokeDelay: false // $ExpectError
})
Cypress.Keyboard.defaults({
delay: 500 // $ExpectError
})
}