Skip to content

Unable to appropriately mock a SignalStore when its within the providers array of the standalone component being tested #4518

Answered by rainerhahnekamp
skyleguy asked this question in Q&A
Discussion options

You must be logged in to vote

@skyleguy, for overriding Services of a component, you need to use TestBed.overrideComponent:

TestBed.overrideComponent(AppComponent, {
  set: {
    providers: [
      {
        provide: AppComponentStore,
        useValue: {
          field: signal('hi'),
        },
      },
    ],
  },
});
TestBed.configureTestingModule(...)

Let me know if that works for you.

Replies: 2 comments 5 replies

Comment options

You must be logged in to vote
0 replies
Answer selected by markostanimirovic
Comment options

You must be logged in to vote
5 replies
@rainerhahnekamp
Comment options

@skyleguy
Comment options

@rainerhahnekamp
Comment options

@skyleguy
Comment options

@rainerhahnekamp
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #4517 on September 06, 2024 20:14.