cypress 7.7.0 → 8.3.0
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +4 -2
- package/bin/cypress +0 -0
- package/lib/cli.js +2 -2
- package/lib/exec/spawn.js +32 -22
- package/lib/exec/xvfb.js +5 -0
- package/lib/util.js +11 -1
- package/package.json +1 -1
- package/types/chai/index.d.ts +3 -5
- package/types/cypress-npm-api.d.ts +1 -1
- package/types/cypress.d.ts +83 -43
- package/types/minimatch/index.d.ts +0 -0
- package/types/net-stubbing.ts +3 -1
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
|
-
|
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/bin/cypress
CHANGED
File without changes
|
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
|
133
|
-
headless: 'hide the browser instead of running headed (
|
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/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); //
|
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 =
|
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
|
-
|
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',
|
153
|
-
const child = cp.spawn(executable,
|
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
package/types/chai/index.d.ts
CHANGED
@@ -1949,8 +1949,6 @@ declare module "chai" {
|
|
1949
1949
|
export = chai;
|
1950
1950
|
}
|
1951
1951
|
|
1952
|
-
|
1953
|
-
|
1954
|
-
|
1955
|
-
// should: Chai.Assertion;
|
1956
|
-
// }
|
1952
|
+
interface Object {
|
1953
|
+
should: Chai.Assertion;
|
1954
|
+
}
|
package/types/cypress.d.ts
CHANGED
@@ -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> :
|
@@ -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/
|
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
|
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
|
-
*
|
2645
|
-
*
|
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
|
-
|
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
|
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
|
File without changes
|
package/types/net-stubbing.ts
CHANGED
@@ -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
|
-
|
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?
|