-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Open
Description
Which @ngrx/* package(s) are relevant/related to the feature request?
events
Information
The Ngrx/signals 20.1.0 update broke a workaround that we have been using to observe Events rather than store state to test component configuration. I.e. we prefer testing the fact that some action in componentA results in events X and Y, rather than mocking the store or writing an integration test. This has kept our unit tests small and tidy.
Is there a way to either
- restore this workaround (It's not clear to me why Events needs to be injected at the Platform level), or
- provide a testing harness for the Events service?
Describe any alternatives/workarounds you're currently using
The workaround involved extending the Events service, but without overriding any core functionality.
@Injectable()
export class EventTestHarness extends Events {
all = toSignal(
super.on().pipe(scan(...))
);
// computeds based on the above signal, e.g.
count()
first()
last()
}We provided it like so:
export function provideEventsTesting() {
return makeEnvironmentProviders([
{ provide: Events, useClass: EventsTestHarness },
{ provide: EventsTestHarness, useFactory: () => inject(Events), deps: [Events] }
]);
}Unfortunately, this is no longer possible in the 20.1.0+ version, since the Events service is now provided in Platform rather than the Root level injector, and we cannot override it in Testbed.
I would be willing to submit a PR to fix this issue
- Yes
- No
Reactions are currently unavailable