cypress 3.1.1 → 3.1.5

Sign up to get free protection for your applications and to get access to all the features.
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
- logger.error();
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 cypress binary cache path',
69
- cacheList: 'list the currently cached versions',
70
- cacheClear: 'delete the Cypress binary cache',
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, 'sub-command');
148
+ unknownOption.call(this, 'cache ' + opts, 'command');
145
149
  }
146
150
 
147
151
  cache[opts]();
package/lib/exec/spawn.js CHANGED
@@ -80,6 +80,7 @@ module.exports = {
80
80
  }
81
81
 
82
82
  var overrides = util.getEnvOverrides();
83
+ var node11WindowsFix = isPlatform('win32');
83
84
 
84
85
  debug('spawning Cypress with executable: %s', executable);
85
86
  debug('spawn forcing env overrides %o', overrides);
@@ -93,6 +94,9 @@ module.exports = {
93
94
  // also figure out whether we should force stdout and stderr into thinking
94
95
  // it is a tty as opposed to a pipe.
95
96
  options.env = _.extend({}, options.env, overrides);
97
+ if (node11WindowsFix) {
98
+ options = _.extend({}, options, { windowsHide: false });
99
+ }
96
100
 
97
101
  var child = cp.spawn(executable, args, options);
98
102
 
@@ -5,7 +5,7 @@ var _templateObject = _taggedTemplateLiteral([' \n Skipping installation
5
5
  _templateObject3 = _taggedTemplateLiteral(['\n ', ' Skipping binary installation: Environment variable CYPRESS_INSTALL_BINARY = 0.'], ['\n ', ' Skipping binary installation: Environment variable CYPRESS_INSTALL_BINARY = 0.']),
6
6
  _templateObject4 = _taggedTemplateLiteral(['\n ', ' Overriding Cypress cache directory to: ', '\n\n Previous installs of Cypress may not be found.\n '], ['\n ', ' Overriding Cypress cache directory to: ', '\n\n Previous installs of Cypress may not be found.\n ']),
7
7
  _templateObject5 = _taggedTemplateLiteral(['\n Failed to access ', ':\n\n ', '\n '], ['\n Failed to access ', ':\n\n ', '\n ']),
8
- _templateObject6 = _taggedTemplateLiteral(['\n Cypress ', ' is already installed in ', '\n '], ['\n Cypress ', ' is already installed in ', '\n ']),
8
+ _templateObject6 = _taggedTemplateLiteral(['\n Cypress ', ' is installed in ', '\n '], ['\n Cypress ', ' is installed in ', '\n ']),
9
9
  _templateObject7 = _taggedTemplateLiteral(['\n ', ' Warning: Forcing a binary version different than the default.\n\n The CLI expected to install version: ', '\n\n Instead we will install version: ', '\n\n These versions may not work properly together.\n '], ['\n ', ' Warning: Forcing a binary version different than the default.\n\n The CLI expected to install version: ', '\n\n Instead we will install version: ', '\n\n These versions may not work properly together.\n ']);
10
10
 
11
11
  function _taggedTemplateLiteral(strings, raw) { return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cypress",
3
- "version": "3.1.1",
3
+ "version": "3.1.5",
4
4
  "main": "index.js",
5
5
  "bin": {
6
6
  "cypress": "bin/cypress"
@@ -30,8 +30,8 @@
30
30
  "@types/lodash": "4.14.87",
31
31
  "@types/minimatch": "3.0.3",
32
32
  "@types/mocha": "2.2.44",
33
- "@types/sinon": "4.0.0",
34
- "@types/sinon-chai": "2.7.29",
33
+ "@types/sinon": "7.0.0",
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",
@@ -49,10 +49,10 @@
49
49
  "is-installed-globally": "0.1.0",
50
50
  "lazy-ass": "1.6.0",
51
51
  "listr": "0.12.0",
52
- "lodash": "4.17.10",
52
+ "lodash": "4.17.11",
53
53
  "log-symbols": "2.2.0",
54
54
  "minimist": "1.2.0",
55
- "progress": "1.1.8",
55
+ "moment": "2.22.2",
56
56
  "ramda": "0.24.1",
57
57
  "request": "2.87.0",
58
58
  "request-progress": "0.3.1",
package/types/index.d.ts CHANGED
@@ -4,18 +4,20 @@
4
4
  // Mike Woudenberg <https://github.com/mikewoudenberg>
5
5
  // Robbert van Markus <https://github.com/rvanmarkus>
6
6
  // Nicholas Boll <https://github.com/nicholasboll>
7
- // TypeScript Version: 2.5
7
+ // TypeScript Version: 2.8
8
8
  // Updated by the Cypress team: https://www.cypress.io/about/
9
9
 
10
10
  /// <reference path="./blob-util.d.ts" />
11
11
  /// <reference path="./bluebird.d.ts" />
12
12
  /// <reference path="./minimatch.d.ts" />
13
+ /// <reference path="./moment.d.ts" />
13
14
 
14
15
  /// <reference types="chai" />
15
16
  /// <reference types="chai-jquery" />
16
17
  /// <reference types="jquery" />
17
18
  /// <reference types="lodash" />
18
19
  /// <reference types="mocha" />
20
+ /// <reference types="moment" />
19
21
  /// <reference types="sinon" />
20
22
  /// <reference types="sinon-chai" />
21
23
 
@@ -100,7 +102,7 @@ declare namespace Cypress {
100
102
  * @example
101
103
  * const todaysDate = Cypress.moment().format("MMM DD, YYYY")
102
104
  */
103
- moment: (...args: any[]) => any // perhaps we want to add moment as a dependency for types?
105
+ moment: Moment.MomentStatic
104
106
  /**
105
107
  * Cypress automatically includes Bluebird and exposes it as Cypress.Promise.
106
108
  *
@@ -114,10 +116,12 @@ declare namespace Cypress {
114
116
  * Cypress version string. i.e. "1.1.2"
115
117
  * @see https://on.cypress.io/version
116
118
  * @example
117
- * expect(Cypress.version).to.be.a('string')
118
- * if (Cypress.version === '1.2.0') {
119
- * // test something specific
120
- * }
119
+ ```
120
+ expect(Cypress.version).to.be.a('string')
121
+ if (Cypress.version === '1.2.0') {
122
+ // test something specific
123
+ }
124
+ ```
121
125
  */
122
126
  version: string
123
127
 
@@ -141,6 +145,15 @@ declare namespace Cypress {
141
145
 
142
146
  /**
143
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
+ ```
144
157
  */
145
158
  spec: {
146
159
  name: string // "config_passing_spec.coffee"
@@ -154,11 +167,45 @@ declare namespace Cypress {
154
167
  browser: Browser
155
168
 
156
169
  /**
170
+ * Returns all configuration objects.
157
171
  * @see https://on.cypress.io/config
172
+ * @example
173
+ ```
174
+ Cypress.config()
175
+ // {defaultCommandTimeout: 10000, pageLoadTimeout: 30000, ...}
176
+ ```
158
177
  */
159
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
+ */
160
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
+ */
161
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
+ */
162
209
  config(Object: Partial<ConfigOptions>): void
163
210
 
164
211
  // no real way to type without generics
@@ -275,16 +322,20 @@ declare namespace Cypress {
275
322
  * @see https://on.cypress.io/variables-and-aliases
276
323
  * @see https://on.cypress.io/get
277
324
  * @example
278
- * // Get the aliased ‘todos’ elements
279
- * cy.get('ul#todos').as('todos')
280
- * //...hack hack hack...
281
- * // later retrieve the todos
282
- * cy.get('@todos')
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
+ ```
283
332
  */
284
333
  as(alias: string): Chainable<Subject>
285
334
 
286
335
  /**
287
- * 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().
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().
288
339
  *
289
340
  * @see https://on.cypress.io/blur
290
341
  */
@@ -353,19 +404,29 @@ declare namespace Cypress {
353
404
  * to clear localStorage inside a single test. Yields `localStorage` object.
354
405
  *
355
406
  * @see https://on.cypress.io/clearlocalstorage
356
- * @example
357
- * cy.clearLocalStorage().should(ls => {
358
- * expect(ls.getItem('prop1')).to.be.null
359
- * })
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
+ ```
360
418
  */
361
419
  clearLocalStorage(key?: string): Chainable<Storage>
362
420
  /**
363
421
  * Clear keys in local storage that match given regular expression.
364
422
  *
365
423
  * @see https://on.cypress.io/clearlocalstorage
424
+ * @param {RegExp} re - regular expression to match.
366
425
  * @example
367
- * // Clear all local storage matching /app-/
368
- * cy.clearLocalStorage(/app-/)
426
+ ```
427
+ // Clear all local storage matching /app-/
428
+ cy.clearLocalStorage(/app-/)
429
+ ```
369
430
  */
370
431
  clearLocalStorage(re: RegExp): Chainable<Storage>
371
432
 
@@ -382,7 +443,8 @@ declare namespace Cypress {
382
443
  /**
383
444
  * Click a DOM element at specific corner / side.
384
445
  *
385
- * @param {String} position The position where the click should be issued. The `center` position is the default position.
446
+ * @param {String} position - The position where the click should be issued.
447
+ * The `center` position is the default position.
386
448
  * @see https://on.cypress.io/click
387
449
  * @example
388
450
  * cy.get('button').click('topRight')
@@ -395,9 +457,11 @@ declare namespace Cypress {
395
457
  * @param {number} y The distance in pixels from the element’s top to issue the click.
396
458
  * @see https://on.cypress.io/click
397
459
  * @example
398
- * // The click below will be issued inside of the element
399
- * // (15px from the left and 40px from the top).
400
- * cy.get('button').click(15, 40)
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
+ ```
401
465
  */
402
466
  click(x: number, y: number, options?: Partial<ClickOptions>): Chainable<Subject>
403
467
 
@@ -621,9 +685,11 @@ declare namespace Cypress {
621
685
  fixture<Contents = any>(path: string, encoding: Encodings, options?: Partial<Timeoutable>): Chainable<Contents> // no log?
622
686
 
623
687
  /**
624
- * Get the DOM element that is currently focused.
688
+ * Focus on a DOM element.
625
689
  *
626
690
  * @see https://on.cypress.io/focus
691
+ * @example
692
+ * cy.get('input').first().focus() // Focus on the first input
627
693
  */
628
694
  focus(options?: Partial<Loggable & Timeoutable>): Chainable<Subject>
629
695
 
@@ -1325,19 +1391,46 @@ declare namespace Cypress {
1325
1391
  *
1326
1392
  * @see https://on.cypress.io/then
1327
1393
  */
1328
- then<S>(fn: (this: ObjectLike, currentSubject: Subject) => Chainable<S>, options?: Partial<Timeoutable>): 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>
1401
+ /**
1402
+ * Enables you to work with the subject yielded from the previous command / promise.
1403
+ *
1404
+ * @see https://on.cypress.io/then
1405
+ */
1406
+ then<S>(fn: (this: ObjectLike, currentSubject: Subject) => PromiseLike<S>): Chainable<S>
1407
+ /**
1408
+ * Enables you to work with the subject yielded from the previous command / promise.
1409
+ *
1410
+ * @see https://on.cypress.io/then
1411
+ */
1412
+ then<S>(options: Partial<Timeoutable>, fn: (this: ObjectLike, currentSubject: Subject) => PromiseLike<S>): Chainable<S>
1329
1413
  /**
1330
1414
  * Enables you to work with the subject yielded from the previous command / promise.
1331
1415
  *
1332
1416
  * @see https://on.cypress.io/then
1333
1417
  */
1334
- then<S>(fn: (this: ObjectLike, currentSubject: Subject) => PromiseLike<S>, options?: Partial<Timeoutable>): Chainable<S>
1418
+ then<S extends object | any[] | string | number | boolean>(fn: (this: ObjectLike, currentSubject: Subject) => S): Chainable<S>
1335
1419
  /**
1336
1420
  * Enables you to work with the subject yielded from the previous command / promise.
1337
1421
  *
1338
1422
  * @see https://on.cypress.io/then
1339
1423
  */
1340
- then<S extends object | any[] | string | number | boolean>(fn: (this: ObjectLike, currentSubject: Subject) => S, options?: Partial<Timeoutable>): Chainable<S>
1424
+ then<S extends object | any[] | string | number | boolean>(options: Partial<Timeoutable>, fn: (this: ObjectLike, currentSubject: Subject) => S): Chainable<S>
1425
+ /**
1426
+ * Enables you to work with the subject yielded from the previous command.
1427
+ *
1428
+ * @see https://on.cypress.io/then
1429
+ * @example
1430
+ * cy.get('.nav').then(($nav) => {}) // Yields .nav as first arg
1431
+ * cy.location().then((loc) => {}) // Yields location object as first arg
1432
+ */
1433
+ then(fn: (this: ObjectLike, currentSubject: Subject) => void): Chainable<Subject>
1341
1434
  /**
1342
1435
  * Enables you to work with the subject yielded from the previous command.
1343
1436
  *
@@ -1346,7 +1439,7 @@ declare namespace Cypress {
1346
1439
  * cy.get('.nav').then(($nav) => {}) // Yields .nav as first arg
1347
1440
  * cy.location().then((loc) => {}) // Yields location object as first arg
1348
1441
  */
1349
- then(fn: (this: ObjectLike, currentSubject: Subject) => void, options?: Partial<Timeoutable>): Chainable<Subject>
1442
+ then(options: Partial<Timeoutable>, fn: (this: ObjectLike, currentSubject: Subject) => void): Chainable<Subject>
1350
1443
 
1351
1444
  /**
1352
1445
  * Move time after overriding a native time function with [cy.clock()](https://on.cypress.io/clock).
@@ -1500,9 +1593,12 @@ declare namespace Cypress {
1500
1593
  visit(url: string, options?: Partial<VisitOptions>): Chainable<Window>
1501
1594
 
1502
1595
  /**
1503
- * Wait for a number of milliseconds or wait for an aliased resource to resolve before moving on to the next command.
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.
1504
1599
  *
1505
1600
  * @see https://on.cypress.io/wait
1601
+ * @param {number} ms - Milliseconds to wait.
1506
1602
  * @example
1507
1603
  * cy.wait(1000) // wait for 1 second
1508
1604
  */
@@ -1511,25 +1607,59 @@ declare namespace Cypress {
1511
1607
  * Wait for a specific XHR to respond.
1512
1608
  *
1513
1609
  * @see https://on.cypress.io/wait
1514
- */
1515
- wait(alias: string, options?: Partial<Loggable & Timeoutable>): Chainable<WaitXHR>
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
+ ```
1624
+ */
1625
+ wait(alias: string, options?: Partial<Loggable & Timeoutable & TimeoutableXHR>): Chainable<WaitXHR>
1516
1626
  /**
1517
1627
  * Wait for list of XHR requests to complete.
1518
1628
  *
1519
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
+ ```
1520
1648
  */
1521
- wait(alias: string[], options?: Partial<Loggable & Timeoutable>): Chainable<WaitXHR[]>
1649
+ wait(alias: string[], options?: Partial<Loggable & Timeoutable & TimeoutableXHR>): Chainable<WaitXHR[]>
1522
1650
 
1523
1651
  /**
1524
1652
  * Get the window object of the page that is currently active.
1525
1653
  *
1526
1654
  * @see https://on.cypress.io/window
1527
1655
  * @example
1528
- * cy.visit('http://localhost:8080/app')
1529
- * cy.window().then(function(win){
1530
- * // win is the remote window
1531
- * // of the page at: http://localhost:8080/app
1532
- * })
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
+ ```
1533
1663
  */
1534
1664
  window(options?: Partial<Loggable & Timeoutable>): Chainable<Window>
1535
1665
 
@@ -1538,14 +1668,15 @@ declare namespace Cypress {
1538
1668
  * Useful when working within a particular group of elements such as a `<form>`.
1539
1669
  * @see https://on.cypress.io/within
1540
1670
  * @example
1541
- * cy.get('form').within(($form) => {
1542
- * // cy.get() will only search for elements within form,
1543
- * // not within the entire document
1544
- * cy.get('input[name="username"]').type('john')
1545
- * cy.get('input[name="password"]').type('password')
1546
- * cy.root().submit()
1547
- * })
1548
- *
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
+ ```
1549
1680
  */
1550
1681
  within(fn: (currentSubject: Subject) => void): Chainable<Subject>
1551
1682
  /**
@@ -1560,21 +1691,38 @@ declare namespace Cypress {
1560
1691
  *
1561
1692
  * @see https://on.cypress.io/wrap
1562
1693
  * @example
1563
- * cy.get('form').within(($form) => {
1564
- * // more commands
1565
- * cy.wrap($form).should('have.class', 'form-container')
1566
- * })
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
+ ```
1567
1701
  */
1568
1702
  wrap<E extends Node = HTMLElement>(element: E | JQuery<E>, options?: Partial<Loggable & Timeoutable>): Chainable<JQuery<E>>
1703
+ /**
1704
+ * Yield the element passed into `.wrap()` to the next command in the Cypress chain.
1705
+ *
1706
+ * @see https://on.cypress.io/wrap
1707
+ * @example
1708
+ ```
1709
+ cy.wrap(new Promise((resolve, reject) => {
1710
+ setTimeout(resolve, 1000);
1711
+ }).then(result => {})
1712
+ ```
1713
+ */
1714
+ wrap<F extends Promise<S>, S>(promise: F, options?: Partial<Loggable & Timeoutable>): Chainable<S>
1569
1715
  /**
1570
1716
  * Yields whatever is passed into `.wrap()` to the next command in the Cypress chain.
1571
1717
  *
1572
1718
  * @see https://on.cypress.io/wrap
1573
1719
  * @example
1574
- * // Make assertions about object
1575
- * cy.wrap({ amount: 10 })
1576
- * .should('have.property', 'amount')
1577
- * .and('eq', 10)
1720
+ ```
1721
+ // Make assertions about object
1722
+ cy.wrap({ amount: 10 })
1723
+ .should('have.property', 'amount')
1724
+ .and('eq', 10)
1725
+ ```
1578
1726
  */
1579
1727
  wrap<S>(object: S, options?: Partial<Loggable & Timeoutable>): Chainable<S>
1580
1728
 
@@ -1582,6 +1730,12 @@ declare namespace Cypress {
1582
1730
  * Write to a file with the specified contents.
1583
1731
  *
1584
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
+ ```
1585
1739
  */
1586
1740
  writeFile<C extends FileContents>(filePath: string, contents: C, options?: Partial<Loggable>): Chainable<C>
1587
1741
  /**
@@ -1645,6 +1799,26 @@ declare namespace Cypress {
1645
1799
  timeout: number
1646
1800
  }
1647
1801
 
1802
+ /**
1803
+ * Options that control how long the Test Runner waits for an XHR request and response to succeed
1804
+ */
1805
+ interface TimeoutableXHR {
1806
+ /**
1807
+ * Time to wait for the request (ms)
1808
+ *
1809
+ * @default {@link Timeoutable#timeout}
1810
+ * @see https://docs.cypress.io/guides/references/configuration.html#Timeouts
1811
+ */
1812
+ requestTimeout: number,
1813
+ /**
1814
+ * Time to wait for the response (ms)
1815
+ *
1816
+ * @default {@link Timeoutable#timeout}
1817
+ * @see https://docs.cypress.io/guides/references/configuration.html#Timeouts
1818
+ */
1819
+ responseTimeout: number
1820
+ }
1821
+
1648
1822
  /**
1649
1823
  * Options to force an event, skipping Actionability check
1650
1824
  * @see https://docs.cypress.io/guides/core-concepts/interacting-with-elements.html#Actionability
@@ -1847,6 +2021,9 @@ declare namespace Cypress {
1847
2021
  env: object
1848
2022
  }
1849
2023
 
2024
+ /**
2025
+ * Full set of possible options for cy.request call
2026
+ */
1850
2027
  interface RequestOptions extends Loggable, Timeoutable {
1851
2028
  auth: object
1852
2029
  body: RequestBody
@@ -1856,7 +2033,7 @@ declare namespace Cypress {
1856
2033
  gzip: boolean
1857
2034
  headers: object
1858
2035
  method: HttpMethod
1859
- qs: string
2036
+ qs: object
1860
2037
  url: string
1861
2038
  }
1862
2039
 
@@ -1922,6 +2099,10 @@ declare namespace Cypress {
1922
2099
  interval: number
1923
2100
  }
1924
2101
 
2102
+ /**
2103
+ * Setting default options for cy.server()
2104
+ * @see https://on.cypress.io/server
2105
+ */
1925
2106
  interface ServerOptions {
1926
2107
  delay: number
1927
2108
  method: HttpMethod
@@ -1934,7 +2115,7 @@ declare namespace Cypress {
1934
2115
  enable: boolean
1935
2116
  force404: boolean
1936
2117
  urlMatchingOptions: object
1937
- whitelist(...args: any[]): void
2118
+ whitelist(xhr: Request): void
1938
2119
  }
1939
2120
 
1940
2121
  interface SetCookieOptions extends Loggable, Timeoutable {
@@ -3635,26 +3816,28 @@ declare namespace Cypress {
3635
3816
  * Fires when an uncaught exception occurs in your application.
3636
3817
  * Cypress will fail the test when this fires.
3637
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.
3638
- * @example
3639
- * // likely want to do this in a support file
3640
- * // so it's applied to all spec files
3641
- * // cypress/support/index.js
3642
- *
3643
- * Cypress.on('uncaught:exception', (err, runnable) => {
3644
- * // returning false here prevents Cypress from
3645
- * // failing the test
3646
- * return false
3647
- * })
3648
- * // stub "window.alert" in a single test
3649
- * it('shows alert', () => {
3650
- * const stub = cy.stub()
3651
- * cy.on('window:alert', stub)
3652
- * // trigger application code that calls alert(...)
3653
- * .then(() => {
3654
- * expect(stub).to.have.been.calledOnce
3655
- * })
3656
- * })
3657
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
+ ```
3658
3841
  */
3659
3842
  (action: 'uncaught:exception', fn: (error: Error, runnable: Mocha.IRunnable) => false | void): void
3660
3843
  /**
@@ -3662,23 +3845,28 @@ declare namespace Cypress {
3662
3845
  * Cypress will auto accept confirmations. Return `false` from this event and the confirmation will be cancelled.
3663
3846
  * @see https://on.cypress.io/catalog-of-events#App-Events
3664
3847
  * @example
3665
- * cy.on('window:confirm', (str) => {
3666
- * console.log(str)
3667
- * return false // simulate "Cancel"
3668
- * })
3848
+ ```
3849
+ cy.on('window:confirm', (str) => {
3850
+ console.log(str)
3851
+ return false // simulate "Cancel"
3852
+ })
3853
+ ```
3669
3854
  */
3670
3855
  (action: 'window:confirm', fn: ((text: string) => false | void) | Agent<sinon.SinonSpy>): void
3671
3856
  /**
3672
3857
  * Fires when your app calls the global `window.alert()` method.
3673
3858
  * Cypress will auto accept alerts. You cannot change this behavior.
3674
3859
  * @example
3675
- * const stub = cy.stub()
3676
- * cy.on('window:alert', stub)
3677
- * // assume the button calls window.alert()
3678
- * cy.get('.my-button').click()
3679
- * .then(() => {
3680
- * expect(stub).to.have.been.calledOnce
3681
- * })
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
+ ```
3682
3870
  * @see https://on.cypress.io/catalog-of-events#App-Events
3683
3871
  */
3684
3872
  (action: 'window:alert', fn: ((text: string) => void) | Agent<sinon.SinonSpy>): void
@@ -3892,26 +4080,29 @@ declare namespace Cypress {
3892
4080
  left: number
3893
4081
  }
3894
4082
 
3895
- // Diff / Omit taken from https://github.com/Microsoft/TypeScript/issues/12215#issuecomment-311923766
4083
+ // Diff taken from https://github.com/Microsoft/TypeScript/issues/12215#issuecomment-311923766
3896
4084
  type Diff<T extends string, U extends string> = ({[P in T]: P } & {[P in U]: never } & { [x: string]: never })[T]
3897
- // @ts-ignore TODO - remove this if possible. Seems a recent change to TypeScript broke this. Possibly https://github.com/Microsoft/TypeScript/pull/17912
3898
- type Omit<T, K extends keyof T> = Pick<T, Diff<keyof T, K>>
4085
+ type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>
3899
4086
  }
3900
4087
 
3901
4088
  /**
3902
4089
  * Global variables `cy` added by Cypress with all API commands.
3903
4090
  * @see https://on.cypress.io/api
3904
4091
  * @example
3905
- * cy.get('button').click()
3906
- * cy.get('.result').contains('Expected text')
4092
+ ```
4093
+ cy.get('button').click()
4094
+ cy.get('.result').contains('Expected text')
4095
+ ```
3907
4096
  */
3908
4097
  declare const cy: Cypress.Chainable<undefined>
3909
4098
  /**
3910
4099
  * Global variable `Cypress` holds common utilities and constants.
3911
4100
  * @see https://on.cypress.io/api
3912
4101
  * @example
3913
- * Cypress.config("pageLoadTimeout") // => 60000
3914
- * Cypress.version // => "1.4.0"
3915
- * Cypress._ // => Lodash _
4102
+ ```
4103
+ Cypress.config("pageLoadTimeout") // => 60000
4104
+ Cypress.version // => "1.4.0"
4105
+ Cypress._ // => Lodash _
4106
+ ```
3916
4107
  */
3917
4108
  declare const Cypress: Cypress.Cypress
@@ -0,0 +1,11 @@
1
+ // Shim definition to export a namespace. Cypress is actually a global module
2
+ // so import/export isn't allowed there. We import here and define a global module
3
+ // so that Cypress can get and use the Moment type
4
+ // tslint:disable-next-line:no-implicit-dependencies
5
+ import * as moment from 'moment'
6
+ export = Moment
7
+ export as namespace Moment
8
+
9
+ declare namespace Moment {
10
+ type MomentStatic = typeof moment
11
+ }