TestBed tạo testing module/environment để render component, inject services và override providers trong unit test.
Nó hữu ích khi test component standalone, service có DI, provider override, pipe/directive hoặc behavior cần gần Angular runtime thật. Với logic thuần TypeScript không phụ thuộc Angular runtime, có thể test class/function trực tiếp để nhanh và ít boilerplate hơn.
TestBed creates a testing module/environment to render components, inject services and override providers in unit tests.
It is useful for standalone component tests, DI-heavy services, provider overrides, pipes/directives or behavior that needs to be close to the real Angular runtime. For pure TypeScript logic that does not depend on Angular runtime, test the class/function directly for less boilerplate and faster tests.