{"id":1820,"date":"2021-11-18T15:39:08","date_gmt":"2021-11-18T15:39:08","guid":{"rendered":"https:\/\/www.toponecrm.com\/blog\/?p=1820"},"modified":"2021-11-18T15:39:08","modified_gmt":"2021-11-18T15:39:08","slug":"how-to-use-cypress","status":"publish","type":"post","link":"https:\/\/toponecrm.com\/blog\/uncategorized\/how-to-use-cypress\/","title":{"rendered":"How to use Cypress?"},"content":{"rendered":"\n<p>Cypress is an end-to-end testing framework for web test automation. It enables us to write automated web tests in JavaScript. <\/p>\n\n\n\n<p>Cypress is universal because it&#8217;s written in JavaScript and uses Node.js when running in browsers. It&#8217;s simple to set up and its fast when it comes to debugging, and if the tests fail, you will be provided with suggestions for how to fix the defect.<\/p>\n\n\n\n<h2><strong>Write your first test<\/strong><\/h2>\n\n\n\n<p>open up the IDE and add the code below <\/p>\n\n\n\ndescribe(&#8216;My First Test&#8217;, () =&gt; {\n  it(&#8216;Does not do much!&#8217;, () =&gt; {\n    expect(true).to.equal(true)\n  })\n})\n\n\n\n<p>after you save the file,  run it using the following command in your terminal<\/p>\n\n\n\nnpx cypress run\n\n\n\n<p> the cypress command log will pop up , click on the name of your file and you will see the following <\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><img loading=\"lazy\" width=\"560\" height=\"130\" src=\"https:\/\/www.toponecrm.com\/blog\/wp-content\/uploads\/2021\/11\/image-3.png\" alt=\"\" class=\"wp-image-1829\" srcset=\"https:\/\/toponecrm.com\/blog\/wp-content\/uploads\/2021\/11\/image-3.png 560w, https:\/\/toponecrm.com\/blog\/wp-content\/uploads\/2021\/11\/image-3-300x70.png 300w, https:\/\/toponecrm.com\/blog\/wp-content\/uploads\/2021\/11\/image-3-350x81.png 350w\" sizes=\"(max-width: 560px) 100vw, 560px\" \/><\/figure><\/div>\n\n\n\n<p><\/p>\n\n\n\n<h2><strong>Debugging using .debug( )<\/strong><\/h2>\n\n\n\n<p>Cypress also exposes a shortcut for debugging commands,\u00a0<a class=\"\" href=\"https:\/\/docs.cypress.io\/api\/commands\/debug\"><code>.debug()<\/code><\/a>.<\/p>\n\n\n\nit(&#8216;let me debug like a fiend&#8217;, () =&gt; {\n  cy.visit(&#8216;\/my\/page\/path&#8217;)\n\n  cy.get(&#8216;.selector-in-question&#8217;).debug()\n})\n\n\n\n<p>The current subject that is yielded by the\u00a0<a class=\"\" href=\"https:\/\/docs.cypress.io\/api\/commands\/get\"><code>cy.get()<\/code><\/a>\u00a0is exposed as the variable\u00a0<code>subject<\/code>\u00a0within your Developer Tools so that you can interact with it in the console.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><img loading=\"lazy\" width=\"844\" height=\"313\" src=\"https:\/\/www.toponecrm.com\/blog\/wp-content\/uploads\/2021\/11\/image-4.png\" alt=\"\" class=\"wp-image-1837\" srcset=\"https:\/\/toponecrm.com\/blog\/wp-content\/uploads\/2021\/11\/image-4.png 844w, https:\/\/toponecrm.com\/blog\/wp-content\/uploads\/2021\/11\/image-4-300x111.png 300w, https:\/\/toponecrm.com\/blog\/wp-content\/uploads\/2021\/11\/image-4-768x285.png 768w, https:\/\/toponecrm.com\/blog\/wp-content\/uploads\/2021\/11\/image-4-350x130.png 350w\" sizes=\"(max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px\" \/><\/figure><\/div>\n\n\n\n<p><\/p>\n\n\n\n<p>Use\u00a0<a class=\"\" href=\"https:\/\/docs.cypress.io\/api\/commands\/debug\"><code>.debug()<\/code><\/a>\u00a0to quickly inspect any (or many!) part(s) of your application during the test. You can attach it to any Cypress chain of commands to have a look at the system&#8217;s state at that moment.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Cypress is an end-to-end testing framework for web test automation. It enables us to write automated web tests in JavaScript. Cypress is universal because it&#8217;s written in JavaScript and uses Node.js when running in browsers. It&#8217;s simple to set up and its fast when it comes to debugging, and if the tests fail, you will &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/toponecrm.com\/blog\/uncategorized\/how-to-use-cypress\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;How to use Cypress?&#8221;<\/span><\/a><\/p>\n","protected":false},"author":18,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_price":"","_stock":"","_tribe_ticket_header":"","_tribe_default_ticket_provider":"","_tribe_ticket_capacity":"0","_ticket_start_date":"","_ticket_end_date":"","_tribe_ticket_show_description":"","_tribe_ticket_show_not_going":false,"_tribe_ticket_use_global_stock":"","_tribe_ticket_global_stock_level":"","_global_stock_mode":"","_global_stock_cap":"","_tribe_rsvp_for_event":"","_tribe_ticket_going_count":"","_tribe_ticket_not_going_count":"","_tribe_tickets_list":[],"_tribe_ticket_has_attendee_info_fields":false},"categories":[1],"tags":[],"ticketed":false,"_links":{"self":[{"href":"https:\/\/toponecrm.com\/blog\/wp-json\/wp\/v2\/posts\/1820"}],"collection":[{"href":"https:\/\/toponecrm.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/toponecrm.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/toponecrm.com\/blog\/wp-json\/wp\/v2\/users\/18"}],"replies":[{"embeddable":true,"href":"https:\/\/toponecrm.com\/blog\/wp-json\/wp\/v2\/comments?post=1820"}],"version-history":[{"count":1,"href":"https:\/\/toponecrm.com\/blog\/wp-json\/wp\/v2\/posts\/1820\/revisions"}],"predecessor-version":[{"id":1839,"href":"https:\/\/toponecrm.com\/blog\/wp-json\/wp\/v2\/posts\/1820\/revisions\/1839"}],"wp:attachment":[{"href":"https:\/\/toponecrm.com\/blog\/wp-json\/wp\/v2\/media?parent=1820"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/toponecrm.com\/blog\/wp-json\/wp\/v2\/categories?post=1820"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/toponecrm.com\/blog\/wp-json\/wp\/v2\/tags?post=1820"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}