For those wondering how it now (2025) works with standalone components, here is a nice tutorial I found out: https://youtu.be/Jv7jOrGTKd0?si=kqvGSDOzs0oA-4Vx&t=434, or text version https://www.angulararchitects.io/en/blog/testing-angular-standalone-components/
tl;dr use TestBed.overrideComponent