cypress 5.1.0 → 5.5.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 {
@@ -114,7 +114,7 @@ declare namespace Cypress {
114
114
  *
115
115
  * @see https://on.cypress.io/experiments
116
116
  */
117
- type CypressSpecType = "integration" | "component"
117
+ type CypressSpecType = 'integration' | 'component'
118
118
 
119
119
  /**
120
120
  * Window type for Application Under Test(AUT)
@@ -413,7 +413,7 @@ declare namespace Cypress {
413
413
  * Returns a boolean indicating whether an object is a DOM object.
414
414
  */
415
415
  isDom(obj: any): boolean
416
- isType(element: JQuery | HTMLElement , type: string): boolean
416
+ isType(element: JQuery | HTMLElement, type: string): boolean
417
417
  /**
418
418
  * Returns a boolean indicating whether an element is visible.
419
419
  */
@@ -518,7 +518,7 @@ declare namespace Cypress {
518
518
  off: Actions
519
519
  }
520
520
 
521
- type CanReturnChainable = void | Chainable
521
+ type CanReturnChainable = void | Chainable | Promise<unknown>
522
522
  type ThenReturn<S, R> =
523
523
  R extends void ? Chainable<S> :
524
524
  R extends R | undefined ? Chainable<S | Exclude<R, undefined>> :
@@ -1607,15 +1607,12 @@ declare namespace Cypress {
1607
1607
 
1608
1608
  /**
1609
1609
  * Traverse into an element's shadow root.
1610
- * Requires `experimentalShadowDomSupport: true` config option
1611
1610
  *
1612
- @example
1613
- ```js
1614
- cy.get('.top-level > my-component')
1615
- .shadow()
1616
- .find('.my-button')
1617
- .click()
1618
- ```
1611
+ * @example
1612
+ * cy.get('my-component')
1613
+ * .shadow()
1614
+ * .find('.my-button')
1615
+ * .click()
1619
1616
  * @see https://on.cypress.io/experimental
1620
1617
  */
1621
1618
  shadow(): Chainable<Subject>
@@ -2302,7 +2299,7 @@ declare namespace Cypress {
2302
2299
  * @default {@link Timeoutable#timeout}
2303
2300
  * @see https://docs.cypress.io/guides/references/configuration.html#Timeouts
2304
2301
  */
2305
- requestTimeout: number,
2302
+ requestTimeout: number
2306
2303
  /**
2307
2304
  * Time to wait for the response (ms)
2308
2305
  *
@@ -2485,7 +2482,7 @@ declare namespace Cypress {
2485
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.
2486
2483
  * @default "bundled"
2487
2484
  */
2488
- nodeVersion: "system" | "bundled"
2485
+ nodeVersion: 'system' | 'bundled'
2489
2486
  /**
2490
2487
  * Path to plugins file. (Pass false to disable)
2491
2488
  * @default "cypress/plugins/index.js"
@@ -2567,7 +2564,7 @@ declare namespace Cypress {
2567
2564
  */
2568
2565
  waitForAnimations: boolean
2569
2566
  /**
2570
- * 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.
2571
2568
  * If a number is supplied, it will apply to `run` mode and `open` mode.
2572
2569
  * Set the interval to `null` or 0 to disable forced garbage collections.
2573
2570
  * @default { runMode: 1, openMode: null }
@@ -2584,22 +2581,24 @@ declare namespace Cypress {
2584
2581
  * @default false
2585
2582
  */
2586
2583
  experimentalNetworkStubbing: boolean
2587
- /**
2588
- * Enables shadow DOM support. Adds the `cy.shadow()` command and
2589
- * the `includeShadowDom` option to some DOM commands.
2590
- * @default false
2591
- */
2592
- experimentalShadowDomSupport: boolean
2593
2584
  /**
2594
2585
  * Number of times to retry a failed test.
2595
2586
  * If a number is set, tests will retry in both runMode and openMode.
2596
2587
  * To enable test retries only in runMode, set e.g. `{ openMode: null, runMode: 2 }`
2597
2588
  * @default null
2598
2589
  */
2599
- retries: Nullable<number | {runMode: Nullable<number>, openMode: Nullable<number>}>
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
2600
2599
  }
2601
2600
 
2602
- interface TestConfigOverrides extends Partial<Pick<ConfigOptions, 'baseUrl' | 'defaultCommandTimeout' | 'taskTimeout' | 'animationDistanceThreshold' | 'waitForAnimations' | 'viewportHeight' | 'viewportWidth' | 'requestTimeout' | 'execTimeout' | 'env' | 'responseTimeout' | 'retries'>> {
2601
+ interface TestConfigOverrides extends Partial<Pick<ConfigOptions, 'baseUrl' | 'defaultCommandTimeout' | 'taskTimeout' | 'animationDistanceThreshold' | 'waitForAnimations' | 'viewportHeight' | 'viewportWidth' | 'requestTimeout' | 'execTimeout' | 'env' | 'responseTimeout' | 'retries' | 'includeShadowDom'>> {
2603
2602
  browser?: IsBrowserMatcher | IsBrowserMatcher[]
2604
2603
  }
2605
2604
 
@@ -2699,18 +2698,18 @@ declare namespace Cypress {
2699
2698
  scale: boolean
2700
2699
  onBeforeScreenshot: ($el: JQuery) => void
2701
2700
  onAfterScreenshot: ($el: JQuery, props: {
2702
- path: string,
2703
- size: number,
2701
+ path: string
2702
+ size: number
2704
2703
  dimensions: {
2705
- width: number,
2704
+ width: number
2706
2705
  height: number
2707
- },
2708
- multipart: boolean,
2709
- pixelRatio: number,
2710
- takenAt: string,
2711
- name: string,
2712
- blackout: string[],
2713
- duration: number,
2706
+ }
2707
+ multipart: boolean
2708
+ pixelRatio: number
2709
+ takenAt: string
2710
+ name: string
2711
+ blackout: string[]
2712
+ duration: number
2714
2713
  testAttemptIndex: number
2715
2714
  }) => void
2716
2715
  }
@@ -2731,13 +2730,13 @@ declare namespace Cypress {
2731
2730
  *
2732
2731
  * @default 'swing'
2733
2732
  */
2734
- easing: 'swing' | 'linear',
2733
+ easing: 'swing' | 'linear'
2735
2734
  /**
2736
2735
  * Ensure element is scrollable. Error if element is not scrollable
2737
2736
  *
2738
2737
  * @default true
2739
2738
  */
2740
- ensureScrollable: boolean,
2739
+ ensureScrollable: boolean
2741
2740
  }
2742
2741
 
2743
2742
  interface ScrollIntoViewOptions extends ScrollToOptions {
@@ -2786,6 +2785,10 @@ declare namespace Cypress {
2786
2785
  sameSite: SameSiteStatus
2787
2786
  }
2788
2787
 
2788
+ interface ShadowDomOptions {
2789
+ includeShadowDom?: boolean
2790
+ }
2791
+
2789
2792
  /**
2790
2793
  * Options that control `cy.type` command
2791
2794
  *
@@ -4948,9 +4951,9 @@ declare namespace Cypress {
4948
4951
  }
4949
4952
 
4950
4953
  interface BrowserLaunchOptions {
4951
- extensions: string[],
4954
+ extensions: string[]
4952
4955
  preferences: { [key: string]: any }
4953
- args: string[],
4956
+ args: string[]
4954
4957
  }
4955
4958
 
4956
4959
  interface Dimensions {
@@ -5039,7 +5042,7 @@ declare namespace Cypress {
5039
5042
  })
5040
5043
  ```
5041
5044
  */
5042
- (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
5043
5046
  /**
5044
5047
  * Fires when your app calls the global `window.confirm()` method.
5045
5048
  * Cypress will auto accept confirmations. Return `false` from this event and the confirmation will be canceled.
@@ -5099,7 +5102,7 @@ declare namespace Cypress {
5099
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.
5100
5103
  * @see https://on.cypress.io/catalog-of-events#App-Events
5101
5104
  */
5102
- (action: 'fail', fn: (error: Error, mocha: Mocha.IRunnable) => void): void
5105
+ (action: 'fail', fn: (error: Error, mocha: Mocha.Runnable) => void): void
5103
5106
  /**
5104
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.
5105
5108
  * @see https://on.cypress.io/catalog-of-events#App-Events
@@ -5144,16 +5147,16 @@ declare namespace Cypress {
5144
5147
  * Fires before the test and all **before** and **beforeEach** hooks run.
5145
5148
  * @see https://on.cypress.io/catalog-of-events#App-Events
5146
5149
  */
5147
- (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
5148
5151
  /**
5149
5152
  * Fires before the test and all **before** and **beforeEach** hooks run. If a `Promise` is returned, it will be awaited before proceeding.
5150
5153
  */
5151
- (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
5152
5155
  /**
5153
5156
  * Fires after the test and all **afterEach** and **after** hooks run.
5154
5157
  * @see https://on.cypress.io/catalog-of-events#App-Events
5155
5158
  */
5156
- (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
5157
5160
  }
5158
5161
 
5159
5162
  // $CommandQueue from `command_queue.coffee` - a lot to type. Might be more useful if it was written in TS
@@ -5291,10 +5294,10 @@ declare namespace Cypress {
5291
5294
  }
5292
5295
 
5293
5296
  type Encodings = 'ascii' | 'base64' | 'binary' | 'hex' | 'latin1' | 'utf8' | 'utf-8' | 'ucs2' | 'ucs-2' | 'utf16le' | 'utf-16le'
5294
- type PositionType = "topLeft" | "top" | "topRight" | "left" | "center" | "right" | "bottomLeft" | "bottom" | "bottomRight"
5295
- 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-16' | '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'
5296
5299
  interface Offset {
5297
- top: number,
5300
+ top: number
5298
5301
  left: number
5299
5302
  }
5300
5303
 
@@ -5382,6 +5385,6 @@ declare namespace Mocha {
5382
5385
  }
5383
5386
 
5384
5387
  interface PendingSuiteFunction {
5385
- (title: string, config: Cypress.TestConfigOverrides, fn: (this: Suite) => void): Suite | void
5388
+ (title: string, config: Cypress.TestConfigOverrides, fn: (this: Suite) => void): Suite | void
5386
5389
  }
5387
5390
  }