Skip to content
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

triggerEventHandler does not recognize signal outputs/models #669

Open
skyleguy opened this issue Sep 6, 2024 · 1 comment
Open

triggerEventHandler does not recognize signal outputs/models #669

skyleguy opened this issue Sep 6, 2024 · 1 comment

Comments

@skyleguy
Copy link

skyleguy commented Sep 6, 2024

Is this a regression?

No

Description

angular: ^18.2.0
spectator: ^19.0.0

Not sure if this is a bug or a missing feature but essentially when using spectator.triggerEventHandler with a component as the first argument (not just the html selector of the component), when you attempt to give the name of the output as the second argument it only knows about outputs decorated with the @Output decorator and not any outputs that use output or model.

As an example assume we have a Component that is using this component:

@Component({
  selector: 'signal-output-test',
  standalone: true,
  template: `some cool ui here`,
})
export class SignalOutputComponent {
  @Output()
  decoratorOutput = new EventEmitter<string>();

  signalOutput = output<string>();

  signalModel = model<string>();
}

when my component goes to try and test how it reacts to outputs from that component we would most likely try to use triggerEventHandler like so:

Screenshot 2024-09-06 at 2 11 36 PM

as you can see it only knows about the decoratorOutput field even though it should know about the signalOutput and signalModel fields as well. You can work around this by doing:

spectator.triggerEventHandler('signal-output-test', 'signalOutput', 'someValue')

but this isnt as helpful and it doesnt have the same type safety that the other approach does

Please provide a link to a minimal reproduction of the bug

No response

Please provide the exception or error you saw

No response

Please provide the environment you discovered this bug in

No response

Anything else?

No response

Do you want to create a pull request?

No

@perktopicus
Copy link

perktopicus commented Oct 31, 2024

This was fixed in 19.1.0 with in it #672.
Although this version was made it was never released on npmjs, that is the final step that seems to be missing.
Let's hope that someone will release it on npmjs

For now a workaround for your case could be
spectator.query('signal-output-test').signalOutput.emit('someValue')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants