cypress 8.3.1 → 8.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.
package/lib/cypress.js CHANGED
@@ -70,6 +70,24 @@ const cypressModuleApi = {
70
70
  return cli.parseRunCommand(args);
71
71
  }
72
72
 
73
+ },
74
+
75
+ /**
76
+ * Provides automatic code completion for configuration in many popular code editors.
77
+ * While it's not strictly necessary for Cypress to parse your configuration, we
78
+ * recommend wrapping your config object with `defineConfig()`
79
+ * @example
80
+ * module.exports = defineConfig({
81
+ * viewportWith: 400
82
+ * })
83
+ *
84
+ * @see ../types/cypress-npm-api.d.ts
85
+ * @param {Cypress.ConfigOptions} config
86
+ * @returns {Cypress.ConfigOptions} the configuration passed in parameter
87
+ */
88
+ defineConfig(config) {
89
+ return config;
73
90
  }
91
+
74
92
  };
75
93
  module.exports = cypressModuleApi;
@@ -24,6 +24,8 @@ const {
24
24
  stripIndent
25
25
  } = require('common-tags');
26
26
 
27
+ const getProxyForUrl = require('proxy-from-env').getProxyForUrl;
28
+
27
29
  const {
28
30
  throwFormErrorText,
29
31
  errors
@@ -35,8 +37,8 @@ const util = require('../util');
35
37
 
36
38
  const defaultBaseUrl = 'https://download.cypress.io/';
37
39
 
38
- const getProxyUrl = () => {
39
- return process.env.HTTPS_PROXY || process.env.https_proxy || process.env.npm_config_https_proxy || process.env.HTTP_PROXY || process.env.http_proxy || process.env.npm_config_proxy || null;
40
+ const getProxyForUrlWithNpmConfig = url => {
41
+ return getProxyForUrl(url) || process.env.npm_config_https_proxy || process.env.npm_config_proxy || null;
40
42
  };
41
43
 
42
44
  const getRealOsArch = () => {
@@ -198,7 +200,7 @@ const downloadFromUrl = ({
198
200
  ca
199
201
  }) => {
200
202
  return new Promise((resolve, reject) => {
201
- const proxy = getProxyUrl();
203
+ const proxy = getProxyForUrlWithNpmConfig(url);
202
204
  debug('Downloading package', {
203
205
  url,
204
206
  proxy,
@@ -338,6 +340,6 @@ const start = opts => {
338
340
  module.exports = {
339
341
  start,
340
342
  getUrl,
341
- getProxyUrl,
343
+ getProxyForUrlWithNpmConfig,
342
344
  getCA
343
345
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cypress",
3
- "version": "8.3.1",
3
+ "version": "8.6.0",
4
4
  "main": "index.js",
5
5
  "scripts": {
6
6
  "postinstall": "node index.js --exec install",
@@ -41,6 +41,7 @@
41
41
  "minimist": "^1.2.5",
42
42
  "ospath": "^1.2.2",
43
43
  "pretty-bytes": "^5.6.0",
44
+ "proxy-from-env": "1.0.0",
44
45
  "ramda": "~0.27.1",
45
46
  "request-progress": "^3.0.0",
46
47
  "supports-color": "^8.1.1",
@@ -377,6 +377,21 @@ declare module 'cypress' {
377
377
  * Cypress does
378
378
  */
379
379
  cli: CypressCommandLine.CypressCliParser
380
+
381
+ /**
382
+ * Provides automatic code completion for configuration in many popular code editors.
383
+ * While it's not strictly necessary for Cypress to parse your configuration, we
384
+ * recommend wrapping your config object with `defineConfig()`
385
+ * @example
386
+ * module.exports = defineConfig({
387
+ * viewportWith: 400
388
+ * })
389
+ *
390
+ * @see ../types/cypress-npm-api.d.ts
391
+ * @param {Cypress.ConfigOptions} config
392
+ * @returns {Cypress.ConfigOptions} the configuration passed in parameter
393
+ */
394
+ defineConfig(config: Cypress.ConfigOptions): Cypress.ConfigOptions
380
395
  }
381
396
 
382
397
  // export Cypress NPM module interface
@@ -22,6 +22,19 @@ declare namespace Cypress {
22
22
  password: string
23
23
  }
24
24
 
25
+ interface RemoteState {
26
+ auth?: {
27
+ username: string
28
+ password: string
29
+ }
30
+ domainName: string
31
+ strategy: 'file' | 'http'
32
+ origin: string
33
+ fileServer: string
34
+ props: Record<string, any>
35
+ visiting: string
36
+ }
37
+
25
38
  interface Backend {
26
39
  /**
27
40
  * Firefox only: Force Cypress to run garbage collection routines.
@@ -155,7 +168,7 @@ declare namespace Cypress {
155
168
  /**
156
169
  * The interface for user-defined properties in Window object under test.
157
170
  */
158
- interface ApplicationWindow {} // tslint:disable-line
171
+ interface ApplicationWindow { } // tslint:disable-line
159
172
 
160
173
  /**
161
174
  * Several libraries are bundled with Cypress by default.
@@ -508,7 +521,7 @@ declare namespace Cypress {
508
521
  /**
509
522
  * @see https://on.cypress.io/keyboard-api
510
523
  */
511
- Keyboard: {
524
+ Keyboard: {
512
525
  defaults(options: Partial<KeyboardDefaultsOptions>): void
513
526
  }
514
527
 
@@ -566,7 +579,7 @@ declare namespace Cypress {
566
579
  }
567
580
 
568
581
  interface SessionOptions {
569
- validate?: () => false|void
582
+ validate?: () => false | void
570
583
  }
571
584
 
572
585
  type CanReturnChainable = void | Chainable | Promise<unknown>
@@ -704,36 +717,36 @@ declare namespace Cypress {
704
717
  ```
705
718
  */
706
719
  clearLocalStorage(re: RegExp): Chainable<Storage>
707
- /**
708
- * Clear data in local storage.
709
- * Cypress automatically runs this command before each test to prevent state from being
710
- * shared across tests. You shouldn’t need to use this command unless you’re using it
711
- * to clear localStorage inside a single test. Yields `localStorage` object.
712
- *
713
- * @see https://on.cypress.io/clearlocalstorage
714
- * @param {options} [object] - options object
715
- * @example
716
- ```
717
- // Removes all local storage items, without logging
718
- cy.clearLocalStorage({ log: false })
719
- ```
720
- */
720
+ /**
721
+ * Clear data in local storage.
722
+ * Cypress automatically runs this command before each test to prevent state from being
723
+ * shared across tests. You shouldn’t need to use this command unless you’re using it
724
+ * to clear localStorage inside a single test. Yields `localStorage` object.
725
+ *
726
+ * @see https://on.cypress.io/clearlocalstorage
727
+ * @param {options} [object] - options object
728
+ * @example
729
+ ```
730
+ // Removes all local storage items, without logging
731
+ cy.clearLocalStorage({ log: false })
732
+ ```
733
+ */
721
734
  clearLocalStorage(options: Partial<Loggable>): Chainable<Storage>
722
- /**
723
- * Clear data in local storage.
724
- * Cypress automatically runs this command before each test to prevent state from being
725
- * shared across tests. You shouldn’t need to use this command unless you’re using it
726
- * to clear localStorage inside a single test. Yields `localStorage` object.
727
- *
728
- * @see https://on.cypress.io/clearlocalstorage
729
- * @param {string} [key] - name of a particular item to remove (optional).
730
- * @param {options} [object] - options object
731
- * @example
732
- ```
733
- // Removes item "todos" without logging
734
- cy.clearLocalStorage("todos", { log: false })
735
- ```
736
- */
735
+ /**
736
+ * Clear data in local storage.
737
+ * Cypress automatically runs this command before each test to prevent state from being
738
+ * shared across tests. You shouldn’t need to use this command unless you’re using it
739
+ * to clear localStorage inside a single test. Yields `localStorage` object.
740
+ *
741
+ * @see https://on.cypress.io/clearlocalstorage
742
+ * @param {string} [key] - name of a particular item to remove (optional).
743
+ * @param {options} [object] - options object
744
+ * @example
745
+ ```
746
+ // Removes item "todos" without logging
747
+ cy.clearLocalStorage("todos", { log: false })
748
+ ```
749
+ */
737
750
  clearLocalStorage(key: string, options: Partial<Loggable>): Chainable<Storage>
738
751
 
739
752
  /**
@@ -821,7 +834,7 @@ declare namespace Cypress {
821
834
  * // or use this shortcut
822
835
  * cy.clock().invoke('restore')
823
836
  */
824
- clock(now: number|Date, options?: Loggable): Chainable<Clock>
837
+ clock(now: number | Date, options?: Loggable): Chainable<Clock>
825
838
  /**
826
839
  * Mocks global clock but only overrides specific functions.
827
840
  *
@@ -830,7 +843,7 @@ declare namespace Cypress {
830
843
  * // keep current date but override "setTimeout" and "clearTimeout"
831
844
  * cy.clock(null, ['setTimeout', 'clearTimeout'])
832
845
  */
833
- clock(now: number|Date, functions?: Array<'setTimeout' | 'clearTimeout' | 'setInterval' | 'clearInterval' | 'Date'>, options?: Loggable): Chainable<Clock>
846
+ clock(now: number | Date, functions?: Array<'setTimeout' | 'clearTimeout' | 'setInterval' | 'clearInterval' | 'Date'>, options?: Loggable): Chainable<Clock>
834
847
  /**
835
848
  * Mocks global clock and all functions.
836
849
  *
@@ -964,14 +977,14 @@ declare namespace Cypress {
964
977
  */
965
978
  debug(options?: Partial<Loggable>): Chainable<Subject>
966
979
 
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>
980
+ /**
981
+ * Save/Restore browser Cookies, LocalStorage, and SessionStorage data resulting from the supplied `setup` function.
982
+ *
983
+ * Only available if the `experimentalSessionSupport` config option is enabled.
984
+ *
985
+ * @see https://on.cypress.io/session
986
+ */
987
+ session(id: string | object, setup?: SessionOptions['validate'], options?: SessionOptions): Chainable<null>
975
988
 
976
989
  /**
977
990
  * Get the window.document of the page that is currently active.
@@ -1635,17 +1648,11 @@ declare namespace Cypress {
1635
1648
  scrollTo(x: number | string, y: number | string, options?: Partial<ScrollToOptions>): Chainable<Subject>
1636
1649
 
1637
1650
  /**
1638
- * Select an `<option>` with specific text within a `<select>`.
1651
+ * Select an `<option>` with specific text, value, or index within a `<select>`.
1639
1652
  *
1640
1653
  * @see https://on.cypress.io/select
1641
1654
  */
1642
- select(text: string | string[], options?: Partial<SelectOptions>): Chainable<Subject>
1643
- /**
1644
- * Select an `<option>` with specific value(s) within a `<select>`.
1645
- *
1646
- * @see https://on.cypress.io/select
1647
- */
1648
- select(value: string | string[], options?: Partial<SelectOptions>): Chainable<Subject>
1655
+ select(valueOrTextOrIndex: string | number | Array<string | number>, options?: Partial<SelectOptions>): Chainable<Subject>
1649
1656
 
1650
1657
  /**
1651
1658
  * @deprecated Use `cy.intercept()` instead.
@@ -1896,13 +1903,13 @@ declare namespace Cypress {
1896
1903
  *
1897
1904
  * @see https://on.cypress.io/then
1898
1905
  */
1899
- then<S extends HTMLElement>(options: Partial<Timeoutable>, fn: (this: ObjectLike, currentSubject: Subject) => S): Chainable<JQuery<S>>
1900
- /**
1901
- * Enables you to work with the subject yielded from the previous command / promise.
1902
- *
1903
- * @see https://on.cypress.io/then
1904
- */
1905
- then<S extends ArrayLike<HTMLElement>>(options: Partial<Timeoutable>, fn: (this: ObjectLike, currentSubject: Subject) => S): Chainable<JQuery<S extends ArrayLike<infer T> ? T : never>>
1906
+ then<S extends HTMLElement>(options: Partial<Timeoutable>, fn: (this: ObjectLike, currentSubject: Subject) => S): Chainable<JQuery<S>>
1907
+ /**
1908
+ * Enables you to work with the subject yielded from the previous command / promise.
1909
+ *
1910
+ * @see https://on.cypress.io/then
1911
+ */
1912
+ then<S extends ArrayLike<HTMLElement>>(options: Partial<Timeoutable>, fn: (this: ObjectLike, currentSubject: Subject) => S): Chainable<JQuery<S extends ArrayLike<infer T> ? T : never>>
1906
1913
  /**
1907
1914
  * Enables you to work with the subject yielded from the previous command / promise.
1908
1915
  *
@@ -2060,7 +2067,7 @@ declare namespace Cypress {
2060
2067
  * @alias cy.location('href')
2061
2068
  * @see https://on.cypress.io/url
2062
2069
  */
2063
- url(options?: Partial<Loggable & Timeoutable>): Chainable<string>
2070
+ url(options?: Partial<UrlOptions>): Chainable<string>
2064
2071
 
2065
2072
  /**
2066
2073
  * Control the size and orientation of the screen for your application.
@@ -2488,6 +2495,47 @@ declare namespace Cypress {
2488
2495
  cmdKey: boolean
2489
2496
  }
2490
2497
 
2498
+ interface PEMCert {
2499
+ /**
2500
+ * Path to the certificate file, relative to project root.
2501
+ */
2502
+ cert: string
2503
+ /**
2504
+ * Path to the private key file, relative to project root.
2505
+ */
2506
+ key: string
2507
+ /**
2508
+ * Path to a text file containing the passphrase, relative to project root.
2509
+ */
2510
+ passphrase?: string
2511
+ }
2512
+
2513
+ interface PFXCert {
2514
+ /**
2515
+ * Path to the certificate container, relative to project root.
2516
+ */
2517
+ pfx: string
2518
+ /**
2519
+ * Path to a text file containing the passphrase, relative to project root.
2520
+ */
2521
+ passphrase?: string
2522
+ }
2523
+
2524
+ interface ClientCertificate {
2525
+ /**
2526
+ * URL to match requests against. Wildcards following [minimatch](https://github.com/isaacs/minimatch) rules are supported.
2527
+ */
2528
+ url: string
2529
+ /**
2530
+ * Paths to one or more CA files to validate certs against, relative to project root.
2531
+ */
2532
+ ca?: string[]
2533
+ /**
2534
+ * A PEM format certificate/private key pair or PFX certificate container
2535
+ */
2536
+ certs: PEMCert[] | PFXCert[]
2537
+ }
2538
+
2491
2539
  interface ResolvedConfigOptions {
2492
2540
  /**
2493
2541
  * Url used as prefix for [cy.visit()](https://on.cypress.io/visit) or [cy.request()](https://on.cypress.io/request) command’s url
@@ -2700,7 +2748,7 @@ declare namespace Cypress {
2700
2748
  * To enable test retries only in runMode, set e.g. `{ openMode: null, runMode: 2 }`
2701
2749
  * @default null
2702
2750
  */
2703
- retries: Nullable<number | {runMode?: Nullable<number>, openMode?: Nullable<number>}>
2751
+ retries: Nullable<number | { runMode?: Nullable<number>, openMode?: Nullable<number> }>
2704
2752
  /**
2705
2753
  * Enables including elements within the shadow DOM when using querying
2706
2754
  * commands (e.g. cy.get(), cy.find()). Can be set globally in cypress.json,
@@ -2750,6 +2798,11 @@ declare namespace Cypress {
2750
2798
  * @default {}
2751
2799
  */
2752
2800
  e2e: Omit<ResolvedConfigOptions, TestingType>
2801
+
2802
+ /**
2803
+ * An array of objects defining the certificates
2804
+ */
2805
+ clientCertificates: ClientCertificate[]
2753
2806
  }
2754
2807
 
2755
2808
  /**
@@ -2810,19 +2863,15 @@ declare namespace Cypress {
2810
2863
  projectName: string
2811
2864
  projectRoot: string
2812
2865
  proxyUrl: string
2866
+ remote: RemoteState
2813
2867
  report: boolean
2814
2868
  reporterRoute: string
2815
2869
  reporterUrl: string
2816
2870
  socketId: null | string
2817
2871
  socketIoCookie: string
2818
2872
  socketIoRoute: string
2819
- spec: {
2820
- absolute: string
2821
- name: string
2822
- relative: string
2823
- specFilter: null | string
2824
- specType: 'integration' | 'component'
2825
- }
2873
+ spec: Cypress['spec'] | null
2874
+ specs: Array<Cypress['spec']>
2826
2875
  xhrRoute: string
2827
2876
  xhrUrl: string
2828
2877
  }
@@ -2836,7 +2885,7 @@ declare namespace Cypress {
2836
2885
  * All configuration items are optional.
2837
2886
  */
2838
2887
  type CoreConfigOptions = Partial<Omit<ResolvedConfigOptions, TestingType>>
2839
- type ConfigOptions = CoreConfigOptions & {e2e?: CoreConfigOptions, component?: CoreConfigOptions }
2888
+ type ConfigOptions = CoreConfigOptions & { e2e?: CoreConfigOptions, component?: CoreConfigOptions }
2840
2889
 
2841
2890
  interface PluginConfigOptions extends ResolvedConfigOptions {
2842
2891
  /**
@@ -2943,6 +2992,7 @@ declare namespace Cypress {
2943
2992
  disableTimersAndAnimations: boolean
2944
2993
  padding: Padding
2945
2994
  scale: boolean
2995
+ overwrite: boolean
2946
2996
  onBeforeScreenshot: ($el: JQuery) => void
2947
2997
  onAfterScreenshot: ($el: JQuery, props: {
2948
2998
  path: string
@@ -3173,6 +3223,18 @@ declare namespace Cypress {
3173
3223
  eventConstructor: string
3174
3224
  }
3175
3225
 
3226
+ /**
3227
+ * Options to change the default behavior of .url()
3228
+ */
3229
+ interface UrlOptions extends Loggable, Timeoutable {
3230
+ /**
3231
+ * Whether the url is decoded
3232
+ *
3233
+ * @default false
3234
+ */
3235
+ decode: boolean
3236
+ }
3237
+
3176
3238
  /** Options to change the default behavior of .writeFile */
3177
3239
  interface WriteFileOptions extends Loggable {
3178
3240
  flag: string
@@ -5263,7 +5325,7 @@ declare namespace Cypress {
5263
5325
  tag?: string
5264
5326
  }
5265
5327
 
5266
- interface DevServerOptions {
5328
+ interface DevServerConfig {
5267
5329
  specs: Spec[]
5268
5330
  config: ResolvedConfigOptions & RuntimeConfigOptions
5269
5331
  devServerEvents: NodeJS.EventEmitter
@@ -5282,7 +5344,7 @@ declare namespace Cypress {
5282
5344
  (action: 'before:spec', fn: (spec: Spec) => void | Promise<void>): void
5283
5345
  (action: 'before:browser:launch', fn: (browser: Browser, browserLaunchOptions: BrowserLaunchOptions) => void | BrowserLaunchOptions | Promise<BrowserLaunchOptions>): void
5284
5346
  (action: 'file:preprocessor', fn: (file: FileObject) => string | Promise<string>): void
5285
- (action: 'dev-server:start', fn: (file: DevServerOptions) => Promise<ResolvedDevServerConfig>): void
5347
+ (action: 'dev-server:start', fn: (file: DevServerConfig) => Promise<ResolvedDevServerConfig>): void
5286
5348
  (action: 'task', tasks: Tasks): void
5287
5349
  }
5288
5350
 
@@ -5636,48 +5698,48 @@ declare namespace Cypress {
5636
5698
  }
5637
5699
  ```
5638
5700
  */
5639
- interface cy extends Chainable<undefined> {}
5701
+ interface cy extends Chainable<undefined> { }
5640
5702
  }
5641
5703
 
5642
5704
  declare namespace Mocha {
5643
5705
  interface TestFunction {
5644
- /**
5645
- * Describe a specification or test-case with the given `title`, TestOptions, and callback `fn` acting
5646
- * as a thunk.
5647
- */
5648
- (title: string, config: Cypress.TestConfigOverrides, fn?: Func): Test
5649
-
5650
- /**
5651
- * Describe a specification or test-case with the given `title`, TestOptions, and callback `fn` acting
5652
- * as a thunk.
5653
- */
5654
- (title: string, config: Cypress.TestConfigOverrides, fn?: AsyncFunc): Test
5706
+ /**
5707
+ * Describe a specification or test-case with the given `title`, TestOptions, and callback `fn` acting
5708
+ * as a thunk.
5709
+ */
5710
+ (title: string, config: Cypress.TestConfigOverrides, fn?: Func): Test
5711
+
5712
+ /**
5713
+ * Describe a specification or test-case with the given `title`, TestOptions, and callback `fn` acting
5714
+ * as a thunk.
5715
+ */
5716
+ (title: string, config: Cypress.TestConfigOverrides, fn?: AsyncFunc): Test
5655
5717
  }
5656
5718
  interface ExclusiveTestFunction {
5657
- /**
5658
- * Describe a specification or test-case with the given `title`, TestOptions, and callback `fn` acting
5659
- * as a thunk.
5660
- */
5661
- (title: string, config: Cypress.TestConfigOverrides, fn?: Func): Test
5662
-
5663
- /**
5664
- * Describe a specification or test-case with the given `title`, TestOptions, and callback `fn` acting
5665
- * as a thunk.
5666
- */
5667
- (title: string, config: Cypress.TestConfigOverrides, fn?: AsyncFunc): Test
5719
+ /**
5720
+ * Describe a specification or test-case with the given `title`, TestOptions, and callback `fn` acting
5721
+ * as a thunk.
5722
+ */
5723
+ (title: string, config: Cypress.TestConfigOverrides, fn?: Func): Test
5724
+
5725
+ /**
5726
+ * Describe a specification or test-case with the given `title`, TestOptions, and callback `fn` acting
5727
+ * as a thunk.
5728
+ */
5729
+ (title: string, config: Cypress.TestConfigOverrides, fn?: AsyncFunc): Test
5668
5730
  }
5669
5731
  interface PendingTestFunction {
5670
- /**
5671
- * Describe a specification or test-case with the given `title`, TestOptions, and callback `fn` acting
5672
- * as a thunk.
5673
- */
5674
- (title: string, config: Cypress.TestConfigOverrides, fn?: Func): Test
5675
-
5676
- /**
5677
- * Describe a specification or test-case with the given `title`, TestOptions, and callback `fn` acting
5678
- * as a thunk.
5679
- */
5680
- (title: string, config: Cypress.TestConfigOverrides, fn?: AsyncFunc): Test
5732
+ /**
5733
+ * Describe a specification or test-case with the given `title`, TestOptions, and callback `fn` acting
5734
+ * as a thunk.
5735
+ */
5736
+ (title: string, config: Cypress.TestConfigOverrides, fn?: Func): Test
5737
+
5738
+ /**
5739
+ * Describe a specification or test-case with the given `title`, TestOptions, and callback `fn` acting
5740
+ * as a thunk.
5741
+ */
5742
+ (title: string, config: Cypress.TestConfigOverrides, fn?: AsyncFunc): Test
5681
5743
  }
5682
5744
 
5683
5745
  interface SuiteFunction {