Skip to content

Commit 99055ec

Browse files
authored
fix: make sure legacy output spies work as intended (#32158)
1 parent ed89b8d commit 99055ec

File tree

5 files changed

+50
-2
lines changed

5 files changed

+50
-2
lines changed

cli/CHANGELOG.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,20 @@
11
<!-- See the ../guides/writing-the-cypress-changelog.md for details on writing the changelog. -->
2+
## 14.5.5
3+
4+
_Released 8/12/2025 (PENDING)_
5+
6+
**Bugfixes:**
7+
8+
- Fixed an issue where Angular legacy `Output()` decorators were broken when making component instance field references safe. Fixes [#32137](https://github.com/cypress-io/cypress/issues/32137).
9+
- Upgraded `tmp` from `~0.2.3` to `~0.2.4`. This removes the [CVE-2025-54798](https://github.com/advisories/GHSA-52f5-9888-hmc6) vulnerability being reported in security scans. Addresses [#32176](https://github.com/cypress-io/cypress/issues/32176).
10+
211
## 14.5.4
312

413
_Released 8/07/2025_
514

615
**Dependency Updates:**
716

817
- Upgraded `tar-fs` to `2.1.3` and `3.1.0` in places we can control, to resolve [CVE-2024-12905](https://github.com/advisories/GHSA-pq67-2wwv-3xjx). `@puppeteer/browsers` still references `3.0.4`, but it is only used to download browsers which is not a feature of `puppeteer` that we utilize. Addressed in [#32160](https://github.com/cypress-io/cypress/pull/32160).
9-
- Upgraded `tmp` from `~0.2.3` to `~0.2.4`. This removes the [CVE-2025-54798](https://github.com/advisories/GHSA-52f5-9888-hmc6) vulnerability being reported in security scans. Addresses [#32176](https://github.com/cypress-io/cypress/issues/32176).
1018

1119
## 14.5.3
1220

npm/angular/src/mount.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,10 @@ function setupComponent<T> (
430430
getComponentOutputs(fixture.componentRef.componentType).forEach((key) => {
431431
const property = component[key]
432432

433-
if (property instanceof EventEmitter) {
433+
// With the introduction of https://github.com/cypress-io/cypress/pull/31993, we want to make sure that component inputs are reference safe inside cy.mount().
434+
// However, the exception to this is if the user passes in a Cypress output spy as a property in order to maintain backwards compatibility.
435+
// @ts-expect-error
436+
if (property instanceof EventEmitter || (config?.componentProperties?.hasOwnProperty(key) && config?.componentProperties[key] instanceof EventEmitter)) {
434437
// only assign props if they are passed into the component
435438
if (config?.componentProperties?.hasOwnProperty(key)) {
436439
// @ts-expect-error
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { SignalsInputComponent } from './signals.input.component'
2+
import { createOutputSpy, mount } from 'cypress/angular'
3+
4+
describe('with output spies', () => {
5+
// regression test for https://github.com/cypress-io/cypress/issues/32137
6+
it('should emit events on button click', () => {
7+
mount(SignalsInputComponent, {
8+
componentProperties: {
9+
newOutput: createOutputSpy('newOutput'),
10+
oldOutput: createOutputSpy('oldOutput'),
11+
},
12+
})
13+
14+
cy.get('#test-button').click()
15+
cy.get('@oldOutput').should('have.been.called')
16+
cy.get('@newOutput').should('have.been.called')
17+
})
18+
})
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<button id="test-button" (click)="onButtonClick()">Test</button>
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { Component, EventEmitter, Output, output } from '@angular/core'
2+
import { CommonModule } from '@angular/common'
3+
4+
@Component({
5+
selector: 'signals-input-component',
6+
standalone: true,
7+
imports: [CommonModule],
8+
templateUrl: './signals.input.component.html',
9+
})
10+
export class SignalsInputComponent {
11+
newOutput = output()
12+
@Output() oldOutput: EventEmitter<void> = new EventEmitter()
13+
14+
onButtonClick () {
15+
this.newOutput.emit()
16+
this.oldOutput.emit()
17+
}
18+
}

0 commit comments

Comments
 (0)