cypress 7.4.0 → 8.0.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/VerboseRenderer.js +72 -0
- package/lib/cli.js +2 -2
- package/lib/errors.js +4 -12
- package/lib/exec/spawn.js +32 -22
- package/lib/exec/xvfb.js +5 -0
- package/lib/tasks/install.js +20 -8
- package/lib/tasks/verify.js +11 -5
- package/package.json +6 -4
- package/types/chai/index.d.ts +5 -3
- package/types/cypress-npm-api.d.ts +2 -2
- package/types/cypress.d.ts +93 -56
- package/types/net-stubbing.ts +6 -2
@@ -0,0 +1,72 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
// Vendored from @cypress/listr-verbose-renderer
|
4
|
+
const figures = require('figures');
|
5
|
+
|
6
|
+
const cliCursor = require('cli-cursor');
|
7
|
+
|
8
|
+
const chalk = require('chalk');
|
9
|
+
|
10
|
+
const dayjs = require('dayjs');
|
11
|
+
|
12
|
+
const formattedLog = (options, output) => {
|
13
|
+
const timestamp = dayjs().format(options.dateFormat); // eslint-disable-next-line no-console
|
14
|
+
|
15
|
+
console.log(`${chalk.dim(`[${timestamp}]`)} ${output}`);
|
16
|
+
};
|
17
|
+
|
18
|
+
const renderHelper = (task, event, options) => {
|
19
|
+
const log = formattedLog.bind(undefined, options);
|
20
|
+
|
21
|
+
if (event.type === 'STATE') {
|
22
|
+
const message = task.isPending() ? 'started' : task.state;
|
23
|
+
log(`${task.title} [${message}]`);
|
24
|
+
|
25
|
+
if (task.isSkipped() && task.output) {
|
26
|
+
log(`${figures.arrowRight} ${task.output}`);
|
27
|
+
}
|
28
|
+
} else if (event.type === 'TITLE') {
|
29
|
+
log(`${task.title} [title changed]`);
|
30
|
+
}
|
31
|
+
};
|
32
|
+
|
33
|
+
const render = (tasks, options) => {
|
34
|
+
for (const task of tasks) {
|
35
|
+
task.subscribe(event => {
|
36
|
+
if (event.type === 'SUBTASKS') {
|
37
|
+
render(task.subtasks, options);
|
38
|
+
return;
|
39
|
+
}
|
40
|
+
|
41
|
+
renderHelper(task, event, options);
|
42
|
+
}, err => {
|
43
|
+
// eslint-disable-next-line no-console
|
44
|
+
console.log(err);
|
45
|
+
});
|
46
|
+
}
|
47
|
+
};
|
48
|
+
|
49
|
+
class VerboseRenderer {
|
50
|
+
constructor(tasks, options) {
|
51
|
+
this._tasks = tasks;
|
52
|
+
this._options = Object.assign({
|
53
|
+
dateFormat: 'HH:mm:ss'
|
54
|
+
}, options);
|
55
|
+
}
|
56
|
+
|
57
|
+
static get nonTTY() {
|
58
|
+
return true;
|
59
|
+
}
|
60
|
+
|
61
|
+
render() {
|
62
|
+
cliCursor.hide();
|
63
|
+
render(this._tasks, this._options);
|
64
|
+
}
|
65
|
+
|
66
|
+
end() {
|
67
|
+
cliCursor.show();
|
68
|
+
}
|
69
|
+
|
70
|
+
}
|
71
|
+
|
72
|
+
module.exports = VerboseRenderer;
|
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/errors.js
CHANGED
@@ -151,13 +151,9 @@ const invalidSmokeTestDisplayError = {
|
|
151
151
|
|
152
152
|
${hr}
|
153
153
|
|
154
|
-
This
|
154
|
+
This may be due to a missing library or dependency. ${chalk.blue(requiredDependenciesUrl)}
|
155
155
|
|
156
|
-
|
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
|
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
|
-
|
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); //
|
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/tasks/install.js
CHANGED
@@ -12,9 +12,9 @@ const chalk = require('chalk');
|
|
12
12
|
|
13
13
|
const debug = require('debug')('cypress:cli');
|
14
14
|
|
15
|
-
const
|
16
|
-
|
17
|
-
|
15
|
+
const {
|
16
|
+
Listr
|
17
|
+
} = require('listr2');
|
18
18
|
|
19
19
|
const Promise = require('bluebird');
|
20
20
|
|
@@ -41,6 +41,8 @@ const {
|
|
41
41
|
errors
|
42
42
|
} = require('../errors');
|
43
43
|
|
44
|
+
const verbose = require('../VerboseRenderer');
|
45
|
+
|
44
46
|
const getNpmArgv = () => {
|
45
47
|
const json = process.env.npm_config_argv;
|
46
48
|
|
@@ -179,7 +181,9 @@ const downloadAndUnzip = ({
|
|
179
181
|
logger.log(`Installing Cypress ${chalk.gray(`(version: ${version})`)}`);
|
180
182
|
logger.log();
|
181
183
|
const tasks = new Listr([{
|
182
|
-
|
184
|
+
options: {
|
185
|
+
title: util.titleize('Downloading Cypress')
|
186
|
+
},
|
183
187
|
task: (ctx, task) => {
|
184
188
|
// as our download progresses indicate the status
|
185
189
|
progress.onProgress = progessify(task, 'Downloading Cypress');
|
@@ -201,7 +205,9 @@ const downloadAndUnzip = ({
|
|
201
205
|
installDir,
|
202
206
|
rendererOptions
|
203
207
|
}), {
|
204
|
-
|
208
|
+
options: {
|
209
|
+
title: util.titleize('Finishing Installation')
|
210
|
+
},
|
205
211
|
task: (ctx, task) => {
|
206
212
|
const cleanup = () => {
|
207
213
|
debug('removing zip file %s', downloadDestination);
|
@@ -213,7 +219,9 @@ const downloadAndUnzip = ({
|
|
213
219
|
util.setTaskTitle(task, util.titleize(chalk.green('Finished Installation'), chalk.gray(installDir)), rendererOptions.renderer);
|
214
220
|
});
|
215
221
|
}
|
216
|
-
}],
|
222
|
+
}], {
|
223
|
+
rendererOptions
|
224
|
+
}); // start the tasks!
|
217
225
|
|
218
226
|
return Promise.resolve(tasks.run());
|
219
227
|
};
|
@@ -361,7 +369,9 @@ const start = (options = {}) => {
|
|
361
369
|
zipFilePath: absolutePath,
|
362
370
|
installDir,
|
363
371
|
rendererOptions
|
364
|
-
})],
|
372
|
+
})], {
|
373
|
+
rendererOptions
|
374
|
+
}).run();
|
365
375
|
}
|
366
376
|
|
367
377
|
if (options.force) {
|
@@ -396,7 +406,9 @@ const unzipTask = ({
|
|
396
406
|
rendererOptions
|
397
407
|
}) => {
|
398
408
|
return {
|
399
|
-
|
409
|
+
options: {
|
410
|
+
title: util.titleize('Unzipping Cypress')
|
411
|
+
},
|
400
412
|
task: (ctx, task) => {
|
401
413
|
// as our unzip progresses indicate the status
|
402
414
|
progress.onProgress = progessify(task, 'Unzipping Cypress');
|
package/lib/tasks/verify.js
CHANGED
@@ -4,12 +4,12 @@ const _ = require('lodash');
|
|
4
4
|
|
5
5
|
const chalk = require('chalk');
|
6
6
|
|
7
|
-
const
|
7
|
+
const {
|
8
|
+
Listr
|
9
|
+
} = require('listr2');
|
8
10
|
|
9
11
|
const debug = require('debug')('cypress:cli');
|
10
12
|
|
11
|
-
const verbose = require('@cypress/listr-verbose-renderer');
|
12
|
-
|
13
13
|
const {
|
14
14
|
stripIndent
|
15
15
|
} = require('common-tags');
|
@@ -22,6 +22,8 @@ const path = require('path');
|
|
22
22
|
|
23
23
|
const os = require('os');
|
24
24
|
|
25
|
+
const verbose = require('../VerboseRenderer');
|
26
|
+
|
25
27
|
const {
|
26
28
|
throwFormErrorText,
|
27
29
|
errors
|
@@ -184,7 +186,9 @@ function testBinary(version, binaryDir, options) {
|
|
184
186
|
renderer
|
185
187
|
};
|
186
188
|
const tasks = new Listr([{
|
187
|
-
|
189
|
+
options: {
|
190
|
+
title: util.titleize('Verifying Cypress can run', chalk.gray(binaryDir))
|
191
|
+
},
|
188
192
|
task: (ctx, task) => {
|
189
193
|
debug('clearing out the verified version');
|
190
194
|
return state.clearBinaryStateAsync(binaryDir).then(() => {
|
@@ -197,7 +201,9 @@ function testBinary(version, binaryDir, options) {
|
|
197
201
|
util.setTaskTitle(task, util.titleize(chalk.green('Verified Cypress!'), chalk.gray(binaryDir)), rendererOptions.renderer);
|
198
202
|
});
|
199
203
|
}
|
200
|
-
}],
|
204
|
+
}], {
|
205
|
+
rendererOptions
|
206
|
+
});
|
201
207
|
return tasks.run();
|
202
208
|
}
|
203
209
|
|
package/package.json
CHANGED
@@ -1,13 +1,12 @@
|
|
1
1
|
{
|
2
2
|
"name": "cypress",
|
3
|
-
"version": "
|
3
|
+
"version": "8.0.0",
|
4
4
|
"main": "index.js",
|
5
5
|
"scripts": {
|
6
6
|
"postinstall": "node index.js --exec install",
|
7
7
|
"size": "t=\"$(npm pack .)\"; wc -c \"${t}\"; tar tvf \"${t}\"; rm \"${t}\";"
|
8
8
|
},
|
9
9
|
"dependencies": {
|
10
|
-
"@cypress/listr-verbose-renderer": "^0.4.1",
|
11
10
|
"@cypress/request": "^2.88.5",
|
12
11
|
"@cypress/xvfb": "^1.2.4",
|
13
12
|
"@types/node": "^14.14.31",
|
@@ -19,21 +18,24 @@
|
|
19
18
|
"cachedir": "^2.3.0",
|
20
19
|
"chalk": "^4.1.0",
|
21
20
|
"check-more-types": "^2.24.0",
|
21
|
+
"cli-cursor": "^3.1.0",
|
22
22
|
"cli-table3": "~0.6.0",
|
23
23
|
"commander": "^5.1.0",
|
24
24
|
"common-tags": "^1.8.0",
|
25
25
|
"dayjs": "^1.10.4",
|
26
|
-
"debug": "4.3.2",
|
26
|
+
"debug": "^4.3.2",
|
27
|
+
"enquirer": "^2.3.6",
|
27
28
|
"eventemitter2": "^6.4.3",
|
28
29
|
"execa": "4.1.0",
|
29
30
|
"executable": "^4.1.1",
|
30
31
|
"extract-zip": "2.0.1",
|
32
|
+
"figures": "^3.2.0",
|
31
33
|
"fs-extra": "^9.1.0",
|
32
34
|
"getos": "^3.2.1",
|
33
35
|
"is-ci": "^3.0.0",
|
34
36
|
"is-installed-globally": "~0.4.0",
|
35
37
|
"lazy-ass": "^1.6.0",
|
36
|
-
"
|
38
|
+
"listr2": "^3.8.3",
|
37
39
|
"lodash": "^4.17.21",
|
38
40
|
"log-symbols": "^4.0.0",
|
39
41
|
"minimist": "^1.2.5",
|
package/types/chai/index.d.ts
CHANGED
@@ -1949,6 +1949,8 @@ declare module "chai" {
|
|
1949
1949
|
export = chai;
|
1950
1950
|
}
|
1951
1951
|
|
1952
|
-
|
1953
|
-
|
1954
|
-
|
1952
|
+
// const a = 1; a.should(1); doesn't work with Cypress
|
1953
|
+
// https://github.com/cypress-io/cypress/issues/16548
|
1954
|
+
// interface Object {
|
1955
|
+
// should: Chai.Assertion;
|
1956
|
+
// }
|
@@ -138,7 +138,7 @@ declare namespace CypressCommandLine {
|
|
138
138
|
/**
|
139
139
|
* Specify configuration
|
140
140
|
*/
|
141
|
-
config:
|
141
|
+
config: Cypress.ConfigOptions
|
142
142
|
/**
|
143
143
|
* Path to the config file to be used.
|
144
144
|
*
|
@@ -160,7 +160,7 @@ declare namespace CypressCommandLine {
|
|
160
160
|
* Specify the type of tests to execute.
|
161
161
|
* @default "e2e"
|
162
162
|
*/
|
163
|
-
testingType:
|
163
|
+
testingType: Cypress.TestingType
|
164
164
|
}
|
165
165
|
|
166
166
|
// small utility types to better express meaning of other types
|
package/types/cypress.d.ts
CHANGED
@@ -8,6 +8,7 @@ declare namespace Cypress {
|
|
8
8
|
type RequestBody = string | object
|
9
9
|
type ViewportOrientation = 'portrait' | 'landscape'
|
10
10
|
type PrevSubject = 'optional' | 'element' | 'document' | 'window'
|
11
|
+
type TestingType = 'e2e' | 'component'
|
11
12
|
type PluginConfig = (on: PluginEvents, config: PluginConfigOptions) => void | ConfigOptions | Promise<ConfigOptions>
|
12
13
|
|
13
14
|
interface CommandOptions {
|
@@ -59,10 +60,26 @@ declare namespace Cypress {
|
|
59
60
|
*/
|
60
61
|
displayName: string
|
61
62
|
version: string
|
62
|
-
majorVersion: number
|
63
|
+
majorVersion: number | string
|
63
64
|
path: string
|
64
65
|
isHeaded: boolean
|
65
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
|
66
83
|
}
|
67
84
|
|
68
85
|
interface LocalStorage {
|
@@ -251,6 +268,11 @@ declare namespace Cypress {
|
|
251
268
|
*/
|
252
269
|
LocalStorage: LocalStorage
|
253
270
|
|
271
|
+
/**
|
272
|
+
* Current testing type, determined by the Test Runner chosen to run.
|
273
|
+
*/
|
274
|
+
testingType: TestingType
|
275
|
+
|
254
276
|
/**
|
255
277
|
* Fire automation:request event for internal use.
|
256
278
|
*/
|
@@ -335,15 +357,6 @@ declare namespace Cypress {
|
|
335
357
|
*/
|
336
358
|
env(object: ObjectLike): void
|
337
359
|
|
338
|
-
/**
|
339
|
-
* Firefox only: Get the current number of tests that will run between forced garbage collections.
|
340
|
-
*
|
341
|
-
* Returns undefined if not in Firefox, returns a null or 0 if forced GC is disabled.
|
342
|
-
*
|
343
|
-
* @see https://on.cypress.io/firefox-gc-issue
|
344
|
-
*/
|
345
|
-
getFirefoxGcInterval(): number | null | undefined
|
346
|
-
|
347
360
|
/**
|
348
361
|
* @returns the number of test retries currently enabled for the run
|
349
362
|
*/
|
@@ -484,6 +497,13 @@ declare namespace Cypress {
|
|
484
497
|
getElementCoordinatesByPositionRelativeToXY(element: JQuery | HTMLElement, x: number, y: number): ElementPositioning
|
485
498
|
}
|
486
499
|
|
500
|
+
/**
|
501
|
+
* @see https://on.cypress.io/keyboard-api
|
502
|
+
*/
|
503
|
+
Keyboard: {
|
504
|
+
defaults(options: Partial<KeyboardDefaultsOptions>): void
|
505
|
+
}
|
506
|
+
|
487
507
|
/**
|
488
508
|
* @see https://on.cypress.io/api/api-server
|
489
509
|
*/
|
@@ -835,7 +855,7 @@ declare namespace Cypress {
|
|
835
855
|
* // tries to find the given text for up to 1 second
|
836
856
|
* cy.contains('my text to find', {timeout: 1000})
|
837
857
|
*/
|
838
|
-
contains(content: string | number | RegExp, options?: Partial<Loggable & Timeoutable & CaseMatchable>): Chainable<Subject>
|
858
|
+
contains(content: string | number | RegExp, options?: Partial<Loggable & Timeoutable & CaseMatchable & Shadow>): Chainable<Subject>
|
839
859
|
/**
|
840
860
|
* Get the child DOM element that contains given text.
|
841
861
|
*
|
@@ -853,7 +873,7 @@ declare namespace Cypress {
|
|
853
873
|
* // yields <ul>...</ul>
|
854
874
|
* cy.contains('ul', 'apples')
|
855
875
|
*/
|
856
|
-
contains<K extends keyof HTMLElementTagNameMap>(selector: K, text: string | number | RegExp, options?: Partial<Loggable & Timeoutable & CaseMatchable>): Chainable<JQuery<HTMLElementTagNameMap[K]>>
|
876
|
+
contains<K extends keyof HTMLElementTagNameMap>(selector: K, text: string | number | RegExp, options?: Partial<Loggable & Timeoutable & CaseMatchable & Shadow>): Chainable<JQuery<HTMLElementTagNameMap[K]>>
|
857
877
|
/**
|
858
878
|
* Get the DOM element using CSS "selector" containing the text or regular expression.
|
859
879
|
*
|
@@ -862,7 +882,7 @@ declare namespace Cypress {
|
|
862
882
|
* // yields <... class="foo">... apples ...</...>
|
863
883
|
* cy.contains('.foo', 'apples')
|
864
884
|
*/
|
865
|
-
contains<E extends Node = HTMLElement>(selector: string, text: string | number | RegExp, options?: Partial<Loggable & Timeoutable & CaseMatchable>): Chainable<JQuery<E>>
|
885
|
+
contains<E extends Node = HTMLElement>(selector: string, text: string | number | RegExp, options?: Partial<Loggable & Timeoutable & CaseMatchable & Shadow>): Chainable<JQuery<E>>
|
866
886
|
|
867
887
|
/**
|
868
888
|
* Double-click a DOM element.
|
@@ -1464,7 +1484,7 @@ declare namespace Cypress {
|
|
1464
1484
|
* @example
|
1465
1485
|
* cy.request('http://dev.local/seed')
|
1466
1486
|
*/
|
1467
|
-
request(url: string, body?: RequestBody): Chainable<Response
|
1487
|
+
request<T = any>(url: string, body?: RequestBody): Chainable<Response<T>>
|
1468
1488
|
/**
|
1469
1489
|
* Make an HTTP request with specific method.
|
1470
1490
|
*
|
@@ -1472,7 +1492,7 @@ declare namespace Cypress {
|
|
1472
1492
|
* @example
|
1473
1493
|
* cy.request('POST', 'http://localhost:8888/users', {name: 'Jane'})
|
1474
1494
|
*/
|
1475
|
-
request(method: HttpMethod, url: string, body?: RequestBody): Chainable<Response
|
1495
|
+
request<T = any>(method: HttpMethod, url: string, body?: RequestBody): Chainable<Response<T>>
|
1476
1496
|
/**
|
1477
1497
|
* Make an HTTP request with specific behavior.
|
1478
1498
|
*
|
@@ -1483,7 +1503,7 @@ declare namespace Cypress {
|
|
1483
1503
|
* followRedirect: false // turn off following redirects
|
1484
1504
|
* })
|
1485
1505
|
*/
|
1486
|
-
request(options: Partial<RequestOptions>): Chainable<Response
|
1506
|
+
request<T = any>(options: Partial<RequestOptions>): Chainable<Response<T>>
|
1487
1507
|
|
1488
1508
|
/**
|
1489
1509
|
* Get the root DOM element.
|
@@ -1820,6 +1840,12 @@ declare namespace Cypress {
|
|
1820
1840
|
* @see https://on.cypress.io/then
|
1821
1841
|
*/
|
1822
1842
|
then<S>(options: Partial<Timeoutable>, fn: (this: ObjectLike, currentSubject: Subject) => PromiseLike<S>): Chainable<S>
|
1843
|
+
/**
|
1844
|
+
* Enables you to work with the subject yielded from the previous command / promise.
|
1845
|
+
*
|
1846
|
+
* @see https://on.cypress.io/then
|
1847
|
+
*/
|
1848
|
+
then<S extends string | number | boolean>(fn: (this: ObjectLike, currentSubject: Subject) => S): Chainable<S>
|
1823
1849
|
/**
|
1824
1850
|
* Enables you to work with the subject yielded from the previous command / promise.
|
1825
1851
|
*
|
@@ -1837,7 +1863,7 @@ declare namespace Cypress {
|
|
1837
1863
|
*
|
1838
1864
|
* @see https://on.cypress.io/then
|
1839
1865
|
*/
|
1840
|
-
then<S extends
|
1866
|
+
then<S extends any[] | object>(fn: (this: ObjectLike, currentSubject: Subject) => S): Chainable<S>
|
1841
1867
|
/**
|
1842
1868
|
* Enables you to work with the subject yielded from the previous command / promise.
|
1843
1869
|
*
|
@@ -2627,13 +2653,6 @@ declare namespace Cypress {
|
|
2627
2653
|
* @default 'top'
|
2628
2654
|
*/
|
2629
2655
|
scrollBehavior: scrollBehaviorOptions
|
2630
|
-
/**
|
2631
|
-
* Firefox version 79 and below only: The number of tests that will run between forced garbage collections.
|
2632
|
-
* If a number is supplied, it will apply to `run` mode and `open` mode.
|
2633
|
-
* Set the interval to `null` or 0 to disable forced garbage collections.
|
2634
|
-
* @default { runMode: 1, openMode: null }
|
2635
|
-
*/
|
2636
|
-
firefoxGcInterval: Nullable<number | { runMode: Nullable<number>, openMode: Nullable<number> }>
|
2637
2656
|
/**
|
2638
2657
|
* Allows listening to the `before:run`, `after:run`, `before:spec`, and `after:spec` events in the plugins file during interactive mode.
|
2639
2658
|
* @default false
|
@@ -2665,17 +2684,46 @@ declare namespace Cypress {
|
|
2665
2684
|
*/
|
2666
2685
|
includeShadowDom: boolean
|
2667
2686
|
|
2687
|
+
/**
|
2688
|
+
* The list of hosts to be blocked
|
2689
|
+
*/
|
2690
|
+
blockHosts: null | string | string[]
|
2691
|
+
/**
|
2692
|
+
* Path to folder containing component test files.
|
2693
|
+
*/
|
2694
|
+
componentFolder: false | string
|
2695
|
+
/**
|
2696
|
+
* A unique ID for the project used for recording
|
2697
|
+
*/
|
2698
|
+
projectId: null | string
|
2699
|
+
/**
|
2700
|
+
* Path to the support folder.
|
2701
|
+
*/
|
2702
|
+
supportFolder: string
|
2703
|
+
/**
|
2704
|
+
* Glob pattern to determine what test files to load.
|
2705
|
+
*/
|
2706
|
+
testFiles: string | string[]
|
2707
|
+
/**
|
2708
|
+
* The user agent the browser sends in all request headers.
|
2709
|
+
*/
|
2710
|
+
userAgent: null | string
|
2711
|
+
/**
|
2712
|
+
* Polyfills `window.fetch` to enable Network spying and stubbing
|
2713
|
+
*/
|
2714
|
+
experimentalFetchPolyfill: boolean
|
2715
|
+
|
2668
2716
|
/**
|
2669
2717
|
* Override default config options for Component Testing runner.
|
2670
2718
|
* @default {}
|
2671
2719
|
*/
|
2672
|
-
component: ResolvedConfigOptions
|
2720
|
+
component: Omit<ResolvedConfigOptions, 'e2e' | 'component'>
|
2673
2721
|
|
2674
2722
|
/**
|
2675
2723
|
* Override default config options for E2E Testing runner.
|
2676
2724
|
* @default {}
|
2677
2725
|
*/
|
2678
|
-
e2e: ResolvedConfigOptions
|
2726
|
+
e2e: Omit<ResolvedConfigOptions, 'e2e' | 'component'>
|
2679
2727
|
}
|
2680
2728
|
|
2681
2729
|
/**
|
@@ -2688,10 +2736,6 @@ declare namespace Cypress {
|
|
2688
2736
|
* @see https://nodejs.org/api/os.html#os_os_arch
|
2689
2737
|
*/
|
2690
2738
|
arch: string
|
2691
|
-
/**
|
2692
|
-
* The list of hosts to be blocked
|
2693
|
-
*/
|
2694
|
-
blockHosts: null | string | string[]
|
2695
2739
|
/**
|
2696
2740
|
* The browser Cypress is running on.
|
2697
2741
|
*/
|
@@ -2700,10 +2744,6 @@ declare namespace Cypress {
|
|
2700
2744
|
* Available browsers found on your system.
|
2701
2745
|
*/
|
2702
2746
|
browsers: Browser[]
|
2703
|
-
/**
|
2704
|
-
* Path to folder containing component test files.
|
2705
|
-
*/
|
2706
|
-
componentFolder: string
|
2707
2747
|
/**
|
2708
2748
|
* Hosts mappings to IP addresses.
|
2709
2749
|
*/
|
@@ -2723,22 +2763,6 @@ declare namespace Cypress {
|
|
2723
2763
|
* The platform Cypress is running on.
|
2724
2764
|
*/
|
2725
2765
|
platform: 'linux' | 'darwin' | 'win32'
|
2726
|
-
/**
|
2727
|
-
* A unique ID for the project used for recording
|
2728
|
-
*/
|
2729
|
-
projectId: null | string
|
2730
|
-
/**
|
2731
|
-
* Path to the support folder.
|
2732
|
-
*/
|
2733
|
-
supportFolder: string
|
2734
|
-
/**
|
2735
|
-
* Glob pattern to determine what test files to load.
|
2736
|
-
*/
|
2737
|
-
testFiles: string
|
2738
|
-
/**
|
2739
|
-
* The user agent the browser sends in all request headers.
|
2740
|
-
*/
|
2741
|
-
userAgent: null | string
|
2742
2766
|
/**
|
2743
2767
|
* The Cypress version being used.
|
2744
2768
|
*/
|
@@ -2750,8 +2774,7 @@ declare namespace Cypress {
|
|
2750
2774
|
clientRoute: string
|
2751
2775
|
configFile: string
|
2752
2776
|
cypressEnv: string
|
2753
|
-
|
2754
|
-
integrationExamplePath: string
|
2777
|
+
devServerPublicPathRoute: string
|
2755
2778
|
isNewProject: boolean
|
2756
2779
|
isTextTerminal: boolean
|
2757
2780
|
morgan: boolean
|
@@ -2780,12 +2803,14 @@ declare namespace Cypress {
|
|
2780
2803
|
|
2781
2804
|
interface TestConfigOverrides extends Partial<Pick<ConfigOptions, 'animationDistanceThreshold' | 'baseUrl' | 'defaultCommandTimeout' | 'env' | 'execTimeout' | 'includeShadowDom' | 'requestTimeout' | 'responseTimeout' | 'retries' | 'scrollBehavior' | 'taskTimeout' | 'viewportHeight' | 'viewportWidth' | 'waitForAnimations'>> {
|
2782
2805
|
browser?: IsBrowserMatcher | IsBrowserMatcher[]
|
2806
|
+
keystrokeDelay?: number
|
2783
2807
|
}
|
2784
2808
|
|
2785
2809
|
/**
|
2786
2810
|
* All configuration items are optional.
|
2787
2811
|
*/
|
2788
|
-
type
|
2812
|
+
type CoreConfigOptions = Partial<Omit<ResolvedConfigOptions, 'e2e' | 'component'>>
|
2813
|
+
type ConfigOptions = CoreConfigOptions & {e2e?: CoreConfigOptions, component?: CoreConfigOptions }
|
2789
2814
|
|
2790
2815
|
interface PluginConfigOptions extends ResolvedConfigOptions {
|
2791
2816
|
/**
|
@@ -2799,7 +2824,7 @@ declare namespace Cypress {
|
|
2799
2824
|
/**
|
2800
2825
|
* Type of test and associated runner that was launched.
|
2801
2826
|
*/
|
2802
|
-
testingType:
|
2827
|
+
testingType: TestingType
|
2803
2828
|
/**
|
2804
2829
|
* Cypress version.
|
2805
2830
|
*/
|
@@ -2830,6 +2855,18 @@ declare namespace Cypress {
|
|
2830
2855
|
env: object
|
2831
2856
|
}
|
2832
2857
|
|
2858
|
+
/**
|
2859
|
+
* Options for Cypress.Keyboard.defaults()
|
2860
|
+
*/
|
2861
|
+
interface KeyboardDefaultsOptions {
|
2862
|
+
/**
|
2863
|
+
* Time, in milliseconds, between each keystroke when typing. (Pass 0 to disable)
|
2864
|
+
*
|
2865
|
+
* @default 10
|
2866
|
+
*/
|
2867
|
+
keystrokeDelay: number
|
2868
|
+
}
|
2869
|
+
|
2833
2870
|
/**
|
2834
2871
|
* Full set of possible options for cy.request call
|
2835
2872
|
*/
|
@@ -5496,9 +5533,9 @@ declare namespace Cypress {
|
|
5496
5533
|
consoleProps(): ObjectLike
|
5497
5534
|
}
|
5498
5535
|
|
5499
|
-
interface Response {
|
5536
|
+
interface Response<T> {
|
5500
5537
|
allRequestResponses: any[]
|
5501
|
-
body:
|
5538
|
+
body: T
|
5502
5539
|
duration: number
|
5503
5540
|
headers: { [key: string]: string | string[] }
|
5504
5541
|
isOkStatusCode: boolean
|
package/types/net-stubbing.ts
CHANGED
@@ -79,7 +79,7 @@ export namespace CyHttpMessages {
|
|
79
79
|
/**
|
80
80
|
* The headers of the HTTP message.
|
81
81
|
*/
|
82
|
-
headers: { [key: string]: string }
|
82
|
+
headers: { [key: string]: string | string[] }
|
83
83
|
}
|
84
84
|
|
85
85
|
export type IncomingResponse = BaseMessage & {
|
@@ -131,6 +131,10 @@ export namespace CyHttpMessages {
|
|
131
131
|
* Request URL.
|
132
132
|
*/
|
133
133
|
url: string
|
134
|
+
/**
|
135
|
+
* URL query string as object.
|
136
|
+
*/
|
137
|
+
query: Record<string, string|number>
|
134
138
|
/**
|
135
139
|
* The HTTP version used in the request. Read only.
|
136
140
|
*/
|
@@ -383,7 +387,7 @@ export type RouteHandler = string | StaticResponse | RouteHandlerController | ob
|
|
383
387
|
/**
|
384
388
|
* Describes a response that will be sent back to the browser to fulfill the request.
|
385
389
|
*/
|
386
|
-
export type StaticResponse = GenericStaticResponse<string, string | object | boolean | null> & {
|
390
|
+
export type StaticResponse = GenericStaticResponse<string, string | object | boolean | ArrayBuffer | null> & {
|
387
391
|
/**
|
388
392
|
* Milliseconds to delay before the response is sent.
|
389
393
|
* @deprecated Use `delay` instead of `delayMs`.
|