Skip to content

Angular Signal model not getting called when updated via ngModel #30417

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
ischemicbg opened this issue Oct 17, 2024 · 2 comments
Closed

Angular Signal model not getting called when updated via ngModel #30417

ischemicbg opened this issue Oct 17, 2024 · 2 comments
Labels
CT Issue related to component testing npm: @cypress/angular @cypress/angular package issues stage: needs investigating Someone from Cypress needs to look at this stale no activity on this issue for a long period

Comments

@ischemicbg
Copy link

ischemicbg commented Oct 17, 2024

Current behavior

On one of my components I have a signal model() which is bound to an html input via [(ngModel)] like so:

searchTerm = model('');
<input
		name="search"
		type="search"
		[placeholder]="placeholder()"
		autocomplete="off"
		#searchField
		[(ngModel)]="searchTerm"
		[disabled]="disabled()"
			/>

I'm trying to test that the searchTermOutput fires when the value in the input changes. My test code is as follows:

    cy.mount(SearchComponent, {
	componentProperties: {
		// @ts-expect-error
		searchTermChange: createOutputSpy('searchTermChange'),
	},
        cy.get('input').type('son');
        cy.get('@searchTermChange').should('have.been.called');
    });

The test fails saying searchTermChange was never called:

image

Desired behavior

Cypress should detect output changes when trigged via ngModel binding

Test code to reproduce

Basic example to reproduce

import { Component, model } from '@angular/core';
import { FormsModule } from '@angular/forms';

@Component({
	selector: 'app-test',
	standalone: true,
	template: '<input name="search" type="search" autocomplete="off" [(ngModel)]="searchTerm" />',
	imports: [FormsModule],
})
export class TestComponent {
	public searchTerm = model('');
}
import { TestComponent } from './test.component.ts';
import { createOutputSpy } from 'cypress/angular-signals';
describe('TestComponent', () => {
	it('model() searchTerm - When text is typed into search input his output will fire with that term', () => {
		cy.mount(TestComponent, {
			componentProperties: {
				// @ts-expect-error
				searchTermChange: createOutputSpy('searchTermChange'),
			},
		});

		cy.get('input').type('son');
		cy.get('@searchTermChange').should('have.been.called');
	});
});

Cypress Version

13.15.0

Node version

v18.20

Operating System

Windows 11

Debug Logs

No response

Other

No response

@jennifer-shehane jennifer-shehane added stage: needs investigating Someone from Cypress needs to look at this npm: @cypress/angular @cypress/angular package issues CT Issue related to component testing labels Oct 19, 2024
@cypress-app-bot
Copy link
Collaborator

This issue has not had any activity in 180 days. Cypress evolves quickly and the reported behavior should be tested on the latest version of Cypress to verify the behavior is still occurring. It will be closed in 14 days if no updates are provided.

@cypress-app-bot cypress-app-bot added the stale no activity on this issue for a long period label May 5, 2025
@cypress-app-bot
Copy link
Collaborator

This issue has been closed due to inactivity.

@cypress-app-bot cypress-app-bot closed this as not planned Won't fix, can't repro, duplicate, stale May 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CT Issue related to component testing npm: @cypress/angular @cypress/angular package issues stage: needs investigating Someone from Cypress needs to look at this stale no activity on this issue for a long period
Projects
None yet
Development

No branches or pull requests

3 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy