cypress 12.6.0 → 12.7.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,20 @@ 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
+ document.body.appendChild(rootElement);
165
+ }
166
+ removeAllRootElements() {
167
+ getContainerEl().innerHTML = '';
168
+ }
169
+ };
170
+ CypressTestComponentRenderer = __decorate([
171
+ Injectable()
172
+ ], CypressTestComponentRenderer);
146
173
  /**
147
174
  * Initializes the TestBed
148
175
  *
@@ -153,6 +180,7 @@ function bootstrapModule(component, config) {
153
180
  function initTestBed(component, config) {
154
181
  const componentFixture = createComponentFixture(component);
155
182
  getTestBed().configureTestingModule(Object.assign({}, bootstrapModule(componentFixture, config)));
183
+ getTestBed().overrideProvider(TestComponentRenderer, { useValue: new CypressTestComponentRenderer() });
156
184
  return componentFixture;
157
185
  }
158
186
  let WrapperComponent = class WrapperComponent {
@@ -302,4 +330,4 @@ getTestBed().initTestEnvironment(BrowserDynamicTestingModule, platformBrowserDyn
302
330
  });
303
331
  setupHooks(cleanup);
304
332
 
305
- export { createOutputSpy, mount };
333
+ 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.7.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": "0cdd8d195f9660f1c6bb357b5fbe1ec32b16c54b",
122
+ "commitDate": "2023-02-24T22:33:04.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,179 @@ 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
+ loc: string | null
3290
+ detectedVersion: string | null
3291
+ }
3292
+
3293
+ interface CypressComponentDependency {
3294
+ /**
3295
+ * Unique idenitifer.
3296
+ * @example 'reactscripts'
3297
+ */
3298
+ type: string
3299
+
3300
+ /**
3301
+ * Name to display in the user interface.
3302
+ * @example "React Scripts"
3303
+ */
3304
+ name: string
3305
+
3306
+ /**
3307
+ * Package name on npm.
3308
+ * @example react-scripts
3309
+ */
3310
+ package: string
3311
+
3312
+ /**
3313
+ * Code to run when installing. Version is optional.
3314
+ *
3315
+ * Should be <package_name>@<version>.
3316
+ *
3317
+ * @example `react`
3318
+ * @example `react@18`
3319
+ * @example `react-scripts`
3320
+ */
3321
+ installer: string
3322
+
3323
+ /**
3324
+ * Description shown in UI. It is recommended to use the same one the package uses on npm.
3325
+ * @example 'Create React apps with no build configuration'
3326
+ */
3327
+ description: string
3328
+
3329
+ /**
3330
+ * Minimum version supported. Should conform to Semantic Versioning as used in `package.json`.
3331
+ * @see https://docs.npmjs.com/cli/v9/configuring-npm/package-json#dependencies
3332
+ * @example '^=4.0.0 || ^=5.0.0'
3333
+ * @example '^2.0.0'
3334
+ */
3335
+ minVersion: string
3336
+ }
3337
+
3338
+ interface ResolvedComponentFrameworkDefinition {
3339
+ /**
3340
+ * A semantic, unique identifier.
3341
+ * Must begin with `cypress-ct-` or `@org/cypress-ct-` for third party implementations.
3342
+ * @example 'reactscripts'
3343
+ * @example 'nextjs'
3344
+ * @example 'cypress-ct-solid-js'
3345
+ */
3346
+ type: string
3347
+
3348
+ /**
3349
+ * Used as the flag for `getPreset` for meta framworks, such as finding the webpack config for CRA, Angular, etc.
3350
+ * It is also the name of the string added to `cypress.config`
3351
+ *
3352
+ * @example
3353
+ * export default {
3354
+ * component: {
3355
+ * devServer: {
3356
+ * framework: 'create-react-app' // can be 'next', 'create-react-app', etc etc.
3357
+ * }
3358
+ * }
3359
+ * }
3360
+ */
3361
+ configFramework: string
3362
+
3363
+ /**
3364
+ * Library (React, Vue) or template (aka "meta framework") (CRA, Next.js, Angular)
3365
+ */
3366
+ category: 'library' | 'template'
3367
+
3368
+ /**
3369
+ * Name displayed in Launchpad when doing initial setup.
3370
+ * @example 'Solid.js'
3371
+ * @example 'Create React App'
3372
+ */
3373
+ name: string
3374
+
3375
+ /**
3376
+ * Supported bundlers.
3377
+ */
3378
+ supportedBundlers: Array<'webpack' | 'vite'>
3379
+
3380
+ /**
3381
+ * Used to attempt to automatically select the correct framework/bundler from the dropdown.
3382
+ *
3383
+ * @example
3384
+ * const SOLID_DETECTOR: Dependency = {
3385
+ * type: 'solid',
3386
+ * name: 'Solid.js',
3387
+ * package: 'solid-js',
3388
+ * installer: 'solid-js',
3389
+ * description: 'Solid is a declarative JavaScript library for creating user interfaces',
3390
+ * minVersion: '^1.0.0',
3391
+ * }
3392
+ */
3393
+ detectors: CypressComponentDependency[]
3394
+
3395
+ /**
3396
+ * Array of required dependencies. This could be the bundler and JavaScript library.
3397
+ */
3398
+ dependencies: (bundler: 'webpack' | 'vite', projectPath: string) => Promise<DependencyToInstall[]>
3399
+
3400
+ /**
3401
+ * This is used interally by Cypress for the "Create From Component" feature.
3402
+ */
3403
+ codeGenFramework?: 'react' | 'vue' | 'svelte' | 'angular'
3404
+
3405
+ /**
3406
+ * This is used interally by Cypress for the "Create From Component" feature.
3407
+ * @example '*.{js,jsx,tsx}'
3408
+ */
3409
+ glob?: string
3410
+
3411
+ /**
3412
+ * This is the path to get mount, eg `import { mount } from <mount_module>,
3413
+ * @example: `cypress-ct-solidjs/src/mount`
3414
+ */
3415
+ mountModule: (projectPath: string) => Promise<string>
3416
+
3417
+ /**
3418
+ * Support status. Internally alpha | beta | full.
3419
+ * Community integrations are "community".
3420
+ */
3421
+ supportStatus: 'alpha' | 'beta' | 'full' | 'community'
3422
+
3423
+ /**
3424
+ * Function returning string for used for the component-index.html file.
3425
+ * Cypress provides a default if one isn't specified for third party integrations.
3426
+ */
3427
+ componentIndexHtml?: () => string
3428
+
3429
+ /**
3430
+ * Used for the Create From Comopnent feature.
3431
+ * This is currently not supported for third party frameworks.
3432
+ */
3433
+ specPattern?: '**/*.cy.ts'
3434
+ }
3435
+
3436
+ type ComponentFrameworkDefinition = Omit<ResolvedComponentFrameworkDefinition, 'dependencies'> & {
3437
+ dependencies: (bundler: 'webpack' | 'vite') => CypressComponentDependency[]
3438
+ }
3439
+
3440
+ /**
3441
+ * Certain properties are not supported for third party frameworks right now,
3442
+ * such as ones related to the "Create From" feature. This is a subset of
3443
+ * properties that are exposed for public usage.
3444
+ */
3445
+
3446
+ type ThirdPartyComponentFrameworkDefinition = Pick<ComponentFrameworkDefinition, 'type' | 'name' | 'supportedBundlers' | 'detectors' | 'dependencies'> & {
3447
+ /**
3448
+ * @example `cypress-ct-${string} for third parties. Any string is valid internally.
3449
+ */
3450
+ type: string
3451
+
3452
+ /**
3453
+ * Raw SVG icon that will be displayed in the Project Setup Wizard. Used for third parties that
3454
+ * want to render a custom icon.
3455
+ */
3456
+ icon?: string
3457
+ }
3458
+
3262
3459
  interface AngularDevServerProjectConfig {
3263
3460
  root: string
3264
3461
  sourceRoot: string
@@ -3545,12 +3742,49 @@ declare namespace Cypress {
3545
3742
  action: 'select' | 'drag-drop'
3546
3743
  }
3547
3744
 
3745
+ /**
3746
+ * Options that control how the `cy.setCookie` command
3747
+ * sets the cookie in the browser.
3748
+ * @see https://on.cypress.io/setcookie#Arguments
3749
+ */
3548
3750
  interface SetCookieOptions extends Loggable, Timeoutable {
3751
+ /**
3752
+ * The path of the cookie.
3753
+ * @default "/"
3754
+ */
3549
3755
  path: string
3756
+ /**
3757
+ * Represents the domain the cookie belongs to (e.g. "docs.cypress.io", "github.com").
3758
+ * @default location.hostname
3759
+ */
3550
3760
  domain: string
3761
+ /**
3762
+ * Whether a cookie's scope is limited to secure channels, such as HTTPS.
3763
+ * @default false
3764
+ */
3551
3765
  secure: boolean
3766
+ /**
3767
+ * Whether or not the cookie is HttpOnly, meaning the cookie is inaccessible to client-side scripts.
3768
+ * The Cypress cookie API has access to HttpOnly cookies.
3769
+ * @default false
3770
+ */
3552
3771
  httpOnly: boolean
3772
+ /**
3773
+ * Whether or not the cookie is a host-only cookie, meaning the request's host must exactly match the domain of the cookie.
3774
+ * @default false
3775
+ */
3776
+ hostOnly: boolean
3777
+ /**
3778
+ * The cookie's expiry time, specified in seconds since Unix Epoch.
3779
+ * The default is expiry is 20 years in the future from current time.
3780
+ */
3553
3781
  expiry: number
3782
+ /**
3783
+ * The cookie's SameSite value. If set, should be one of `lax`, `strict`, or `no_restriction`.
3784
+ * `no_restriction` is the equivalent of `SameSite=None`. Pass `undefined` to use the browser's default.
3785
+ * Note: `no_restriction` can only be used if the secure flag is set to `true`.
3786
+ * @default undefined
3787
+ */
3554
3788
  sameSite: SameSiteStatus
3555
3789
  }
3556
3790
 
@@ -6080,6 +6314,7 @@ declare namespace Cypress {
6080
6314
  value: string
6081
6315
  path: string
6082
6316
  domain: string
6317
+ hostOnly?: boolean
6083
6318
  httpOnly: boolean
6084
6319
  secure: boolean
6085
6320
  expiry?: number