cypress 12.6.0 → 12.8.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,10 @@
1
+ # [@cypress/angular-v2.0.2](https://github.com/cypress-io/cypress/compare/@cypress/angular-v2.0.1...@cypress/angular-v2.0.2) (2023-02-17)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * mount component in [data-cy-root] ([#25807](https://github.com/cypress-io/cypress/issues/25807)) ([104eef5](https://github.com/cypress-io/cypress/commit/104eef5dfb4b619a748e7ddd59534eadb1044ae7))
7
+
1
8
  # [@cypress/angular-v2.0.1](https://github.com/cypress-io/cypress/compare/@cypress/angular-v2.0.0...@cypress/angular-v2.0.1) (2022-11-08)
2
9
 
3
10
 
@@ -1,7 +1,7 @@
1
1
  /// <reference types="cypress" />
2
2
 
3
3
  import { Type } from '@angular/core';
4
- import { TestModuleMetadata, ComponentFixture } from '@angular/core/testing';
4
+ import { TestModuleMetadata, ComponentFixture, TestComponentRenderer } from '@angular/core/testing';
5
5
 
6
6
  /**
7
7
  * Additional module configurations needed while mounting the component, like
@@ -72,6 +72,10 @@ declare type MountResponse<T> = {
72
72
  */
73
73
  component: T;
74
74
  };
75
+ declare class CypressTestComponentRenderer extends TestComponentRenderer {
76
+ insertRootElement(rootElId: string): void;
77
+ removeAllRootElements(): void;
78
+ }
75
79
  /**
76
80
  * Mounts an Angular component inside Cypress browser
77
81
  *
@@ -121,4 +125,4 @@ declare function mount<T>(component: Type<T> | string, config?: MountConfig<T>):
121
125
  */
122
126
  declare const createOutputSpy: <T>(alias: string) => any;
123
127
 
124
- export { MountConfig, MountResponse, createOutputSpy, mount };
128
+ export { CypressTestComponentRenderer, MountConfig, MountResponse, createOutputSpy, mount };
@@ -9,7 +9,7 @@ import 'zone.js';
9
9
  import 'zone.js/testing';
10
10
  import { CommonModule } from '@angular/common';
11
11
  import { Injectable, Component, EventEmitter, SimpleChange, ErrorHandler } from '@angular/core';
12
- import { getTestBed, TestBed } from '@angular/core/testing';
12
+ import { getTestBed, TestComponentRenderer, TestBed } from '@angular/core/testing';
13
13
  import { BrowserDynamicTestingModule, platformBrowserDynamicTesting } from '@angular/platform-browser-dynamic/testing';
14
14
 
15
15
  /******************************************************************************
@@ -46,6 +46,19 @@ function __decorate(decorators, target, key, desc) {
46
46
  return c > 3 && r && Object.defineProperty(target, key, r), r;
47
47
  }
48
48
 
49
+ const ROOT_SELECTOR = '[data-cy-root]';
50
+ /**
51
+ * Gets the root element used to mount the component.
52
+ * @returns {HTMLElement} The root element
53
+ * @throws {Error} If the root element is not found
54
+ */
55
+ const getContainerEl = () => {
56
+ const el = document.querySelector(ROOT_SELECTOR);
57
+ if (el) {
58
+ return el;
59
+ }
60
+ throw Error(`No element found that matches selector ${ROOT_SELECTOR}. Please add a root element with data-cy-root attribute to your "component-index.html" file so that Cypress can attach your component to the DOM.`);
61
+ };
49
62
  /**
50
63
  * Utility function to register CT side effects and run cleanup code during the "test:before:run" Cypress hook
51
64
  * @param optionalCallback Callback to be called before the next test runs
@@ -143,6 +156,19 @@ function bootstrapModule(component, config) {
143
156
  }
144
157
  return testModuleMetaData;
145
158
  }
159
+ let CypressTestComponentRenderer = class CypressTestComponentRenderer extends TestComponentRenderer {
160
+ insertRootElement(rootElId) {
161
+ this.removeAllRootElements();
162
+ const rootElement = getContainerEl();
163
+ rootElement.setAttribute('id', rootElId);
164
+ }
165
+ removeAllRootElements() {
166
+ getContainerEl().innerHTML = '';
167
+ }
168
+ };
169
+ CypressTestComponentRenderer = __decorate([
170
+ Injectable()
171
+ ], CypressTestComponentRenderer);
146
172
  /**
147
173
  * Initializes the TestBed
148
174
  *
@@ -153,6 +179,7 @@ function bootstrapModule(component, config) {
153
179
  function initTestBed(component, config) {
154
180
  const componentFixture = createComponentFixture(component);
155
181
  getTestBed().configureTestingModule(Object.assign({}, bootstrapModule(componentFixture, config)));
182
+ getTestBed().overrideProvider(TestComponentRenderer, { useValue: new CypressTestComponentRenderer() });
156
183
  return componentFixture;
157
184
  }
158
185
  let WrapperComponent = class WrapperComponent {
@@ -302,4 +329,4 @@ getTestBed().initTestEnvironment(BrowserDynamicTestingModule, platformBrowserDyn
302
329
  });
303
330
  setupHooks(cleanup);
304
331
 
305
- export { createOutputSpy, mount };
332
+ export { CypressTestComponentRenderer, createOutputSpy, mount };
package/index.mjs CHANGED
@@ -8,6 +8,8 @@ export default cypress
8
8
 
9
9
  export const defineConfig = cypress.defineConfig
10
10
 
11
+ export const defineComponentFramework = cypress.defineComponentFramework
12
+
11
13
  export const run = cypress.run
12
14
 
13
15
  export const open = cypress.open
package/lib/cypress.js CHANGED
@@ -76,6 +76,23 @@ const cypressModuleApi = {
76
76
  */
77
77
  defineConfig(config) {
78
78
  return config;
79
+ },
80
+ /**
81
+ * Provides automatic code completion for Component Frameworks Definitions.
82
+ * While it's not strictly necessary for Cypress to parse your configuration, we
83
+ * recommend wrapping your Component Framework Definition object with `defineComponentFramework()`
84
+ * @example
85
+ * module.exports = defineComponentFramework({
86
+ * type: 'cypress-ct-solid-js'
87
+ * // ...
88
+ * })
89
+ *
90
+ * @see ../types/cypress-npm-api.d.ts
91
+ * @param {Cypress.ThirdPartyComponentFrameworkDefinition} config
92
+ * @returns {Cypress.ThirdPartyComponentFrameworkDefinition} the configuration passed in parameter
93
+ */
94
+ defineComponentFramework(config) {
95
+ return config;
79
96
  }
80
97
  };
81
98
  module.exports = cypressModuleApi;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cypress",
3
- "version": "12.6.0",
3
+ "version": "12.8.0",
4
4
  "main": "index.js",
5
5
  "scripts": {
6
6
  "postinstall": "node index.js --exec install",
@@ -118,8 +118,8 @@
118
118
  },
119
119
  "buildInfo": {
120
120
  "commitBranch": "develop",
121
- "commitSha": "9e27540f0547163a8ec745da2d66ce455683187c",
122
- "commitDate": "2023-02-15T14:25:30.000Z",
121
+ "commitSha": "34b61575dcfd582acda719dc9b0d3d56906ede68",
122
+ "commitDate": "2023-03-14T14:53:19.000Z",
123
123
  "stable": true
124
124
  },
125
125
  "description": "Cypress is a next generation front end testing tool built for the modern web",
@@ -397,6 +397,21 @@ declare module 'cypress' {
397
397
  * @returns {Cypress.ConfigOptions} the configuration passed in parameter
398
398
  */
399
399
  defineConfig<ComponentDevServerOpts = any>(config: Cypress.ConfigOptions<ComponentDevServerOpts>): Cypress.ConfigOptions
400
+
401
+ /**
402
+ * Provides automatic code completion for Component Frameworks Definitions.
403
+ * While it's not strictly necessary for Cypress to parse your configuration, we
404
+ * recommend wrapping your Component Framework Definition object with `defineComponentFramework()`
405
+ * @example
406
+ * module.exports = defineComponentFramework({
407
+ * type: 'cypress-ct-solid-js'
408
+ * })
409
+ *
410
+ * @see ../types/cypress-npm-api.d.ts
411
+ * @param {Cypress.ThirdPartyComponentFrameworkDefinition} config
412
+ * @returns {Cypress.ThirdPartyComponentFrameworkDefinition} the configuration passed in parameter
413
+ */
414
+ defineComponentFramework(config: Cypress.ThirdPartyComponentFrameworkDefinition): Cypress.ThirdPartyComponentFrameworkDefinition
400
415
  }
401
416
 
402
417
  // export Cypress NPM module interface
@@ -1816,9 +1816,21 @@ declare namespace Cypress {
1816
1816
  *
1817
1817
  * @see https://on.cypress.io/reload
1818
1818
  * @example
1819
+ * cy.visit('http://localhost:3000/admin')
1819
1820
  * cy.reload()
1820
1821
  */
1821
- reload(options?: Partial<Loggable & Timeoutable>): Chainable<AUTWindow>
1822
+ reload(): Chainable<AUTWindow>
1823
+ /**
1824
+ * Reload the page.
1825
+ *
1826
+ * @see https://on.cypress.io/reload
1827
+ * @param {Partial<Loggable & Timeoutable>} options Pass in an options object to modify the default behavior of cy.reload()
1828
+ * @example
1829
+ * // Reload the page, do not log it in the command log and timeout after 15s
1830
+ * cy.visit('http://localhost:3000/admin')
1831
+ * cy.reload({log: false, timeout: 15000})
1832
+ */
1833
+ reload(options: Partial<Loggable & Timeoutable>): Chainable<AUTWindow>
1822
1834
  /**
1823
1835
  * Reload the page without cache
1824
1836
  *
@@ -1830,6 +1842,18 @@ declare namespace Cypress {
1830
1842
  * cy.reload(true)
1831
1843
  */
1832
1844
  reload(forceReload: boolean): Chainable<AUTWindow>
1845
+ /**
1846
+ * Reload the page without cache and with log and timeout options
1847
+ *
1848
+ * @see https://on.cypress.io/reload
1849
+ * @param {Boolean} forceReload Whether to reload the current page without using the cache. true forces the reload without cache.
1850
+ * @param {Partial<Loggable & Timeoutable>} options Pass in an options object to modify the default behavior of cy.reload()
1851
+ * @example
1852
+ * // Reload the page without using the cache, do not log it in the command log and timeout after 15s
1853
+ * cy.visit('http://localhost:3000/admin')
1854
+ * cy.reload(true, {log: false, timeout: 15000})
1855
+ */
1856
+ reload(forceReload: boolean, options: Partial<Loggable & Timeoutable>): Chainable<AUTWindow>
1833
1857
 
1834
1858
  /**
1835
1859
  * Make an HTTP GET request.
@@ -3259,6 +3283,178 @@ declare namespace Cypress {
3259
3283
 
3260
3284
  type PickConfigOpt<T> = T extends keyof DefineDevServerConfig ? DefineDevServerConfig[T] : any
3261
3285
 
3286
+ interface DependencyToInstall {
3287
+ dependency: CypressComponentDependency
3288
+ satisfied: boolean
3289
+ detectedVersion: string | null
3290
+ }
3291
+
3292
+ interface CypressComponentDependency {
3293
+ /**
3294
+ * Unique idenitifer.
3295
+ * @example 'reactscripts'
3296
+ */
3297
+ type: string
3298
+
3299
+ /**
3300
+ * Name to display in the user interface.
3301
+ * @example "React Scripts"
3302
+ */
3303
+ name: string
3304
+
3305
+ /**
3306
+ * Package name on npm.
3307
+ * @example react-scripts
3308
+ */
3309
+ package: string
3310
+
3311
+ /**
3312
+ * Code to run when installing. Version is optional.
3313
+ *
3314
+ * Should be <package_name>@<version>.
3315
+ *
3316
+ * @example `react`
3317
+ * @example `react@18`
3318
+ * @example `react-scripts`
3319
+ */
3320
+ installer: string
3321
+
3322
+ /**
3323
+ * Description shown in UI. It is recommended to use the same one the package uses on npm.
3324
+ * @example 'Create React apps with no build configuration'
3325
+ */
3326
+ description: string
3327
+
3328
+ /**
3329
+ * Minimum version supported. Should conform to Semantic Versioning as used in `package.json`.
3330
+ * @see https://docs.npmjs.com/cli/v9/configuring-npm/package-json#dependencies
3331
+ * @example '^=4.0.0 || ^=5.0.0'
3332
+ * @example '^2.0.0'
3333
+ */
3334
+ minVersion: string
3335
+ }
3336
+
3337
+ interface ResolvedComponentFrameworkDefinition {
3338
+ /**
3339
+ * A semantic, unique identifier.
3340
+ * Must begin with `cypress-ct-` or `@org/cypress-ct-` for third party implementations.
3341
+ * @example 'reactscripts'
3342
+ * @example 'nextjs'
3343
+ * @example 'cypress-ct-solid-js'
3344
+ */
3345
+ type: string
3346
+
3347
+ /**
3348
+ * Used as the flag for `getPreset` for meta framworks, such as finding the webpack config for CRA, Angular, etc.
3349
+ * It is also the name of the string added to `cypress.config`
3350
+ *
3351
+ * @example
3352
+ * export default {
3353
+ * component: {
3354
+ * devServer: {
3355
+ * framework: 'create-react-app' // can be 'next', 'create-react-app', etc etc.
3356
+ * }
3357
+ * }
3358
+ * }
3359
+ */
3360
+ configFramework: string
3361
+
3362
+ /**
3363
+ * Library (React, Vue) or template (aka "meta framework") (CRA, Next.js, Angular)
3364
+ */
3365
+ category: 'library' | 'template'
3366
+
3367
+ /**
3368
+ * Name displayed in Launchpad when doing initial setup.
3369
+ * @example 'Solid.js'
3370
+ * @example 'Create React App'
3371
+ */
3372
+ name: string
3373
+
3374
+ /**
3375
+ * Supported bundlers.
3376
+ */
3377
+ supportedBundlers: Array<'webpack' | 'vite'>
3378
+
3379
+ /**
3380
+ * Used to attempt to automatically select the correct framework/bundler from the dropdown.
3381
+ *
3382
+ * @example
3383
+ * const SOLID_DETECTOR: Dependency = {
3384
+ * type: 'solid',
3385
+ * name: 'Solid.js',
3386
+ * package: 'solid-js',
3387
+ * installer: 'solid-js',
3388
+ * description: 'Solid is a declarative JavaScript library for creating user interfaces',
3389
+ * minVersion: '^1.0.0',
3390
+ * }
3391
+ */
3392
+ detectors: CypressComponentDependency[]
3393
+
3394
+ /**
3395
+ * Array of required dependencies. This could be the bundler and JavaScript library.
3396
+ */
3397
+ dependencies: (bundler: 'webpack' | 'vite', projectPath: string) => Promise<DependencyToInstall[]>
3398
+
3399
+ /**
3400
+ * This is used interally by Cypress for the "Create From Component" feature.
3401
+ */
3402
+ codeGenFramework?: 'react' | 'vue' | 'svelte' | 'angular'
3403
+
3404
+ /**
3405
+ * This is used interally by Cypress for the "Create From Component" feature.
3406
+ * @example '*.{js,jsx,tsx}'
3407
+ */
3408
+ glob?: string
3409
+
3410
+ /**
3411
+ * This is the path to get mount, eg `import { mount } from <mount_module>,
3412
+ * @example: `cypress-ct-solidjs/src/mount`
3413
+ */
3414
+ mountModule: (projectPath: string) => Promise<string>
3415
+
3416
+ /**
3417
+ * Support status. Internally alpha | beta | full.
3418
+ * Community integrations are "community".
3419
+ */
3420
+ supportStatus: 'alpha' | 'beta' | 'full' | 'community'
3421
+
3422
+ /**
3423
+ * Function returning string for used for the component-index.html file.
3424
+ * Cypress provides a default if one isn't specified for third party integrations.
3425
+ */
3426
+ componentIndexHtml?: () => string
3427
+
3428
+ /**
3429
+ * Used for the Create From Comopnent feature.
3430
+ * This is currently not supported for third party frameworks.
3431
+ */
3432
+ specPattern?: '**/*.cy.ts'
3433
+ }
3434
+
3435
+ type ComponentFrameworkDefinition = Omit<ResolvedComponentFrameworkDefinition, 'dependencies'> & {
3436
+ dependencies: (bundler: 'webpack' | 'vite') => CypressComponentDependency[]
3437
+ }
3438
+
3439
+ /**
3440
+ * Certain properties are not supported for third party frameworks right now,
3441
+ * such as ones related to the "Create From" feature. This is a subset of
3442
+ * properties that are exposed for public usage.
3443
+ */
3444
+
3445
+ type ThirdPartyComponentFrameworkDefinition = Pick<ComponentFrameworkDefinition, 'type' | 'name' | 'supportedBundlers' | 'detectors' | 'dependencies'> & {
3446
+ /**
3447
+ * @example `cypress-ct-${string} for third parties. Any string is valid internally.
3448
+ */
3449
+ type: string
3450
+
3451
+ /**
3452
+ * Raw SVG icon that will be displayed in the Project Setup Wizard. Used for third parties that
3453
+ * want to render a custom icon.
3454
+ */
3455
+ icon?: string
3456
+ }
3457
+
3262
3458
  interface AngularDevServerProjectConfig {
3263
3459
  root: string
3264
3460
  sourceRoot: string
@@ -3545,12 +3741,49 @@ declare namespace Cypress {
3545
3741
  action: 'select' | 'drag-drop'
3546
3742
  }
3547
3743
 
3744
+ /**
3745
+ * Options that control how the `cy.setCookie` command
3746
+ * sets the cookie in the browser.
3747
+ * @see https://on.cypress.io/setcookie#Arguments
3748
+ */
3548
3749
  interface SetCookieOptions extends Loggable, Timeoutable {
3750
+ /**
3751
+ * The path of the cookie.
3752
+ * @default "/"
3753
+ */
3549
3754
  path: string
3755
+ /**
3756
+ * Represents the domain the cookie belongs to (e.g. "docs.cypress.io", "github.com").
3757
+ * @default location.hostname
3758
+ */
3550
3759
  domain: string
3760
+ /**
3761
+ * Whether a cookie's scope is limited to secure channels, such as HTTPS.
3762
+ * @default false
3763
+ */
3551
3764
  secure: boolean
3765
+ /**
3766
+ * Whether or not the cookie is HttpOnly, meaning the cookie is inaccessible to client-side scripts.
3767
+ * The Cypress cookie API has access to HttpOnly cookies.
3768
+ * @default false
3769
+ */
3552
3770
  httpOnly: boolean
3771
+ /**
3772
+ * Whether or not the cookie is a host-only cookie, meaning the request's host must exactly match the domain of the cookie.
3773
+ * @default false
3774
+ */
3775
+ hostOnly: boolean
3776
+ /**
3777
+ * The cookie's expiry time, specified in seconds since Unix Epoch.
3778
+ * The default is expiry is 20 years in the future from current time.
3779
+ */
3553
3780
  expiry: number
3781
+ /**
3782
+ * The cookie's SameSite value. If set, should be one of `lax`, `strict`, or `no_restriction`.
3783
+ * `no_restriction` is the equivalent of `SameSite=None`. Pass `undefined` to use the browser's default.
3784
+ * Note: `no_restriction` can only be used if the secure flag is set to `true`.
3785
+ * @default undefined
3786
+ */
3554
3787
  sameSite: SameSiteStatus
3555
3788
  }
3556
3789
 
@@ -6080,6 +6313,7 @@ declare namespace Cypress {
6080
6313
  value: string
6081
6314
  path: string
6082
6315
  domain: string
6316
+ hostOnly?: boolean
6083
6317
  httpOnly: boolean
6084
6318
  secure: boolean
6085
6319
  expiry?: number
@@ -395,7 +395,17 @@ export interface RouteMatcherOptionsGeneric<S> {
395
395
 
396
396
  export type RouteHandlerController = HttpRequestInterceptor
397
397
 
398
- export type RouteHandler = string | StaticResponse | RouteHandlerController | object
398
+ export type RouteHandler = string | StaticResponseWithOptions | RouteHandlerController | object
399
+
400
+ export type InterceptOptions = {
401
+ /**
402
+ * If set to `false`, matching requests will not be shown in the Command Log.
403
+ * @default true
404
+ */
405
+ log?: boolean
406
+ }
407
+
408
+ export type StaticResponseWithOptions = StaticResponse & InterceptOptions
399
409
 
400
410
  /**
401
411
  * Describes a response that will be sent back to the browser to fulfill the request.