cypress 9.4.0 → 9.4.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,404 +1,404 @@
1
- //
2
- // Cypress NPM api type declarations
3
- // https://on.cypress.io/module-api
4
- // https://github.com/cypress-io/cypress/issues/2141
5
- //
6
- // in the future the NPM module itself will be in TypeScript
7
- // but for now describe it as an ambient module
8
-
9
- declare namespace CypressCommandLine {
10
- type HookName = 'before' | 'beforeEach' | 'afterEach' | 'after'
11
-
12
- interface TestError {
13
- name: string
14
- message: string
15
- stack: string
16
- }
17
- /**
18
- * All options that one can pass to "cypress.run"
19
- * @see https://on.cypress.io/module-api#cypress-run
20
- * @example
21
- ```
22
- const cypress = require('cypress')
23
- cypress.run({
24
- reporter: 'junit',
25
- browser: 'chrome',
26
- config: {
27
- baseUrl: 'http://localhost:8080',
28
- chromeWebSecurity: false,
29
- },
30
- env: {
31
- foo: 'bar',
32
- baz: 'quux',
33
- }
34
- })
35
- ```
36
- */
37
- interface CypressRunOptions extends CypressCommonOptions {
38
- /**
39
- * Specify different browser to run tests in, either by name or by filesystem path
40
- */
41
- browser: string
42
- /**
43
- * Specify a unique identifier for a run to enable grouping or parallelization
44
- */
45
- ciBuildId: string
46
- /**
47
- * Group recorded tests together under a single run name
48
- */
49
- group: string
50
- /**
51
- * Tag string for the recorded run, like "production,nightly"
52
- */
53
- tag: string
54
- /**
55
- * Display the browser instead of running headlessly
56
- */
57
- headed: boolean
58
- /**
59
- * Hide the browser instead of running headed
60
- */
61
- headless: boolean
62
- /**
63
- * Specify your secret record key
64
- */
65
- key: string
66
- /**
67
- * Keep Cypress open after all tests run
68
- */
69
- noExit: boolean
70
- /**
71
- * Run recorded specs in parallel across multiple machines
72
- */
73
- parallel: boolean
74
- /**
75
- * Override default port
76
- */
77
- port: number
78
- /**
79
- * Run quietly, using only the configured reporter
80
- */
81
- quiet: boolean
82
- /**
83
- * Whether to record the test run
84
- */
85
- record: boolean
86
- /**
87
- * Specify a mocha reporter
88
- */
89
- reporter: string
90
- /**
91
- * Specify mocha reporter options
92
- */
93
- reporterOptions: any
94
- /**
95
- * Slow test threshold in milliseconds. Only affects the visual output of some reporters. For example, the spec reporter will display the test time in yellow if over the threshold.
96
- */
97
- slowTestThreshold: number
98
- /**
99
- * Specify the specs to run
100
- */
101
- spec: string
102
- }
103
-
104
- /**
105
- * All options that one can pass to "cypress.open"
106
- * @see https://on.cypress.io/module-api#cypress-open
107
- * @example
108
- ```
109
- const cypress = require('cypress')
110
- cypress.open({
111
- env: {
112
- username: 'Joe Doe',
113
- email: 'joe@acme.co'
114
- },
115
- project: '~/demos/my-project'
116
- })
117
- ```
118
- */
119
- interface CypressOpenOptions extends CypressCommonOptions {
120
- /**
121
- * Specify a filesystem path to a custom browser
122
- */
123
- browser: string
124
- /**
125
- * Open Cypress in detached mode
126
- */
127
- detached: boolean
128
- /**
129
- * Run in global mode
130
- */
131
- global: boolean
132
- /**
133
- * Override default port
134
- */
135
- port: number
136
- }
137
-
138
- /**
139
- * Options available for `cypress.open` and `cypress.run`
140
- */
141
- interface CypressCommonOptions {
142
- /**
143
- * Specify configuration
144
- */
145
- config: Cypress.ConfigOptions
146
- /**
147
- * Path to the config file to be used.
148
- *
149
- * If `false` is passed, no config file will be used.
150
- *
151
- * @default "cypress.json"
152
- */
153
- configFile: string | false
154
- /**
155
- * Specify environment variables.
156
- * TODO: isn't this duplicate of config.env?!
157
- */
158
- env: object
159
- /**
160
- * Path to a specific project
161
- */
162
- project: string
163
- /**
164
- * Specify the type of tests to execute.
165
- * @default "e2e"
166
- */
167
- testingType: Cypress.TestingType
168
- }
169
-
170
- // small utility types to better express meaning of other types
171
- type dateTimeISO = string
172
- type ms = number
173
- type pixels = number
174
-
175
- /**
176
- * Cypress single test result
177
- */
178
- interface TestResult {
179
- title: string[]
180
- state: string
181
- body: string
182
- /**
183
- * Error string as it's presented in console if the test fails
184
- */
185
- displayError: string | null
186
- attempts: AttemptResult[]
187
- }
188
-
189
- interface AttemptResult {
190
- state: string
191
- error: TestError | null
192
- startedAt: dateTimeISO
193
- duration: ms
194
- videoTimestamp: ms
195
- screenshots: ScreenshotInformation[]
196
- }
197
-
198
- /**
199
- * Information about a single "before", "beforeEach", "afterEach" and "after" hook.
200
- */
201
- interface HookInformation {
202
- hookName: HookName
203
- title: string[]
204
- body: string
205
- }
206
-
207
- /**
208
- * Information about a single screenshot.
209
- */
210
- interface ScreenshotInformation {
211
- name: string
212
- takenAt: dateTimeISO
213
- /**
214
- * Absolute path to the saved image
215
- */
216
- path: string
217
- height: pixels
218
- width: pixels
219
- }
220
-
221
- /**
222
- * Cypress test run result for a single spec.
223
- */
224
- interface RunResult {
225
- /**
226
- * Accurate test results collected by Cypress.
227
- */
228
- stats: {
229
- suites: number
230
- tests: number
231
- passes: number
232
- pending: number
233
- skipped: number
234
- failures: number
235
- startedAt: dateTimeISO
236
- endedAt: dateTimeISO
237
- duration: ms
238
- }
239
- /**
240
- * Reporter name like "spec"
241
- */
242
- reporter: string
243
- /**
244
- * This is controlled by the reporter, and Cypress cannot guarantee
245
- * the properties. Usually this object has suites, tests, passes, etc
246
- */
247
- reporterStats: object
248
- hooks: HookInformation[]
249
- tests: TestResult[]
250
- error: string | null
251
- video: string | null
252
- /**
253
- * information about the spec test file.
254
- */
255
- spec: {
256
- /**
257
- * filename like "spec.js"
258
- */
259
- name: string
260
- /**
261
- * name relative to the project root, like "cypress/integration/spec.js"
262
- */
263
- relative: string
264
- /**
265
- * resolved filename of the spec
266
- */
267
- absolute: string
268
- }
269
- shouldUploadVideo: boolean
270
- }
271
-
272
- /**
273
- * Results returned by the test run.
274
- * @see https://on.cypress.io/module-api
275
- */
276
- interface CypressRunResult {
277
- status: 'finished'
278
- startedTestsAt: dateTimeISO
279
- endedTestsAt: dateTimeISO
280
- totalDuration: ms
281
- totalSuites: number
282
- totalTests: number
283
- totalFailed: number
284
- totalPassed: number
285
- totalPending: number
286
- totalSkipped: number
287
- /**
288
- * If Cypress test run is being recorded, full url will be provided.
289
- * @see https://on.cypress.io/dashboard-introduction
290
- */
291
- runUrl?: string
292
- runs: RunResult[]
293
- browserPath: string
294
- browserName: string
295
- browserVersion: string
296
- osName: string
297
- osVersion: string
298
- cypressVersion: string
299
- config: Cypress.ResolvedConfigOptions
300
- }
301
-
302
- /**
303
- * If Cypress fails to run at all (for example, if there are no spec files to run),
304
- * then it will return a CypressFailedRunResult. Check the failures attribute.
305
- * @example
306
- ```
307
- const result = await cypress.run()
308
- if (result.status === 'failed') {
309
- console.error('failures %d', result.failures)
310
- console.error(result.message)
311
- process.exit(result.failures)
312
- }
313
- ```
314
- *
315
- **/
316
- interface CypressFailedRunResult {
317
- status: 'failed'
318
- failures: number
319
- message: string
320
- }
321
-
322
- /**
323
- * Methods allow parsing given CLI arguments the same way Cypress CLI does it.
324
- */
325
- interface CypressCliParser {
326
- /**
327
- * Parses the given array of string arguments to "cypress run"
328
- * just like Cypress CLI does it.
329
- * @see https://on.cypress.io/module-api
330
- * @example
331
- * const cypress = require('cypress')
332
- * const args = ['cypress', 'run', '--browser', 'chrome']
333
- * const options = await cypress.cli.parseRunArguments(args)
334
- * // options is {browser: 'chrome'}
335
- * // pass the options to cypress.run()
336
- * const results = await cypress.run(options)
337
- */
338
- parseRunArguments(args: string[]): Promise<Partial<CypressRunOptions>>
339
- }
340
- }
341
-
342
- declare module 'cypress' {
343
- /**
344
- * Cypress NPM module interface.
345
- * @see https://on.cypress.io/module-api
346
- * @example
347
- ```
348
- const cypress = require('cypress')
349
- cypress.run().then(results => ...)
350
- ```
351
- */
352
- interface CypressNpmApi {
353
- /**
354
- * Execute a headless Cypress test run.
355
- * @see https://on.cypress.io/module-api#cypress-run
356
- * @example
357
- ```
358
- const cypress = require('cypress')
359
- // runs all spec files matching a wildcard
360
- cypress.run({
361
- spec: 'cypress/integration/admin*-spec.js'
362
- }).then(results => {
363
- if (results.status === 'failed') {
364
- // Cypress could not run
365
- } else {
366
- // inspect results object
367
- }
368
- })
369
- ```
370
- */
371
- run(options?: Partial<CypressCommandLine.CypressRunOptions>): Promise<CypressCommandLine.CypressRunResult | CypressCommandLine.CypressFailedRunResult>
372
- /**
373
- * Opens Cypress GUI. Resolves with void when the
374
- * GUI is closed.
375
- * @see https://on.cypress.io/module-api#cypress-open
376
- */
377
- open(options?: Partial<CypressCommandLine.CypressOpenOptions>): Promise<void>
378
-
379
- /**
380
- * Utility functions for parsing CLI arguments the same way
381
- * Cypress does
382
- */
383
- cli: CypressCommandLine.CypressCliParser
384
-
385
- /**
386
- * Provides automatic code completion for configuration in many popular code editors.
387
- * While it's not strictly necessary for Cypress to parse your configuration, we
388
- * recommend wrapping your config object with `defineConfig()`
389
- * @example
390
- * module.exports = defineConfig({
391
- * viewportWith: 400
392
- * })
393
- *
394
- * @see ../types/cypress-npm-api.d.ts
395
- * @param {Cypress.ConfigOptions} config
396
- * @returns {Cypress.ConfigOptions} the configuration passed in parameter
397
- */
398
- defineConfig(config: Cypress.ConfigOptions): Cypress.ConfigOptions
399
- }
400
-
401
- // export Cypress NPM module interface
402
- const cypress: CypressNpmApi
403
- export = cypress
404
- }
1
+ //
2
+ // Cypress NPM api type declarations
3
+ // https://on.cypress.io/module-api
4
+ // https://github.com/cypress-io/cypress/issues/2141
5
+ //
6
+ // in the future the NPM module itself will be in TypeScript
7
+ // but for now describe it as an ambient module
8
+
9
+ declare namespace CypressCommandLine {
10
+ type HookName = 'before' | 'beforeEach' | 'afterEach' | 'after'
11
+
12
+ interface TestError {
13
+ name: string
14
+ message: string
15
+ stack: string
16
+ }
17
+ /**
18
+ * All options that one can pass to "cypress.run"
19
+ * @see https://on.cypress.io/module-api#cypress-run
20
+ * @example
21
+ ```
22
+ const cypress = require('cypress')
23
+ cypress.run({
24
+ reporter: 'junit',
25
+ browser: 'chrome',
26
+ config: {
27
+ baseUrl: 'http://localhost:8080',
28
+ chromeWebSecurity: false,
29
+ },
30
+ env: {
31
+ foo: 'bar',
32
+ baz: 'quux',
33
+ }
34
+ })
35
+ ```
36
+ */
37
+ interface CypressRunOptions extends CypressCommonOptions {
38
+ /**
39
+ * Specify different browser to run tests in, either by name or by filesystem path
40
+ */
41
+ browser: string
42
+ /**
43
+ * Specify a unique identifier for a run to enable grouping or parallelization
44
+ */
45
+ ciBuildId: string
46
+ /**
47
+ * Group recorded tests together under a single run name
48
+ */
49
+ group: string
50
+ /**
51
+ * Tag string for the recorded run, like "production,nightly"
52
+ */
53
+ tag: string
54
+ /**
55
+ * Display the browser instead of running headlessly
56
+ */
57
+ headed: boolean
58
+ /**
59
+ * Hide the browser instead of running headed
60
+ */
61
+ headless: boolean
62
+ /**
63
+ * Specify your secret record key
64
+ */
65
+ key: string
66
+ /**
67
+ * Keep Cypress open after all tests run
68
+ */
69
+ noExit: boolean
70
+ /**
71
+ * Run recorded specs in parallel across multiple machines
72
+ */
73
+ parallel: boolean
74
+ /**
75
+ * Override default port
76
+ */
77
+ port: number
78
+ /**
79
+ * Run quietly, using only the configured reporter
80
+ */
81
+ quiet: boolean
82
+ /**
83
+ * Whether to record the test run
84
+ */
85
+ record: boolean
86
+ /**
87
+ * Specify a mocha reporter
88
+ */
89
+ reporter: string
90
+ /**
91
+ * Specify mocha reporter options
92
+ */
93
+ reporterOptions: any
94
+ /**
95
+ * Slow test threshold in milliseconds. Only affects the visual output of some reporters. For example, the spec reporter will display the test time in yellow if over the threshold.
96
+ */
97
+ slowTestThreshold: number
98
+ /**
99
+ * Specify the specs to run
100
+ */
101
+ spec: string
102
+ }
103
+
104
+ /**
105
+ * All options that one can pass to "cypress.open"
106
+ * @see https://on.cypress.io/module-api#cypress-open
107
+ * @example
108
+ ```
109
+ const cypress = require('cypress')
110
+ cypress.open({
111
+ env: {
112
+ username: 'Joe Doe',
113
+ email: 'joe@acme.co'
114
+ },
115
+ project: '~/demos/my-project'
116
+ })
117
+ ```
118
+ */
119
+ interface CypressOpenOptions extends CypressCommonOptions {
120
+ /**
121
+ * Specify a filesystem path to a custom browser
122
+ */
123
+ browser: string
124
+ /**
125
+ * Open Cypress in detached mode
126
+ */
127
+ detached: boolean
128
+ /**
129
+ * Run in global mode
130
+ */
131
+ global: boolean
132
+ /**
133
+ * Override default port
134
+ */
135
+ port: number
136
+ }
137
+
138
+ /**
139
+ * Options available for `cypress.open` and `cypress.run`
140
+ */
141
+ interface CypressCommonOptions {
142
+ /**
143
+ * Specify configuration
144
+ */
145
+ config: Cypress.ConfigOptions
146
+ /**
147
+ * Path to the config file to be used.
148
+ *
149
+ * If `false` is passed, no config file will be used.
150
+ *
151
+ * @default "cypress.json"
152
+ */
153
+ configFile: string | false
154
+ /**
155
+ * Specify environment variables.
156
+ * TODO: isn't this duplicate of config.env?!
157
+ */
158
+ env: object
159
+ /**
160
+ * Path to a specific project
161
+ */
162
+ project: string
163
+ /**
164
+ * Specify the type of tests to execute.
165
+ * @default "e2e"
166
+ */
167
+ testingType: Cypress.TestingType
168
+ }
169
+
170
+ // small utility types to better express meaning of other types
171
+ type dateTimeISO = string
172
+ type ms = number
173
+ type pixels = number
174
+
175
+ /**
176
+ * Cypress single test result
177
+ */
178
+ interface TestResult {
179
+ title: string[]
180
+ state: string
181
+ body: string
182
+ /**
183
+ * Error string as it's presented in console if the test fails
184
+ */
185
+ displayError: string | null
186
+ attempts: AttemptResult[]
187
+ }
188
+
189
+ interface AttemptResult {
190
+ state: string
191
+ error: TestError | null
192
+ startedAt: dateTimeISO
193
+ duration: ms
194
+ videoTimestamp: ms
195
+ screenshots: ScreenshotInformation[]
196
+ }
197
+
198
+ /**
199
+ * Information about a single "before", "beforeEach", "afterEach" and "after" hook.
200
+ */
201
+ interface HookInformation {
202
+ hookName: HookName
203
+ title: string[]
204
+ body: string
205
+ }
206
+
207
+ /**
208
+ * Information about a single screenshot.
209
+ */
210
+ interface ScreenshotInformation {
211
+ name: string
212
+ takenAt: dateTimeISO
213
+ /**
214
+ * Absolute path to the saved image
215
+ */
216
+ path: string
217
+ height: pixels
218
+ width: pixels
219
+ }
220
+
221
+ /**
222
+ * Cypress test run result for a single spec.
223
+ */
224
+ interface RunResult {
225
+ /**
226
+ * Accurate test results collected by Cypress.
227
+ */
228
+ stats: {
229
+ suites: number
230
+ tests: number
231
+ passes: number
232
+ pending: number
233
+ skipped: number
234
+ failures: number
235
+ startedAt: dateTimeISO
236
+ endedAt: dateTimeISO
237
+ duration: ms
238
+ }
239
+ /**
240
+ * Reporter name like "spec"
241
+ */
242
+ reporter: string
243
+ /**
244
+ * This is controlled by the reporter, and Cypress cannot guarantee
245
+ * the properties. Usually this object has suites, tests, passes, etc
246
+ */
247
+ reporterStats: object
248
+ hooks: HookInformation[]
249
+ tests: TestResult[]
250
+ error: string | null
251
+ video: string | null
252
+ /**
253
+ * information about the spec test file.
254
+ */
255
+ spec: {
256
+ /**
257
+ * filename like "spec.js"
258
+ */
259
+ name: string
260
+ /**
261
+ * name relative to the project root, like "cypress/integration/spec.js"
262
+ */
263
+ relative: string
264
+ /**
265
+ * resolved filename of the spec
266
+ */
267
+ absolute: string
268
+ }
269
+ shouldUploadVideo: boolean
270
+ }
271
+
272
+ /**
273
+ * Results returned by the test run.
274
+ * @see https://on.cypress.io/module-api
275
+ */
276
+ interface CypressRunResult {
277
+ status: 'finished'
278
+ startedTestsAt: dateTimeISO
279
+ endedTestsAt: dateTimeISO
280
+ totalDuration: ms
281
+ totalSuites: number
282
+ totalTests: number
283
+ totalFailed: number
284
+ totalPassed: number
285
+ totalPending: number
286
+ totalSkipped: number
287
+ /**
288
+ * If Cypress test run is being recorded, full url will be provided.
289
+ * @see https://on.cypress.io/dashboard-introduction
290
+ */
291
+ runUrl?: string
292
+ runs: RunResult[]
293
+ browserPath: string
294
+ browserName: string
295
+ browserVersion: string
296
+ osName: string
297
+ osVersion: string
298
+ cypressVersion: string
299
+ config: Cypress.ResolvedConfigOptions
300
+ }
301
+
302
+ /**
303
+ * If Cypress fails to run at all (for example, if there are no spec files to run),
304
+ * then it will return a CypressFailedRunResult. Check the failures attribute.
305
+ * @example
306
+ ```
307
+ const result = await cypress.run()
308
+ if (result.status === 'failed') {
309
+ console.error('failures %d', result.failures)
310
+ console.error(result.message)
311
+ process.exit(result.failures)
312
+ }
313
+ ```
314
+ *
315
+ **/
316
+ interface CypressFailedRunResult {
317
+ status: 'failed'
318
+ failures: number
319
+ message: string
320
+ }
321
+
322
+ /**
323
+ * Methods allow parsing given CLI arguments the same way Cypress CLI does it.
324
+ */
325
+ interface CypressCliParser {
326
+ /**
327
+ * Parses the given array of string arguments to "cypress run"
328
+ * just like Cypress CLI does it.
329
+ * @see https://on.cypress.io/module-api
330
+ * @example
331
+ * const cypress = require('cypress')
332
+ * const args = ['cypress', 'run', '--browser', 'chrome']
333
+ * const options = await cypress.cli.parseRunArguments(args)
334
+ * // options is {browser: 'chrome'}
335
+ * // pass the options to cypress.run()
336
+ * const results = await cypress.run(options)
337
+ */
338
+ parseRunArguments(args: string[]): Promise<Partial<CypressRunOptions>>
339
+ }
340
+ }
341
+
342
+ declare module 'cypress' {
343
+ /**
344
+ * Cypress NPM module interface.
345
+ * @see https://on.cypress.io/module-api
346
+ * @example
347
+ ```
348
+ const cypress = require('cypress')
349
+ cypress.run().then(results => ...)
350
+ ```
351
+ */
352
+ interface CypressNpmApi {
353
+ /**
354
+ * Execute a headless Cypress test run.
355
+ * @see https://on.cypress.io/module-api#cypress-run
356
+ * @example
357
+ ```
358
+ const cypress = require('cypress')
359
+ // runs all spec files matching a wildcard
360
+ cypress.run({
361
+ spec: 'cypress/integration/admin*-spec.js'
362
+ }).then(results => {
363
+ if (results.status === 'failed') {
364
+ // Cypress could not run
365
+ } else {
366
+ // inspect results object
367
+ }
368
+ })
369
+ ```
370
+ */
371
+ run(options?: Partial<CypressCommandLine.CypressRunOptions>): Promise<CypressCommandLine.CypressRunResult | CypressCommandLine.CypressFailedRunResult>
372
+ /**
373
+ * Opens Cypress GUI. Resolves with void when the
374
+ * GUI is closed.
375
+ * @see https://on.cypress.io/module-api#cypress-open
376
+ */
377
+ open(options?: Partial<CypressCommandLine.CypressOpenOptions>): Promise<void>
378
+
379
+ /**
380
+ * Utility functions for parsing CLI arguments the same way
381
+ * Cypress does
382
+ */
383
+ cli: CypressCommandLine.CypressCliParser
384
+
385
+ /**
386
+ * Provides automatic code completion for configuration in many popular code editors.
387
+ * While it's not strictly necessary for Cypress to parse your configuration, we
388
+ * recommend wrapping your config object with `defineConfig()`
389
+ * @example
390
+ * module.exports = defineConfig({
391
+ * viewportWith: 400
392
+ * })
393
+ *
394
+ * @see ../types/cypress-npm-api.d.ts
395
+ * @param {Cypress.ConfigOptions} config
396
+ * @returns {Cypress.ConfigOptions} the configuration passed in parameter
397
+ */
398
+ defineConfig(config: Cypress.ConfigOptions): Cypress.ConfigOptions
399
+ }
400
+
401
+ // export Cypress NPM module interface
402
+ const cypress: CypressNpmApi
403
+ export = cypress
404
+ }