Mock non-standalone dependencies in standalone components for unit tests

56 Views Asked by At

I have a standalone component with some non-standalone dependencies. These dependencies were added with related modules to the imports array. How can I mock dependencies of non-standalone components for Unit tests. I have all needed stub components, but can't figure out how to add these dependencies, because I can include only modules. Here is the component decorator

@Component({
  selector: 'app-test',
  standalone: true,
  templateUrl: 'app-test.component.html',
  styleUrls: ['app-test.component.scss'],
  changeDetection: ChangeDetectionStrategy.OnPush,
  imports: [LoaderModule, SharedModule],
}) 

In LoaderModule, SharedModule i have some components that i want to mock. Do I need to create some module with all needed stub dependencies and include it in the standalone imports array?

0

There are 0 best solutions below