-
Notifications
You must be signed in to change notification settings - Fork 90
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
signalInputs #432
Comments
it seems that something needs to be adapted because when I run some tests on components with signal inputs, I get the following type of error: |
could it be related to this issue? angular/angular#54013 |
@FabienDehopre thanks for the information. |
I'm facing the same issue. Seems like it's fixed in thymikee/jest-preset-angular#2246 |
@tutkli the referenced PR allows us to set signal inputs via other components, but not directly using |
Update: after also updating Jest this does work For an example see https://github.com/testing-library/angular-testing-library/blob/main/apps/example-app/src/app/examples/22-signal-inputs.component.spec.ts |
How do we handle Example: @Component({
selector: 'app-search',
standalone: true,
template: `<input [(ngModel)]="keywords()" />`,
})
export class SearchComponent {
public keywords = model('');
} Anyone who consumes this component can split the i/o like <app-search [keywords]="keywords" (keywordsChange)="handleKeywordsChange($event)" /> I'd like to write a test like so but it doesnt appear to be handled currently: test('it outputs form values per vale change.', async () => {
const keywordsChange = jest.fn();
const { getByLabelText } = await renderComponent({
componentOutputs: {
keywordsChange,
}
});
await userEvent.type(getByLabelText('Search'), 'a');
expect(keywordsChange).toHaveBeenCalledWith('a');
await userEvent.type(getByLabelText('Search'), 'b');
expect(keywordsChange).toHaveBeenLastCalledWith('ab');
await userEvent.type(getByLabelText('Search'), 'c');
expect(keywordsChange).toHaveBeenLastCalledWith('abc');
await userEvent.type(getByLabelText('Search'), '{backspace}');
expect(keywordsChange).toHaveBeenLastCalledWith('ab');
await userEvent.type(getByLabelText('Search'), '{backspace}');
expect(keywordsChange).toHaveBeenLastCalledWith('a');
await userEvent.type(getByLabelText('Search'), '{backspace}');
expect(keywordsChange).toHaveBeenLastCalledWith('');
}); |
We haven't looked into supporting |
This is not working for me 😞. I updated jest-preset, Testing Library and jest, but I get still the error Similar to this
|
Do you got a reproduction @mnkyjs ? |
I've seen this too. Some input names do not work. For me it was 'visible'. Changing the input name fixed it. |
@johnwalshuk see #443 to test output/models |
It was my bad 🤦 , after I removed my node_modules folder and rerun npm install everything worked again 👍 |
Add test cases for signal inputs.
Do we need to do something to cover these, or does this just work? 👀
The text was updated successfully, but these errors were encountered: