<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Rodrigo Santos</title>
    <description>The latest articles on Forem by Rodrigo Santos (@rodrigosta).</description>
    <link>https://forem.com/rodrigosta</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F696093%2Fd73d3af8-5bf9-4e5f-808b-f0a56c35dc27.jpeg</url>
      <title>Forem: Rodrigo Santos</title>
      <link>https://forem.com/rodrigosta</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/rodrigosta"/>
    <language>en</language>
    <item>
      <title>Cypress for beginners: 5 basics commands to get started</title>
      <dc:creator>Rodrigo Santos</dc:creator>
      <pubDate>Tue, 17 May 2022 10:45:58 +0000</pubDate>
      <link>https://forem.com/rodrigosta/cypress-for-beginners-5-basics-commands-to-get-started-566</link>
      <guid>https://forem.com/rodrigosta/cypress-for-beginners-5-basics-commands-to-get-started-566</guid>
      <description>&lt;p&gt;Cypress is a simple framework based in Javascript that allows you to write your tests for front-end applications. So, in this post I'll show you 5 basics commands to get started in Cypress.&lt;/p&gt;

&lt;h2&gt;
  
  
  .visit
&lt;/h2&gt;

&lt;p&gt;We use this command for access the address sent by parameter. This parameter can be a string with a value, a variable or a empty string, but in this last case the Cypress will look for &lt;em&gt;baseUrl&lt;/em&gt; attribute on &lt;a href="https://docs.cypress.io/guides/references/configuration#cypress-json" rel="noopener noreferrer"&gt;&lt;em&gt;cypress.json&lt;/em&gt;&lt;/a&gt; file.&lt;/p&gt;

&lt;h3&gt;
  
  
  Usage
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;cy.visit('https://dev.to/rodrigosta')&lt;/code&gt;&lt;br&gt;
&lt;code&gt;cy.visit(someVariable)&lt;/code&gt;&lt;br&gt;
&lt;code&gt;cy.visit('')&lt;/code&gt; &lt;/p&gt;

&lt;h2&gt;
  
  
  .get
&lt;/h2&gt;

&lt;p&gt;This command, as the name implies, select a element in &lt;a href="https://developer.mozilla.org/en-US/docs/Web/API/Document_Object_Model/Introduction" rel="noopener noreferrer"&gt;DOM&lt;/a&gt; by selector or &lt;a href="https://docs.cypress.io/guides/core-concepts/variables-and-aliases" rel="noopener noreferrer"&gt;&lt;em&gt;alias&lt;/em&gt;&lt;/a&gt;. It's one of the most simplest and basic commands and can get elements for any selector, for example: &lt;em&gt;id, class, data-testid tags etc.&lt;/em&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Usage
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;cy.get('#emailInput')&lt;/code&gt;&lt;br&gt;
&lt;code&gt;cy.get('.dropdown-menu')&lt;/code&gt;&lt;br&gt;
&lt;code&gt;cy.get('input')&lt;/code&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  .type
&lt;/h2&gt;

&lt;p&gt;When we want to type something in some element in the DOM, we use this command. The most common case is to pass a string or variable per parameter, but it can be special character too, to do actions, for example: &lt;em&gt;{backspace}, {enter} etc.&lt;/em&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Usage
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;cy.get('input').type('something')&lt;/code&gt;&lt;br&gt;
&lt;code&gt;cy.get('.passwordInput').type(someVariable)&lt;/code&gt;&lt;br&gt;
&lt;code&gt;cy.get('#emailInput').type('teste@example {enter}')&lt;/code&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  .click
&lt;/h2&gt;

&lt;p&gt;With this command we can click on the elements of the DOM. By parameter we can send coordinates or even specific positions to click on the page. Related to click, Cypress provides commands for some other behaviors, for example: &lt;em&gt;{.rightclick()} and {dbclick()}&lt;/em&gt;. But the usage for .click() is below.&lt;/p&gt;

&lt;h3&gt;
  
  
  Usage
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;cy.get('input').click()&lt;/code&gt;&lt;br&gt;
&lt;code&gt;cy.contais('Some word').click(position)&lt;/code&gt;&lt;br&gt;
&lt;code&gt;cy.get('#button).click(‘topRight’)&lt;/code&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  .should
&lt;/h2&gt;

&lt;p&gt;Last but not least we have the command that creates assertions in Cypress. Most of times it's common to send two values per parameter, the one you want validate and a value, but you have the possibility to send only one parameter as well. &lt;/p&gt;

&lt;h2&gt;
  
  
  Usage
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;cy.get('input').should('have.value', 'Jane')&lt;/code&gt;&lt;br&gt;
&lt;code&gt;cy.get('#loginInput').should('be.visible')&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Even though this post is very simple and short, I hope it awakens in you a passion for Cypress and automated software testing. If you want more information about the framework, you can access de &lt;a href="https://docs.cypress.io/" rel="noopener noreferrer"&gt;Cypress documentation&lt;/a&gt;. &lt;/p&gt;

&lt;p&gt;It's all for today, but I hope this text helps you, and if you have any ask, text me in the comments. I see you soon. &lt;/p&gt;

</description>
    </item>
    <item>
      <title>Using Cypress for API tests</title>
      <dc:creator>Rodrigo Santos</dc:creator>
      <pubDate>Sun, 26 Sep 2021 02:54:10 +0000</pubDate>
      <link>https://forem.com/rodrigosta/using-cypress-for-api-tests-1gm5</link>
      <guid>https://forem.com/rodrigosta/using-cypress-for-api-tests-1gm5</guid>
      <description>&lt;p&gt;Hey, today I'm here to show you how we can use Cypress for testing APIs but, before this, I have one disclaimer for you.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;I assume you know the basics about Javascript, Cypress, and your setup, so I will just skip the setup of cypress and introductions about the technology.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;In this post, I using the JSON Placeholder API for tests, but you can use any API of your preference. We are going to use &lt;a href="https://docs.cypress.io/api/commands/request#Syntax" rel="noopener noreferrer"&gt;cy.request&lt;/a&gt; for sending requests for API, so in our requests, we will use this structure:&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;cy.request(method, url, body)&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;So let's start the fun&lt;/p&gt;

&lt;p&gt;First, we need to send our request to have something for the test, right? We will the &lt;code&gt;/posts&lt;/code&gt; endpoint in this case, but you can use others, no problem. I separated the test case into two parts, first I show the request body, and the second part, our tests.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    cy.request({
        method: 'POST',
        url: 'posts',
        body: {
            title: 'Something Interested',
            body: 'Lorem Ipsum is simply dummy text of the printing and typesetting industry.',
            userId: 1
        }
     })
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In request, we are creating a post with the title &lt;em&gt;Something Interested&lt;/em&gt; in user of ID is 1. According to the documentation of &lt;a href="https://jsonplaceholder.typicode.com/guide/" rel="noopener noreferrer"&gt;API&lt;/a&gt;, the response should have four params, so now, we go check this and explore the ways &lt;em&gt;Cypress&lt;/em&gt; provides for API tests.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.then((response) =&amp;gt; {
            expect(response.status).to.eq(201)
            expect(response.body).to.have.property('id')
            expect(response.body).to.have.property('title', 'Something Interested')
            expect(response.body).to.have.property('body', 'Lorem Ipsum is simply dummy text of the printing and typesetting industry.')
            expect(response.body).to.have.property('userId')
        })
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;expect(response.status).to.eq(201)&lt;/code&gt;: How the request is for creating a post, we need to receive a &lt;code&gt;201&lt;/code&gt; status code, what is &lt;code&gt;Created&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;expect(response.body).to.have.property('title', 'Something Interested')&lt;/code&gt;: Here we are checked if a title post is correct.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;expect(response.body).to.have.property('body', 'Lorem Ipsum is simply dummy text of the printing and typesetting industry.')&lt;/code&gt;: In this test, we are checked if a body post is correct.&lt;/li&gt;
&lt;li&gt; &lt;code&gt;expect(response.body).to.have.property('userId')&lt;/code&gt;: So in this case, we are verifying if in the response body the user ID exists.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In Cypress exists some other methods for test API and you can find them in &lt;a href="https://docs.cypress.io/guides/overview/why-cypress#API" rel="noopener noreferrer"&gt;documentation&lt;/a&gt;, this post was an example of what Cypress can do. The full project are in my &lt;a href="https://github.com/rodrigosta/testing-api-with-cypress" rel="noopener noreferrer"&gt;github&lt;/a&gt;, if you want to see closer.&lt;br&gt;
So thank for your time and I hope it helps.&lt;/p&gt;

</description>
      <category>cypress</category>
      <category>javascript</category>
      <category>testing</category>
    </item>
    <item>
      <title>How to setup Cypress on Github Actions</title>
      <dc:creator>Rodrigo Santos</dc:creator>
      <pubDate>Sun, 05 Sep 2021 23:48:59 +0000</pubDate>
      <link>https://forem.com/rodrigosta/how-to-setup-cypress-on-github-actions-45b6</link>
      <guid>https://forem.com/rodrigosta/how-to-setup-cypress-on-github-actions-45b6</guid>
      <description>&lt;p&gt;In this text, I try to show you how to set up Cypress on Github Actions, but first I have one disclaimer for you.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;I assume you know the basics about Github, that is  &lt;strong&gt;commits&lt;/strong&gt;, &lt;strong&gt;pull requests&lt;/strong&gt;, and &lt;strong&gt;branches&lt;/strong&gt; need to be familiar concepts.&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Github Actions it's an important tool for automating and run software workflows day by day. In this article, I show to you when every time someone creates a pull request for your project repository, you can automatically run a command that executes a software testing script.&lt;/p&gt;

&lt;p&gt;But first, I need you to have any Github repository with any Cypress test.&lt;/p&gt;

&lt;p&gt;So let's start the fun...&lt;/p&gt;

&lt;p&gt;1 . In your Github repository create a new file in directory &lt;em&gt;.github/workflows&lt;/em&gt; called &lt;em&gt;github-actions-init.yml&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;2 . In this file we must add content with steps of our workflow:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;name: GitHub Actions Demo
on: [pull_request]
jobs:
 cypress-run:
    runs-on: ubuntu-latest
    steps: 
      - name: Checkout
        uses: actions/checkout@v2
      - name: Install node
        uses: actions/setup-node@v2
        with:
            node:version: '14'
      - name: Install dependencies
        run: npm install       
      - name: Cypress run
        uses: cypress-io/github-action@v2
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this YAML file, we have some terms that need explanation, so let's go undestand line by line: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;name: GitHub Actions Demo&lt;/code&gt;: It's basically the name of our workflow.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;on: [pull_request]&lt;/code&gt;: Shows for github actions when running the workflow &lt;/li&gt;
&lt;li&gt;
&lt;code&gt;jobs&lt;/code&gt;: Group all jobs in file&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;cypress-run&lt;/code&gt;: It's job's name &lt;/li&gt;
&lt;li&gt;
&lt;code&gt;runs-on: ubuntu-latest&lt;/code&gt;: Indicates to a workflow should run in a Ubuntu Linux executor.
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;steps&lt;/code&gt;: All steps to run in workflow&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;Checkout&lt;/code&gt;: It's a step's name&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;uses: actions/checkout@v2&lt;/code&gt;: In this line basically our workflow checks our repository allowing you to run actions against own code&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;name: Install node&lt;/code&gt;: It's a step's name&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;uses: actions/setup-node@v2&lt;/code&gt;: This step is used for install a specified node version&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;node-version&lt;/code&gt;: Indicate a node version&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;name: Install dependencies&lt;/code&gt;: It's a step's name&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;run: npm install&lt;/code&gt;: Run the command install in node, to install all dependencies in project&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;name: Cypress run&lt;/code&gt;: It's a step's name&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;uses: cypress-io/github-action@v2&lt;/code&gt;: Run a Cypress command to execute all tests cases in project.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;3 . After adding this file to the repository, it's time to create a pull request and see the magic happen.&lt;/p&gt;

&lt;p&gt;It's all for today, but I hope this text helps you, and if you have any ask, text me in the comments. I see you soon&lt;/p&gt;

&lt;h5&gt;
  
  
  Project Repository: &lt;a href="https://github.com/rodrigosta/e2e-toDoList" rel="noopener noreferrer"&gt;https://github.com/rodrigosta/e2e-toDoList&lt;/a&gt;
&lt;/h5&gt;

&lt;h5&gt;
  
  
  References:
&lt;/h5&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://docs.github.com/en/actions/learn-github-actions/introduction-to-github-actions" rel="noopener noreferrer"&gt;https://docs.github.com/en/actions/learn-github-actions/introduction-to-github-actions&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.cypress.io/guides/continuous-integration/github-actions" rel="noopener noreferrer"&gt;https://docs.cypress.io/guides/continuous-integration/github-actions&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>github</category>
      <category>javascript</category>
      <category>testing</category>
      <category>cypress</category>
    </item>
  </channel>
</rss>
