Angular fornisce un setup di test completo (Jasmine + Karma per impostazione predefinita, anche se molti team usano Jest). Fornisce TestBed per configurare un modulo di test e istanziare componenti/servizi con le loro dipendenze — sfruttando DI per iniettare mock.
Testing a service (simplest)
(, {
: ;
: ;
( {
.({
: [],
: [],
});
service = .();
httpMock = .();
});
(, {
service.().( (users.).());
req = httpMock.();
req.([{ : }, { : }]);
});
});
