cypress 9.5.3 → 9.6.1

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,
package/lib/exec/spawn.js CHANGED
@@ -26,8 +26,18 @@ const errors = require('../errors');
26
26
 
27
27
  const isXlibOrLibudevRe = /^(?:Xlib|libudev)/;
28
28
  const isHighSierraWarningRe = /\*\*\* WARNING/;
29
- const isRenderWorkerRe = /\.RenderWorker-/;
30
- const GARBAGE_WARNINGS = [isXlibOrLibudevRe, isHighSierraWarningRe, isRenderWorkerRe];
29
+ const isRenderWorkerRe = /\.RenderWorker-/; // Chromium (which Electron uses) always makes several attempts to connect to the system dbus.
30
+ // This works fine in most desktop environments, but in a docker container, there is no dbus service
31
+ // and Chromium emits several error lines, similar to these:
32
+ // [1957:0406/160550.146820:ERROR:bus.cc(392)] Failed to connect to the bus: Failed to connect to socket /var/run/dbus/system_bus_socket: No such file or directory
33
+ // [1957:0406/160550.147994:ERROR:bus.cc(392)] Failed to connect to the bus: Address does not contain a colon
34
+ // These warnings are absolutely harmless. Failure to connect to dbus means that electron won't be able to access the user's
35
+ // credential wallet (none exists in a docker container) and won't show up in the system tray (again, none exists).
36
+ // Failure to connect is expected and normal here, but users frequently misidentify these errors as the cause of their problems.
37
+ // https://github.com/cypress-io/cypress/issues/19299
38
+
39
+ const isDbusWarning = /Failed to connect to the bus:/;
40
+ const GARBAGE_WARNINGS = [isXlibOrLibudevRe, isHighSierraWarningRe, isRenderWorkerRe, isDbusWarning];
31
41
 
32
42
  const isGarbageLineWarning = str => {
33
43
  return _.some(GARBAGE_WARNINGS, re => {
@@ -81,7 +81,7 @@ const getBinaryDir = (version = util.pkgVersion()) => {
81
81
 
82
82
  const getVersionDir = (version = util.pkgVersion(), buildInfo = util.pkgBuildInfo()) => {
83
83
  if (buildInfo && !buildInfo.stable) {
84
- version = ['beta', version, buildInfo.commitBranch, buildInfo.commitSha].join('-');
84
+ version = ['beta', version, buildInfo.commitBranch, buildInfo.commitSha.slice(0, 8)].join('-');
85
85
  }
86
86
 
87
87
  return path.join(getCacheDir(), version);
@@ -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.3",
3
+ "version": "9.6.1",
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": "51ec479d53ce16c91ca9907d745212ce9f6642be",
70
- "commitDate": "2022-03-28T19:23:42.000Z",
69
+ "commitSha": "37df3cab6430532b63b19586c4da9e5c0beec5cb",
70
+ "commitDate": "2022-05-09T14:49:05.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
  }
@@ -24,9 +27,15 @@ declare namespace Cypress {
24
27
  interface CommandFn<T extends keyof ChainableMethods> {
25
28
  (this: Mocha.Context, ...args: Parameters<ChainableMethods[T]>): ReturnType<ChainableMethods[T]> | void
26
29
  }
30
+ interface CommandFns {
31
+ [name: string]: (this: Mocha.Context, ...args: any) => any
32
+ }
27
33
  interface CommandFnWithSubject<T extends keyof ChainableMethods, S> {
28
34
  (this: Mocha.Context, prevSubject: S, ...args: Parameters<ChainableMethods[T]>): ReturnType<ChainableMethods[T]> | void
29
35
  }
36
+ interface CommandFnsWithSubject<S> {
37
+ [name: string]: (this: Mocha.Context, prevSubject: S, ...args: any) => any
38
+ }
30
39
  interface CommandOriginalFn<T extends keyof ChainableMethods> extends CallableFunction {
31
40
  (...args: Parameters<ChainableMethods[T]>): ReturnType<ChainableMethods[T]>
32
41
  }
@@ -47,19 +56,6 @@ declare namespace Cypress {
47
56
  password: string
48
57
  }
49
58
 
50
- interface RemoteState {
51
- auth?: {
52
- username: string
53
- password: string
54
- }
55
- domainName: string
56
- strategy: 'file' | 'http'
57
- origin: string
58
- fileServer: string
59
- props: Record<string, any>
60
- visiting: string
61
- }
62
-
63
59
  interface Backend {
64
60
  /**
65
61
  * Firefox only: Force Cypress to run garbage collection routines.
@@ -461,12 +457,22 @@ declare namespace Cypress {
461
457
  Commands: {
462
458
  add<T extends keyof Chainable>(name: T, fn: CommandFn<T>): void
463
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
464
461
  add<T extends keyof Chainable, S extends PrevSubject>(
465
- 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]>,
466
463
  ): void
467
464
  add<T extends keyof Chainable, S extends PrevSubject>(
468
465
  name: T, options: CommandOptions & { prevSubject: S[] }, fn: CommandFnWithSubject<T, PrevSubjectMap<void>[S]>,
469
466
  ): void
467
+ addAll<T extends keyof Chainable>(fns: CommandFns): void
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
470
+ addAll<T extends keyof Chainable, S extends PrevSubject>(
471
+ options: CommandOptions & { prevSubject: S | ['optional'] }, fns: CommandFnsWithSubject<PrevSubjectMap[S]>,
472
+ ): void
473
+ addAll<T extends keyof Chainable, S extends PrevSubject>(
474
+ options: CommandOptions & { prevSubject: S[] }, fns: CommandFnsWithSubject<PrevSubjectMap<void>[S]>,
475
+ ): void
470
476
  overwrite<T extends keyof Chainable>(name: T, fn: CommandFnWithOriginalFn<T>): void
471
477
  overwrite<T extends keyof Chainable, S extends PrevSubject>(name: T, fn: CommandFnWithOriginalFnAndSubject<T, PrevSubjectMap[S]>): void
472
478
  }
@@ -620,7 +626,7 @@ declare namespace Cypress {
620
626
  * Trigger action
621
627
  * @private
622
628
  */
623
- action: (action: string, ...args: any[]) => void
629
+ action: (action: string, ...args: any[]) => any[] | void
624
630
 
625
631
  /**
626
632
  * Load files
@@ -1045,7 +1051,7 @@ declare namespace Cypress {
1045
1051
  /**
1046
1052
  * Save/Restore browser Cookies, LocalStorage, and SessionStorage data resulting from the supplied `setup` function.
1047
1053
  *
1048
- * Only available if the `experimentalSessionSupport` config option is enabled.
1054
+ * Only available if the `experimentalSessionAndOrigin` config option is enabled.
1049
1055
  *
1050
1056
  * @see https://on.cypress.io/session
1051
1057
  */
@@ -1407,6 +1413,29 @@ declare namespace Cypress {
1407
1413
  */
1408
1414
  off: Actions
1409
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
+
1410
1439
  /**
1411
1440
  * Get the parent DOM element of a set of DOM elements.
1412
1441
  *
@@ -2341,7 +2370,7 @@ declare namespace Cypress {
2341
2370
  type Agent<T extends sinon.SinonSpy> = SinonSpyAgent<T> & T
2342
2371
 
2343
2372
  interface CookieDefaults {
2344
- preserve: string | string[] | RegExp | ((cookie: any) => boolean)
2373
+ preserve: string | string[] | RegExp | ((cookie: Cookie) => boolean)
2345
2374
  }
2346
2375
 
2347
2376
  interface Failable {
@@ -2500,7 +2529,7 @@ declare namespace Cypress {
2500
2529
  action: 'select' | 'drag-drop'
2501
2530
  }
2502
2531
 
2503
- interface BlurOptions extends Loggable, Forceable { }
2532
+ interface BlurOptions extends Loggable, Timeoutable, Forceable { }
2504
2533
 
2505
2534
  interface CheckOptions extends Loggable, Timeoutable, ActionableOptions {
2506
2535
  interval: number
@@ -2803,15 +2832,15 @@ declare namespace Cypress {
2803
2832
  */
2804
2833
  scrollBehavior: scrollBehaviorOptions
2805
2834
  /**
2806
- * 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.
2807
2836
  * @default false
2808
2837
  */
2809
- experimentalSessionSupport: boolean
2838
+ experimentalInteractiveRunEvents: boolean
2810
2839
  /**
2811
- * 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.
2812
2841
  * @default false
2813
2842
  */
2814
- experimentalInteractiveRunEvents: boolean
2843
+ experimentalSessionAndOrigin: boolean
2815
2844
  /**
2816
2845
  * Generate and save commands directly to your test suite by interacting with your app as an end user would.
2817
2846
  * @default false
@@ -2943,7 +2972,6 @@ declare namespace Cypress {
2943
2972
  projectName: string
2944
2973
  projectRoot: string
2945
2974
  proxyUrl: string
2946
- remote: RemoteState
2947
2975
  report: boolean
2948
2976
  reporterRoute: string
2949
2977
  reporterUrl: string
@@ -5433,6 +5461,21 @@ declare namespace Cypress {
5433
5461
  (action: 'task', tasks: Tasks): void
5434
5462
  }
5435
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
+
5436
5479
  // for just a few events like "window:alert" it makes sense to allow passing cy.stub() or
5437
5480
  // a user callback function. Others probably only need a callback function.
5438
5481
 
@@ -5538,7 +5581,7 @@ declare namespace Cypress {
5538
5581
  * This event exists because it's extremely useful for debugging purposes.
5539
5582
  * @see https://on.cypress.io/catalog-of-events#App-Events
5540
5583
  */
5541
- (action: 'fail', fn: (error: Error, mocha: Mocha.Runnable) => void): Cypress
5584
+ (action: 'fail', fn: (error: CypressError, mocha: Mocha.Runnable) => void): Cypress
5542
5585
  /**
5543
5586
  * Fires whenever the viewport changes via a `cy.viewport()` or naturally when
5544
5587
  * Cypress resets the viewport to the default between tests. Useful for debugging purposes.
@@ -5572,6 +5615,12 @@ declare namespace Cypress {
5572
5615
  * @see https://on.cypress.io/catalog-of-events#App-Events
5573
5616
  */
5574
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
5575
5624
  /**
5576
5625
  * Fires whenever a command begins its retrying routines.
5577
5626
  * This is called on the trailing edge after Cypress has internally
@@ -5662,10 +5711,13 @@ declare namespace Cypress {
5662
5711
  }
5663
5712
 
5664
5713
  interface EnqueuedCommand {
5714
+ id: string
5665
5715
  name: string
5666
5716
  args: any[]
5667
5717
  type: string
5668
5718
  chainerId: string
5719
+ injected: boolean
5720
+ userInvocationStack?: string
5669
5721
  fn(...args: any[]): any
5670
5722
  }
5671
5723
 
@@ -5704,6 +5756,8 @@ declare namespace Cypress {
5704
5756
  }
5705
5757
 
5706
5758
  interface LogConfig extends Timeoutable {
5759
+ /** Unique id for the log, in the form of '<origin>-<number>' */
5760
+ id: string
5707
5761
  /** The JQuery element for the command. This will highlight the command in the main window when debugging */
5708
5762
  $el: JQuery
5709
5763
  /** The scope of the log entry. If child, will appear nested below parents, prefixed with '-' */
@@ -5712,9 +5766,12 @@ declare namespace Cypress {
5712
5766
  name: string
5713
5767
  /** Override *name* for display purposes only */
5714
5768
  displayName: string
5769
+ /** additional information to include in the log */
5715
5770
  message: any
5716
5771
  /** Set to false if you want to control the finishing of the command in the log yourself */
5717
5772
  autoEnd: boolean
5773
+ /** Set to true to immediately finish the log */
5774
+ end: boolean
5718
5775
  /** Return an object that will be printed in the dev tools console */
5719
5776
  consoleProps(): ObjectLike
5720
5777
  }