cypress 7.6.0 → 8.2.0

Sign up to get free protection for your applications and to get access to all the features.
package/README.md CHANGED
@@ -1,8 +1,10 @@
1
1
  # Cypress
2
2
 
3
+ Fast, easy and reliable testing for anything that runs in a browser.
4
+
3
5
  ## What is this?
4
6
 
5
- Cypress comes packaged as an `npm` module, which is all you need to get started.
7
+ [Cypress](https://www.cypress.io/) comes packaged as an `npm` module, which is all you need to get started testing.
6
8
 
7
9
  After installing you'll be able to:
8
10
 
@@ -12,7 +14,7 @@ After installing you'll be able to:
12
14
 
13
15
  ## Install
14
16
 
15
- Requires Node version >= 10.0.0
17
+ Please check our [system requirements](https://on.cypress.io/installing-cypress).
16
18
 
17
19
  ```sh
18
20
  npm install --save-dev cypress
package/lib/cli.js CHANGED
@@ -129,8 +129,8 @@ const descriptions = {
129
129
  forceInstall: 'force install the Cypress binary',
130
130
  global: 'force Cypress into global mode as if its globally installed',
131
131
  group: 'a named group for recorded runs in the Cypress Dashboard',
132
- headed: 'displays the browser instead of running headlessly (defaults to true for Firefox and Chromium-family browsers)',
133
- headless: 'hide the browser instead of running headed (defaults to true for Electron)',
132
+ headed: 'displays the browser instead of running headlessly',
133
+ headless: 'hide the browser instead of running headed (default for cypress run)',
134
134
  key: 'your secret Record Key. you can omit this if you set a CYPRESS_RECORD_KEY environment variable.',
135
135
  parallel: 'enables concurrent runs and automatic load balancing of specs across multiple machines or processes',
136
136
  port: 'runs Cypress on a specific port. overrides any value in cypress.json.',
package/lib/errors.js CHANGED
@@ -151,13 +151,9 @@ const invalidSmokeTestDisplayError = {
151
151
 
152
152
  ${hr}
153
153
 
154
- This is usually caused by a missing library or dependency.
154
+ This may be due to a missing library or dependency. ${chalk.blue(requiredDependenciesUrl)}
155
155
 
156
- The error above should indicate which dependency is missing.
157
-
158
- ${chalk.blue(requiredDependenciesUrl)}
159
-
160
- If you are using Docker, we provide containers with all required dependencies installed.
156
+ Please refer to the error above for more detail.
161
157
  `;
162
158
  }
163
159
 
@@ -166,13 +162,9 @@ const missingDependency = {
166
162
  description: 'Cypress failed to start.',
167
163
  // this message is too Linux specific
168
164
  solution: stripIndent`
169
- This is usually caused by a missing library or dependency.
170
-
171
- The error below should indicate which dependency is missing.
165
+ This may be due to a missing library or dependency. ${chalk.blue(requiredDependenciesUrl)}
172
166
 
173
- ${chalk.blue(requiredDependenciesUrl)}
174
-
175
- If you are using Docker, we provide containers with all required dependencies installed.
167
+ Please refer to the error below for more details.
176
168
  `
177
169
  };
178
170
  const invalidCacheDirectory = {
package/lib/exec/spawn.js CHANGED
@@ -76,15 +76,17 @@ module.exports = {
76
76
  executable = path.resolve(util.getEnv('CYPRESS_RUN_BINARY'));
77
77
  }
78
78
 
79
- debug('needs to start own Xvfb?', needsXvfb); // 1. Start arguments with "--" so Electron knows these are OUR
80
- // arguments and does not try to sanitize them. Otherwise on Windows
81
- // an url in one of the arguments crashes it :(
82
- // https://github.com/cypress-io/cypress/issues/5466
83
- // 2. Always push cwd into the args
79
+ debug('needs to start own Xvfb?', needsXvfb); // Always push cwd into the args
84
80
  // which additionally acts as a signal to the
85
81
  // binary that it was invoked through the NPM module
86
82
 
87
- args = ['--'].concat(args, '--cwd', process.cwd());
83
+ args = args || [];
84
+
85
+ if (typeof args === 'string') {
86
+ args = [args];
87
+ }
88
+
89
+ args = [...args, '--cwd', process.cwd()];
88
90
 
89
91
  _.defaults(options, {
90
92
  dev: false,
@@ -100,28 +102,24 @@ module.exports = {
100
102
  electronLogging: false
101
103
  });
102
104
 
103
- if (options.dev) {
104
- // if we're in dev then reset
105
- // the launch cmd to be 'npm run dev'
106
- executable = 'node';
107
- args.unshift(path.resolve(__dirname, '..', '..', '..', 'scripts', 'start.js'));
108
- debug('in dev mode the args became %o', args);
109
- }
110
-
111
105
  const {
112
106
  onStderrData,
113
107
  electronLogging
114
108
  } = overrides;
115
109
  const envOverrides = util.getEnvOverrides(options);
116
-
117
- const electronArgs = _.clone(args);
118
-
110
+ const electronArgs = [];
119
111
  const node11WindowsFix = isPlatform('win32');
120
112
 
113
+ if (options.dev) {
114
+ // if we're in dev then reset
115
+ // the launch cmd to be 'npm run dev'
116
+ executable = 'node';
117
+ electronArgs.unshift(path.resolve(__dirname, '..', '..', '..', 'scripts', 'start.js'));
118
+ debug('in dev mode the args became %o', args);
119
+ }
120
+
121
121
  if (!options.dev && verify.needsSandbox()) {
122
- // this is one of the Electron's command line switches
123
- // thus it needs to be before "--" separator
124
- electronArgs.unshift('--no-sandbox');
122
+ electronArgs.push('--no-sandbox');
125
123
  } // strip dev out of child process options
126
124
 
127
125
 
@@ -148,9 +146,21 @@ module.exports = {
148
146
  stdioOptions.env.DISPLAY = process.env.DISPLAY;
149
147
  }
150
148
 
149
+ if (stdioOptions.env.ELECTRON_RUN_AS_NODE) {
150
+ // Since we are running electron as node, we need to add an entry point file.
151
+ const serverEntryPoint = path.join(state.getBinaryPkgPath(path.dirname(executable)), '..', 'index.js');
152
+ args = [serverEntryPoint, ...args];
153
+ } else {
154
+ // Start arguments with "--" so Electron knows these are OUR
155
+ // arguments and does not try to sanitize them. Otherwise on Windows
156
+ // an url in one of the arguments crashes it :(
157
+ // https://github.com/cypress-io/cypress/issues/5466
158
+ args = [...electronArgs, '--', ...args];
159
+ }
160
+
151
161
  debug('spawning Cypress with executable: %s', executable);
152
- debug('spawn args %o %o', electronArgs, _.omit(stdioOptions, 'env'));
153
- const child = cp.spawn(executable, electronArgs, stdioOptions);
162
+ debug('spawn args %o %o', args, _.omit(stdioOptions, 'env'));
163
+ const child = cp.spawn(executable, args, stdioOptions);
154
164
 
155
165
  function resolveOn(event) {
156
166
  return function (code, signal) {
package/lib/exec/xvfb.js CHANGED
@@ -65,6 +65,11 @@ module.exports = {
65
65
  },
66
66
 
67
67
  isNeeded() {
68
+ if (process.env.ELECTRON_RUN_AS_NODE) {
69
+ debug('Environment variable ELECTRON_RUN_AS_NODE detected, xvfb is not needed');
70
+ return false; // xvfb required for electron processes only.
71
+ }
72
+
68
73
  if (os.platform() !== 'linux') {
69
74
  return false;
70
75
  }
package/lib/util.js CHANGED
@@ -263,7 +263,17 @@ const util = {
263
263
  .mapValues(value => {
264
264
  // stringify to 1 or 0
265
265
  return value ? '1' : '0';
266
- }).value();
266
+ }).extend(util.getOriginalNodeOptions(options)).value();
267
+ },
268
+
269
+ getOriginalNodeOptions(options) {
270
+ if (process.env.NODE_OPTIONS) {
271
+ return {
272
+ ORIGINAL_NODE_OPTIONS: process.env.NODE_OPTIONS
273
+ };
274
+ }
275
+
276
+ return {};
267
277
  },
268
278
 
269
279
  getForceTty() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cypress",
3
- "version": "7.6.0",
3
+ "version": "8.2.0",
4
4
  "main": "index.js",
5
5
  "scripts": {
6
6
  "postinstall": "node index.js --exec install",
@@ -138,7 +138,7 @@ declare namespace CypressCommandLine {
138
138
  /**
139
139
  * Specify configuration
140
140
  */
141
- config: Partial<Cypress.ResolvedConfigOptions>
141
+ config: Cypress.ConfigOptions
142
142
  /**
143
143
  * Path to the config file to be used.
144
144
  *
@@ -64,6 +64,22 @@ declare namespace Cypress {
64
64
  path: string
65
65
  isHeaded: boolean
66
66
  isHeadless: boolean
67
+ /**
68
+ * Informational text to accompany this browser. Shown in desktop-gui.
69
+ */
70
+ info?: string
71
+ /**
72
+ * Warning text to accompany this browser. Shown in desktop-gui.
73
+ */
74
+ warning?: string
75
+ /**
76
+ * The minimum majorVersion of this browser supported by Cypress.
77
+ */
78
+ minSupportedVersion?: number
79
+ /**
80
+ * If `true`, this browser is too old to be supported by Cypress.
81
+ */
82
+ unsupportedVersion?: boolean
67
83
  }
68
84
 
69
85
  interface LocalStorage {
@@ -242,6 +258,14 @@ declare namespace Cypress {
242
258
  */
243
259
  spec: Spec
244
260
 
261
+ /**
262
+ * Currently executing test runnable instance.
263
+ */
264
+ currentTest: {
265
+ title: string,
266
+ titlePath: string[]
267
+ }
268
+
245
269
  /**
246
270
  * Information about the browser currently running the tests
247
271
  */
@@ -341,15 +365,6 @@ declare namespace Cypress {
341
365
  */
342
366
  env(object: ObjectLike): void
343
367
 
344
- /**
345
- * Firefox only: Get the current number of tests that will run between forced garbage collections.
346
- *
347
- * Returns undefined if not in Firefox, returns a null or 0 if forced GC is disabled.
348
- *
349
- * @see https://on.cypress.io/firefox-gc-issue
350
- */
351
- getFirefoxGcInterval(): number | null | undefined
352
-
353
368
  /**
354
369
  * @returns the number of test retries currently enabled for the run
355
370
  */
@@ -550,6 +565,10 @@ declare namespace Cypress {
550
565
  onSpecWindow: (window: Window, specList: string[] | Array<() => Promise<void>>) => void
551
566
  }
552
567
 
568
+ interface SessionOptions {
569
+ validate?: () => false|void
570
+ }
571
+
553
572
  type CanReturnChainable = void | Chainable | Promise<unknown>
554
573
  type ThenReturn<S, R> =
555
574
  R extends void ? Chainable<S> :
@@ -848,7 +867,7 @@ declare namespace Cypress {
848
867
  * // tries to find the given text for up to 1 second
849
868
  * cy.contains('my text to find', {timeout: 1000})
850
869
  */
851
- contains(content: string | number | RegExp, options?: Partial<Loggable & Timeoutable & CaseMatchable>): Chainable<Subject>
870
+ contains(content: string | number | RegExp, options?: Partial<Loggable & Timeoutable & CaseMatchable & Shadow>): Chainable<Subject>
852
871
  /**
853
872
  * Get the child DOM element that contains given text.
854
873
  *
@@ -866,7 +885,7 @@ declare namespace Cypress {
866
885
  * // yields <ul>...</ul>
867
886
  * cy.contains('ul', 'apples')
868
887
  */
869
- contains<K extends keyof HTMLElementTagNameMap>(selector: K, text: string | number | RegExp, options?: Partial<Loggable & Timeoutable & CaseMatchable>): Chainable<JQuery<HTMLElementTagNameMap[K]>>
888
+ contains<K extends keyof HTMLElementTagNameMap>(selector: K, text: string | number | RegExp, options?: Partial<Loggable & Timeoutable & CaseMatchable & Shadow>): Chainable<JQuery<HTMLElementTagNameMap[K]>>
870
889
  /**
871
890
  * Get the DOM element using CSS "selector" containing the text or regular expression.
872
891
  *
@@ -875,7 +894,7 @@ declare namespace Cypress {
875
894
  * // yields <... class="foo">... apples ...</...>
876
895
  * cy.contains('.foo', 'apples')
877
896
  */
878
- contains<E extends Node = HTMLElement>(selector: string, text: string | number | RegExp, options?: Partial<Loggable & Timeoutable & CaseMatchable>): Chainable<JQuery<E>>
897
+ contains<E extends Node = HTMLElement>(selector: string, text: string | number | RegExp, options?: Partial<Loggable & Timeoutable & CaseMatchable & Shadow>): Chainable<JQuery<E>>
879
898
 
880
899
  /**
881
900
  * Double-click a DOM element.
@@ -945,6 +964,15 @@ declare namespace Cypress {
945
964
  */
946
965
  debug(options?: Partial<Loggable>): Chainable<Subject>
947
966
 
967
+ /**
968
+ * Save/Restore browser Cookies, LocalStorage, and SessionStorage data resulting from the supplied `setup` function.
969
+ *
970
+ * Only available if the `experimentalSessionSupport` config option is enabled.
971
+ *
972
+ * @see https://on.cypress.io/session
973
+ */
974
+ session(id: string|object, setup?: SessionOptions['validate'], options?: SessionOptions): Chainable<null>
975
+
948
976
  /**
949
977
  * Get the window.document of the page that is currently active.
950
978
  *
@@ -1654,7 +1682,7 @@ declare namespace Cypress {
1654
1682
  * .shadow()
1655
1683
  * .find('.my-button')
1656
1684
  * .click()
1657
- * @see https://on.cypress.io/experimental
1685
+ * @see https://on.cypress.io/shadow
1658
1686
  */
1659
1687
  shadow(): Chainable<Subject>
1660
1688
 
@@ -1833,6 +1861,12 @@ declare namespace Cypress {
1833
1861
  * @see https://on.cypress.io/then
1834
1862
  */
1835
1863
  then<S>(options: Partial<Timeoutable>, fn: (this: ObjectLike, currentSubject: Subject) => PromiseLike<S>): Chainable<S>
1864
+ /**
1865
+ * Enables you to work with the subject yielded from the previous command / promise.
1866
+ *
1867
+ * @see https://on.cypress.io/then
1868
+ */
1869
+ then<S extends string | number | boolean>(fn: (this: ObjectLike, currentSubject: Subject) => S): Chainable<S>
1836
1870
  /**
1837
1871
  * Enables you to work with the subject yielded from the previous command / promise.
1838
1872
  *
@@ -1850,7 +1884,7 @@ declare namespace Cypress {
1850
1884
  *
1851
1885
  * @see https://on.cypress.io/then
1852
1886
  */
1853
- then<S extends object | any[] | string | number | boolean>(fn: (this: ObjectLike, currentSubject: Subject) => S): Chainable<S>
1887
+ then<S extends any[] | object>(fn: (this: ObjectLike, currentSubject: Subject) => S): Chainable<S>
1854
1888
  /**
1855
1889
  * Enables you to work with the subject yielded from the previous command / promise.
1856
1890
  *
@@ -2641,12 +2675,10 @@ declare namespace Cypress {
2641
2675
  */
2642
2676
  scrollBehavior: scrollBehaviorOptions
2643
2677
  /**
2644
- * Firefox version 79 and below only: The number of tests that will run between forced garbage collections.
2645
- * If a number is supplied, it will apply to `run` mode and `open` mode.
2646
- * Set the interval to `null` or 0 to disable forced garbage collections.
2647
- * @default { runMode: 1, openMode: null }
2678
+ * Enable experimental session support. See https://on.cypress.io/session
2679
+ * @default false
2648
2680
  */
2649
- firefoxGcInterval: Nullable<number | { runMode: Nullable<number>, openMode: Nullable<number> }>
2681
+ experimentalSessionSupport: boolean
2650
2682
  /**
2651
2683
  * Allows listening to the `before:run`, `after:run`, `before:spec`, and `after:spec` events in the plugins file during interactive mode.
2652
2684
  * @default false
@@ -2678,17 +2710,46 @@ declare namespace Cypress {
2678
2710
  */
2679
2711
  includeShadowDom: boolean
2680
2712
 
2713
+ /**
2714
+ * The list of hosts to be blocked
2715
+ */
2716
+ blockHosts: null | string | string[]
2717
+ /**
2718
+ * Path to folder containing component test files.
2719
+ */
2720
+ componentFolder: false | string
2721
+ /**
2722
+ * A unique ID for the project used for recording
2723
+ */
2724
+ projectId: null | string
2725
+ /**
2726
+ * Path to the support folder.
2727
+ */
2728
+ supportFolder: string
2729
+ /**
2730
+ * Glob pattern to determine what test files to load.
2731
+ */
2732
+ testFiles: string | string[]
2733
+ /**
2734
+ * The user agent the browser sends in all request headers.
2735
+ */
2736
+ userAgent: null | string
2737
+ /**
2738
+ * Polyfills `window.fetch` to enable Network spying and stubbing
2739
+ */
2740
+ experimentalFetchPolyfill: boolean
2741
+
2681
2742
  /**
2682
2743
  * Override default config options for Component Testing runner.
2683
2744
  * @default {}
2684
2745
  */
2685
- component: ResolvedConfigOptions
2746
+ component: Omit<ResolvedConfigOptions, TestingType>
2686
2747
 
2687
2748
  /**
2688
2749
  * Override default config options for E2E Testing runner.
2689
2750
  * @default {}
2690
2751
  */
2691
- e2e: ResolvedConfigOptions
2752
+ e2e: Omit<ResolvedConfigOptions, TestingType>
2692
2753
  }
2693
2754
 
2694
2755
  /**
@@ -2701,10 +2762,6 @@ declare namespace Cypress {
2701
2762
  * @see https://nodejs.org/api/os.html#os_os_arch
2702
2763
  */
2703
2764
  arch: string
2704
- /**
2705
- * The list of hosts to be blocked
2706
- */
2707
- blockHosts: null | string | string[]
2708
2765
  /**
2709
2766
  * The browser Cypress is running on.
2710
2767
  */
@@ -2713,10 +2770,6 @@ declare namespace Cypress {
2713
2770
  * Available browsers found on your system.
2714
2771
  */
2715
2772
  browsers: Browser[]
2716
- /**
2717
- * Path to folder containing component test files.
2718
- */
2719
- componentFolder: string
2720
2773
  /**
2721
2774
  * Hosts mappings to IP addresses.
2722
2775
  */
@@ -2736,22 +2789,6 @@ declare namespace Cypress {
2736
2789
  * The platform Cypress is running on.
2737
2790
  */
2738
2791
  platform: 'linux' | 'darwin' | 'win32'
2739
- /**
2740
- * A unique ID for the project used for recording
2741
- */
2742
- projectId: null | string
2743
- /**
2744
- * Path to the support folder.
2745
- */
2746
- supportFolder: string
2747
- /**
2748
- * Glob pattern to determine what test files to load.
2749
- */
2750
- testFiles: string
2751
- /**
2752
- * The user agent the browser sends in all request headers.
2753
- */
2754
- userAgent: null | string
2755
2792
  /**
2756
2793
  * The Cypress version being used.
2757
2794
  */
@@ -2763,6 +2800,7 @@ declare namespace Cypress {
2763
2800
  clientRoute: string
2764
2801
  configFile: string
2765
2802
  cypressEnv: string
2803
+ devServerPublicPathRoute: string
2766
2804
  isNewProject: boolean
2767
2805
  isTextTerminal: boolean
2768
2806
  morgan: boolean
@@ -2797,7 +2835,8 @@ declare namespace Cypress {
2797
2835
  /**
2798
2836
  * All configuration items are optional.
2799
2837
  */
2800
- type ConfigOptions = Partial<ResolvedConfigOptions>
2838
+ type CoreConfigOptions = Partial<Omit<ResolvedConfigOptions, TestingType>>
2839
+ type ConfigOptions = CoreConfigOptions & {e2e?: CoreConfigOptions, component?: CoreConfigOptions }
2801
2840
 
2802
2841
  interface PluginConfigOptions extends ResolvedConfigOptions {
2803
2842
  /**
@@ -5496,6 +5535,7 @@ declare namespace Cypress {
5496
5535
 
5497
5536
  interface Log {
5498
5537
  end(): Log
5538
+ error(error: Error): Log
5499
5539
  finish(): void
5500
5540
  get<K extends keyof LogConfig>(attr: K): LogConfig[K]
5501
5541
  get(): LogConfig
@@ -267,9 +267,11 @@ interface RequestEvents {
267
267
  */
268
268
  export interface Interception {
269
269
  id: string
270
+ /* @internal */
271
+ browserRequestId?: string
270
272
  routeId: string
271
273
  /* @internal */
272
- log?: any
274
+ setLogFlag: (flag: 'spied' | 'stubbed' | 'reqModified' | 'resModified') => void
273
275
  request: CyHttpMessages.IncomingRequest
274
276
  /**
275
277
  * Was `cy.wait()` used to wait on this request?