Skip to content

Commit 707b06b

Browse files
committed
chore: add angular 21 documentation
1 parent 45b166a commit 707b06b

File tree

4 files changed

+45
-19
lines changed

4 files changed

+45
-19
lines changed

docs/app/component-testing/angular/api.mdx

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ sidebar_label: API
1313

1414
### mount
1515

16+
```js
17+
// for Angular 20 and 21 using zoneless configuration
18+
import { mount } from 'cypress/angular-zoneless'
19+
```
20+
1621
```js
1722
import { mount } from 'cypress/angular'
1823
```
@@ -142,18 +147,18 @@ providers, declarations, imports and even component @Inputs()
142147
<td>Description</td>
143148
</thead>
144149
<tr>
145-
<td>autoSpyOutputs</td>
150+
<td>autoSpyOutputs (deprecated)</td>
146151
<td>boolean (optional)</td>
147152
<td>
148153
flag to automatically create a cy.spy() for every component @Output()
149-
property
154+
property. This is deprecated and not supported in `cypress/angular-zoneless` and will be removed in a future version
150155
</td>
151156
</tr>
152157
<tr>
153-
<td>autoDetectChanges</td>
158+
<td>autoDetectChanges (deprecated)</td>
154159
<td>boolean (optional)</td>
155160
<td>
156-
flag defaulted to true to automatically detect changes in your components
161+
flag defaulted to true to automatically detect changes in your components. This is deprecated and not supported in `cypress/angular-zoneless` and will be removed in a future version as it is not needed with zoneless configuration
157162
</td>
158163
</tr>
159164
<tr>

docs/app/component-testing/angular/examples.mdx

Lines changed: 32 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ in the options:
4646
cy.mount(StepperComponent, {
4747
componentProperties: {
4848
count: 100,
49-
change: new EventEmitter(),
5049
},
5150
})
5251
```
@@ -157,6 +156,24 @@ it('clicking + fires a change event with the incremented value', () => {
157156
})
158157
```
159158

159+
### Working with Legacy @Input() Decorators
160+
161+
With the release of Angular 18, [signals](https://angular.dev/guide/signals) became the preferred way to handle data binding.
162+
However, legacy components that use `@Input()` and `@Output()` decorators are still supported.
163+
164+
Interacting with legacy `@Input()` decorators is a bit different than working with signals.
165+
In order to update the `@Input()` value, you need to use the `componentRef.setInput` method so Angular change detection runs properly.
166+
Otherwise, you may see errors.
167+
168+
```ts
169+
cy.mount(StepperComponent, { componentProperties: { count: 100 } }).then(({ fixture }) => {
170+
return cy.contains('span', '100').wrap(fixture)
171+
}).then((fixture) => {
172+
fixture.componentRef.setInput('count', 110)
173+
return cy.contains('span', '110')
174+
})
175+
```
176+
160177
### Using createOutputSpy()
161178

162179
To make spying on event emitters easier, there is a utility function called
@@ -179,7 +196,13 @@ it('clicking + fires a change event with the incremented value', () => {
179196
})
180197
```
181198

182-
### Using autoSpyOutputs
199+
### Using autoSpyOutputs (deprecated)
200+
201+
:::caution
202+
203+
The `autoSpyOutputs` flag is deprecated and not supported in `cypress/angular-zoneless` and will be removed in a future version.
204+
205+
:::
183206

184207
You might find yourself repeatedly creating a `cy.spy()` for each of your
185208
component outputs. Because of this, we created an easy mechanism to handle this
@@ -208,17 +231,8 @@ function. It currently does not work with the template syntax.
208231

209232
:::
210233

211-
:::caution
212-
213-
`autoSpyOutput` is an **experimental feature** and could be removed or changed
214-
in the future
215-
216-
:::
217-
218234
### Signals
219235

220-
With the releases of Angular versions [17.1](https://github.com/angular/angular/blob/main/CHANGELOG.md#1710-2024-01-17) and [17.2](https://github.com/angular/angular/blob/main/CHANGELOG.md#1720-2024-02-14), [input](https://github.com/angular/angular/pull/53521) and [model](https://github.com/angular/angular/pull/54252) signals were introduced into the `@angular/core` API. Though basic signals were introduced in Angular `16`, using all signals requires Angular `17.2` and above.
221-
222236
:::info
223237

224238
With Cypress 14, signal support is directly included in the `cypress/angular` testing harness.
@@ -434,7 +448,13 @@ This custom mount command will allow you to skip manually passing in the
434448
`ButtonComponent` and `CardComponent` as declarations into each `cy.mount()`
435449
call.
436450

437-
### autoSpyOutputs
451+
### autoSpyOutputs (deprecated)
452+
453+
:::caution
454+
455+
The `autoSpyOutputs` flag is deprecated and not supported in `cypress/angular-zoneless` and will be removed in a future version.
456+
457+
:::
438458

439459
Here is an example of defaulting `autoSpyOutputs` for every mounted component:
440460

docs/app/component-testing/angular/overview.mdx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,12 @@ sidebar_label: Overview
2020

2121
## Framework Support
2222

23-
Cypress Component Testing supports Angular `^18.0.0`, `^19.0.0`, and `^20.0.0`.
23+
Cypress Component Testing supports Angular `^18.0.0`, `^19.0.0`, `^20.0.0`, and `^21.0.0`.
2424

2525
:::info
2626

2727
Our testing harness, `cypress/angular`, still requires `zone.js` and `@angular-devkit/build-angular` to be installed in your project, even if your project is zoneless or is built with `@angular/build`.
28+
If you wish to use the zoneless configuration, which is the default in Angular 21, you can use `cypress/angular-zoneless` testing harness instead as of Cypress `15.8.0`.
2829
:::
2930

3031
## Tutorial
@@ -129,5 +130,5 @@ export default {
129130

130131
#### Sample Angular Apps
131132

132-
- [Angular 18](https://github.com/cypress-io/cypress-component-testing-apps/tree/main/angular)
133133
- [Angular 20 Standalone](https://github.com/cypress-io/cypress-component-testing-apps/tree/main/angular-standalone)
134+
- [Angular 21 Zoneless](https://github.com/cypress-io/cypress-component-testing-apps/tree/main/angular-zoneless)

docs/app/component-testing/get-started.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ following development servers and frameworks:
4747
| [Next.js 14-16](/app/component-testing/react/overview#Nextjs) | React 18-19 | Webpack 5 |
4848
| [Vue with Vite](/app/component-testing/vue/overview#Vue-with-Vite) | Vue 3 | Vite 5-7 |
4949
| [Vue with Webpack](/app/component-testing/vue/overview#Vue-with-Webpack) | Vue 3 | Webpack 5 |
50-
| [Angular](/app/component-testing/angular/overview#Framework-Configuration) | Angular 18-20 | Webpack 5 |
50+
| [Angular](/app/component-testing/angular/overview#Framework-Configuration) | Angular 18-21 | Webpack 5 |
5151
| [Svelte with Vite](/app/component-testing/svelte/overview#Svelte-with-Vite) <Badge type="info">Alpha</Badge> | Svelte 5 | Vite 5-7 |
5252
| [Svelte with Webpack](/app/component-testing/svelte/overview#Svelte-with-Webpack) <Badge type="info">Alpha</Badge> | Svelte 5 | Webpack 5 |
5353

0 commit comments

Comments
 (0)