cypress 5.0.0 → 5.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -8,6 +8,7 @@
8
8
 
9
9
  declare namespace CypressCommandLine {
10
10
  type HookName = 'before' | 'beforeEach' | 'afterEach' | 'after'
11
+
11
12
  interface TestError {
12
13
  name: string
13
14
  message: string
@@ -225,7 +226,7 @@ declare namespace CypressCommandLine {
225
226
  startedAt: dateTimeISO
226
227
  endedAt: dateTimeISO
227
228
  duration: ms
228
- },
229
+ }
229
230
  /**
230
231
  * Reporter name like "spec"
231
232
  */
@@ -255,7 +256,7 @@ declare namespace CypressCommandLine {
255
256
  * resolved filename of the spec
256
257
  */
257
258
  absolute: string
258
- },
259
+ }
259
260
  shouldUploadVideo: boolean
260
261
  }
261
262
 
@@ -264,6 +265,7 @@ declare namespace CypressCommandLine {
264
265
  * @see https://on.cypress.io/module-api
265
266
  */
266
267
  interface CypressRunResult {
268
+ status: 'finished'
267
269
  startedTestsAt: dateTimeISO
268
270
  endedTestsAt: dateTimeISO
269
271
  totalDuration: ms
@@ -294,7 +296,8 @@ declare namespace CypressCommandLine {
294
296
  * @example
295
297
  ```
296
298
  const result = await cypress.run()
297
- if (result.failures) {
299
+ if (result.status === 'failed') {
300
+ console.error('failures %d', result.failures)
298
301
  console.error(result.message)
299
302
  process.exit(result.failures)
300
303
  }
@@ -302,6 +305,7 @@ declare namespace CypressCommandLine {
302
305
  *
303
306
  **/
304
307
  interface CypressFailedRunResult {
308
+ status: 'failed'
305
309
  failures: number
306
310
  message: string
307
311
  }
@@ -347,11 +351,15 @@ declare module 'cypress' {
347
351
  cypress.run({
348
352
  spec: 'cypress/integration/admin*-spec.js'
349
353
  }).then(results => {
350
- // inspect results object
354
+ if (results.status === 'failed') {
355
+ // Cypress could not run
356
+ } else {
357
+ // inspect results object
358
+ }
351
359
  })
352
360
  ```
353
361
  */
354
- run(options?: Partial<CypressCommandLine.CypressRunOptions>): Promise<CypressCommandLine.CypressRunResult | CypressCommandLine.CypressFailedRunResult>,
362
+ run(options?: Partial<CypressCommandLine.CypressRunOptions>): Promise<CypressCommandLine.CypressRunResult | CypressCommandLine.CypressFailedRunResult>
355
363
  /**
356
364
  * Opens Cypress GUI. Resolves with void when the
357
365
  * GUI is closed.
@@ -1,10 +1,10 @@
1
1
  declare namespace Cypress {
2
2
  type FileContents = string | any[] | object
3
- type HistoryDirection = "back" | "forward"
3
+ type HistoryDirection = 'back' | 'forward'
4
4
  type HttpMethod = string
5
5
  type RequestBody = string | object
6
- type ViewportOrientation = "portrait" | "landscape"
7
- type PrevSubject = "optional" | "element" | "document" | "window"
6
+ type ViewportOrientation = 'portrait' | 'landscape'
7
+ type PrevSubject = 'optional' | 'element' | 'document' | 'window'
8
8
  type PluginConfig = (on: PluginEvents, config: PluginConfigOptions) => void | ConfigOptions | Promise<ConfigOptions>
9
9
 
10
10
  interface CommandOptions {
@@ -26,6 +26,7 @@ declare namespace Cypress {
26
26
  * @see https://on.cypress.io/firefox-gc-issue
27
27
  */
28
28
  (task: 'firefox:force:gc'): Promise<void>
29
+ (task: 'net', eventName: string, frame: any): Promise<void>
29
30
  }
30
31
 
31
32
  type BrowserName = 'electron' | 'chrome' | 'chromium' | 'firefox' | 'edge' | string
@@ -107,6 +108,14 @@ declare namespace Cypress {
107
108
  fromAutWindow: WindowPosition & { x: number, y: number }
108
109
  }
109
110
 
111
+ /**
112
+ * Spec type for the given test. "integration" is the default, but
113
+ * tests run using experimentalComponentTesting will be "component"
114
+ *
115
+ * @see https://on.cypress.io/experiments
116
+ */
117
+ type CypressSpecType = 'integration' | 'component'
118
+
110
119
  /**
111
120
  * Window type for Application Under Test(AUT)
112
121
  */
@@ -221,6 +230,7 @@ declare namespace Cypress {
221
230
  // name: "config_passing_spec.coffee",
222
231
  // relative: "cypress/integration/config_passing_spec.coffee",
223
232
  // absolute: "/users/smith/projects/web/cypress/integration/config_passing_spec.coffee"
233
+ // specType: "integration"
224
234
  // }
225
235
  ```
226
236
  */
@@ -229,6 +239,7 @@ declare namespace Cypress {
229
239
  relative: string // "cypress/integration/config_passing_spec.coffee" or "__all" if clicked all specs button
230
240
  absolute: string
231
241
  specFilter?: string // optional spec filter used by the user
242
+ specType?: CypressSpecType
232
243
  }
233
244
 
234
245
  /**
@@ -402,7 +413,7 @@ declare namespace Cypress {
402
413
  * Returns a boolean indicating whether an object is a DOM object.
403
414
  */
404
415
  isDom(obj: any): boolean
405
- isType(element: JQuery | HTMLElement , type: string): boolean
416
+ isType(element: JQuery | HTMLElement, type: string): boolean
406
417
  /**
407
418
  * Returns a boolean indicating whether an element is visible.
408
419
  */
@@ -507,7 +518,7 @@ declare namespace Cypress {
507
518
  off: Actions
508
519
  }
509
520
 
510
- type CanReturnChainable = void | Chainable
521
+ type CanReturnChainable = void | Chainable | Promise<unknown>
511
522
  type ThenReturn<S, R> =
512
523
  R extends void ? Chainable<S> :
513
524
  R extends R | undefined ? Chainable<S | Exclude<R, undefined>> :
@@ -1596,15 +1607,12 @@ declare namespace Cypress {
1596
1607
 
1597
1608
  /**
1598
1609
  * Traverse into an element's shadow root.
1599
- * Requires `experimentalShadowDomSupport: true` config option
1600
1610
  *
1601
- @example
1602
- ```js
1603
- cy.get('.top-level > my-component')
1604
- .shadow()
1605
- .find('.my-button')
1606
- .click()
1607
- ```
1611
+ * @example
1612
+ * cy.get('my-component')
1613
+ * .shadow()
1614
+ * .find('.my-button')
1615
+ * .click()
1608
1616
  * @see https://on.cypress.io/experimental
1609
1617
  */
1610
1618
  shadow(): Chainable<Subject>
@@ -2291,7 +2299,7 @@ declare namespace Cypress {
2291
2299
  * @default {@link Timeoutable#timeout}
2292
2300
  * @see https://docs.cypress.io/guides/references/configuration.html#Timeouts
2293
2301
  */
2294
- requestTimeout: number,
2302
+ requestTimeout: number
2295
2303
  /**
2296
2304
  * Time to wait for the response (ms)
2297
2305
  *
@@ -2474,7 +2482,7 @@ declare namespace Cypress {
2474
2482
  * If set to `system`, Cypress will try to find a `node` executable on your path to use when executing your plugins. Otherwise, Cypress will use the Node version bundled with Cypress.
2475
2483
  * @default "bundled"
2476
2484
  */
2477
- nodeVersion: "system" | "bundled"
2485
+ nodeVersion: 'system' | 'bundled'
2478
2486
  /**
2479
2487
  * Path to plugins file. (Pass false to disable)
2480
2488
  * @default "cypress/plugins/index.js"
@@ -2556,7 +2564,7 @@ declare namespace Cypress {
2556
2564
  */
2557
2565
  waitForAnimations: boolean
2558
2566
  /**
2559
- * Firefox-only: The number of tests that will run between forced garbage collections.
2567
+ * Firefox version 79 and below only: The number of tests that will run between forced garbage collections.
2560
2568
  * If a number is supplied, it will apply to `run` mode and `open` mode.
2561
2569
  * Set the interval to `null` or 0 to disable forced garbage collections.
2562
2570
  * @default { runMode: 1, openMode: null }
@@ -2569,10 +2577,10 @@ declare namespace Cypress {
2569
2577
  */
2570
2578
  experimentalSourceRewriting: boolean
2571
2579
  /**
2572
- * Enables shadow DOM support. Adds the `cy.shadow()` command and
2573
- * the `includeShadowDom` option to some DOM commands.
2580
+ * Enables `cy.route2`, which can be used to dynamically intercept/stub/await any HTTP request or response (XHRs, fetch, beacons, etc.)
2581
+ * @default false
2574
2582
  */
2575
- experimentalShadowDomSupport: boolean
2583
+ experimentalNetworkStubbing: boolean
2576
2584
  /**
2577
2585
  * Number of times to retry a failed test.
2578
2586
  * If a number is set, tests will retry in both runMode and openMode.
@@ -2580,10 +2588,17 @@ declare namespace Cypress {
2580
2588
  * @default null
2581
2589
  */
2582
2590
  retries: Nullable<number | {runMode: Nullable<number>, openMode: Nullable<number>}>
2591
+ /**
2592
+ * Enables including elements within the shadow DOM when using querying
2593
+ * commands (e.g. cy.get(), cy.find()). Can be set globally in cypress.json,
2594
+ * per-suite or per-test in the test configuration object, or programmatically
2595
+ * with Cypress.config()
2596
+ * @default false
2597
+ */
2598
+ includeShadowDom: boolean
2583
2599
  }
2584
2600
 
2585
- interface TestConfigOverrides extends Partial<Pick<ConfigOptions, 'baseUrl' | 'defaultCommandTimeout' | 'taskTimeout' | 'animationDistanceThreshold' | 'waitForAnimations' | 'viewportHeight' | 'viewportWidth' | 'requestTimeout' | 'execTimeout' | 'env' | 'responseTimeout'>> {
2586
- // retries?: number
2601
+ interface TestConfigOverrides extends Partial<Pick<ConfigOptions, 'baseUrl' | 'defaultCommandTimeout' | 'taskTimeout' | 'animationDistanceThreshold' | 'waitForAnimations' | 'viewportHeight' | 'viewportWidth' | 'requestTimeout' | 'execTimeout' | 'env' | 'responseTimeout' | 'retries' | 'includeShadowDom'>> {
2587
2602
  browser?: IsBrowserMatcher | IsBrowserMatcher[]
2588
2603
  }
2589
2604
 
@@ -2683,18 +2698,18 @@ declare namespace Cypress {
2683
2698
  scale: boolean
2684
2699
  onBeforeScreenshot: ($el: JQuery) => void
2685
2700
  onAfterScreenshot: ($el: JQuery, props: {
2686
- path: string,
2687
- size: number,
2701
+ path: string
2702
+ size: number
2688
2703
  dimensions: {
2689
- width: number,
2704
+ width: number
2690
2705
  height: number
2691
- },
2692
- multipart: boolean,
2693
- pixelRatio: number,
2694
- takenAt: string,
2695
- name: string,
2696
- blackout: string[],
2697
- duration: number,
2706
+ }
2707
+ multipart: boolean
2708
+ pixelRatio: number
2709
+ takenAt: string
2710
+ name: string
2711
+ blackout: string[]
2712
+ duration: number
2698
2713
  testAttemptIndex: number
2699
2714
  }) => void
2700
2715
  }
@@ -2715,13 +2730,13 @@ declare namespace Cypress {
2715
2730
  *
2716
2731
  * @default 'swing'
2717
2732
  */
2718
- easing: 'swing' | 'linear',
2733
+ easing: 'swing' | 'linear'
2719
2734
  /**
2720
2735
  * Ensure element is scrollable. Error if element is not scrollable
2721
2736
  *
2722
2737
  * @default true
2723
2738
  */
2724
- ensureScrollable: boolean,
2739
+ ensureScrollable: boolean
2725
2740
  }
2726
2741
 
2727
2742
  interface ScrollIntoViewOptions extends ScrollToOptions {
@@ -2770,6 +2785,10 @@ declare namespace Cypress {
2770
2785
  sameSite: SameSiteStatus
2771
2786
  }
2772
2787
 
2788
+ interface ShadowDomOptions {
2789
+ includeShadowDom?: boolean
2790
+ }
2791
+
2773
2792
  /**
2774
2793
  * Options that control `cy.type` command
2775
2794
  *
@@ -2900,6 +2919,12 @@ declare namespace Cypress {
2900
2919
  * @default true
2901
2920
  */
2902
2921
  cancelable: boolean
2922
+ /**
2923
+ * The type of the event you want to trigger
2924
+ *
2925
+ * @default 'Event'
2926
+ */
2927
+ eventConstructor: string
2903
2928
  }
2904
2929
 
2905
2930
  /** Options to change the default behavior of .writeFile */
@@ -4926,9 +4951,9 @@ declare namespace Cypress {
4926
4951
  }
4927
4952
 
4928
4953
  interface BrowserLaunchOptions {
4929
- extensions: string[],
4954
+ extensions: string[]
4930
4955
  preferences: { [key: string]: any }
4931
- args: string[],
4956
+ args: string[]
4932
4957
  }
4933
4958
 
4934
4959
  interface Dimensions {
@@ -5017,7 +5042,7 @@ declare namespace Cypress {
5017
5042
  })
5018
5043
  ```
5019
5044
  */
5020
- (action: 'uncaught:exception', fn: (error: Error, runnable: Mocha.IRunnable) => false | void): void
5045
+ (action: 'uncaught:exception', fn: (error: Error, runnable: Mocha.Runnable) => false | void): void
5021
5046
  /**
5022
5047
  * Fires when your app calls the global `window.confirm()` method.
5023
5048
  * Cypress will auto accept confirmations. Return `false` from this event and the confirmation will be canceled.
@@ -5077,7 +5102,7 @@ declare namespace Cypress {
5077
5102
  * Fires when the test has failed. It is technically possible to prevent the test from actually failing by binding to this event and invoking an async `done` callback. However this is **strongly discouraged**. Tests should never legitimately fail. This event exists because it's extremely useful for debugging purposes.
5078
5103
  * @see https://on.cypress.io/catalog-of-events#App-Events
5079
5104
  */
5080
- (action: 'fail', fn: (error: Error, mocha: Mocha.IRunnable) => void): void
5105
+ (action: 'fail', fn: (error: Error, mocha: Mocha.Runnable) => void): void
5081
5106
  /**
5082
5107
  * Fires whenever the viewport changes via a `cy.viewport()` or naturally when Cypress resets the viewport to the default between tests. Useful for debugging purposes.
5083
5108
  * @see https://on.cypress.io/catalog-of-events#App-Events
@@ -5122,16 +5147,16 @@ declare namespace Cypress {
5122
5147
  * Fires before the test and all **before** and **beforeEach** hooks run.
5123
5148
  * @see https://on.cypress.io/catalog-of-events#App-Events
5124
5149
  */
5125
- (action: 'test:before:run', fn: (attributes: ObjectLike, test: Mocha.ITest) => void): void
5150
+ (action: 'test:before:run', fn: (attributes: ObjectLike, test: Mocha.Test) => void): void
5126
5151
  /**
5127
5152
  * Fires before the test and all **before** and **beforeEach** hooks run. If a `Promise` is returned, it will be awaited before proceeding.
5128
5153
  */
5129
- (action: 'test:before:run:async', fn: (attributes: ObjectLike, test: Mocha.ITest) => void | Promise<any>): void
5154
+ (action: 'test:before:run:async', fn: (attributes: ObjectLike, test: Mocha.Test) => void | Promise<any>): void
5130
5155
  /**
5131
5156
  * Fires after the test and all **afterEach** and **after** hooks run.
5132
5157
  * @see https://on.cypress.io/catalog-of-events#App-Events
5133
5158
  */
5134
- (action: 'test:after:run', fn: (attributes: ObjectLike, test: Mocha.ITest) => void): void
5159
+ (action: 'test:after:run', fn: (attributes: ObjectLike, test: Mocha.Test) => void): void
5135
5160
  }
5136
5161
 
5137
5162
  // $CommandQueue from `command_queue.coffee` - a lot to type. Might be more useful if it was written in TS
@@ -5269,10 +5294,10 @@ declare namespace Cypress {
5269
5294
  }
5270
5295
 
5271
5296
  type Encodings = 'ascii' | 'base64' | 'binary' | 'hex' | 'latin1' | 'utf8' | 'utf-8' | 'ucs2' | 'ucs-2' | 'utf16le' | 'utf-16le'
5272
- type PositionType = "topLeft" | "top" | "topRight" | "left" | "center" | "right" | "bottomLeft" | "bottom" | "bottomRight"
5273
- type ViewportPreset = 'macbook-15' | 'macbook-13' | 'macbook-11' | 'ipad-2' | 'ipad-mini' | 'iphone-xr' | 'iphone-x' | 'iphone-6+' | 'iphone-6' | 'iphone-5' | 'iphone-4' | 'iphone-3' | 'samsung-s10' | 'samsung-note9'
5297
+ type PositionType = 'topLeft' | 'top' | 'topRight' | 'left' | 'center' | 'right' | 'bottomLeft' | 'bottom' | 'bottomRight'
5298
+ type ViewportPreset = 'macbook-15' | 'macbook-13' | 'macbook-11' | 'ipad-2' | 'ipad-mini' | 'iphone-xr' | 'iphone-x' | 'iphone-6+' | 'iphone-se2' | 'iphone-8' | 'iphone-7' | 'iphone-6' | 'iphone-5' | 'iphone-4' | 'iphone-3' | 'samsung-s10' | 'samsung-note9'
5274
5299
  interface Offset {
5275
- top: number,
5300
+ top: number
5276
5301
  left: number
5277
5302
  }
5278
5303
 
@@ -5305,39 +5330,39 @@ declare namespace Cypress {
5305
5330
  declare namespace Mocha {
5306
5331
  interface TestFunction {
5307
5332
  /**
5308
- * Describe a specification or test-case with the given `title`, TestCptions, and callback `fn` acting
5333
+ * Describe a specification or test-case with the given `title`, TestOptions, and callback `fn` acting
5309
5334
  * as a thunk.
5310
5335
  */
5311
5336
  (title: string, config: Cypress.TestConfigOverrides, fn?: Func): Test
5312
5337
 
5313
5338
  /**
5314
- * Describe a specification or test-case with the given `title`, TestCptions, and callback `fn` acting
5339
+ * Describe a specification or test-case with the given `title`, TestOptions, and callback `fn` acting
5315
5340
  * as a thunk.
5316
5341
  */
5317
5342
  (title: string, config: Cypress.TestConfigOverrides, fn?: AsyncFunc): Test
5318
5343
  }
5319
5344
  interface ExclusiveTestFunction {
5320
5345
  /**
5321
- * Describe a specification or test-case with the given `title`, TestCptions, and callback `fn` acting
5346
+ * Describe a specification or test-case with the given `title`, TestOptions, and callback `fn` acting
5322
5347
  * as a thunk.
5323
5348
  */
5324
5349
  (title: string, config: Cypress.TestConfigOverrides, fn?: Func): Test
5325
5350
 
5326
5351
  /**
5327
- * Describe a specification or test-case with the given `title`, TestCptions, and callback `fn` acting
5352
+ * Describe a specification or test-case with the given `title`, TestOptions, and callback `fn` acting
5328
5353
  * as a thunk.
5329
5354
  */
5330
5355
  (title: string, config: Cypress.TestConfigOverrides, fn?: AsyncFunc): Test
5331
5356
  }
5332
5357
  interface PendingTestFunction {
5333
5358
  /**
5334
- * Describe a specification or test-case with the given `title`, TestCptions, and callback `fn` acting
5359
+ * Describe a specification or test-case with the given `title`, TestOptions, and callback `fn` acting
5335
5360
  * as a thunk.
5336
5361
  */
5337
5362
  (title: string, config: Cypress.TestConfigOverrides, fn?: Func): Test
5338
5363
 
5339
5364
  /**
5340
- * Describe a specification or test-case with the given `title`, TestCptions, and callback `fn` acting
5365
+ * Describe a specification or test-case with the given `title`, TestOptions, and callback `fn` acting
5341
5366
  * as a thunk.
5342
5367
  */
5343
5368
  (title: string, config: Cypress.TestConfigOverrides, fn?: AsyncFunc): Test
@@ -5345,7 +5370,7 @@ declare namespace Mocha {
5345
5370
 
5346
5371
  interface SuiteFunction {
5347
5372
  /**
5348
- * Describe a "suite" with the given `title`, TestCptions, and callback `fn` containing
5373
+ * Describe a "suite" with the given `title`, TestOptions, and callback `fn` containing
5349
5374
  * nested suites.
5350
5375
  */
5351
5376
  (title: string, config: Cypress.TestConfigOverrides, fn: (this: Suite) => void): Suite
@@ -5353,13 +5378,13 @@ declare namespace Mocha {
5353
5378
 
5354
5379
  interface ExclusiveSuiteFunction {
5355
5380
  /**
5356
- * Describe a "suite" with the given `title`, TestCptions, and callback `fn` containing
5381
+ * Describe a "suite" with the given `title`, TestOptions, and callback `fn` containing
5357
5382
  * nested suites. Indicates this suite should be executed exclusively.
5358
5383
  */
5359
5384
  (title: string, config: Cypress.TestConfigOverrides, fn: (this: Suite) => void): Suite
5360
5385
  }
5361
5386
 
5362
5387
  interface PendingSuiteFunction {
5363
- (title: string, config: Cypress.TestConfigOverrides, fn: (this: Suite) => void): Suite | void
5388
+ (title: string, config: Cypress.TestConfigOverrides, fn: (this: Suite) => void): Suite | void
5364
5389
  }
5365
5390
  }
package/types/index.d.ts CHANGED
@@ -27,6 +27,7 @@
27
27
  // hmm, how to load it better?
28
28
  /// <reference path="./cypress-npm-api.d.ts" />
29
29
 
30
+ /// <reference path="./net-stubbing.ts" />
30
31
  /// <reference path="./cypress.d.ts" />
31
32
  /// <reference path="./cypress-global-vars.d.ts" />
32
33
  /// <reference path="./cypress-type-helpers.d.ts" />