NestJS एक बिल्ट-इन testing utility (@nestjs/testing) प्रदान करता जो Jest सह एकीकृत आहे, आणि त्याचे dependency-injection architecture testing विशेषतः स्वच्छ करते — तुम्ही एक testing module तयार करता आणि dependencies साठी mocks inject करता. Tests unit tests (isolated) आणि e2e tests (full app) मध्ये विभागलेले आहेत.
Unit testing एक service (mocked dependencies सह)
{ } ;
(, {
: ;
mockRepo = { : jest.(), : jest.() };
( () => {
= .({
: [
,
{ : (), : mockRepo },
],
}).();
service = .<>();
});
(, () => {
mockRepo..([{ : , : }]);
result = service.();
(result).();
(mockRepo.).();
});
});
