cypress 9.5.4 → 9.6.0

Sign up to get free protection for your applications and to get access to all the features.
package/lib/errors.js CHANGED
@@ -58,6 +58,12 @@ const failedUnzip = {
58
58
  description: 'The Cypress App could not be unzipped.',
59
59
  solution: genericErrorSolution
60
60
  };
61
+ const failedUnzipWindowsMaxPathLength = {
62
+ description: 'The Cypress App could not be unzipped.',
63
+ solution: `This is most likely because the maximum path length is being exceeded on your system.
64
+
65
+ Read here for solutions to this problem: https://on.cypress.io/win-max-path-length-error`
66
+ };
61
67
 
62
68
  const missingApp = binaryDir => {
63
69
  return {
@@ -383,6 +389,7 @@ module.exports = {
383
389
  unexpected,
384
390
  failedDownload,
385
391
  failedUnzip,
392
+ failedUnzipWindowsMaxPathLength,
386
393
  invalidCypressEnv,
387
394
  invalidCacheDirectory,
388
395
  CYPRESS_RUN_BINARY,
@@ -188,7 +188,11 @@ const unzip = ({
188
188
  });
189
189
  };
190
190
 
191
- const start = ({
191
+ function isMaybeWindowsMaxPathLengthError(err) {
192
+ return os.platform() === 'win32' && err.code === 'ENOENT' && err.syscall === 'realpath';
193
+ }
194
+
195
+ const start = async ({
192
196
  zipFilePath,
193
197
  installDir,
194
198
  progress
@@ -203,18 +207,23 @@ const start = ({
203
207
  };
204
208
  }
205
209
 
206
- return fs.pathExists(installDir).then(exists => {
207
- if (exists) {
210
+ try {
211
+ const installDirExists = await fs.pathExists(installDir);
212
+
213
+ if (installDirExists) {
208
214
  debug('removing existing unzipped binary', installDir);
209
- return fs.removeAsync(installDir);
215
+ await fs.removeAsync(installDir);
210
216
  }
211
- }).then(() => {
212
- return unzip({
217
+
218
+ await unzip({
213
219
  zipFilePath,
214
220
  installDir,
215
221
  progress
216
222
  });
217
- }).catch(throwFormErrorText(errors.failedUnzip));
223
+ } catch (err) {
224
+ const errorTemplate = isMaybeWindowsMaxPathLengthError(err) ? errors.failedUnzipWindowsMaxPathLength : errors.failedUnzip;
225
+ await throwFormErrorText(errorTemplate)(err);
226
+ }
218
227
  };
219
228
 
220
229
  module.exports = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cypress",
3
- "version": "9.5.4",
3
+ "version": "9.6.0",
4
4
  "main": "index.js",
5
5
  "scripts": {
6
6
  "postinstall": "node index.js --exec install",
@@ -66,8 +66,8 @@
66
66
  "types": "types",
67
67
  "buildInfo": {
68
68
  "commitBranch": "develop",
69
- "commitSha": "6934c0398fea92cc05714b18f21f7f06645a0b70",
70
- "commitDate": "2022-04-11T17:25:33.000Z",
69
+ "commitSha": "676fc97f46f9798b5f17ee6d292924f8e1a0c82b",
70
+ "commitDate": "2022-04-25T12:54:32.000Z",
71
71
  "stable": true
72
72
  },
73
73
  "description": "Cypress.io end to end testing tool",
@@ -10,10 +10,13 @@ declare namespace Cypress {
10
10
  type PrevSubject = keyof PrevSubjectMap
11
11
  type TestingType = 'e2e' | 'component'
12
12
  type PluginConfig = (on: PluginEvents, config: PluginConfigOptions) => void | ConfigOptions | Promise<ConfigOptions>
13
+ interface JQueryWithSelector<TElement = HTMLElement> extends JQuery<TElement> {
14
+ selector?: string | null
15
+ }
13
16
 
14
17
  interface PrevSubjectMap<O = unknown> {
15
18
  optional: O
16
- element: JQuery
19
+ element: JQueryWithSelector
17
20
  document: Document
18
21
  window: Window
19
22
  }
@@ -53,19 +56,6 @@ declare namespace Cypress {
53
56
  password: string
54
57
  }
55
58
 
56
- interface RemoteState {
57
- auth?: {
58
- username: string
59
- password: string
60
- }
61
- domainName: string
62
- strategy: 'file' | 'http'
63
- origin: string
64
- fileServer: string
65
- props: Record<string, any>
66
- visiting: string
67
- }
68
-
69
59
  interface Backend {
70
60
  /**
71
61
  * Firefox only: Force Cypress to run garbage collection routines.
@@ -467,16 +457,18 @@ declare namespace Cypress {
467
457
  Commands: {
468
458
  add<T extends keyof Chainable>(name: T, fn: CommandFn<T>): void
469
459
  add<T extends keyof Chainable>(name: T, options: CommandOptions & {prevSubject: false}, fn: CommandFn<T>): void
460
+ add<T extends keyof Chainable, S = any>(name: T, options: CommandOptions & {prevSubject: true}, fn: CommandFnWithSubject<T, S>): void
470
461
  add<T extends keyof Chainable, S extends PrevSubject>(
471
- name: T, options: CommandOptions & { prevSubject: true | S | ['optional'] }, fn: CommandFnWithSubject<T, PrevSubjectMap[S]>,
462
+ name: T, options: CommandOptions & { prevSubject: S | ['optional'] }, fn: CommandFnWithSubject<T, PrevSubjectMap[S]>,
472
463
  ): void
473
464
  add<T extends keyof Chainable, S extends PrevSubject>(
474
465
  name: T, options: CommandOptions & { prevSubject: S[] }, fn: CommandFnWithSubject<T, PrevSubjectMap<void>[S]>,
475
466
  ): void
476
467
  addAll<T extends keyof Chainable>(fns: CommandFns): void
477
468
  addAll<T extends keyof Chainable>(options: CommandOptions & {prevSubject: false}, fns: CommandFns): void
469
+ addAll<T extends keyof Chainable, S = any>(options: CommandOptions & { prevSubject: true }, fns: CommandFnsWithSubject<S>): void
478
470
  addAll<T extends keyof Chainable, S extends PrevSubject>(
479
- options: CommandOptions & { prevSubject: true | S | ['optional'] }, fns: CommandFnsWithSubject<PrevSubjectMap[S]>,
471
+ options: CommandOptions & { prevSubject: S | ['optional'] }, fns: CommandFnsWithSubject<PrevSubjectMap[S]>,
480
472
  ): void
481
473
  addAll<T extends keyof Chainable, S extends PrevSubject>(
482
474
  options: CommandOptions & { prevSubject: S[] }, fns: CommandFnsWithSubject<PrevSubjectMap<void>[S]>,
@@ -634,7 +626,7 @@ declare namespace Cypress {
634
626
  * Trigger action
635
627
  * @private
636
628
  */
637
- action: (action: string, ...args: any[]) => void
629
+ action: (action: string, ...args: any[]) => any[] | void
638
630
 
639
631
  /**
640
632
  * Load files
@@ -1059,7 +1051,7 @@ declare namespace Cypress {
1059
1051
  /**
1060
1052
  * Save/Restore browser Cookies, LocalStorage, and SessionStorage data resulting from the supplied `setup` function.
1061
1053
  *
1062
- * Only available if the `experimentalSessionSupport` config option is enabled.
1054
+ * Only available if the `experimentalSessionAndOrigin` config option is enabled.
1063
1055
  *
1064
1056
  * @see https://on.cypress.io/session
1065
1057
  */
@@ -1421,6 +1413,29 @@ declare namespace Cypress {
1421
1413
  */
1422
1414
  off: Actions
1423
1415
 
1416
+ /**
1417
+ * Enables running Cypress commands in a secondary origin.
1418
+ * @see https://on.cypress.io/origin
1419
+ * @example
1420
+ * cy.origin('example.com', () => {
1421
+ * cy.get('h1').should('equal', 'Example Domain')
1422
+ * })
1423
+ */
1424
+ origin<T extends any>(urlOrDomain: string, fn: () => void): Chainable<T>
1425
+
1426
+ /**
1427
+ * Enables running Cypress commands in a secondary origin.
1428
+ * @see https://on.cypress.io/origin
1429
+ * @example
1430
+ * cy.origin('example.com', { args: { key: 'value', foo: 'foo' } }, ({ key, foo }) => {
1431
+ * expect(key).to.equal('value')
1432
+ * expect(foo).to.equal('foo')
1433
+ * })
1434
+ */
1435
+ origin<T, S extends any>(urlOrDomain: string, options: {
1436
+ args: T
1437
+ }, fn: (args: T) => void): Chainable<S>
1438
+
1424
1439
  /**
1425
1440
  * Get the parent DOM element of a set of DOM elements.
1426
1441
  *
@@ -2514,7 +2529,7 @@ declare namespace Cypress {
2514
2529
  action: 'select' | 'drag-drop'
2515
2530
  }
2516
2531
 
2517
- interface BlurOptions extends Loggable, Forceable { }
2532
+ interface BlurOptions extends Loggable, Timeoutable, Forceable { }
2518
2533
 
2519
2534
  interface CheckOptions extends Loggable, Timeoutable, ActionableOptions {
2520
2535
  interval: number
@@ -2817,15 +2832,15 @@ declare namespace Cypress {
2817
2832
  */
2818
2833
  scrollBehavior: scrollBehaviorOptions
2819
2834
  /**
2820
- * Enable experimental session support. See https://on.cypress.io/session
2835
+ * Allows listening to the `before:run`, `after:run`, `before:spec`, and `after:spec` events in the plugins file during interactive mode.
2821
2836
  * @default false
2822
2837
  */
2823
- experimentalSessionSupport: boolean
2838
+ experimentalInteractiveRunEvents: boolean
2824
2839
  /**
2825
- * Allows listening to the `before:run`, `after:run`, `before:spec`, and `after:spec` events in the plugins file during interactive mode.
2840
+ * Enables cross-origin and improved session support, including the `cy.origin` and `cy.session` commands. See https://on.cypress.io/origin and https://on.cypress.io/session.
2826
2841
  * @default false
2827
2842
  */
2828
- experimentalInteractiveRunEvents: boolean
2843
+ experimentalSessionAndOrigin: boolean
2829
2844
  /**
2830
2845
  * Generate and save commands directly to your test suite by interacting with your app as an end user would.
2831
2846
  * @default false
@@ -2957,7 +2972,6 @@ declare namespace Cypress {
2957
2972
  projectName: string
2958
2973
  projectRoot: string
2959
2974
  proxyUrl: string
2960
- remote: RemoteState
2961
2975
  report: boolean
2962
2976
  reporterRoute: string
2963
2977
  reporterUrl: string
@@ -5447,6 +5461,21 @@ declare namespace Cypress {
5447
5461
  (action: 'task', tasks: Tasks): void
5448
5462
  }
5449
5463
 
5464
+ interface CodeFrame {
5465
+ frame: string
5466
+ language: string
5467
+ line: number
5468
+ column: number
5469
+ absoluteFile: string
5470
+ originalFile: string
5471
+ relativeFile: string
5472
+ }
5473
+
5474
+ interface CypressError extends Error {
5475
+ docsUrl?: string
5476
+ codeFrame?: CodeFrame
5477
+ }
5478
+
5450
5479
  // for just a few events like "window:alert" it makes sense to allow passing cy.stub() or
5451
5480
  // a user callback function. Others probably only need a callback function.
5452
5481
 
@@ -5552,7 +5581,7 @@ declare namespace Cypress {
5552
5581
  * This event exists because it's extremely useful for debugging purposes.
5553
5582
  * @see https://on.cypress.io/catalog-of-events#App-Events
5554
5583
  */
5555
- (action: 'fail', fn: (error: Error, mocha: Mocha.Runnable) => void): Cypress
5584
+ (action: 'fail', fn: (error: CypressError, mocha: Mocha.Runnable) => void): Cypress
5556
5585
  /**
5557
5586
  * Fires whenever the viewport changes via a `cy.viewport()` or naturally when
5558
5587
  * Cypress resets the viewport to the default between tests. Useful for debugging purposes.
@@ -5586,6 +5615,12 @@ declare namespace Cypress {
5586
5615
  * @see https://on.cypress.io/catalog-of-events#App-Events
5587
5616
  */
5588
5617
  (action: 'command:end', fn: (command: CommandQueue) => void): Cypress
5618
+ /**
5619
+ * Fires when a command is skipped, namely the `should` command.
5620
+ * Useful for debugging and understanding how commands are handled.
5621
+ * @see https://on.cypress.io/catalog-of-events#App-Events
5622
+ */
5623
+ (action: 'skipped:command:end', fn: (command: CommandQueue) => void): Cypress
5589
5624
  /**
5590
5625
  * Fires whenever a command begins its retrying routines.
5591
5626
  * This is called on the trailing edge after Cypress has internally
@@ -5676,10 +5711,13 @@ declare namespace Cypress {
5676
5711
  }
5677
5712
 
5678
5713
  interface EnqueuedCommand {
5714
+ id: string
5679
5715
  name: string
5680
5716
  args: any[]
5681
5717
  type: string
5682
5718
  chainerId: string
5719
+ injected: boolean
5720
+ userInvocationStack?: string
5683
5721
  fn(...args: any[]): any
5684
5722
  }
5685
5723
 
@@ -5718,6 +5756,8 @@ declare namespace Cypress {
5718
5756
  }
5719
5757
 
5720
5758
  interface LogConfig extends Timeoutable {
5759
+ /** Unique id for the log, in the form of '<origin>-<number>' */
5760
+ id: string
5721
5761
  /** The JQuery element for the command. This will highlight the command in the main window when debugging */
5722
5762
  $el: JQuery
5723
5763
  /** The scope of the log entry. If child, will appear nested below parents, prefixed with '-' */
@@ -5730,6 +5770,8 @@ declare namespace Cypress {
5730
5770
  message: any
5731
5771
  /** Set to false if you want to control the finishing of the command in the log yourself */
5732
5772
  autoEnd: boolean
5773
+ /** Set to true to immediately finish the log */
5774
+ end: boolean
5733
5775
  /** Return an object that will be printed in the dev tools console */
5734
5776
  consoleProps(): ObjectLike
5735
5777
  }