cypress 13.12.0 → 13.13.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,74 @@
1
+ {
2
+ "name": "@cypress/angular-signals",
3
+ "version": "0.0.0-development",
4
+ "description": "Test Angular Components using Signals with Cypress",
5
+ "main": "dist/index.js",
6
+ "scripts": {
7
+ "prebuild": "rimraf dist",
8
+ "build": "rollup -c rollup.config.mjs",
9
+ "postbuild": "node ../../scripts/sync-exported-npm-with-cli.js",
10
+ "check-ts": "tsc --noEmit",
11
+ "dev": "rollup -c rollup.config.mjs -w",
12
+ "lint": "eslint --ext .js,.ts,.json, ."
13
+ },
14
+ "dependencies": {},
15
+ "devDependencies": {
16
+ "@angular/common": "^17.2.0",
17
+ "@angular/core": "^17.2.0",
18
+ "@angular/platform-browser-dynamic": "^17.2.0",
19
+ "@cypress/mount-utils": "0.0.0-development",
20
+ "typescript": "~5.4.5",
21
+ "zone.js": "~0.14.6"
22
+ },
23
+ "peerDependencies": {
24
+ "@angular/common": ">=17.2",
25
+ "@angular/core": ">=17.2",
26
+ "@angular/platform-browser-dynamic": ">=17.2",
27
+ "rxjs": ">=7.5.0",
28
+ "zone.js": ">=0.13.0"
29
+ },
30
+ "files": [
31
+ "dist"
32
+ ],
33
+ "types": "dist/index.d.ts",
34
+ "license": "MIT",
35
+ "repository": {
36
+ "type": "git",
37
+ "url": "https://github.com/cypress-io/cypress.git"
38
+ },
39
+ "homepage": "https://github.com/cypress-io/cypress/blob/develop/npm/angular-signals/#readme",
40
+ "bugs": "https://github.com/cypress-io/cypress/issues/new?assignees=&labels=npm%3A%20%40cypress%2Fangular&template=1-bug-report.md&title=",
41
+ "keywords": [
42
+ "angular",
43
+ "cypress",
44
+ "cypress-io",
45
+ "test",
46
+ "testing"
47
+ ],
48
+ "contributors": [
49
+ {
50
+ "name": "Bill Glesias",
51
+ "social": "@atofstryker"
52
+ }
53
+ ],
54
+ "module": "dist/index.js",
55
+ "publishConfig": {
56
+ "access": "public"
57
+ },
58
+ "nx": {
59
+ "targets": {
60
+ "build": {
61
+ "outputs": [
62
+ "{workspaceRoot}/cli/angular-signals"
63
+ ]
64
+ }
65
+ }
66
+ },
67
+ "standard": {
68
+ "globals": [
69
+ "Cypress",
70
+ "cy",
71
+ "expect"
72
+ ]
73
+ }
74
+ }
@@ -0,0 +1,136 @@
1
+ /// <reference types="cypress" />
2
+
3
+ import { InputSignal, WritableSignal, Type } from '@angular/core';
4
+ import { TestModuleMetadata, ComponentFixture, TestComponentRenderer } from '@angular/core/testing';
5
+
6
+ /**
7
+ * Additional module configurations needed while mounting the component, like
8
+ * providers, declarations, imports and even component @Inputs()
9
+ *
10
+ * @interface MountConfig
11
+ * @see https://angular.io/api/core/testing/TestModuleMetadata
12
+ */
13
+ interface MountConfig<T> extends TestModuleMetadata {
14
+ /**
15
+ * @memberof MountConfig
16
+ * @description flag to automatically create a cy.spy() for every component @Output() property
17
+ * @example
18
+ * export class ButtonComponent {
19
+ * @Output clicked = new EventEmitter()
20
+ * }
21
+ *
22
+ * cy.mount(ButtonComponent, { autoSpyOutputs: true })
23
+ * cy.get('@clickedSpy).should('have.been.called')
24
+ */
25
+ autoSpyOutputs?: boolean;
26
+ /**
27
+ * @memberof MountConfig
28
+ * @description flag defaulted to true to automatically detect changes in your components
29
+ */
30
+ autoDetectChanges?: boolean;
31
+ /**
32
+ * @memberof MountConfig
33
+ * @example
34
+ * import { ButtonComponent } from 'button/button.component'
35
+ * it('renders a button with Save text', () => {
36
+ * cy.mount(ButtonComponent, { componentProperties: { text: 'Save' }})
37
+ * cy.get('button').contains('Save')
38
+ * })
39
+ *
40
+ * it('renders a button with a cy.spy() replacing EventEmitter', () => {
41
+ * cy.mount(ButtonComponent, {
42
+ * componentProperties: {
43
+ * clicked: cy.spy().as('mySpy)
44
+ * }
45
+ * })
46
+ * cy.get('button').click()
47
+ * cy.get('@mySpy').should('have.been.called')
48
+ * })
49
+ */
50
+ componentProperties?: Partial<{
51
+ [P in keyof T]: T[P] extends InputSignal<infer V> ? InputSignal<V> | WritableSignal<V> | V : T[P];
52
+ }>;
53
+ }
54
+ /**
55
+ * Type that the `mount` function returns
56
+ * @type MountResponse<T>
57
+ */
58
+ type MountResponse<T> = {
59
+ /**
60
+ * Fixture for debugging and testing a component.
61
+ *
62
+ * @memberof MountResponse
63
+ * @see https://angular.io/api/core/testing/ComponentFixture
64
+ */
65
+ fixture: ComponentFixture<T>;
66
+ /**
67
+ * The instance of the root component class
68
+ *
69
+ * @memberof MountResponse
70
+ * @see https://angular.io/api/core/testing/ComponentFixture#componentInstance
71
+ */
72
+ component: T;
73
+ };
74
+ declare class CypressTestComponentRenderer extends TestComponentRenderer {
75
+ insertRootElement(rootElId: string): void;
76
+ removeAllRootElements(): void;
77
+ }
78
+ /**
79
+ * Mounts an Angular component inside Cypress browser
80
+ *
81
+ * @param component Angular component being mounted or its template
82
+ * @param config configuration used to configure the TestBed
83
+ * @example
84
+ * import { mount } from '@cypress/angular-signals'
85
+ * import { StepperComponent } from './stepper.component'
86
+ * import { MyService } from 'services/my.service'
87
+ * import { SharedModule } from 'shared/shared.module';
88
+ * it('mounts', () => {
89
+ * mount(StepperComponent, {
90
+ * providers: [MyService],
91
+ * imports: [SharedModule]
92
+ * })
93
+ * cy.get('[data-cy=increment]').click()
94
+ * cy.get('[data-cy=counter]').should('have.text', '1')
95
+ * })
96
+ *
97
+ * // or
98
+ *
99
+ * it('mounts with template', () => {
100
+ * mount('<app-stepper></app-stepper>', {
101
+ * declarations: [StepperComponent],
102
+ * })
103
+ * })
104
+ *
105
+ * @see {@link https://on.cypress.io/mounting-angular} for more details.
106
+ *
107
+ * @returns A component and component fixture
108
+ */
109
+ declare function mount<T>(component: Type<T> | string, config?: MountConfig<T>): Cypress.Chainable<MountResponse<T>>;
110
+ /**
111
+ * Creates a new Event Emitter and then spies on it's `emit` method
112
+ *
113
+ * @param {string} alias name you want to use for your cy.spy() alias
114
+ * @returns EventEmitter<T>
115
+ * @example
116
+ * import { StepperComponent } from './stepper.component'
117
+ * import { mount, createOutputSpy } from '@cypress/angular-signals'
118
+ *
119
+ * it('Has spy', () => {
120
+ * mount(StepperComponent, { componentProperties: { change: createOutputSpy('changeSpy') } })
121
+ * cy.get('[data-cy=increment]').click()
122
+ * cy.get('@changeSpy').should('have.been.called')
123
+ * })
124
+ *
125
+ * // Or for use with Angular Signals following the output nomenclature.
126
+ * // see https://v17.angular.io/guide/model-inputs#differences-between-model-and-input/
127
+ *
128
+ * it('Has spy', () => {
129
+ * mount(StepperComponent, { componentProperties: { count: signal(0), countChange: createOutputSpy('countChange') } })
130
+ * cy.get('[data-cy=increment]').click()
131
+ * cy.get('@countChange').should('have.been.called')
132
+ * })
133
+ */
134
+ declare const createOutputSpy: <T>(alias: string) => any;
135
+
136
+ export { CypressTestComponentRenderer, MountConfig, MountResponse, createOutputSpy, mount };