Here's the component constructor:
constructor(
public dialogRef: MatDialogRef<TaskActionModalContainer>,
@Inject(MAT_DIALOG_DATA) data
) {}
Here's the testbed:
TestBed.configureTestingModule({
imports: [ MatDialogModule ],
declarations: [ TaskActionModalContainer ],
schemas: [
CUSTOM_ELEMENTS_SCHEMA
],
providers: [
{
provide: MatDialogRef,
useValue: {},
},
{
provide: MAT_DIALOG_DATA,
useValue: {}
}
]
})
.compileComponents();
Here's the error:
StaticInjectorError(DynamicTestModule)[TaskActionModalContainer -> MatDialogRef]:
StaticInjectorError(Platform: core)[TaskActionModalContainer -> MatDialogRef]:
NullInjectorError: No provider for MatDialogRef!
I've searched high and low and see this NullInjector error everywhere, but I'm continuing to get it. I thought an angular guru could solve this quickly.
Help!
EDIT:
I've also used useClass
with no success.
Of interest is that I also have this:
beforeEach(inject(
[
MatDialogRef,
MAT_DIALOG_DATA
],
(
dialogRef,
dialogData
) => {
console.log(dialogRef);
console.log(dialogData);
}));
and I am seeing those console.log's when running the test....right before it shows me the error at TestBed.createComponent
EDIT #2 - I feel like this is because this is an entryComponent, which I have no idea what that means, but this is one. I have a ModalContainer which pops up this one (so I guess it's a dynamically created one) - any help there?
Mistakenly closed this as a dupe, mine was about unit testing so the answer is a little more nuanced.