cypress 3.1.4 → 3.1.5
Sign up to get free protection for your applications and to get access to all the features.
- package/lib/cli.js +10 -6
- package/package.json +2 -2
- package/types/index.d.ts +240 -88
package/lib/cli.js
CHANGED
@@ -26,8 +26,7 @@ function unknownOption(flag) {
|
|
26
26
|
logger.error(' error: unknown ' + type + ':', flag);
|
27
27
|
logger.error();
|
28
28
|
this.outputHelp();
|
29
|
-
|
30
|
-
process.exit(1);
|
29
|
+
util.exit(1);
|
31
30
|
}
|
32
31
|
commander.Command.prototype.unknownOption = unknownOption;
|
33
32
|
|
@@ -65,9 +64,9 @@ var descriptions = {
|
|
65
64
|
dev: 'runs cypress in development and bypasses binary check',
|
66
65
|
forceInstall: 'force install the Cypress binary',
|
67
66
|
exit: 'keep the browser open after tests finish',
|
68
|
-
cachePath: 'print the
|
69
|
-
cacheList: 'list
|
70
|
-
cacheClear: 'delete
|
67
|
+
cachePath: 'print the path to the binary cache',
|
68
|
+
cacheList: 'list cached binary versions',
|
69
|
+
cacheClear: 'delete all cached binaries',
|
71
70
|
group: 'a named group for recorded runs in the Cypress dashboard',
|
72
71
|
parallel: 'enables concurrent runs and automatic load balancing of specs across multiple machines or processes',
|
73
72
|
ciBuildId: 'the unique identifier for a run on your CI provider. typically a "BUILD_ID" env var. this value is automatically detected for most CI providers'
|
@@ -140,8 +139,13 @@ module.exports = {
|
|
140
139
|
});
|
141
140
|
|
142
141
|
program.command('cache').usage('[command]').description('Manages the Cypress binary cache').option('list', text('cacheList')).option('path', text('cachePath')).option('clear', text('cacheClear')).action(function (opts) {
|
142
|
+
if (!_.isString(opts)) {
|
143
|
+
this.outputHelp();
|
144
|
+
util.exit(1);
|
145
|
+
}
|
146
|
+
|
143
147
|
if (opts.command || !_.includes(['list', 'path', 'clear'], opts)) {
|
144
|
-
unknownOption.call(this, 'cache ' + opts, '
|
148
|
+
unknownOption.call(this, 'cache ' + opts, 'command');
|
145
149
|
}
|
146
150
|
|
147
151
|
cache[opts]();
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "cypress",
|
3
|
-
"version": "3.1.
|
3
|
+
"version": "3.1.5",
|
4
4
|
"main": "index.js",
|
5
5
|
"bin": {
|
6
6
|
"cypress": "bin/cypress"
|
@@ -31,7 +31,7 @@
|
|
31
31
|
"@types/minimatch": "3.0.3",
|
32
32
|
"@types/mocha": "2.2.44",
|
33
33
|
"@types/sinon": "7.0.0",
|
34
|
-
"@types/sinon-chai": "2.
|
34
|
+
"@types/sinon-chai": "3.2.2",
|
35
35
|
"bluebird": "3.5.0",
|
36
36
|
"cachedir": "1.3.0",
|
37
37
|
"chalk": "2.4.1",
|
package/types/index.d.ts
CHANGED
@@ -116,10 +116,12 @@ declare namespace Cypress {
|
|
116
116
|
* Cypress version string. i.e. "1.1.2"
|
117
117
|
* @see https://on.cypress.io/version
|
118
118
|
* @example
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
119
|
+
```
|
120
|
+
expect(Cypress.version).to.be.a('string')
|
121
|
+
if (Cypress.version === '1.2.0') {
|
122
|
+
// test something specific
|
123
|
+
}
|
124
|
+
```
|
123
125
|
*/
|
124
126
|
version: string
|
125
127
|
|
@@ -143,6 +145,15 @@ declare namespace Cypress {
|
|
143
145
|
|
144
146
|
/**
|
145
147
|
* Currently executing spec file.
|
148
|
+
* @example
|
149
|
+
```
|
150
|
+
Cypress.spec
|
151
|
+
// {
|
152
|
+
// name: "config_passing_spec.coffee",
|
153
|
+
// relative: "cypress/integration/config_passing_spec.coffee",
|
154
|
+
// absolute: "/users/smith/projects/web/cypress/integration/config_passing_spec.coffee"
|
155
|
+
// }
|
156
|
+
```
|
146
157
|
*/
|
147
158
|
spec: {
|
148
159
|
name: string // "config_passing_spec.coffee"
|
@@ -156,11 +167,45 @@ declare namespace Cypress {
|
|
156
167
|
browser: Browser
|
157
168
|
|
158
169
|
/**
|
170
|
+
* Returns all configuration objects.
|
159
171
|
* @see https://on.cypress.io/config
|
172
|
+
* @example
|
173
|
+
```
|
174
|
+
Cypress.config()
|
175
|
+
// {defaultCommandTimeout: 10000, pageLoadTimeout: 30000, ...}
|
176
|
+
```
|
160
177
|
*/
|
161
178
|
config(): ConfigOptions
|
179
|
+
/**
|
180
|
+
* Returns one configuration value.
|
181
|
+
* @see https://on.cypress.io/config
|
182
|
+
* @example
|
183
|
+
```
|
184
|
+
Cypress.config('pageLoadTimeout')
|
185
|
+
// 60000
|
186
|
+
```
|
187
|
+
*/
|
162
188
|
config<K extends keyof ConfigOptions>(key: K): ConfigOptions[K]
|
189
|
+
/**
|
190
|
+
* Sets one configuration value.
|
191
|
+
* @see https://on.cypress.io/config
|
192
|
+
* @example
|
193
|
+
```
|
194
|
+
Cypress.config('viewportWidth', 800)
|
195
|
+
```
|
196
|
+
*/
|
163
197
|
config<K extends keyof ConfigOptions>(key: K, value: ConfigOptions[K]): void
|
198
|
+
/**
|
199
|
+
* Sets multiple configuration values at once.
|
200
|
+
* @see https://on.cypress.io/config
|
201
|
+
* @example
|
202
|
+
```
|
203
|
+
Cypress.config({
|
204
|
+
defaultCommandTimeout: 10000,
|
205
|
+
viewportHeight: 900
|
206
|
+
})
|
207
|
+
```
|
208
|
+
*/
|
164
209
|
config(Object: Partial<ConfigOptions>): void
|
165
210
|
|
166
211
|
// no real way to type without generics
|
@@ -277,16 +322,20 @@ declare namespace Cypress {
|
|
277
322
|
* @see https://on.cypress.io/variables-and-aliases
|
278
323
|
* @see https://on.cypress.io/get
|
279
324
|
* @example
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
325
|
+
```
|
326
|
+
// Get the aliased ‘todos’ elements
|
327
|
+
cy.get('ul#todos').as('todos')
|
328
|
+
//...hack hack hack...
|
329
|
+
// later retrieve the todos
|
330
|
+
cy.get('@todos')
|
331
|
+
```
|
285
332
|
*/
|
286
333
|
as(alias: string): Chainable<Subject>
|
287
334
|
|
288
335
|
/**
|
289
|
-
* Blur a focused element. This element must currently be in focus.
|
336
|
+
* Blur a focused element. This element must currently be in focus.
|
337
|
+
* If you want to ensure an element is focused before blurring,
|
338
|
+
* try using .focus() before .blur().
|
290
339
|
*
|
291
340
|
* @see https://on.cypress.io/blur
|
292
341
|
*/
|
@@ -355,19 +404,29 @@ declare namespace Cypress {
|
|
355
404
|
* to clear localStorage inside a single test. Yields `localStorage` object.
|
356
405
|
*
|
357
406
|
* @see https://on.cypress.io/clearlocalstorage
|
358
|
-
* @
|
359
|
-
*
|
360
|
-
|
361
|
-
|
407
|
+
* @param {string} [key] - name of a particular item to remove (optional).
|
408
|
+
* @example
|
409
|
+
```
|
410
|
+
// removes all local storage keys
|
411
|
+
cy.clearLocalStorage()
|
412
|
+
.should(ls => {
|
413
|
+
expect(ls.getItem('prop1')).to.be.null
|
414
|
+
})
|
415
|
+
// removes item "todos"
|
416
|
+
cy.clearLocalStorage("todos")
|
417
|
+
```
|
362
418
|
*/
|
363
419
|
clearLocalStorage(key?: string): Chainable<Storage>
|
364
420
|
/**
|
365
421
|
* Clear keys in local storage that match given regular expression.
|
366
422
|
*
|
367
423
|
* @see https://on.cypress.io/clearlocalstorage
|
424
|
+
* @param {RegExp} re - regular expression to match.
|
368
425
|
* @example
|
369
|
-
|
370
|
-
|
426
|
+
```
|
427
|
+
// Clear all local storage matching /app-/
|
428
|
+
cy.clearLocalStorage(/app-/)
|
429
|
+
```
|
371
430
|
*/
|
372
431
|
clearLocalStorage(re: RegExp): Chainable<Storage>
|
373
432
|
|
@@ -384,7 +443,8 @@ declare namespace Cypress {
|
|
384
443
|
/**
|
385
444
|
* Click a DOM element at specific corner / side.
|
386
445
|
*
|
387
|
-
* @param {String} position The position where the click should be issued.
|
446
|
+
* @param {String} position - The position where the click should be issued.
|
447
|
+
* The `center` position is the default position.
|
388
448
|
* @see https://on.cypress.io/click
|
389
449
|
* @example
|
390
450
|
* cy.get('button').click('topRight')
|
@@ -397,9 +457,11 @@ declare namespace Cypress {
|
|
397
457
|
* @param {number} y The distance in pixels from the element’s top to issue the click.
|
398
458
|
* @see https://on.cypress.io/click
|
399
459
|
* @example
|
400
|
-
|
401
|
-
|
402
|
-
|
460
|
+
```
|
461
|
+
// The click below will be issued inside of the element
|
462
|
+
// (15px from the left and 40px from the top).
|
463
|
+
cy.get('button').click(15, 40)
|
464
|
+
```
|
403
465
|
*/
|
404
466
|
click(x: number, y: number, options?: Partial<ClickOptions>): Chainable<Subject>
|
405
467
|
|
@@ -623,9 +685,11 @@ declare namespace Cypress {
|
|
623
685
|
fixture<Contents = any>(path: string, encoding: Encodings, options?: Partial<Timeoutable>): Chainable<Contents> // no log?
|
624
686
|
|
625
687
|
/**
|
626
|
-
*
|
688
|
+
* Focus on a DOM element.
|
627
689
|
*
|
628
690
|
* @see https://on.cypress.io/focus
|
691
|
+
* @example
|
692
|
+
* cy.get('input').first().focus() // Focus on the first input
|
629
693
|
*/
|
630
694
|
focus(options?: Partial<Loggable & Timeoutable>): Chainable<Subject>
|
631
695
|
|
@@ -1327,19 +1391,37 @@ declare namespace Cypress {
|
|
1327
1391
|
*
|
1328
1392
|
* @see https://on.cypress.io/then
|
1329
1393
|
*/
|
1330
|
-
then<S>(fn: (this: ObjectLike, currentSubject: Subject) => Chainable<S
|
1394
|
+
then<S>(fn: (this: ObjectLike, currentSubject: Subject) => Chainable<S>): Chainable<S>
|
1395
|
+
/**
|
1396
|
+
* Enables you to work with the subject yielded from the previous command.
|
1397
|
+
*
|
1398
|
+
* @see https://on.cypress.io/then
|
1399
|
+
*/
|
1400
|
+
then<S>(options: Partial<Timeoutable>, fn: (this: ObjectLike, currentSubject: Subject) => Chainable<S>): Chainable<S>
|
1331
1401
|
/**
|
1332
1402
|
* Enables you to work with the subject yielded from the previous command / promise.
|
1333
1403
|
*
|
1334
1404
|
* @see https://on.cypress.io/then
|
1335
1405
|
*/
|
1336
|
-
then<S>(fn: (this: ObjectLike, currentSubject: Subject) => PromiseLike<S
|
1406
|
+
then<S>(fn: (this: ObjectLike, currentSubject: Subject) => PromiseLike<S>): Chainable<S>
|
1337
1407
|
/**
|
1338
1408
|
* Enables you to work with the subject yielded from the previous command / promise.
|
1339
1409
|
*
|
1340
1410
|
* @see https://on.cypress.io/then
|
1341
1411
|
*/
|
1342
|
-
then<S
|
1412
|
+
then<S>(options: Partial<Timeoutable>, fn: (this: ObjectLike, currentSubject: Subject) => PromiseLike<S>): Chainable<S>
|
1413
|
+
/**
|
1414
|
+
* Enables you to work with the subject yielded from the previous command / promise.
|
1415
|
+
*
|
1416
|
+
* @see https://on.cypress.io/then
|
1417
|
+
*/
|
1418
|
+
then<S extends object | any[] | string | number | boolean>(fn: (this: ObjectLike, currentSubject: Subject) => S): Chainable<S>
|
1419
|
+
/**
|
1420
|
+
* Enables you to work with the subject yielded from the previous command / promise.
|
1421
|
+
*
|
1422
|
+
* @see https://on.cypress.io/then
|
1423
|
+
*/
|
1424
|
+
then<S extends object | any[] | string | number | boolean>(options: Partial<Timeoutable>, fn: (this: ObjectLike, currentSubject: Subject) => S): Chainable<S>
|
1343
1425
|
/**
|
1344
1426
|
* Enables you to work with the subject yielded from the previous command.
|
1345
1427
|
*
|
@@ -1348,7 +1430,16 @@ declare namespace Cypress {
|
|
1348
1430
|
* cy.get('.nav').then(($nav) => {}) // Yields .nav as first arg
|
1349
1431
|
* cy.location().then((loc) => {}) // Yields location object as first arg
|
1350
1432
|
*/
|
1351
|
-
then(fn: (this: ObjectLike, currentSubject: Subject) => void
|
1433
|
+
then(fn: (this: ObjectLike, currentSubject: Subject) => void): Chainable<Subject>
|
1434
|
+
/**
|
1435
|
+
* Enables you to work with the subject yielded from the previous command.
|
1436
|
+
*
|
1437
|
+
* @see https://on.cypress.io/then
|
1438
|
+
* @example
|
1439
|
+
* cy.get('.nav').then(($nav) => {}) // Yields .nav as first arg
|
1440
|
+
* cy.location().then((loc) => {}) // Yields location object as first arg
|
1441
|
+
*/
|
1442
|
+
then(options: Partial<Timeoutable>, fn: (this: ObjectLike, currentSubject: Subject) => void): Chainable<Subject>
|
1352
1443
|
|
1353
1444
|
/**
|
1354
1445
|
* Move time after overriding a native time function with [cy.clock()](https://on.cypress.io/clock).
|
@@ -1502,9 +1593,12 @@ declare namespace Cypress {
|
|
1502
1593
|
visit(url: string, options?: Partial<VisitOptions>): Chainable<Window>
|
1503
1594
|
|
1504
1595
|
/**
|
1505
|
-
* Wait for a number of milliseconds
|
1596
|
+
* Wait for a number of milliseconds.
|
1597
|
+
* You almost never need to wait for an arbitrary period of time.
|
1598
|
+
* There are always better ways to express this in Cypress, see the documentation.
|
1506
1599
|
*
|
1507
1600
|
* @see https://on.cypress.io/wait
|
1601
|
+
* @param {number} ms - Milliseconds to wait.
|
1508
1602
|
* @example
|
1509
1603
|
* cy.wait(1000) // wait for 1 second
|
1510
1604
|
*/
|
@@ -1513,12 +1607,44 @@ declare namespace Cypress {
|
|
1513
1607
|
* Wait for a specific XHR to respond.
|
1514
1608
|
*
|
1515
1609
|
* @see https://on.cypress.io/wait
|
1610
|
+
* @param {string} alias - Name of the alias to wait for.
|
1611
|
+
*
|
1612
|
+
```
|
1613
|
+
// Wait for the route aliased as 'getAccount' to respond
|
1614
|
+
// without changing or stubbing its response
|
1615
|
+
cy.server()
|
1616
|
+
cy.route('/accounts/*').as('getAccount')
|
1617
|
+
cy.visit('/accounts/123')
|
1618
|
+
cy.wait('@getAccount').then((xhr) => {
|
1619
|
+
// we can now access the low level xhr
|
1620
|
+
// that contains the request body,
|
1621
|
+
// response body, status, etc
|
1622
|
+
})
|
1623
|
+
```
|
1516
1624
|
*/
|
1517
1625
|
wait(alias: string, options?: Partial<Loggable & Timeoutable & TimeoutableXHR>): Chainable<WaitXHR>
|
1518
1626
|
/**
|
1519
1627
|
* Wait for list of XHR requests to complete.
|
1520
1628
|
*
|
1521
1629
|
* @see https://on.cypress.io/wait
|
1630
|
+
* @param {string[]} aliases - An array of aliased routes as defined using the `.as()` command.
|
1631
|
+
*
|
1632
|
+
```
|
1633
|
+
// wait for 3 XHR requests to complete
|
1634
|
+
cy.server()
|
1635
|
+
cy.route('users/*').as('getUsers')
|
1636
|
+
cy.route('activities/*').as('getActivities')
|
1637
|
+
cy.route('comments/*').as('getComments')
|
1638
|
+
cy.visit('/dashboard')
|
1639
|
+
|
1640
|
+
cy.wait(['@getUsers', '@getActivities', '@getComments'])
|
1641
|
+
.then((xhrs) => {
|
1642
|
+
// xhrs will now be an array of matching XHR's
|
1643
|
+
// xhrs[0] <-- getUsers
|
1644
|
+
// xhrs[1] <-- getActivities
|
1645
|
+
// xhrs[2] <-- getComments
|
1646
|
+
})
|
1647
|
+
```
|
1522
1648
|
*/
|
1523
1649
|
wait(alias: string[], options?: Partial<Loggable & Timeoutable & TimeoutableXHR>): Chainable<WaitXHR[]>
|
1524
1650
|
|
@@ -1527,11 +1653,13 @@ declare namespace Cypress {
|
|
1527
1653
|
*
|
1528
1654
|
* @see https://on.cypress.io/window
|
1529
1655
|
* @example
|
1530
|
-
|
1531
|
-
|
1532
|
-
|
1533
|
-
|
1534
|
-
|
1656
|
+
```
|
1657
|
+
cy.visit('http://localhost:8080/app')
|
1658
|
+
cy.window().then(function(win){
|
1659
|
+
// win is the remote window
|
1660
|
+
// of the page at: http://localhost:8080/app
|
1661
|
+
})
|
1662
|
+
```
|
1535
1663
|
*/
|
1536
1664
|
window(options?: Partial<Loggable & Timeoutable>): Chainable<Window>
|
1537
1665
|
|
@@ -1540,14 +1668,15 @@ declare namespace Cypress {
|
|
1540
1668
|
* Useful when working within a particular group of elements such as a `<form>`.
|
1541
1669
|
* @see https://on.cypress.io/within
|
1542
1670
|
* @example
|
1543
|
-
|
1544
|
-
|
1545
|
-
|
1546
|
-
|
1547
|
-
|
1548
|
-
|
1549
|
-
|
1550
|
-
|
1671
|
+
```
|
1672
|
+
cy.get('form').within(($form) => {
|
1673
|
+
// cy.get() will only search for elements within form,
|
1674
|
+
// not within the entire document
|
1675
|
+
cy.get('input[name="username"]').type('john')
|
1676
|
+
cy.get('input[name="password"]').type('password')
|
1677
|
+
cy.root().submit()
|
1678
|
+
})
|
1679
|
+
```
|
1551
1680
|
*/
|
1552
1681
|
within(fn: (currentSubject: Subject) => void): Chainable<Subject>
|
1553
1682
|
/**
|
@@ -1562,10 +1691,13 @@ declare namespace Cypress {
|
|
1562
1691
|
*
|
1563
1692
|
* @see https://on.cypress.io/wrap
|
1564
1693
|
* @example
|
1565
|
-
|
1566
|
-
|
1567
|
-
|
1568
|
-
|
1694
|
+
```
|
1695
|
+
// wraps DOM element
|
1696
|
+
cy.get('form').within(($form) => {
|
1697
|
+
// more commands
|
1698
|
+
cy.wrap($form).should('have.class', 'form-container')
|
1699
|
+
})
|
1700
|
+
```
|
1569
1701
|
*/
|
1570
1702
|
wrap<E extends Node = HTMLElement>(element: E | JQuery<E>, options?: Partial<Loggable & Timeoutable>): Chainable<JQuery<E>>
|
1571
1703
|
/**
|
@@ -1573,9 +1705,11 @@ declare namespace Cypress {
|
|
1573
1705
|
*
|
1574
1706
|
* @see https://on.cypress.io/wrap
|
1575
1707
|
* @example
|
1576
|
-
|
1577
|
-
|
1578
|
-
|
1708
|
+
```
|
1709
|
+
cy.wrap(new Promise((resolve, reject) => {
|
1710
|
+
setTimeout(resolve, 1000);
|
1711
|
+
}).then(result => {})
|
1712
|
+
```
|
1579
1713
|
*/
|
1580
1714
|
wrap<F extends Promise<S>, S>(promise: F, options?: Partial<Loggable & Timeoutable>): Chainable<S>
|
1581
1715
|
/**
|
@@ -1583,10 +1717,12 @@ declare namespace Cypress {
|
|
1583
1717
|
*
|
1584
1718
|
* @see https://on.cypress.io/wrap
|
1585
1719
|
* @example
|
1586
|
-
|
1587
|
-
|
1588
|
-
|
1589
|
-
|
1720
|
+
```
|
1721
|
+
// Make assertions about object
|
1722
|
+
cy.wrap({ amount: 10 })
|
1723
|
+
.should('have.property', 'amount')
|
1724
|
+
.and('eq', 10)
|
1725
|
+
```
|
1590
1726
|
*/
|
1591
1727
|
wrap<S>(object: S, options?: Partial<Loggable & Timeoutable>): Chainable<S>
|
1592
1728
|
|
@@ -1594,6 +1730,12 @@ declare namespace Cypress {
|
|
1594
1730
|
* Write to a file with the specified contents.
|
1595
1731
|
*
|
1596
1732
|
* @see https://on.cypress.io/writefile
|
1733
|
+
```
|
1734
|
+
cy.writeFile('path/to/message.txt', 'Hello World')
|
1735
|
+
.then((text) => {
|
1736
|
+
expect(text).to.equal('Hello World') // true
|
1737
|
+
})
|
1738
|
+
```
|
1597
1739
|
*/
|
1598
1740
|
writeFile<C extends FileContents>(filePath: string, contents: C, options?: Partial<Loggable>): Chainable<C>
|
1599
1741
|
/**
|
@@ -3674,26 +3816,28 @@ declare namespace Cypress {
|
|
3674
3816
|
* Fires when an uncaught exception occurs in your application.
|
3675
3817
|
* Cypress will fail the test when this fires.
|
3676
3818
|
* Return `false` from this event and Cypress will not fail the test. Also useful for debugging purposes because the actual `error` instance is provided to you.
|
3677
|
-
* @example
|
3678
|
-
* // likely want to do this in a support file
|
3679
|
-
* // so it's applied to all spec files
|
3680
|
-
* // cypress/support/index.js
|
3681
|
-
*
|
3682
|
-
* Cypress.on('uncaught:exception', (err, runnable) => {
|
3683
|
-
* // returning false here prevents Cypress from
|
3684
|
-
* // failing the test
|
3685
|
-
* return false
|
3686
|
-
* })
|
3687
|
-
* // stub "window.alert" in a single test
|
3688
|
-
* it('shows alert', () => {
|
3689
|
-
* const stub = cy.stub()
|
3690
|
-
* cy.on('window:alert', stub)
|
3691
|
-
* // trigger application code that calls alert(...)
|
3692
|
-
* .then(() => {
|
3693
|
-
* expect(stub).to.have.been.calledOnce
|
3694
|
-
* })
|
3695
|
-
* })
|
3696
3819
|
* @see https://on.cypress.io/catalog-of-events#App-Events
|
3820
|
+
* @example
|
3821
|
+
```
|
3822
|
+
// likely want to do this in a support file
|
3823
|
+
// so it's applied to all spec files
|
3824
|
+
// cypress/support/index.js
|
3825
|
+
|
3826
|
+
Cypress.on('uncaught:exception', (err, runnable) => {
|
3827
|
+
// returning false here prevents Cypress from
|
3828
|
+
// failing the test
|
3829
|
+
return false
|
3830
|
+
})
|
3831
|
+
// stub "window.alert" in a single test
|
3832
|
+
it('shows alert', () => {
|
3833
|
+
const stub = cy.stub()
|
3834
|
+
cy.on('window:alert', stub)
|
3835
|
+
// trigger application code that calls alert(...)
|
3836
|
+
.then(() => {
|
3837
|
+
expect(stub).to.have.been.calledOnce
|
3838
|
+
})
|
3839
|
+
})
|
3840
|
+
```
|
3697
3841
|
*/
|
3698
3842
|
(action: 'uncaught:exception', fn: (error: Error, runnable: Mocha.IRunnable) => false | void): void
|
3699
3843
|
/**
|
@@ -3701,23 +3845,28 @@ declare namespace Cypress {
|
|
3701
3845
|
* Cypress will auto accept confirmations. Return `false` from this event and the confirmation will be cancelled.
|
3702
3846
|
* @see https://on.cypress.io/catalog-of-events#App-Events
|
3703
3847
|
* @example
|
3704
|
-
|
3705
|
-
|
3706
|
-
|
3707
|
-
|
3848
|
+
```
|
3849
|
+
cy.on('window:confirm', (str) => {
|
3850
|
+
console.log(str)
|
3851
|
+
return false // simulate "Cancel"
|
3852
|
+
})
|
3853
|
+
```
|
3708
3854
|
*/
|
3709
3855
|
(action: 'window:confirm', fn: ((text: string) => false | void) | Agent<sinon.SinonSpy>): void
|
3710
3856
|
/**
|
3711
3857
|
* Fires when your app calls the global `window.alert()` method.
|
3712
3858
|
* Cypress will auto accept alerts. You cannot change this behavior.
|
3713
3859
|
* @example
|
3714
|
-
|
3715
|
-
|
3716
|
-
|
3717
|
-
|
3718
|
-
|
3719
|
-
|
3720
|
-
|
3860
|
+
```
|
3861
|
+
const stub = cy.stub()
|
3862
|
+
cy.on('window:alert', stub)
|
3863
|
+
// assume the button calls window.alert()
|
3864
|
+
cy.get('.my-button')
|
3865
|
+
.click()
|
3866
|
+
.then(() => {
|
3867
|
+
expect(stub).to.have.been.calledOnce
|
3868
|
+
})
|
3869
|
+
```
|
3721
3870
|
* @see https://on.cypress.io/catalog-of-events#App-Events
|
3722
3871
|
*/
|
3723
3872
|
(action: 'window:alert', fn: ((text: string) => void) | Agent<sinon.SinonSpy>): void
|
@@ -3931,26 +4080,29 @@ declare namespace Cypress {
|
|
3931
4080
|
left: number
|
3932
4081
|
}
|
3933
4082
|
|
3934
|
-
// Diff
|
4083
|
+
// Diff taken from https://github.com/Microsoft/TypeScript/issues/12215#issuecomment-311923766
|
3935
4084
|
type Diff<T extends string, U extends string> = ({[P in T]: P } & {[P in U]: never } & { [x: string]: never })[T]
|
3936
|
-
|
3937
|
-
type Omit<T, K extends keyof T> = Pick<T, Diff<keyof T, K>> // tslint:disable-line
|
4085
|
+
type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>
|
3938
4086
|
}
|
3939
4087
|
|
3940
4088
|
/**
|
3941
4089
|
* Global variables `cy` added by Cypress with all API commands.
|
3942
4090
|
* @see https://on.cypress.io/api
|
3943
4091
|
* @example
|
3944
|
-
|
3945
|
-
|
4092
|
+
```
|
4093
|
+
cy.get('button').click()
|
4094
|
+
cy.get('.result').contains('Expected text')
|
4095
|
+
```
|
3946
4096
|
*/
|
3947
4097
|
declare const cy: Cypress.Chainable<undefined>
|
3948
4098
|
/**
|
3949
4099
|
* Global variable `Cypress` holds common utilities and constants.
|
3950
4100
|
* @see https://on.cypress.io/api
|
3951
4101
|
* @example
|
3952
|
-
|
3953
|
-
|
3954
|
-
|
4102
|
+
```
|
4103
|
+
Cypress.config("pageLoadTimeout") // => 60000
|
4104
|
+
Cypress.version // => "1.4.0"
|
4105
|
+
Cypress._ // => Lodash _
|
4106
|
+
```
|
3955
4107
|
*/
|
3956
4108
|
declare const Cypress: Cypress.Cypress
|