cypress 3.3.2 → 3.6.0

Sign up to get free protection for your applications and to get access to all the features.
package/types/index.d.ts CHANGED
@@ -19,6 +19,10 @@
19
19
  /// <reference path="./jquery/index.d.ts" />
20
20
  /// <reference path="./chai-jquery/index.d.ts" />
21
21
 
22
+ // jQuery includes dependency "sizzle" that provides types
23
+ // so we include it too in "node_modules/sizzle".
24
+ // This way jQuery can load it using 'reference types="sizzle"' directive
25
+
22
26
  // "moment" types are with "node_modules/moment"
23
27
  /// <reference types="moment" />
24
28
 
@@ -288,7 +292,6 @@ declare namespace Cypress {
288
292
  add(name: string, fn: (...args: any[]) => void): void
289
293
  add(name: string, options: CommandOptions, fn: (...args: any[]) => void): void
290
294
  overwrite(name: string, fn: (...args: any[]) => void): void
291
- overwrite(name: string, options: CommandOptions, fn: (...args: any[]) => void): void
292
295
  }
293
296
 
294
297
  /**
@@ -327,6 +330,12 @@ declare namespace Cypress {
327
330
  */
328
331
  on: Actions
329
332
 
333
+ /**
334
+ * These events come from Cypress as it issues commands and reacts to their state. These are all useful to listen to for debugging purposes.
335
+ * @see https://on.cypress.io/catalog-of-events#App-Events
336
+ */
337
+ once: Actions
338
+
330
339
  /**
331
340
  * These events come from Cypress as it issues commands and reacts to their state. These are all useful to listen to for debugging purposes.
332
341
  * @see https://on.cypress.io/catalog-of-events#App-Events
@@ -573,8 +582,10 @@ declare namespace Cypress {
573
582
  * cy.contains(/^b\w+/)
574
583
  * // yields <ul>...</ul>
575
584
  * cy.contains('ul', 'apples')
585
+ * // tries to find the given text for up to 1 second
586
+ * cy.contains('my text to find', {timeout: 1000})
576
587
  */
577
- contains(content: string | number | RegExp): Chainable<Subject>
588
+ contains(content: string | number | RegExp, options?: Partial<Loggable & Timeoutable>): Chainable<Subject>
578
589
  /**
579
590
  * Get the child DOM element that contains given text.
580
591
  *
@@ -608,7 +619,14 @@ declare namespace Cypress {
608
619
  *
609
620
  * @see https://on.cypress.io/dblclick
610
621
  */
611
- dblclick(options?: Partial<Loggable>): Chainable
622
+ dblclick(options?: Partial<ClickOptions>): Chainable<Subject>
623
+
624
+ /**
625
+ * Right-click a DOM element.
626
+ *
627
+ * @see https://on.cypress.io/rightclick
628
+ */
629
+ rightclick(options?: Partial<ClickOptions>): Chainable<Subject>
612
630
 
613
631
  /**
614
632
  * Set a debugger and log what the previous command yields.
@@ -750,7 +768,7 @@ declare namespace Cypress {
750
768
  * cy.get('input').should('be.disabled')
751
769
  * cy.get('button').should('be.visible')
752
770
  */
753
- get<K extends keyof HTMLElementTagNameMap>(selector: K, options?: Partial<Loggable & Timeoutable>): Chainable<JQuery<HTMLElementTagNameMap[K]>>
771
+ get<K extends keyof HTMLElementTagNameMap>(selector: K, options?: Partial<Loggable & Timeoutable & Withinable>): Chainable<JQuery<HTMLElementTagNameMap[K]>>
754
772
  /**
755
773
  * Get one or more DOM elements by selector.
756
774
  * The querying behavior of this command matches exactly how $(…) works in jQuery.
@@ -760,7 +778,7 @@ declare namespace Cypress {
760
778
  * cy.get('ul li:first').should('have.class', 'active')
761
779
  * cy.get('.dropdown-menu').click()
762
780
  */
763
- get<E extends Node = HTMLElement>(selector: string, options?: Partial<Loggable & Timeoutable>): Chainable<JQuery<E>>
781
+ get<E extends Node = HTMLElement>(selector: string, options?: Partial<Loggable & Timeoutable & Withinable>): Chainable<JQuery<E>>
764
782
  /**
765
783
  * Get one or more DOM elements by alias.
766
784
  * @see https://on.cypress.io/get#Alias
@@ -771,7 +789,7 @@ declare namespace Cypress {
771
789
  * //later retrieve the todos
772
790
  * cy.get('@todos')
773
791
  */
774
- get<S = any>(alias: string, options?: Partial<Loggable & Timeoutable>): Chainable<S>
792
+ get<S = any>(alias: string, options?: Partial<Loggable & Timeoutable & Withinable>): Chainable<S>
775
793
 
776
794
  /**
777
795
  * Get a browser cookie by its name.
@@ -846,6 +864,8 @@ declare namespace Cypress {
846
864
  * @example
847
865
  * cy.location('host') // Get the host of the location object
848
866
  * cy.location('port') // Get the port of the location object
867
+ * // Assert on the href of the location
868
+ * cy.location('href').should('contain', '/tag/tutorials')
849
869
  */
850
870
  location(key: string, options?: Partial<Loggable & Timeoutable>): Chainable<Location>
851
871
 
@@ -930,6 +950,12 @@ declare namespace Cypress {
930
950
  */
931
951
  on: Actions
932
952
 
953
+ /**
954
+ * These events come from Cypress as it issues commands and reacts to their state. These are all useful to listen to for debugging purposes.
955
+ * @see https://on.cypress.io/catalog-of-events#App-Events
956
+ */
957
+ once: Actions
958
+
933
959
  /**
934
960
  * These events come from Cypress as it issues commands and reacts to their state. These are all useful to listen to for debugging purposes.
935
961
  * @see https://on.cypress.io/catalog-of-events#App-Events
@@ -1276,6 +1302,9 @@ declare namespace Cypress {
1276
1302
  * Create an assertion. Assertions are automatically retried until they pass or time out.
1277
1303
  *
1278
1304
  * @see https://on.cypress.io/should
1305
+ * @example
1306
+ * // Assert on the href of the location
1307
+ * cy.location('href').should('contain', '/tag/tutorials/')
1279
1308
  */
1280
1309
  should: Chainer<Subject>
1281
1310
 
@@ -1855,6 +1884,20 @@ declare namespace Cypress {
1855
1884
  retryOnNetworkFailure: boolean
1856
1885
  }
1857
1886
 
1887
+ /**
1888
+ * Options that control how a command behaves in the `within` scope.
1889
+ * These options will determine how nodes are selected.
1890
+ */
1891
+
1892
+ interface Withinable {
1893
+ /**
1894
+ * Element to search for children in. If null, search begins from root-level DOM element.
1895
+ *
1896
+ * @default depends on context, null if outside of within wrapper
1897
+ */
1898
+ withinSubject: JQuery | HTMLElement | null
1899
+ }
1900
+
1858
1901
  /**
1859
1902
  * Options that control how a command is logged in the Reporter
1860
1903
  */
@@ -2011,11 +2054,26 @@ declare namespace Cypress {
2011
2054
  * @default "cypress/integration"
2012
2055
  */
2013
2056
  integrationFolder: string
2057
+ /**
2058
+ * If set to `system`, Cypress will try to find a `node` executable on your path to use when executing your plugins. Otherwise, Cypress will use the Node version bundled with Cypress.
2059
+ * @default "bundled"
2060
+ */
2061
+ nodeVersion: "system" | "bundled"
2014
2062
  /**
2015
2063
  * Path to plugins file. (Pass false to disable)
2016
2064
  * @default "cypress/plugins/index.js"
2017
2065
  */
2018
2066
  pluginsFile: string
2067
+ /**
2068
+ * If `nodeVersion === 'system'` and a `node` executable is found, this will be the full filesystem path to that executable.
2069
+ * @default null
2070
+ */
2071
+ resolvedNodePath: string
2072
+ /**
2073
+ * The version of `node` that is being used to execute plugins.
2074
+ * @example 1.2.3
2075
+ */
2076
+ resolvedNodeVersion: string
2019
2077
  /**
2020
2078
  * Path to folder where screenshots will be saved from [cy.screenshot()](https://on.cypress.io/screenshot) command or after a headless or CI run’s test failure
2021
2079
  * @default "cypress/screenshots"
@@ -2137,11 +2195,19 @@ declare namespace Cypress {
2137
2195
  height: number
2138
2196
  }
2139
2197
 
2198
+ type Padding =
2199
+ | number
2200
+ | [number]
2201
+ | [number, number]
2202
+ | [number, number, number]
2203
+ | [number, number, number, number]
2204
+
2140
2205
  interface ScreenshotOptions {
2141
2206
  blackout: string[]
2142
2207
  capture: 'runner' | 'viewport' | 'fullPage'
2143
2208
  clip: Dimensions
2144
2209
  disableTimersAndAnimations: boolean
2210
+ padding: Padding
2145
2211
  scale: boolean
2146
2212
  beforeScreenshot(doc: Document): void
2147
2213
  afterScreenshot(doc: Document): void
@@ -2196,6 +2262,9 @@ declare namespace Cypress {
2196
2262
  force404: boolean
2197
2263
  urlMatchingOptions: object
2198
2264
  whitelist(xhr: Request): void
2265
+ onAnyRequest(route: RouteOptions, proxy: any): void
2266
+ onAnyResponse(route: RouteOptions, proxy: any): void
2267
+ onAnyAbort(route: RouteOptions, proxy: any): void
2199
2268
  }
2200
2269
 
2201
2270
  interface SetCookieOptions extends Loggable, Timeoutable {
@@ -2218,6 +2287,13 @@ declare namespace Cypress {
2218
2287
  * @default 10
2219
2288
  */
2220
2289
  delay: number
2290
+ /**
2291
+ * Parse special characters for strings surrounded by `{}`,
2292
+ * such as `{esc}`. Set to `false` to type the literal characters instead
2293
+ *
2294
+ * @default true
2295
+ */
2296
+ parseSpecialCharSequences: boolean
2221
2297
  /**
2222
2298
  * Forces the action, disables waiting for actionability
2223
2299
  *
@@ -2306,6 +2382,11 @@ declare namespace Cypress {
2306
2382
  * })
2307
2383
  */
2308
2384
  auth: Auth
2385
+
2386
+ /**
2387
+ * Query parameters to append to the `url` of the request.
2388
+ */
2389
+ qs: object
2309
2390
  }
2310
2391
 
2311
2392
  /**
@@ -3691,6 +3772,22 @@ declare namespace Cypress {
3691
3772
  * @see https://on.cypress.io/assertions
3692
3773
  */
3693
3774
  (chainer: 'have.html', value: string): Chainable<Subject>
3775
+ /**
3776
+ * Assert that the html of the first element of the selection partially contains the given html, using `.html()`.
3777
+ * @example
3778
+ * cy.get('#result').should('contain.html', '<em>John Doe</em>')
3779
+ * @see http://chaijs.com/plugins/chai-jquery/#htmlhtml
3780
+ * @see https://on.cypress.io/assertions
3781
+ */
3782
+ (chainer: 'contain.html', value: string): Chainable<Subject>
3783
+ /**
3784
+ * Assert that the html of the first element of the selection partially contains the given html, using `.html()`.
3785
+ * @example
3786
+ * cy.get('#result').should('include.html', '<em>John Doe</em>')
3787
+ * @see http://chaijs.com/plugins/chai-jquery/#htmlhtml
3788
+ * @see https://on.cypress.io/assertions
3789
+ */
3790
+ (chainer: 'include.html', value: string): Chainable<Subject>
3694
3791
  /**
3695
3792
  * Assert that the first element of the selection has the given id, using `.attr('id')`.
3696
3793
  * @example
@@ -3716,6 +3813,22 @@ declare namespace Cypress {
3716
3813
  * @see https://on.cypress.io/assertions
3717
3814
  */
3718
3815
  (chainer: 'have.text', value: string): Chainable<Subject>
3816
+ /**
3817
+ * Assert that the text of the first element of the selection partially contains the given text, using `.text()`.
3818
+ * @example
3819
+ * cy.get('#result').should('contain.text', 'John Doe')
3820
+ * @see http://chaijs.com/plugins/chai-jquery/#texttext
3821
+ * @see https://on.cypress.io/assertions
3822
+ */
3823
+ (chainer: 'contain.text', value: string): Chainable<Subject>
3824
+ /**
3825
+ * Assert that the text of the first element of the selection partially contains the given text, using `.text()`.
3826
+ * @example
3827
+ * cy.get('#result').should('include.text', 'John Doe')
3828
+ * @see http://chaijs.com/plugins/chai-jquery/#texttext
3829
+ * @see https://on.cypress.io/assertions
3830
+ */
3831
+ (chainer: 'include.text', value: string): Chainable<Subject>
3719
3832
  /**
3720
3833
  * Assert that the first element of the selection has the given value, using `.val()`.
3721
3834
  * @example
@@ -3724,6 +3837,22 @@ declare namespace Cypress {
3724
3837
  * @see https://on.cypress.io/assertions
3725
3838
  */
3726
3839
  (chainer: 'have.value', value: string): Chainable<Subject>
3840
+ /**
3841
+ * Assert that the first element of the selection partially contains the given value, using `.val()`.
3842
+ * @example
3843
+ * cy.get('textarea').should('contain.value', 'foo bar baz')
3844
+ * @see http://chaijs.com/plugins/chai-jquery/#valuevalue
3845
+ * @see https://on.cypress.io/assertions
3846
+ */
3847
+ (chainer: 'contain.value', value: string): Chainable<Subject>
3848
+ /**
3849
+ * Assert that the first element of the selection partially contains the given value, using `.val()`.
3850
+ * @example
3851
+ * cy.get('textarea').should('include.value', 'foo bar baz')
3852
+ * @see http://chaijs.com/plugins/chai-jquery/#valuevalue
3853
+ * @see https://on.cypress.io/assertions
3854
+ */
3855
+ (chainer: 'include.value', value: string): Chainable<Subject>
3727
3856
  /**
3728
3857
  * Assert that the selection matches a given selector, using `.is()`. Note that this overrides the built-in chai assertion. If the object asserted against is not a jQuery object, the original implementation will be called.
3729
3858
  * @example
@@ -3871,6 +4000,22 @@ declare namespace Cypress {
3871
4000
  * @see https://on.cypress.io/assertions
3872
4001
  */
3873
4002
  (chainer: 'not.have.html', value: string): Chainable<Subject>
4003
+ /**
4004
+ * Assert that the html of the first element of the selection does not contain the given html, using `.html()`.
4005
+ * @example
4006
+ * cy.get('#result').should('not.contain.html', '<em>John Doe</em>')
4007
+ * @see http://chaijs.com/plugins/chai-jquery/#htmlhtml
4008
+ * @see https://on.cypress.io/assertions
4009
+ */
4010
+ (chainer: 'not.contain.html', value: string): Chainable<Subject>
4011
+ /**
4012
+ * Assert that the html of the first element of the selection does not contain the given html, using `.html()`.
4013
+ * @example
4014
+ * cy.get('#result').should('not.include.html', '<em>John Doe</em>')
4015
+ * @see http://chaijs.com/plugins/chai-jquery/#htmlhtml
4016
+ * @see https://on.cypress.io/assertions
4017
+ */
4018
+ (chainer: 'not.include.html', value: string): Chainable<Subject>
3874
4019
  /**
3875
4020
  * Assert that the first element of the selection does not have the given id, using `.attr('id')`.
3876
4021
  * @example
@@ -3896,6 +4041,22 @@ declare namespace Cypress {
3896
4041
  * @see https://on.cypress.io/assertions
3897
4042
  */
3898
4043
  (chainer: 'not.have.text', value: string): Chainable<Subject>
4044
+ /**
4045
+ * Assert that the text of the first element of the selection does not contain the given text, using `.text()`.
4046
+ * @example
4047
+ * cy.get('#result').should('not.contain.text', 'John Doe')
4048
+ * @see http://chaijs.com/plugins/chai-jquery/#texttext
4049
+ * @see https://on.cypress.io/assertions
4050
+ */
4051
+ (chainer: 'not.contain.text', value: string): Chainable<Subject>
4052
+ /**
4053
+ * Assert that the text of the first element of the selection does not contain the given text, using `.text()`.
4054
+ * @example
4055
+ * cy.get('#result').should('not.include.text', 'John Doe')
4056
+ * @see http://chaijs.com/plugins/chai-jquery/#texttext
4057
+ * @see https://on.cypress.io/assertions
4058
+ */
4059
+ (chainer: 'not.include.text', value: string): Chainable<Subject>
3899
4060
  /**
3900
4061
  * Assert that the first element of the selection does not have the given value, using `.val()`.
3901
4062
  * @example
@@ -3904,6 +4065,22 @@ declare namespace Cypress {
3904
4065
  * @see https://on.cypress.io/assertions
3905
4066
  */
3906
4067
  (chainer: 'not.have.value', value: string): Chainable<Subject>
4068
+ /**
4069
+ * Assert that the first element of the selection does not contain the given value, using `.val()`.
4070
+ * @example
4071
+ * cy.get('textarea').should('not.contain.value', 'foo bar baz')
4072
+ * @see http://chaijs.com/plugins/chai-jquery/#valuevalue
4073
+ * @see https://on.cypress.io/assertions
4074
+ */
4075
+ (chainer: 'not.contain.value', value: string): Chainable<Subject>
4076
+ /**
4077
+ * Assert that the first element of the selection does not contain the given value, using `.val()`.
4078
+ * @example
4079
+ * cy.get('textarea').should('not.include.value', 'foo bar baz')
4080
+ * @see http://chaijs.com/plugins/chai-jquery/#valuevalue
4081
+ * @see https://on.cypress.io/assertions
4082
+ */
4083
+ (chainer: 'not.include.value', value: string): Chainable<Subject>
3907
4084
  /**
3908
4085
  * Assert that the selection does not match a given selector, using `.is()`. Note that this overrides the built-in chai assertion. If the object asserted against is not a jQuery object, the original implementation will be called.
3909
4086
  * @example
@@ -3993,7 +4170,7 @@ declare namespace Cypress {
3993
4170
  (action: 'uncaught:exception', fn: (error: Error, runnable: Mocha.IRunnable) => false | void): void
3994
4171
  /**
3995
4172
  * Fires when your app calls the global `window.confirm()` method.
3996
- * Cypress will auto accept confirmations. Return `false` from this event and the confirmation will be cancelled.
4173
+ * Cypress will auto accept confirmations. Return `false` from this event and the confirmation will be canceled.
3997
4174
  * @see https://on.cypress.io/catalog-of-events#App-Events
3998
4175
  * @example
3999
4176
  ```
@@ -4225,7 +4402,7 @@ declare namespace Cypress {
4225
4402
 
4226
4403
  type Encodings = 'ascii' | 'base64' | 'binary' | 'hex' | 'latin1' | 'utf8' | 'utf-8' | 'ucs2' | 'ucs-2' | 'utf16le' | 'utf-16le'
4227
4404
  type PositionType = "topLeft" | "top" | "topRight" | "left" | "center" | "right" | "bottomLeft" | "bottom" | "bottomRight"
4228
- type ViewportPreset = 'macbook-15' | 'macbook-13' | 'macbook-11' | 'ipad-2' | 'ipad-mini' | 'iphone-6+' | 'iphone-6' | 'iphone-5' | 'iphone-4' | 'iphone-3'
4405
+ type ViewportPreset = 'macbook-15' | 'macbook-13' | 'macbook-11' | 'ipad-2' | 'ipad-mini' | 'iphone-xr' | 'iphone-x' | 'iphone-6+' | 'iphone-6' | 'iphone-5' | 'iphone-4' | 'iphone-3' | 'samsung-s10' | 'samsung-note9'
4229
4406
  interface Offset {
4230
4407
  top: number,
4231
4408
  left: number
@@ -4234,22 +4411,44 @@ declare namespace Cypress {
4234
4411
  // Diff taken from https://github.com/Microsoft/TypeScript/issues/12215#issuecomment-311923766
4235
4412
  type Diff<T extends string, U extends string> = ({ [P in T]: P } & { [P in U]: never } & { [x: string]: never })[T]
4236
4413
  type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>
4414
+
4415
+ /**
4416
+ * Public interface for the global "cy" object. If you want to add
4417
+ * a custom property to this object, you should extend this interface.
4418
+ * @see https://on.cypress.io/typescript#Types-for-custom-commands
4419
+ *
4420
+ ```
4421
+ // in your TS file
4422
+ declare namespace Cypress {
4423
+ interface cy {
4424
+ // declare additional properties on "cy" object, like
4425
+ // label: string
4426
+ }
4427
+ interface Chainable {
4428
+ // declare additional custom commands as methods, like
4429
+ // login(username: string, password: string)
4430
+ }
4431
+ }
4432
+ ```
4433
+ */
4434
+ interface cy extends Chainable<undefined> {}
4237
4435
  }
4238
4436
 
4239
4437
  /**
4240
4438
  * Global variables `cy` added by Cypress with all API commands.
4241
4439
  * @see https://on.cypress.io/api
4242
- * @example
4440
+ *
4243
4441
  ```
4244
4442
  cy.get('button').click()
4245
4443
  cy.get('.result').contains('Expected text')
4246
4444
  ```
4247
4445
  */
4248
- declare const cy: Cypress.Chainable<undefined>
4446
+ declare const cy: Cypress.cy
4447
+
4249
4448
  /**
4250
4449
  * Global variable `Cypress` holds common utilities and constants.
4251
4450
  * @see https://on.cypress.io/api
4252
- * @example
4451
+ *
4253
4452
  ```
4254
4453
  Cypress.config("pageLoadTimeout") // => 60000
4255
4454
  Cypress.version // => "1.4.0"