{"id":346892,"date":"2023-03-17T15:00:26","date_gmt":"2023-03-17T15:00:26","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=346892"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=346892","title":{"rendered":"<span>\u0422\u0435\u0441\u0442\u0438\u0440\u0443\u0439\u0442\u0435 API, \u043a\u0430\u043a \u043f\u0440\u043e\u0444\u0435\u0441\u0438\u043e\u043d\u0430\u043b. \u0427\u0430\u0441\u0442\u044c 2: \u041a\u0430\u043a \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c API \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e &#8216;cypress-plugin-api&#8217;<\/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-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p><a href=\"https:\/\/github.com\/filiphric\/cypress-plugin-api?ref=cypress-blog\"><u>cypress-plugin-api<\/u><\/a>, \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0439 \u0430\u043c\u0431\u0430\u0441\u0441\u0430\u0434\u043e\u0440\u043e\u043c Cypress <a href=\"https:\/\/github.com\/filiphric?ref=cypress-blog\"><u>\u0424\u0438\u043b\u0438\u043f\u043e\u043c \u0425\u0440\u0438\u043a\u043e\u043c<\/u><\/a> (Filip Hric), \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043e\u0431\u043e\u0439 \u043f\u043b\u0430\u0433\u0438\u043d \u0434\u043b\u044f \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e\u0433\u043e \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f API. \u041f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u044c\u0442\u0435 \u0441\u0435\u0431\u0435 Postman, \u043d\u043e \u0432 Cypress; \u044d\u0442\u043e\u0442 \u043f\u043b\u0430\u0433\u0438\u043d \u0432\u044b\u0432\u043e\u0434\u0438\u0442 \u043d\u0430 \u043f\u0435\u0447\u0430\u0442\u044c \u0432\u0441\u044e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u0432\u044b\u0437\u043e\u0432\u0435 API \u0432 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u043e\u043c \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f Cypress, \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0432\u0430\u044f \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432:<\/p>\n<ul>\n<li>\n<p>\u0412 <code>cypress-plugin-api<\/code> \u043a\u043e\u043c\u0430\u043d\u0434\u0430 <code>cy.api()<\/code> \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0442\u0430\u043a\u0436\u0435 \u043a\u0430\u043a <code>cy.request()<\/code>. \u041e\u0441\u043d\u043e\u0432\u043d\u043e\u0435 \u043e\u0442\u043b\u0438\u0447\u0438\u0435 \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u043f\u043e\u043c\u0438\u043c\u043e \u0432\u044b\u0437\u043e\u0432\u0430 \u0432\u0430\u0448\u0435\u0433\u043e API, <code>cy.api()<\/code> \u0442\u0430\u043a\u0436\u0435 \u043f\u0435\u0447\u0430\u0442\u0430\u0435\u0442 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u0432\u044b\u0437\u043e\u0432\u0435 API \u0432 \u0432\u0430\u0448\u0435\u043c Cypress Test Runner.<\/p>\n<\/li>\n<li>\n<p>\u0412\u0441\u044e \u044d\u0442\u0443 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0432 \u0432\u0438\u0434\u0435 <a href=\"https:\/\/docs.cypress.io\/guides\/core-concepts\/cypress-app?ref=cypress-blog#Time-traveling\"><u>time-travel<\/u><\/a> (\u0440\u0435\u0432\u0435\u0440\u0441\u0438\u0432\u043d\u0430\u044f \u043e\u0442\u043b\u0430\u0434\u043a\u0430) snapshots.<\/p>\n<\/li>\n<li>\n<p>\u0422\u0430\u043a\u0436\u0435 \u0444\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u043f\u0440\u043e\u0441\u0442\u0430\u044f \u0442\u0430\u0431\u043b\u0438\u0446\u0430 \u0434\u043b\u044f \u043f\u0440\u043e\u0441\u043c\u043e\u0442\u0440\u0430 \u0444\u0430\u0439\u043b\u043e\u0432 cookie, \u0441\u0432\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u043d\u0438\u044f \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u0434\u0430\u043d\u043d\u044b\u0445 JSON \u0438 \u043c\u0430\u0441\u0441\u0438\u0432\u0430, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0446\u0432\u0435\u0442\u043e\u0432\u043e\u0433\u043e \u043a\u043e\u0434\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u0432 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u043e\u0433\u043e \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430 \u0438 \u043d\u0430 \u0442\u0430\u0439\u043c\u043b\u0430\u0439\u043d\u0435 (\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u0448\u043a\u0430\u043b\u0435)<\/p>\n<\/li>\n<\/ul>\n<p><em>\u0421\u0430\u043c\u043e\u0435 \u0432\u0430\u0436\u043d\u043e\u0435:<\/em> <code>cy.api()<\/code> \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 <code>cy.request()<\/code> \u0432 \u0444\u043e\u043d\u043e\u0432\u043e\u043c \u0440\u0435\u0436\u0438\u043c\u0435. \u042d\u0442\u043e \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e \u0432\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0435 \u0442\u0443 \u0436\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u043f\u043b\u044e\u0441 \u0432\u0438\u0437\u0443\u0430\u043b\u044c\u043d\u044b\u0439 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0439 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441!<\/p>\n<h3>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0432\u043c\u0435\u0441\u0442\u0435 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043c \u043f\u043b\u0430\u0433\u0438\u043d cypress-plugin-api\u00a0<\/h3>\n<p><strong>\u0428\u0430\u0433 1<\/strong><\/p>\n<p>\u0423\u0441\u0442\u043d\u043e\u0432\u0438\u0442\u0435 <a href=\"https:\/\/github.com\/filiphric\/cypress-plugin-api?ref=cypress-blog\"><u>\u043f\u043b\u0430\u0433\u0438\u043d, <\/u><\/a>\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f npm \u0438\u043b\u0438 yarn.<\/p>\n<pre><code>npm i cypress-plugin-api # or yarn add cypress-plugin-api<\/code><\/pre>\n<p>\u041f\u043e\u0441\u043b\u0435 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 \u043f\u043b\u0430\u0433\u0438\u043d\u0430 API \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0443\u0432\u0438\u0434\u0435\u0442\u044c \u0435\u0433\u043e \u0432 \u0444\u0430\u0439\u043b\u0435 package.json:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/347\/111\/98f\/34711198fa40503daaa053a8ad07e4e9.png\" alt=\"\" title=\"\" width=\"655\" height=\"571\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/347\/111\/98f\/34711198fa40503daaa053a8ad07e4e9.png\"\/><\/figure>\n<p><strong>\u0428\u0430\u0433 2<\/strong><\/p>\n<p>\u0414\u0430\u043b\u0435\u0435 \u0434\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u043f\u043b\u0430\u0433\u0438\u043d\u00a0 <code>cypress\/support\/e2e.js<\/code> \u0432 \u0444\u0430\u0439\u043b:<\/p>\n<pre><code>import 'cypress-plugin-api' \/\/ or require('cypress-plugin-api')<\/code><\/pre>\n<p>\u0412\u0430\u0448\u0438 e2e.js \u0444\u0430\u0439\u043b\u044b \u0431\u0443\u0434\u0443\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0442\u0430\u043a:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/68d\/c57\/8f1\/68dc578f163ce4e6c52c1a20116c7005.png\" alt=\"\" title=\"\" width=\"668\" height=\"558\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/68d\/c57\/8f1\/68dc578f163ce4e6c52c1a20116c7005.png\"\/><\/figure>\n<p><strong>\u0428\u0430\u0433 3<\/strong><\/p>\n<p>\u0421\u043e\u0437\u0434\u0430\u0439\u0442\u0435 \u043f\u043b\u0430\u0433\u0438\u043d <code>cypress_plugin_api.cy.js<\/code> \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043c\u0435\u0442\u043e\u0434\u043e\u0432 (GET, POST, PUT, DELETE).<\/p>\n<p>\u0414\u043b\u044f \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u043e\u0431\u0437\u043e\u0440\u0430 \u044f \u0431\u0435\u0440\u0443 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u044b \u043c\u0435\u0442\u043e\u0434\u043e\u0432 API \u0438\u0437 \u044d\u0442\u043e\u0433\u043e \u0440\u0435\u0441\u0443\u0440\u0441\u0430: <a href=\"https:\/\/reqres.in\/\"><u>https:\/\/reqres.in\/<\/u><\/a>.<\/p>\n<p><strong>GET \u0417\u0430\u043f\u0440\u043e\u0441<\/strong><\/p>\n<pre><code>it(\"GET API testing Using Cypress API Plugin\", () => {  cy.api(\"GET\", \"https:\/\/reqres.in\/api\/users?page=2\").should((response) => {    expect(response.status).to.eq(200);  }); });<\/code><\/pre>\n<p><strong>POST \u0417\u0430\u043f\u0440\u043e\u0441<\/strong><\/p>\n<pre><code>it(\"POST API testing Using Cypress API Plugin\", () => {  cy.api(\"POST\", \"https:\/\/reqres.in\/api\/users\", {    name: \"morpheus\",    job: \"leader\",  }).should((response) => {    expect(response.status).to.eq(201);  }); });<\/code><\/pre>\n<p><strong>PUT \u0417\u0430\u043f\u0440\u043e\u0441<\/strong><\/p>\n<pre><code>it(\"PUT API testing Using Cypress API Plugin\", () => {  cy.api(\"PUT\", \"https:\/\/reqres.in\/api\/users\/2\", {    name: \"morpheus\",    job: \"zion resident\",  }).should((response) => {    expect(response.status).to.eq(200);  }); });<\/code><\/pre>\n<p><strong>DELETE \u0417\u0430\u043f\u0440\u043e\u0441<\/strong><\/p>\n<pre><code>it(\"DELETE API testing Using Cypress API Plugin\", () => {  cy.api(\"DELETE\", \"https:\/\/reqres.in\/api\/users\/2\").should((response) => {    expect(response.status).to.eq(204);  }); });<\/code><\/pre>\n<h3>\u041e\u0442\u0447\u0435\u0442 \u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0438 \u0442\u0435\u0441\u0442\u043e\u0432\u043e\u0433\u043e \u043a\u0435\u0439\u0441\u0430 API<\/h3>\n<p>\u041d\u0430 \u0441\u043a\u0440\u0438\u043d\u0448\u043e\u0442\u0435 \u043d\u0438\u0436\u0435 \u043c\u044b \u0432\u0438\u0434\u0438\u043c \u0434\u0430\u043d\u043d\u044b\u0435 Body, Response, Headers \u0438 Cookies, \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u043d\u044b\u0435 \u0432 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u043e\u043c \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f Cypress. \u0420\u0430\u043d\u0435\u0435 \u0434\u043b\u044f \u043f\u0440\u043e\u0441\u043c\u043e\u0442\u0440\u0430 \u044d\u0442\u043e\u0439 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043d\u0430\u043c \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u043b\u043e\u0441\u044c \u043d\u0430\u0436\u0438\u043c\u0430\u0442\u044c \u043d\u0430 \u043a\u043d\u043e\u043f\u043a\u0443 &#8216;inspect&#8217;, \u043d\u043e \u0442\u0435\u043f\u0435\u0440\u044c \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0439 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043d\u0430\u043c \u043b\u0435\u0433\u043a\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043a \u043d\u0435\u0439 \u0434\u043e\u0441\u0442\u0443\u043f.<\/p>\n<p><strong>GET \u0417\u0430\u043f\u0440\u043e\u0441<\/strong><\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/99d\/a73\/4af\/99da734afd9b242beed66eb484ef5d2f.png\" width=\"1600\" height=\"706\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/99d\/a73\/4af\/99da734afd9b242beed66eb484ef5d2f.png\"\/><\/figure>\n<p><strong>POST \u0417\u0430\u043f\u0440\u043e\u0441<\/strong><\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/1ed\/bb9\/798\/1edbb97989cdb51f6f0ebc5c061d4969.png\" width=\"1600\" height=\"717\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/1ed\/bb9\/798\/1edbb97989cdb51f6f0ebc5c061d4969.png\"\/><\/figure>\n<p><strong>PUT \u0417\u0430\u043f\u0440\u043e\u0441<\/strong><\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/524\/3a2\/43a\/5243a243a34880bc546e2fdb1e0f14cb.png\" width=\"1600\" height=\"727\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/524\/3a2\/43a\/5243a243a34880bc546e2fdb1e0f14cb.png\"\/><\/figure>\n<p><strong>DELETE \u0417\u0430\u043f\u0440\u043e\u0441<\/strong><\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/8c1\/c99\/3dd\/8c1c993ddc7b15b59bc529204c35b024.png\" width=\"1600\" height=\"717\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/8c1\/c99\/3dd\/8c1c993ddc7b15b59bc529204c35b024.png\"\/><\/figure>\n<p>\u0412 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u0435 \u043f\u0440\u0438\u0433\u043b\u0430\u0448\u0430\u0435\u043c \u0432\u0441\u0435\u0445 \u0436\u0435\u043b\u0430\u044e\u0449\u0438\u0445 \u043d\u0430 \u043e\u0442\u043a\u0440\u044b\u0442\u044b\u0439 \u0443\u0440\u043e\u043a \u00ab\u0410\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0430\u0446\u0438\u044f API + \u0443\u0434\u043e\u0431\u043d\u044b\u0435 \u043e\u0442\u0447\u0435\u0442\u044b\u00bb, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0440\u043e\u0439\u0434\u0435\u0442 24 \u043c\u0430\u0440\u0442\u0430 \u0432 \u043f\u0440\u0435\u0434\u0434\u0432\u0435\u0440\u0438\u0438 \u0441\u0442\u0430\u0440\u0442\u0430 \u043a\u0443\u0440\u0441\u0430 &#171;JavaScript QA Engineer&#187;. <\/p>\n<ul>\n<li>\n<p><a href=\"https:\/\/otus.pw\/pq4C\/\">\u0417\u0430\u043f\u0438\u0441\u0430\u0442\u044c\u0441\u044f \u043d\u0430 \u0431\u0435\u0441\u043f\u043b\u0430\u0442\u043d\u044b\u0439 \u0443\u0440\u043e\u043a<\/a><\/p>\n<\/li>\n<\/ul>\n<\/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\/company\/otus\/blog\/723182\/\"> https:\/\/habr.com\/ru\/company\/otus\/blog\/723182\/<\/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-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p><a href=\"https:\/\/github.com\/filiphric\/cypress-plugin-api?ref=cypress-blog\"><u>cypress-plugin-api<\/u><\/a>, \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0439 \u0430\u043c\u0431\u0430\u0441\u0441\u0430\u0434\u043e\u0440\u043e\u043c Cypress <a href=\"https:\/\/github.com\/filiphric?ref=cypress-blog\"><u>\u0424\u0438\u043b\u0438\u043f\u043e\u043c \u0425\u0440\u0438\u043a\u043e\u043c<\/u><\/a> (Filip Hric), \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043e\u0431\u043e\u0439 \u043f\u043b\u0430\u0433\u0438\u043d \u0434\u043b\u044f \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e\u0433\u043e \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f API. \u041f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u044c\u0442\u0435 \u0441\u0435\u0431\u0435 Postman, \u043d\u043e \u0432 Cypress; \u044d\u0442\u043e\u0442 \u043f\u043b\u0430\u0433\u0438\u043d \u0432\u044b\u0432\u043e\u0434\u0438\u0442 \u043d\u0430 \u043f\u0435\u0447\u0430\u0442\u044c \u0432\u0441\u044e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u0432\u044b\u0437\u043e\u0432\u0435 API \u0432 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u043e\u043c \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f Cypress, \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0432\u0430\u044f \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432:<\/p>\n<ul>\n<li>\n<p>\u0412 <code>cypress-plugin-api<\/code> \u043a\u043e\u043c\u0430\u043d\u0434\u0430 <code>cy.api()<\/code> \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0442\u0430\u043a\u0436\u0435 \u043a\u0430\u043a <code>cy.request()<\/code>. \u041e\u0441\u043d\u043e\u0432\u043d\u043e\u0435 \u043e\u0442\u043b\u0438\u0447\u0438\u0435 \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u043f\u043e\u043c\u0438\u043c\u043e \u0432\u044b\u0437\u043e\u0432\u0430 \u0432\u0430\u0448\u0435\u0433\u043e API, <code>cy.api()<\/code> \u0442\u0430\u043a\u0436\u0435 \u043f\u0435\u0447\u0430\u0442\u0430\u0435\u0442 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u0432\u044b\u0437\u043e\u0432\u0435 API \u0432 \u0432\u0430\u0448\u0435\u043c Cypress Test Runner.<\/p>\n<\/li>\n<li>\n<p>\u0412\u0441\u044e \u044d\u0442\u0443 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0432 \u0432\u0438\u0434\u0435 <a href=\"https:\/\/docs.cypress.io\/guides\/core-concepts\/cypress-app?ref=cypress-blog#Time-traveling\"><u>time-travel<\/u><\/a> (\u0440\u0435\u0432\u0435\u0440\u0441\u0438\u0432\u043d\u0430\u044f \u043e\u0442\u043b\u0430\u0434\u043a\u0430) snapshots.<\/p>\n<\/li>\n<li>\n<p>\u0422\u0430\u043a\u0436\u0435 \u0444\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u043f\u0440\u043e\u0441\u0442\u0430\u044f \u0442\u0430\u0431\u043b\u0438\u0446\u0430 \u0434\u043b\u044f \u043f\u0440\u043e\u0441\u043c\u043e\u0442\u0440\u0430 \u0444\u0430\u0439\u043b\u043e\u0432 cookie, \u0441\u0432\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u043d\u0438\u044f \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u0434\u0430\u043d\u043d\u044b\u0445 JSON \u0438 \u043c\u0430\u0441\u0441\u0438\u0432\u0430, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0446\u0432\u0435\u0442\u043e\u0432\u043e\u0433\u043e \u043a\u043e\u0434\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u0432 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u043e\u0433\u043e \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430 \u0438 \u043d\u0430 \u0442\u0430\u0439\u043c\u043b\u0430\u0439\u043d\u0435 (\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u0448\u043a\u0430\u043b\u0435)<\/p>\n<\/li>\n<\/ul>\n<p><em>\u0421\u0430\u043c\u043e\u0435 \u0432\u0430\u0436\u043d\u043e\u0435:<\/em> <code>cy.api()<\/code> \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 <code>cy.request()<\/code> \u0432 \u0444\u043e\u043d\u043e\u0432\u043e\u043c \u0440\u0435\u0436\u0438\u043c\u0435. \u042d\u0442\u043e \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e \u0432\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0435 \u0442\u0443 \u0436\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u043f\u043b\u044e\u0441 \u0432\u0438\u0437\u0443\u0430\u043b\u044c\u043d\u044b\u0439 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0439 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441!<\/p>\n<h3>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0432\u043c\u0435\u0441\u0442\u0435 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043c \u043f\u043b\u0430\u0433\u0438\u043d cypress-plugin-api\u00a0<\/h3>\n<p><strong>\u0428\u0430\u0433 1<\/strong><\/p>\n<p>\u0423\u0441\u0442\u043d\u043e\u0432\u0438\u0442\u0435 <a href=\"https:\/\/github.com\/filiphric\/cypress-plugin-api?ref=cypress-blog\"><u>\u043f\u043b\u0430\u0433\u0438\u043d, <\/u><\/a>\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f npm \u0438\u043b\u0438 yarn.<\/p>\n<pre><code>npm i cypress-plugin-api # or yarn add cypress-plugin-api<\/code><\/pre>\n<p>\u041f\u043e\u0441\u043b\u0435 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 \u043f\u043b\u0430\u0433\u0438\u043d\u0430 API \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0443\u0432\u0438\u0434\u0435\u0442\u044c \u0435\u0433\u043e \u0432 \u0444\u0430\u0439\u043b\u0435 package.json:<\/p>\n<figure class=\"full-width\"><\/figure>\n<p><strong>\u0428\u0430\u0433 2<\/strong><\/p>\n<p>\u0414\u0430\u043b\u0435\u0435 \u0434\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u043f\u043b\u0430\u0433\u0438\u043d\u00a0 <code>cypress\/support\/e2e.js<\/code> \u0432 \u0444\u0430\u0439\u043b:<\/p>\n<pre><code>import 'cypress-plugin-api' \/\/ or require('cypress-plugin-api')<\/code><\/pre>\n<p>\u0412\u0430\u0448\u0438 e2e.js \u0444\u0430\u0439\u043b\u044b \u0431\u0443\u0434\u0443\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0442\u0430\u043a:<\/p>\n<figure class=\"full-width\"><\/figure>\n<p><strong>\u0428\u0430\u0433 3<\/strong><\/p>\n<p>\u0421\u043e\u0437\u0434\u0430\u0439\u0442\u0435 \u043f\u043b\u0430\u0433\u0438\u043d <code>cypress_plugin_api.cy.js<\/code> \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043c\u0435\u0442\u043e\u0434\u043e\u0432 (GET, POST, PUT, DELETE).<\/p>\n<p>\u0414\u043b\u044f \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u043e\u0431\u0437\u043e\u0440\u0430 \u044f \u0431\u0435\u0440\u0443 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u044b \u043c\u0435\u0442\u043e\u0434\u043e\u0432 API \u0438\u0437 \u044d\u0442\u043e\u0433\u043e \u0440\u0435\u0441\u0443\u0440\u0441\u0430: <a href=\"https:\/\/reqres.in\/\"><u>https:\/\/reqres.in\/<\/u><\/a>.<\/p>\n<p><strong>GET \u0417\u0430\u043f\u0440\u043e\u0441<\/strong><\/p>\n<pre><code>it(\"GET API testing Using Cypress API Plugin\", () => {  cy.api(\"GET\", \"https:\/\/reqres.in\/api\/users?page=2\").should((response) => {    expect(response.status).to.eq(200);  }); });<\/code><\/pre>\n<p><strong>POST \u0417\u0430\u043f\u0440\u043e\u0441<\/strong><\/p>\n<pre><code>it(\"POST API testing Using Cypress API Plugin\", () => {  cy.api(\"POST\", \"https:\/\/reqres.in\/api\/users\", {    name: \"morpheus\",    job: \"leader\",  }).should((response) => {    expect(response.status).to.eq(201);  }); });<\/code><\/pre>\n<p><strong>PUT \u0417\u0430\u043f\u0440\u043e\u0441<\/strong><\/p>\n<pre><code>it(\"PUT API testing Using Cypress API Plugin\", () => {  cy.api(\"PUT\", \"https:\/\/reqres.in\/api\/users\/2\", {    name: \"morpheus\",    job: \"zion resident\",  }).should((response) => {    expect(response.status).to.eq(200);  }); });<\/code><\/pre>\n<p><strong>DELETE \u0417\u0430\u043f\u0440\u043e\u0441<\/strong><\/p>\n<pre><code>it(\"DELETE API testing Using Cypress API Plugin\", () => {  cy.api(\"DELETE\", \"https:\/\/reqres.in\/api\/users\/2\").should((response) => {    expect(response.status).to.eq(204);  }); });<\/code><\/pre>\n<h3>\u041e\u0442\u0447\u0435\u0442 \u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0438 \u0442\u0435\u0441\u0442\u043e\u0432\u043e\u0433\u043e \u043a\u0435\u0439\u0441\u0430 API<\/h3>\n<p>\u041d\u0430 \u0441\u043a\u0440\u0438\u043d\u0448\u043e\u0442\u0435 \u043d\u0438\u0436\u0435 \u043c\u044b \u0432\u0438\u0434\u0438\u043c \u0434\u0430\u043d\u043d\u044b\u0435 Body, Response, Headers \u0438 Cookies, \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u043d\u044b\u0435 \u0432 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u043e\u043c \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f Cypress. \u0420\u0430\u043d\u0435\u0435 \u0434\u043b\u044f \u043f\u0440\u043e\u0441\u043c\u043e\u0442\u0440\u0430 \u044d\u0442\u043e\u0439 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043d\u0430\u043c \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u043b\u043e\u0441\u044c \u043d\u0430\u0436\u0438\u043c\u0430\u0442\u044c \u043d\u0430 \u043a\u043d\u043e\u043f\u043a\u0443 &#8216;inspect&#8217;, \u043d\u043e \u0442\u0435\u043f\u0435\u0440\u044c \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0439 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043d\u0430\u043c \u043b\u0435\u0433\u043a\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043a \u043d\u0435\u0439 \u0434\u043e\u0441\u0442\u0443\u043f.<\/p>\n<p><strong>GET \u0417\u0430\u043f\u0440\u043e\u0441<\/strong><\/p>\n<figure class=\"full-width\"><\/figure>\n<p><strong>POST \u0417\u0430\u043f\u0440\u043e\u0441<\/strong><\/p>\n<figure class=\"full-width\"><\/figure>\n<p><strong>PUT \u0417\u0430\u043f\u0440\u043e\u0441<\/strong><\/p>\n<figure class=\"full-width\"><\/figure>\n<p><strong>DELETE \u0417\u0430\u043f\u0440\u043e\u0441<\/strong><\/p>\n<figure class=\"full-width\"><\/figure>\n<p>\u0412 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u0435 \u043f\u0440\u0438\u0433\u043b\u0430\u0448\u0430\u0435\u043c \u0432\u0441\u0435\u0445 \u0436\u0435\u043b\u0430\u044e\u0449\u0438\u0445 \u043d\u0430 \u043e\u0442\u043a\u0440\u044b\u0442\u044b\u0439 \u0443\u0440\u043e\u043a \u00ab\u0410\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0430\u0446\u0438\u044f API + \u0443\u0434\u043e\u0431\u043d\u044b\u0435 \u043e\u0442\u0447\u0435\u0442\u044b\u00bb, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0440\u043e\u0439\u0434\u0435\u0442 24 \u043c\u0430\u0440\u0442\u0430 \u0432 \u043f\u0440\u0435\u0434\u0434\u0432\u0435\u0440\u0438\u0438 \u0441\u0442\u0430\u0440\u0442\u0430 \u043a\u0443\u0440\u0441\u0430 &#171;JavaScript QA Engineer&#187;. <\/p>\n<ul>\n<li>\n<p><a href=\"https:\/\/otus.pw\/pq4C\/\">\u0417\u0430\u043f\u0438\u0441\u0430\u0442\u044c\u0441\u044f \u043d\u0430 \u0431\u0435\u0441\u043f\u043b\u0430\u0442\u043d\u044b\u0439 \u0443\u0440\u043e\u043a<\/a><\/p>\n<\/li>\n<\/ul>\n<\/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\/company\/otus\/blog\/723182\/\"> https:\/\/habr.com\/ru\/company\/otus\/blog\/723182\/<\/a><br \/><\/br><\/br><\/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-346892","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/346892","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=346892"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/346892\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=346892"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=346892"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=346892"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}