{"id":365952,"date":"2024-05-21T02:49:03","date_gmt":"2024-05-21T02:49:03","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=365952"},"modified":"-0001-11-30T00:00:00","modified_gmt":"2024-05-21T02:49:03","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=365952","title":{"rendered":"<span>\u0417\u043d\u0430\u043a\u043e\u043c\u0441\u0442\u0432\u043e \u0441 Jest Mocks<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-1\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/fq\/s6\/q7\/fqs6q73h2ntilxglk5ouaz5ccp4.png\" data-src=\"https:\/\/habrastorage.org\/webt\/fq\/s6\/q7\/fqs6q73h2ntilxglk5ouaz5ccp4.png\"\/><\/p>\n<p>  \u041c\u043e\u043a\u0438\u043d\u0433 \u2014 \u044d\u0442\u043e \u0442\u0435\u0445\u043d\u0438\u043a\u0430 \u0438\u0437\u043e\u043b\u044f\u0446\u0438\u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043f\u0443\u0442\u0435\u043c \u0437\u0430\u043c\u0435\u043d\u044b \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439 \u043e\u0431\u044a\u0435\u043a\u0442\u0430\u043c\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c \u0438 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c. \u0417\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044c\u044e \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0432\u0441\u0451, \u043e\u0442 \u0447\u0435\u0433\u043e \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0431\u044a\u0435\u043a\u0442, \u043d\u043e \u043e\u0431\u044b\u0447\u043d\u043e \u044d\u0442\u043e \u043c\u043e\u0434\u0443\u043b\u044c, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u0431\u044a\u0435\u043a\u0442 \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u0442.<a name=\"habracut\"><\/a><\/p>\n<p>  \u0415\u0441\u0442\u044c \u0445\u043e\u0440\u043e\u0448\u0438\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u0434\u043b\u044f \u043c\u043e\u043a\u0438\u043d\u0433\u0430 \u0432 JavaScript, \u0442\u0430\u043a\u0438\u0435 \u043a\u0430\u043a <a href=\"https:\/\/github.com\/testdouble\/testdouble.js\">testdouble<\/a> \u0438 <a href=\"http:\/\/sinonjs.org\/\">sinon<\/a>, \u0430 Jest \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0432\u0430\u0435\u0442 \u043c\u043e\u043a\u0438\u043d\u0433 \u0438\u0437 \u043a\u043e\u0440\u043e\u0431\u043a\u0438.<\/p>\n<p>  \u041d\u0435\u0434\u0430\u0432\u043d\u043e \u044f \u0441\u0442\u0430\u043b \u0441\u043e\u0430\u0432\u0442\u043e\u0440\u043e\u043c Jest, \u0447\u0442\u043e\u0431\u044b <a href=\"https:\/\/github.com\/facebook\/jest\/issues?utf8=%E2%9C%93&amp;q=involves%3Arickhanlonii\">\u043f\u043e\u043c\u043e\u0447\u044c \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u0442\u044c\u0441\u044f<\/a> \u0441 \u0431\u0430\u0433-\u0442\u0440\u0435\u043a\u0435\u0440\u043e\u043c, \u0438 \u0441\u0440\u0430\u0437\u0443 \u0437\u0430\u043c\u0435\u0442\u0438\u043b, \u0447\u0442\u043e \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0435\u0442 \u043c\u043d\u043e\u0433\u043e \u0432\u043e\u043f\u0440\u043e\u0441\u043e\u0432 \u043e \u0442\u043e\u043c, <a href=\"https:\/\/github.com\/facebook\/jest\/issues?utf8=%E2%9C%93&amp;q=how+mock+\">\u043a\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043c\u043e\u043a\u0438\u043d\u0433<\/a> \u0432 Jest. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u044f \u0440\u0435\u0448\u0438\u043b \u0441\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0435 \u0440\u0443\u043a\u043e\u0432\u043e\u0434\u0441\u0442\u0432\u043e.<\/p>\n<p>  \u0413\u043e\u0432\u043e\u0440\u044f \u043e \u043c\u043e\u043a\u0438\u043d\u0433\u0435 \u0432 Jest, \u043c\u044b \u043e\u0431\u044b\u0447\u043d\u043e \u0438\u043c\u0435\u0435\u043c \u0432 \u0432\u0438\u0434\u0443 \u0437\u0430\u043c\u0435\u043d\u0443 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439 \u043d\u0430 <a href=\"https:\/\/facebook.github.io\/jest\/docs\/en\/mock-function-api.html\">\u043c\u043e\u043a-\u0444\u0443\u043d\u043a\u0446\u0438\u0438<\/a>. \u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043c\u044b \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043c\u043e\u043a-\u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u0430 \u0437\u0430\u0442\u0435\u043c \u043f\u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u043c\u0441\u044f \u0441 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u043c\u0438 \u0441\u043f\u043e\u0441\u043e\u0431\u0430\u043c\u0438 \u0437\u0430\u043c\u0435\u043d\u044b \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439 \u0441 \u0438\u0445 \u043f\u043e\u043c\u043e\u0449\u044c\u044e.<\/p>\n<h2>\u041c\u043e\u043a-\u0444\u0443\u043d\u043a\u0446\u0438\u044f<\/h2>\n<p>  \u0426\u0435\u043b\u044c \u043c\u043e\u043a\u0438\u043d\u0433\u0430, \u0432\u044b\u0440\u0430\u0436\u0430\u044f\u0441\u044c \u043f\u0440\u043e\u0441\u0442\u044b\u043c \u044f\u0437\u044b\u043a\u043e\u043c \u2014 \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u044c \u0442\u043e, \u0447\u0442\u043e \u043c\u044b \u043d\u0435 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u0438\u0440\u0443\u0435\u043c, \u043d\u0430 \u0442\u043e, \u0447\u0442\u043e \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u0438\u0440\u0443\u0435\u043c. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432\u0430\u0436\u043d\u043e, \u0447\u0442\u043e\u0431\u044b \u0442\u043e, \u0447\u0435\u043c \u043c\u044b \u044d\u0442\u043e \u0437\u0430\u043c\u0435\u043d\u0438\u043c, \u043e\u0431\u043b\u0430\u0434\u0430\u043b\u043e \u0432\u0441\u0435\u043c\u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u043c\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u044f\u043c\u0438.<\/p>\n<p>  \u041c\u043e\u043a-\u0444\u0443\u043d\u043a\u0446\u0438\u044f \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442:  <\/p>\n<ul>\n<li>\u041f\u0435\u0440\u0435\u0445\u0432\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u0432\u044b\u0437\u043e\u0432\u044b<\/li>\n<li>\u0423\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0442\u044c \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u044b\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f<\/li>\n<li>\u0418\u0437\u043c\u0435\u043d\u044f\u0442\u044c \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e<\/li>\n<\/ul>\n<p>  \u0421\u0430\u043c\u044b\u0439 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043c\u043e\u043a-\u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u2014 \u044d\u0442\u043e jest.fn().<br \/>  \u0421 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043d\u0435\u0433\u043e \u0438 <a href=\"https:\/\/facebook.github.io\/jest\/docs\/en\/expect.html\">Jest Expect<\/a> \u043c\u043e\u0436\u043d\u043e \u043b\u0435\u0433\u043a\u043e \u043f\u0440\u043e\u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u0435\u0440\u0435\u0445\u0432\u0430\u0447\u0435\u043d\u043d\u044b\u0435 \u0432\u044b\u0437\u043e\u0432\u044b:<\/p>\n<pre><code class=\"javascript\">test(\"returns undefined by default\", () => {   const mock = jest.fn();    let result = mock(\"foo\");    expect(result).toBeUndefined();   expect(mock).toHaveBeenCalled();   expect(mock).toHaveBeenCalledTimes(1);   expect(mock).toHaveBeenCalledWith(\"foo\"); });<\/code><\/pre>\n<p>  \u0438 \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435, \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u0438\u043b\u0438 \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u043f\u0440\u043e\u043c\u0438\u0441\u0430:<\/p>\n<pre><code class=\"javascript\">test(\"mock implementation\", () => {   const mock = jest.fn(() => \"bar\");    expect(mock(\"foo\")).toBe(\"bar\");   expect(mock).toHaveBeenCalledWith(\"foo\"); });  test(\"also mock implementation\", () => {   const mock = jest.fn().mockImplementation(() => \"bar\");    expect(mock(\"foo\")).toBe(\"bar\");   expect(mock).toHaveBeenCalledWith(\"foo\"); });  test(\"mock implementation one time\", () => {   const mock = jest.fn().mockImplementationOnce(() => \"bar\");    expect(mock(\"foo\")).toBe(\"bar\");   expect(mock).toHaveBeenCalledWith(\"foo\");    expect(mock(\"baz\")).toBe(undefined);   expect(mock).toHaveBeenCalledWith(\"baz\"); });  test(\"mock return value\", () => {   const mock = jest.fn();   mock.mockReturnValue(\"bar\");    expect(mock(\"foo\")).toBe(\"bar\");   expect(mock).toHaveBeenCalledWith(\"foo\"); });  test(\"mock promise resolution\", () => {   const mock = jest.fn();   mock.mockResolvedValue(\"bar\");    expect(mock(\"foo\")).resolves.toBe(\"bar\");   expect(mock).toHaveBeenCalledWith(\"foo\"); });<\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c, \u043a\u043e\u0433\u0434\u0430 \u043c\u044b \u043f\u043e\u0433\u043e\u0432\u043e\u0440\u0438\u043b\u0438 \u043e \u0442\u043e\u043c, \u0447\u0442\u043e \u0442\u0430\u043a\u043e\u0435 \u043c\u043e\u043a-\u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0438 \u0447\u0442\u043e \u0441 \u0435\u0435 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043c\u043e\u0436\u043d\u043e \u0434\u0435\u043b\u0430\u0442\u044c, \u043f\u0435\u0440\u0435\u0439\u0434\u0435\u043c \u043a \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043d\u0438\u044e \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u0432 \u0435\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f.<\/p>\n<h2>\u0418\u043d\u044a\u0435\u043a\u0446\u0438\u044f \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439<\/h2>\n<p>  \u041e\u0434\u0438\u043d \u0438\u0437 \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0435\u043d\u043d\u044b\u0445 \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u0432 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u043c\u043e\u043a-\u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u2014 \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0430 \u0435\u0435 \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430 \u0442\u0435\u0441\u0442\u0438\u0440\u0443\u0435\u043c\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438. \u042d\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u043e\u0431\u044a\u0435\u043a\u0442 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f, \u0430 \u0437\u0430\u0442\u0435\u043c \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c, \u043a\u0430\u043a \u0431\u044b\u043b \u0432\u044b\u0437\u0432\u0430\u043d \u043c\u043e\u043a \u0438 \u0441 \u043a\u0430\u043a\u0438\u043c\u0438 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430\u043c\u0438:<\/p>\n<pre><code class=\"javascript\">const doAdd = (a, b, callback) => {   callback(a + b); };  test(\"calls callback with arguments added\", () => {   const mockCallback = jest.fn();   doAdd(1, 2, mockCallback);   expect(mockCallback).toHaveBeenCalledWith(3); });<\/code><\/pre>\n<p>  \u042d\u0442\u0430 \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u044f \u0445\u043e\u0440\u043e\u0448\u0430, \u043d\u043e \u043e\u043d\u0430 \u0442\u0440\u0435\u0431\u0443\u0435\u0442, \u0447\u0442\u043e\u0431\u044b \u043a\u043e\u0434 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u043b \u0438\u043d\u044a\u0435\u043a\u0446\u0438\u044e \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439. \u0417\u0430\u0447\u0430\u0441\u0442\u0443\u044e \u044d\u0442\u043e \u043d\u0435 \u0442\u0430\u043a, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043d\u0430\u043c \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u044f\u0442\u0441\u044f \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u044b \u0434\u043b\u044f \u043c\u043e\u043a\u0438\u043d\u0433\u0430 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0445 \u043c\u043e\u0434\u0443\u043b\u0435\u0439 \u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0439.<\/p>\n<h2>\u041c\u043e\u043a\u0438\u043d\u0433 \u043c\u043e\u0434\u0443\u043b\u0435\u0439 \u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0439<\/h2>\n<p>  \u0412 Jest \u0435\u0441\u0442\u044c \u0442\u0440\u0438 \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0445 \u0442\u0438\u043f\u0430 \u043c\u043e\u043a\u0438\u043d\u0433\u0430 \u043c\u043e\u0434\u0443\u043b\u0435\u0439 \u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0439:  <\/p>\n<ul>\n<li>jest.fn: \u0438\u043c\u0438\u0442\u0430\u0446\u0438\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0438<\/li>\n<li>jest.mock: \u0438\u043c\u0438\u0442\u0430\u0446\u0438\u044f \u043c\u043e\u0434\u0443\u043b\u044f<\/li>\n<li>jest.spyOn: \u00ab\u0448\u043f\u0438\u043e\u043d\u0441\u0442\u0432\u043e\u00bb \u0438\u043b\u0438 \u0438\u043c\u0438\u0442\u0430\u0446\u0438\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0438<\/li>\n<\/ul>\n<p>  \u041a\u0430\u0436\u0434\u044b\u0439 \u0438\u0437 \u043d\u0438\u0445 \u0432 \u0442\u043e\u0439 \u0438\u043b\u0438 \u0438\u043d\u043e\u0439 \u0441\u0442\u0435\u043f\u0435\u043d\u0438 \u0441\u043e\u0437\u0434\u0430\u0435\u0442 \u043c\u043e\u043a-\u0444\u0443\u043d\u043a\u0446\u0438\u044e. \u0427\u0442\u043e\u0431\u044b \u043e\u0431\u044a\u044f\u0441\u043d\u0438\u0442\u044c, \u043a\u0430\u043a \u043a\u0430\u0436\u0434\u044b\u0439 \u0438\u0437 \u043d\u0438\u0445 \u044d\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442, \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u043f\u0440\u043e\u0435\u043a\u0442\u0430:<\/p>\n<pre><code class=\"javascript\">\u251c example\/ | \u2514\u2500\u2500 app.js | \u2514\u2500\u2500 app.test.js | \u2514\u2500\u2500 math.js<\/code><\/pre>\n<p>  \u0412 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043e\u0431\u044b\u0447\u043d\u043e \u0442\u0435\u0441\u0442\u0438\u0440\u0443\u044e\u0442 app.js \u0438 \u0445\u043e\u0442\u044f\u0442 \u043b\u0438\u0431\u043e \u043d\u0435 \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c \u0444\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 math.js, \u043b\u0438\u0431\u043e \u0448\u043f\u0438\u043e\u043d\u0438\u0442\u044c \u0437\u0430 \u043d\u0438\u043c\u0438, \u0447\u0442\u043e\u0431\u044b \u0443\u0431\u0435\u0434\u0438\u0442\u044c\u0441\u044f, \u0447\u0442\u043e \u043e\u043d\u0438 \u0432\u044b\u0437\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u0442\u0430\u043a, \u043a\u0430\u043a \u043e\u0436\u0438\u0434\u0430\u0435\u0442\u0441\u044f. \u042d\u0442\u043e\u0442 \u043f\u0440\u0438\u043c\u0435\u0440 \u0431\u0430\u043d\u0430\u043b\u0435\u043d, \u043d\u043e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u044c\u0442\u0435, \u0447\u0442\u043e math.js \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043e\u0431\u043e\u0439 \u0441\u043b\u043e\u0436\u043d\u043e\u0435 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0435 \u0438\u043b\u0438 \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439 \u0432\u0432\u043e\u0434\u0430-\u0432\u044b\u0432\u043e\u0434\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0432\u044b \u0445\u043e\u0442\u0438\u0442\u0435 \u0438\u0437\u0431\u0435\u0436\u0430\u0442\u044c:<\/p>\n<pre><code class=\"javascript\">export const add      = (a, b) => a + b; export const subtract = (a, b) => b - a; export const multiply = (a, b) => a * b; export const divide   = (a, b) => b \/ a;<\/code><\/pre>\n<pre><code class=\"javascript\">import * as math from '.\/math.js';  export const doAdd      = (a, b) => math.add(a, b); export const doSubtract = (a, b) => math.subtract(a, b); export const doMultiply = (a, b) => math.multiply(a, b); export const doDivide   = (a, b) => math.divide(a, b);<\/code><\/pre>\n<h2>\u041c\u043e\u043a\u0438\u043d\u0433 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e jest.fn<\/h2>\n<p>  \u0411\u0430\u0437\u043e\u0432\u0430\u044f \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u044f \u043c\u043e\u043a\u0438\u043d\u0433\u0430 \u2014 \u043f\u0435\u0440\u0435\u043d\u0430\u0437\u043d\u0430\u0447\u0438\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u043d\u0430 \u043c\u043e\u043a-\u0444\u0443\u043d\u043a\u0446\u0438\u044e. \u041f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u0432\u0435\u0437\u0434\u0435, \u0433\u0434\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u043f\u0435\u0440\u0435\u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u043d\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u0432\u043c\u0435\u0441\u0442\u043e \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c\u0441\u044f \u043c\u043e\u043a:<\/p>\n<pre><code class=\"javascript\">import * as app from \".\/app\"; import * as math from \".\/math\";  math.add = jest.fn(); math.subtract = jest.fn();  test(\"calls math.add\", () => {   app.doAdd(1, 2);   expect(math.add).toHaveBeenCalledWith(1, 2); });  test(\"calls math.subtract\", () => {   app.doSubtract(1, 2);   expect(math.subtract).toHaveBeenCalledWith(1, 2); });<\/code><\/pre>\n<p>  \u042d\u0442\u043e\u0442 \u0442\u0438\u043f \u043c\u043e\u043a\u0438\u043d\u0433\u0430 \u0432\u0441\u0442\u0440\u0435\u0447\u0430\u0435\u0442\u0441\u044f \u0440\u0435\u0436\u0435 \u043f\u043e \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u043c \u043f\u0440\u0438\u0447\u0438\u043d\u0430\u043c:  <\/p>\n<ul>\n<li><code>jest.mock<\/code> \u0434\u0435\u043b\u0430\u0435\u0442 \u044d\u0442\u043e \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0434\u043b\u044f \u0432\u0441\u0435\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0432 \u043c\u043e\u0434\u0443\u043b\u0435<\/li>\n<li><code>jest.spyOn<\/code> \u0434\u0435\u043b\u0430\u0435\u0442 \u0442\u043e \u0436\u0435 \u0441\u0430\u043c\u043e\u0435, \u043d\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0432\u043e\u0441\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0438\u0441\u0445\u043e\u0434\u043d\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e<\/li>\n<\/ul>\n<p>  <\/p>\n<h2>\u041c\u043e\u043a\u0438\u043d\u0433 \u043c\u043e\u0434\u0443\u043b\u044f \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e jest.mock<\/h2>\n<p>  \u0411\u043e\u043b\u0435\u0435 \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0435\u043d\u043d\u044b\u043c \u043f\u043e\u0434\u0445\u043e\u0434\u043e\u043c \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435<code> jest.mock<\/code> \u0434\u043b\u044f \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 \u0432\u0441\u0435\u0445 \u044d\u043a\u0441\u043f\u043e\u0440\u0442\u043e\u0432 \u043c\u043e\u0434\u0443\u043b\u044f \u0432 \u043c\u043e\u043a-\u0444\u0443\u043d\u043a\u0446\u0438\u044e. \u0422\u0430\u043a, \u0432\u044b\u0437\u043e\u0432 <code>jest.mock('.\/math.js');<\/code> \u043f\u043e \u0441\u0443\u0442\u0438, \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442 <code>math.js<\/code> \u0432:<\/p>\n<pre><code class=\"javascript\">export const add      = jest.fn(); export const subtract = jest.fn(); export const multiply = jest.fn(); export const divide   = jest.fn();<\/code><\/pre>\n<p>  \u041c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043b\u044e\u0431\u0443\u044e \u0438\u0437 \u0432\u044b\u0448\u0435\u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0435\u043d\u043d\u044b\u0445 \u0444\u0438\u0447\u0435\u0439 \u043c\u043e\u043a-\u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0434\u043b\u044f \u0432\u0441\u0435\u0445 \u044d\u043a\u0441\u043f\u043e\u0440\u0442\u043e\u0432 \u043c\u043e\u0434\u0443\u043b\u044f:<\/p>\n<pre><code class=\"javascript\">import * as app from \".\/app\"; import * as math from \".\/math\";  \/\/ \u0423\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043c \u0434\u043b\u044f \u0432\u0441\u0435\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u043c\u043e\u0434\u0443\u043b\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 jest.fn jest.mock(\".\/math.js\");  test(\"calls math.add\", () => {   app.doAdd(1, 2);   expect(math.add).toHaveBeenCalledWith(1, 2); });  test(\"calls math.subtract\", () => {   app.doSubtract(1, 2);   expect(math.subtract).toHaveBeenCalledWith(1, 2); });<\/code><\/pre>\n<p>  \u042d\u0442\u043e \u0441\u0430\u043c\u0430\u044f \u043f\u0440\u043e\u0441\u0442\u0430\u044f \u0438 \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0435\u043d\u043d\u0430\u044f \u0444\u043e\u0440\u043c\u0430 \u043c\u043e\u043a\u0438\u043d\u0433\u0430, \u0438 \u044d\u0442\u043e \u0442\u043e\u0442 \u0442\u0438\u043f \u043c\u043e\u043a\u0438\u043d\u0433\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 Jest \u0434\u0435\u043b\u0430\u0435\u0442 \u0437\u0430 \u0432\u0430\u0441 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <code>automock: true<\/code>.<\/p>\n<p>  \u0415\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u043c \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043a\u043e\u043c \u044d\u0442\u043e\u0439 \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u0438 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0442\u0440\u0443\u0434\u043d\u043e\u0434\u043e\u0441\u0442\u0443\u043f\u043d\u043e\u0441\u0442\u044c \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u044c\u043d\u043e\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043c\u043e\u0434\u0443\u043b\u044f. \u0414\u043b\u044f \u0442\u0430\u043a\u0438\u0445 \u0441\u043b\u0443\u0447\u0430\u0435\u0432 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <code>spyOn<\/code>.<\/p>\n<h2>\u0428\u043f\u0438\u043e\u043d\u0441\u0442\u0432\u043e \u0438\u043b\u0438 \u043c\u043e\u043a\u0438\u043d\u0433 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e jest.spyOn<\/h2>\n<p>  \u0418\u043d\u043e\u0433\u0434\u0430 \u0432\u044b \u0445\u043e\u0442\u0438\u0442\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0430\u0431\u043b\u044e\u0434\u0430\u0442\u044c \u0437\u0430 \u0432\u044b\u0437\u043e\u0432\u043e\u043c \u043c\u0435\u0442\u043e\u0434\u0430, \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u044f \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u0435\u0433\u043e \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u044c\u043d\u0443\u044e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e. \u0412 \u0434\u0440\u0443\u0433\u0438\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445 \u0432\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u0432\u0435\u0441\u0442\u0438 \u043c\u043e\u043a\u0438\u043d\u0433 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438, \u043d\u043e \u0432\u043e\u0441\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u043f\u043e\u0437\u0436\u0435 \u0432 \u043d\u0430\u0431\u043e\u0440\u0435.<\/p>\n<p>  \u0412 \u044d\u0442\u0438\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <code>jest.spyOn<\/code>.<\/p>\n<p>  \u0417\u0434\u0435\u0441\u044c \u043c\u044b \u043f\u0440\u043e\u0441\u0442\u043e \u00ab\u0448\u043f\u0438\u043e\u043d\u0438\u043c\u00bb \u0437\u0430 \u0432\u044b\u0437\u043e\u0432\u0430\u043c\u0438 \u043c\u0430\u0442\u0435\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u043d\u043e \u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u043c \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u044c\u043d\u0443\u044e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u043d\u0430 \u043c\u0435\u0441\u0442\u0435:<\/p>\n<pre><code class=\"javascript\">import * as app from \".\/app\"; import * as math from \".\/math\";  test(\"calls math.add\", () => {   const addMock = jest.spyOn(math, \"add\");  \/\/ \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u044c\u043d\u0443\u044e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e   expect(app.doAdd(1, 2)).toEqual(3);  \/\/ \u0430 \u0448\u043f\u0438\u043e\u043d \u0445\u0440\u0430\u043d\u0438\u0442 \u0432\u044b\u0437\u043e\u0432\u044b \u0434\u043b\u044f \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f   expect(addMock).toHaveBeenCalledWith(1, 2); });<\/code><\/pre>\n<p>  \u042d\u0442\u043e \u043f\u043e\u043b\u0435\u0437\u043d\u043e \u0432 \u0440\u044f\u0434\u0435 \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0435\u0432, \u043a\u043e\u0433\u0434\u0430 \u0432\u044b \u0445\u043e\u0442\u0438\u0442\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c, \u0447\u0442\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0435 \u043f\u043e\u0431\u043e\u0447\u043d\u044b\u0435 \u044d\u0444\u0444\u0435\u043a\u0442\u044b \u0438\u043c\u0435\u044e\u0442 \u043c\u0435\u0441\u0442\u043e, \u043d\u0435 \u0437\u0430\u043c\u0435\u043d\u044f\u044f \u0438\u0445 \u043d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435.<\/p>\n<p>  \u0412 \u0434\u0440\u0443\u0433\u0438\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445 \u0432\u0430\u043c \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f \u0438\u043c\u0438\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044e, \u043d\u043e \u0437\u0430\u0442\u0435\u043c \u0432\u043e\u0441\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0438\u0441\u0445\u043e\u0434\u043d\u0443\u044e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e:<\/p>\n<pre><code class=\"javascript\">import * as app from \".\/app\"; import * as math from \".\/math\";  test(\"calls math.add\", () => {   const addMock = jest.spyOn(math, \"add\");  \/\/ \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e   addMock.mockImplementation(() => \"mock\");   expect(app.doAdd(1, 2)).toEqual(\"mock\");   \/\/ \u0432\u043e\u0441\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u0438\u0441\u0445\u043e\u0434\u043d\u0443\u044e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e   addMock.mockRestore();   expect(app.doAdd(1, 2)).toEqual(3); });<\/code><\/pre>\n<p>  \u042d\u0442\u043e \u043f\u043e\u043b\u0435\u0437\u043d\u043e \u0434\u043b\u044f \u0442\u0435\u0441\u0442\u043e\u0432 \u0432 \u043e\u0434\u043d\u043e\u043c \u0444\u0430\u0439\u043b\u0435, \u043d\u043e \u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u0434\u0435\u043b\u0430\u0442\u044c \u0432 <code>afterAll<\/code> \u0445\u0443\u043a\u0435, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043a\u0430\u0436\u0434\u044b\u0439 \u0444\u0430\u0439\u043b \u0442\u0435\u0441\u0442\u0430 \u0432 Jest \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0432 \u043f\u0435\u0441\u043e\u0447\u043d\u0438\u0446\u0435.<\/p>\n<p>  \u0413\u043b\u0430\u0432\u043d\u043e\u0435, \u0447\u0442\u043e \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u043c\u043d\u0438\u0442\u044c \u043e <code>jest.spyOn<\/code>, \u2014 \u0442\u0430\u043a \u044d\u0442\u043e \u0442\u043e, \u0447\u0442\u043e \u044d\u0442\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u0441\u0430\u0445\u0430\u0440 \u0434\u043b\u044f \u0431\u0430\u0437\u043e\u0432\u043e\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f <code>jest.fn()<\/code>. \u041c\u043e\u0436\u043d\u043e \u0434\u043e\u0441\u0442\u0438\u0447\u044c \u0442\u043e\u0439 \u0436\u0435 \u0446\u0435\u043b\u0438, \u0435\u0441\u043b\u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u044c\u043d\u0443\u044e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e, \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u043c\u043e\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u044c\u043d\u0443\u044e \u0438 \u043f\u0435\u0440\u0435\u043d\u0430\u0437\u043d\u0430\u0447\u0438\u0442\u044c \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u044c\u043d\u0443\u044e \u043f\u043e\u0437\u0436\u0435:<\/p>\n<pre><code class=\"javascript\">import * as app from \".\/app\"; import * as math from \".\/math\";  test(\"calls math.add\", () => { \/\/ \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u043c \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u044c\u043d\u0443\u044e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e   const originalAdd = math.add;  \/\/ \u0438\u043c\u0438\u0442\u0438\u0440\u0443\u0435\u043c add \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u044c\u043d\u043e\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438   math.add = jest.fn(originalAdd);   \/\/ \u0448\u043f\u0438\u043e\u043d\u0438\u043c \u0437\u0430 \u0432\u044b\u0437\u043e\u0432\u0430\u043c\u0438 add   expect(app.doAdd(1, 2)).toEqual(3);   expect(math.add).toHaveBeenCalledWith(1, 2);   \/\/ \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e   math.add.mockImplementation(() => \"mock\");   expect(app.doAdd(1, 2)).toEqual(\"mock\");   expect(math.add).toHaveBeenCalledWith(1, 2);  \/\/ \u0432\u043e\u0441\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u0438\u0441\u0445\u043e\u0434\u043d\u0443\u044e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e   math.add = originalAdd;   expect(app.doAdd(1, 2)).toEqual(3); });<\/code><\/pre>\n<p>  \u0424\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438, \u0438\u043c\u0435\u043d\u043d\u043e \u0442\u0430\u043a <a href=\"https:\/\/github.com\/facebook\/jest\/blob\/e9aa321e0587d0990bd2b5ca5065e84a1aecb2fa\/packages\/jest-mock\/src\/index.js#L674-L708\">\u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d<\/a> <code>jest.spyOn<\/code>.<\/p>\n<h2>\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/h2>\n<p>  \u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043c\u044b \u0443\u0437\u043d\u0430\u043b\u0438 \u043e \u043c\u043e\u043a-\u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0438 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u044f\u0445 \u043f\u0435\u0440\u0435\u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043c\u043e\u0434\u0443\u043b\u0435\u0439 \u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0434\u043b\u044f \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u043d\u0438\u044f \u0432\u044b\u0437\u043e\u0432\u043e\u0432, \u0437\u0430\u043c\u0435\u043d\u044b \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0439 \u0438 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u044b\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439.<br \/>  \u041d\u0430\u0434\u0435\u044e\u0441\u044c, \u0432\u044b \u0441\u0442\u0430\u043b\u0438 \u043b\u0443\u0447\u0448\u0435 \u043f\u043e\u043d\u0438\u043c\u0430\u0442\u044c Jest mocks, \u0438 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0442\u0435\u0441\u0442\u043e\u0432 \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u0445\u043e\u0434\u0438\u0442\u044c \u043b\u0435\u0433\u0447\u0435. \u0427\u0442\u043e\u0431\u044b \u0443\u0437\u043d\u0430\u0442\u044c \u0431\u043e\u043b\u044c\u0448\u0435 \u043e \u043c\u043e\u043a\u0438\u043d\u0433\u0435, \u043e\u0437\u043d\u0430\u043a\u043e\u043c\u044c\u0442\u0435\u0441\u044c \u0441 700+ \u0441\u043b\u0430\u0439\u0434\u043e\u0432\u044b\u043c <a href=\"https:\/\/www.youtube.com\/watch?v=Af4M8GMoxi4\">\u0434\u043e\u043a\u043b\u0430\u0434\u043e\u043c<\/a> \u043f\u043e\u0434 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435\u043c Don&#8217;t Mock Me \u043e\u0442 Justin Searles.<\/p>\n<p>  <a href=\"https:\/\/otus.pw\/w3xC\/\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/qt\/mz\/yf\/qtmzyfwkrn1snee-zgcykifv7yq.png\" data-src=\"https:\/\/habrastorage.org\/webt\/qt\/mz\/yf\/qtmzyfwkrn1snee-zgcykifv7yq.png\"\/><\/a><\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/788004\/\"> https:\/\/habr.com\/ru\/articles\/788004\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-1\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/fq\/s6\/q7\/fqs6q73h2ntilxglk5ouaz5ccp4.png\" data-src=\"https:\/\/habrastorage.org\/webt\/fq\/s6\/q7\/fqs6q73h2ntilxglk5ouaz5ccp4.png\"\/><\/p>\n<p>  \u041c\u043e\u043a\u0438\u043d\u0433 \u2014 \u044d\u0442\u043e \u0442\u0435\u0445\u043d\u0438\u043a\u0430 \u0438\u0437\u043e\u043b\u044f\u0446\u0438\u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043f\u0443\u0442\u0435\u043c \u0437\u0430\u043c\u0435\u043d\u044b \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439 \u043e\u0431\u044a\u0435\u043a\u0442\u0430\u043c\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c \u0438 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c. \u0417\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044c\u044e \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0432\u0441\u0451, \u043e\u0442 \u0447\u0435\u0433\u043e \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0431\u044a\u0435\u043a\u0442, \u043d\u043e \u043e\u0431\u044b\u0447\u043d\u043e \u044d\u0442\u043e \u043c\u043e\u0434\u0443\u043b\u044c, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u0431\u044a\u0435\u043a\u0442 \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u0442.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-365952","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/365952","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=365952"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/365952\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=365952"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=365952"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=365952"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}