cypress 5.2.0 → 5.6.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.
@@ -1107,7 +1107,7 @@ declare namespace Cypress {
1107
1107
  ...args: any[]
1108
1108
  ): Chainable<R>
1109
1109
  invoke<K extends keyof Subject, F extends ((...args: any[]) => any) & Subject[K], R = ReturnType<F>>(
1110
- options: Loggable,
1110
+ options: Partial<Loggable & Timeoutable>,
1111
1111
  functionName: K,
1112
1112
  ...args: any[]
1113
1113
  ): Chainable<R>
@@ -1117,7 +1117,7 @@ declare namespace Cypress {
1117
1117
  * @see https://on.cypress.io/invoke
1118
1118
  */
1119
1119
  invoke<T extends (...args: any[]) => any, Subject extends T[]>(index: number): Chainable<ReturnType<T>>
1120
- invoke<T extends (...args: any[]) => any, Subject extends T[]>(options: Loggable, index: number): Chainable<ReturnType<T>>
1120
+ invoke<T extends (...args: any[]) => any, Subject extends T[]>(options: Partial<Loggable & Timeoutable>, index: number): Chainable<ReturnType<T>>
1121
1121
 
1122
1122
  /**
1123
1123
  * Invoke a function on the previously yielded subject by a property path.
@@ -1138,8 +1138,8 @@ declare namespace Cypress {
1138
1138
  * // Drill into nested properties by using dot notation
1139
1139
  * cy.wrap({foo: {bar: {baz: 1}}}).its('foo.bar.baz')
1140
1140
  */
1141
- its<K extends keyof Subject>(propertyName: K, options?: Loggable): Chainable<Subject[K]>
1142
- its(propertyPath: string, options?: Loggable): Chainable
1141
+ its<K extends keyof Subject>(propertyName: K, options?: Partial<Loggable & Timeoutable>): Chainable<Subject[K]>
1142
+ its(propertyPath: string, options?: Partial<Loggable & Timeoutable>): Chainable
1143
1143
 
1144
1144
  /**
1145
1145
  * Get a value by index from an array yielded from the previous command.
@@ -1147,7 +1147,7 @@ declare namespace Cypress {
1147
1147
  * @example
1148
1148
  * cy.wrap(['a', 'b']).its(1).should('equal', 'b')
1149
1149
  */
1150
- its<T, Subject extends T[]>(index: number, options?: Loggable): Chainable<T>
1150
+ its<T, Subject extends T[]>(index: number, options?: Partial<Loggable & Timeoutable>): Chainable<T>
1151
1151
 
1152
1152
  /**
1153
1153
  * Get the last DOM element within a set of DOM elements.
@@ -1766,7 +1766,7 @@ declare namespace Cypress {
1766
1766
  *
1767
1767
  * @see https://on.cypress.io/task
1768
1768
  */
1769
- task(event: string, arg?: any, options?: Partial<Loggable & Timeoutable>): Chainable<Subject>
1769
+ task<S = unknown>(event: string, arg?: any, options?: Partial<Loggable & Timeoutable>): Chainable<S>
1770
1770
 
1771
1771
  /**
1772
1772
  * Enables you to work with the subject yielded from the previous command.
@@ -2564,7 +2564,7 @@ declare namespace Cypress {
2564
2564
  */
2565
2565
  waitForAnimations: boolean
2566
2566
  /**
2567
- * 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.
2568
2568
  * If a number is supplied, it will apply to `run` mode and `open` mode.
2569
2569
  * Set the interval to `null` or 0 to disable forced garbage collections.
2570
2570
  * @default { runMode: 1, openMode: null }
@@ -2587,7 +2587,7 @@ declare namespace Cypress {
2587
2587
  * To enable test retries only in runMode, set e.g. `{ openMode: null, runMode: 2 }`
2588
2588
  * @default null
2589
2589
  */
2590
- retries: Nullable<number | {runMode: Nullable<number>, openMode: Nullable<number>}>
2590
+ retries: Nullable<number | {runMode?: Nullable<number>, openMode?: Nullable<number>}>
2591
2591
  /**
2592
2592
  * Enables including elements within the shadow DOM when using querying
2593
2593
  * commands (e.g. cy.get(), cy.find()). Can be set globally in cypress.json,
@@ -5042,7 +5042,7 @@ declare namespace Cypress {
5042
5042
  })
5043
5043
  ```
5044
5044
  */
5045
- (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
5046
5046
  /**
5047
5047
  * Fires when your app calls the global `window.confirm()` method.
5048
5048
  * Cypress will auto accept confirmations. Return `false` from this event and the confirmation will be canceled.
@@ -5102,7 +5102,7 @@ declare namespace Cypress {
5102
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.
5103
5103
  * @see https://on.cypress.io/catalog-of-events#App-Events
5104
5104
  */
5105
- (action: 'fail', fn: (error: Error, mocha: Mocha.IRunnable) => void): void
5105
+ (action: 'fail', fn: (error: Error, mocha: Mocha.Runnable) => void): void
5106
5106
  /**
5107
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.
5108
5108
  * @see https://on.cypress.io/catalog-of-events#App-Events
@@ -5147,16 +5147,16 @@ declare namespace Cypress {
5147
5147
  * Fires before the test and all **before** and **beforeEach** hooks run.
5148
5148
  * @see https://on.cypress.io/catalog-of-events#App-Events
5149
5149
  */
5150
- (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
5151
5151
  /**
5152
5152
  * Fires before the test and all **before** and **beforeEach** hooks run. If a `Promise` is returned, it will be awaited before proceeding.
5153
5153
  */
5154
- (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
5155
5155
  /**
5156
5156
  * Fires after the test and all **afterEach** and **after** hooks run.
5157
5157
  * @see https://on.cypress.io/catalog-of-events#App-Events
5158
5158
  */
5159
- (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
5160
5160
  }
5161
5161
 
5162
5162
  // $CommandQueue from `command_queue.coffee` - a lot to type. Might be more useful if it was written in TS
@@ -5237,7 +5237,7 @@ declare namespace Cypress {
5237
5237
  snapshot(name?: string, options?: { at?: number, next: string }): Log
5238
5238
  }
5239
5239
 
5240
- interface LogConfig {
5240
+ interface LogConfig extends Timeoutable {
5241
5241
  /** The JQuery element for the command. This will highlight the command in the main window when debugging */
5242
5242
  $el: JQuery
5243
5243
  /** Allows the name of the command to be overwritten */
@@ -5295,7 +5295,7 @@ declare namespace Cypress {
5295
5295
 
5296
5296
  type Encodings = 'ascii' | 'base64' | 'binary' | 'hex' | 'latin1' | 'utf8' | 'utf-8' | 'ucs2' | 'ucs-2' | 'utf16le' | 'utf-16le'
5297
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-6' | 'iphone-5' | 'iphone-4' | 'iphone-3' | 'samsung-s10' | 'samsung-note9'
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'
5299
5299
  interface Offset {
5300
5300
  top: number
5301
5301
  left: number