{"id":27315,"date":"2021-03-01T20:37:37","date_gmt":"2021-03-01T20:37:37","guid":{"rendered":"https:\/\/app14743.cloudwayssites.com\/?p=27315"},"modified":"2021-03-03T21:11:28","modified_gmt":"2021-03-03T21:11:28","slug":"github-actions-with-cypress-and-applitools","status":"publish","type":"post","link":"https:\/\/app14743.cloudwayssites.com\/blog\/github-actions-with-cypress-and-applitools\/","title":{"rendered":"How to Setup GitHub Actions with Cypress &#038; Applitools for a Better Automated Testing Workflow"},"content":{"rendered":"\n<p>Applitools provides a number of SDKs that allows you to easily integrate it into your existing workflow. Using tools like<a href=\"https:\/\/app14743.cloudwayssites.com\/tutorials\/cypress.html\"> Cypress<\/a>,<a href=\"https:\/\/app14743.cloudwayssites.com\/tutorials\/espresso.html\"> Espresso<\/a>, <a href=\"https:\/\/app14743.cloudwayssites.com\/tutorials\/selenium-java.html\">Selenium<\/a>, <a href=\"https:\/\/app14743.cloudwayssites.com\/tutorials\/appium-native-csharp.html\">Appium<\/a>, and a wide <a href=\"https:\/\/app14743.cloudwayssites.com\/tutorials\/\">variety of others<\/a>, web and native platforms can get automated visual testing coverage with the power of<a href=\"https:\/\/app14743.cloudwayssites.com\/products-eyes\/\"> Applitools Eyes<\/a>.<\/p>\n\n\n\n<p>But what if you\u2019re not looking to integrate it directly to an existing testing workflow because maybe you don\u2019t have one or maybe you don\u2019t have access to it? Or what if you want to provide blanket visual testing coverage on a website without having to maintain which pages get checked?<\/p>\n\n\n\n<p>We&#8217;ll walk through how we were able to take advantage of the power of Applitools Eyes and flexibility of<a href=\"https:\/\/github.com\/features\/actions\"> GitHub Actions<\/a> to<a href=\"https:\/\/github.com\/colbyfayock\/applitools-eyes-action\"> create a solution<\/a> that can fit into any GitHub-based workflow.<\/p>\n\n\n\n<p><em>Note: if you want to skip the \u201cHow it Works\u201d and go directly to how to use it, you can check out the<\/em><a href=\"https:\/\/github.com\/colbyfayock\/applitools-eyes-action\"><em> <\/em><em>Applitools Eyes GitHub Action<\/em><\/a><em> on github.com.<\/em><a href=\"https:\/\/github.com\/colbyfayock\/applitools-eyes-action\"><em> <\/em><em>https:\/\/github.com\/colbyfayock\/applitools-eyes-action<\/em><\/a><\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-what-are-github-actions\">What are GitHub Actions?<\/h2>\n\n\n\n<p>To start, GitHub Actions are CI\/CD-like workflows that you\u2019re able to run right inside of your GitHub repository.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"365\" src=\"https:\/\/app14743.cloudwayssites.com\/wp-content\/uploads\/2021\/03\/github-action-1024x365.jpg\" alt=\"GitHub Actions logs and pull request\" class=\"wp-image-27316\" srcset=\"https:\/\/app14743.cloudwayssites.com\/wp-content\/uploads\/2021\/03\/github-action-1024x365.jpg 1024w, https:\/\/app14743.cloudwayssites.com\/wp-content\/uploads\/2021\/03\/github-action-300x107.jpg 300w, https:\/\/app14743.cloudwayssites.com\/wp-content\/uploads\/2021\/03\/github-action-768x274.jpg 768w, https:\/\/app14743.cloudwayssites.com\/wp-content\/uploads\/2021\/03\/github-action-1536x548.jpg 1536w, https:\/\/app14743.cloudwayssites.com\/wp-content\/uploads\/2021\/03\/github-action.jpg 2000w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><figcaption><em>Running build, test, and publish on a branch with GitHub Actions<\/em><\/figcaption><\/figure>\n\n\n\n<p>Using a YAML file, we can set up our project to run tests or really any kind of script based on events such as a commit, pull request, or even on a schedule with cron.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>name: Tests\n\non:\n  push:\n\tbranches: &#91; main ]\n  pull_request:\n\tbranches: &#91; main ]\n\njobs:\n  test:\n\truns-on: ubuntu-latest\n\tsteps:\n\t- uses: actions\/checkout@v2\n\t- uses: actions\/setup-node@v2\n\t  with:\n\t\tnode-version: '12'\n\t- run: npm ci\n\t- run: npm test<\/code><\/pre>\n\n\n\n<p>Setting up simpler workflows like our example above, where we\u2019re installing our dependencies and running our tests, is a great example of how we can automate critical code tasks, but GitHub also gives developers a way to package up complex scripts that can reach beyond what a configurable YML file can do.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-using-custom-github-actions-to-simplify-complex-workflows\">Using custom GitHub Actions to simplify complex workflows<\/h2>\n\n\n\n<p>When<a href=\"https:\/\/docs.github.com\/en\/actions\/creating-actions\"> creating a custom GitHub Action<\/a>, we unlock the ability to use scripting tools like shell and<a href=\"https:\/\/nodejs.org\/en\/\"> node<\/a> to a greater extent, as well as the ability to stand up entire environments using Docker, which can allow us to really take advantage of our allotted environment just like we could on any other CI\/CD platform.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"226\" src=\"https:\/\/app14743.cloudwayssites.com\/wp-content\/uploads\/2021\/03\/github-action-build-logs-1024x226.jpg\" alt=\"GitHub Actions Build Logs\" class=\"wp-image-27317\" srcset=\"https:\/\/app14743.cloudwayssites.com\/wp-content\/uploads\/2021\/03\/github-action-build-logs-1024x226.jpg 1024w, https:\/\/app14743.cloudwayssites.com\/wp-content\/uploads\/2021\/03\/github-action-build-logs-300x66.jpg 300w, https:\/\/app14743.cloudwayssites.com\/wp-content\/uploads\/2021\/03\/github-action-build-logs-768x169.jpg 768w, https:\/\/app14743.cloudwayssites.com\/wp-content\/uploads\/2021\/03\/github-action-build-logs-1536x339.jpg 1536w, https:\/\/app14743.cloudwayssites.com\/wp-content\/uploads\/2021\/03\/github-action-build-logs.jpg 2000w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><figcaption><em>Building a container in a GitHub Action<\/em><\/figcaption><\/figure>\n\n\n\n<p>In our case, we want to allow someone to run Applitools Eyes without ever having to think about setting up a test runner.<\/p>\n\n\n\n<p>To achieve this, we can include<a href=\"https:\/\/www.cypress.io\/\"> Cypress<\/a> (or another test runner) right along with our Action, which would then get installed as a dependency on the workflow environment. This allows us to hook right into the environment to run our tests.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-scaffolding-a-cypress-environment-in-a-github-action-workflow-with-docker\">Scaffolding a Cypress environment in a GitHub Action workflow with Docker<\/h2>\n\n\n\n<p>Setting up Cypress is typically a somewhat simple process. You can install it locally using<a href=\"https:\/\/www.npmjs.com\/\"> npm<\/a> or<a href=\"https:\/\/yarnpkg.com\/\"> yarn<\/a> where Cypress will manage configuring it for your environment.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"219\" src=\"https:\/\/app14743.cloudwayssites.com\/wp-content\/uploads\/2021\/03\/cypress-install-1024x219.jpg\" alt=\"How to install cypress\" class=\"wp-image-27318\" srcset=\"https:\/\/app14743.cloudwayssites.com\/wp-content\/uploads\/2021\/03\/cypress-install-1024x219.jpg 1024w, https:\/\/app14743.cloudwayssites.com\/wp-content\/uploads\/2021\/03\/cypress-install-300x64.jpg 300w, https:\/\/app14743.cloudwayssites.com\/wp-content\/uploads\/2021\/03\/cypress-install-768x164.jpg 768w, https:\/\/app14743.cloudwayssites.com\/wp-content\/uploads\/2021\/03\/cypress-install-1536x328.jpg 1536w, https:\/\/app14743.cloudwayssites.com\/wp-content\/uploads\/2021\/03\/cypress-install-2048x438.jpg 2048w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><figcaption><em>Installing Cypress with npm via cypress.io<\/em><\/figcaption><\/figure>\n\n\n\n<p>This works roughly the same inside of a standard YAML-based GitHub Action workflow. When we use the included environment, GitHub gives us access to a workspace where we can install our packages just like we would locally.<\/p>\n\n\n\n<p>It becomes a bit trickier however when trying to run a custom GitHub Action, where you would want to potentially have access to both the project and the Action\u2019s code to set up the environment and run the tests.<\/p>\n\n\n\n<p>While it might be possible to figure out a solution using only node, Cypress additionally ships a variety of<a href=\"https:\/\/github.com\/cypress-io\/cypress-docker-images\"> publicly available Docker images<\/a> which let\u2019s us confidently spin up an environment that Cypress supports. It also gives us a bit more control over how we can configure and run our code inside of that environment in a repeatable way.<\/p>\n\n\n\n<p>Because one of our options for creating a custom Action is<a href=\"https:\/\/docs.github.com\/en\/actions\/creating-actions\/creating-a-docker-container-action\"> Docker<\/a>, we can easily reference one of the Cypress images right from the start:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>FROM cypress\/browsers:node12.18.3-chrome87-ff82<\/code><\/pre>\n\n\n\n<p>In this particular instance, we\u2019re spinning up a new Cypress-supported environment with node 12.18.3 installed along with Chrome 87 and Firefox 82.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-installing-cypress-and-action-dependencies\">Installing Cypress and Action dependencies<\/h2>\n\n\n\n<p>With our base environment set up, we move to installing dependencies and starting the script. While we\u2019re using a Cypress image that has built-in support, Cypress doesn\u2019t actually come already installed.<\/p>\n\n\n\n<p>When installing Cypress, it uses cache directories to store download binaries of Cypress itself. When using Docker and working with different environments, its important to have predictable locations of where these caches exist, so that we\u2019re able to reference it later.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"76\" src=\"https:\/\/app14743.cloudwayssites.com\/wp-content\/uploads\/2021\/03\/cypress-cache-1024x76.jpg\" alt=\"Cypress cache verification\" class=\"wp-image-27320\" srcset=\"https:\/\/app14743.cloudwayssites.com\/wp-content\/uploads\/2021\/03\/cypress-cache-1024x76.jpg 1024w, https:\/\/app14743.cloudwayssites.com\/wp-content\/uploads\/2021\/03\/cypress-cache-300x22.jpg 300w, https:\/\/app14743.cloudwayssites.com\/wp-content\/uploads\/2021\/03\/cypress-cache-768x57.jpg 768w, https:\/\/app14743.cloudwayssites.com\/wp-content\/uploads\/2021\/03\/cypress-cache-1536x114.jpg 1536w, https:\/\/app14743.cloudwayssites.com\/wp-content\/uploads\/2021\/03\/cypress-cache.jpg 1558w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><figcaption><em>Cypress verifies that it can correctly identify an installation path from cache<\/em><\/figcaption><\/figure>\n\n\n\n<p>In our Docker file, we additionally configure that environment with:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ENV NPM_CACHE_FOLDER=\/root\/.cache\/npm\nENV CYPRESS_CACHE_FOLDER=\/root\/.cache\/Cypress<\/code><\/pre>\n\n\n\n<p>When npm and Cypress goes to install, they\u2019ll use those directories for caching.<\/p>\n\n\n\n<p>We also need to set up an entrypoint which tells Docker what script to run to initiate our Action.<\/p>\n\n\n\n<p>Inside of our Dockerfile, we add:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>COPY entrypoint.sh \/entrypoint.sh\n\nENTRYPOINT &#91;\"\/entrypoint.sh\"]<\/code><\/pre>\n\n\n\n<p>We\u2019ll use a shell script to initiate our initial installation procedure so we can have a little more control over setting things up.<\/p>\n\n\n\n<p>Finally, inside of our referenced shell script, we include:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#!\/bin\/sh -l\n\ncd $GITHUB_WORKSPACE\n\ngit clone https:\/\/github.com\/colbyfayock\/applitools-eyes-action\ncd applitools-eyes-action\n\nnpm ci\n\nnode .\/src\/action.js<\/code><\/pre>\n\n\n\n<p>This will first navigate into our GitHub\u2019s Workspace directory, to make sure our session is in the right location.<\/p>\n\n\n\n<p>We then clone down a copy of our custom Action\u2019s code, which is referencing itself at this point, but it allows us to have a fresh copy in our Workspace directory, giving us access to the script and dependencies we ultimately need.<\/p>\n\n\n\n<p>And with our Action cloned within our working environment, we can now install the dependencies of our action and run the script that will coordinate our tests.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-dynamically-creating-a-sitemap-in-node\">Dynamically creating a sitemap in node<\/h2>\n\n\n\n<p>Once our node script is kicked off, the first few steps are to find environment variables and gather Action inputs that will allow our script to be configured by the person using it.<\/p>\n\n\n\n<p>But before we can actually run any tests, we need to know what pages we can run the tests on.<\/p>\n\n\n\n<p>To add some flexibility, we added a few options:<\/p>\n\n\n\n<ul><li>Base URL: the URL that the tests will run on<\/li><li>Sitemap URL: this allows someone to pass in an already sitemap URL, rather than trying to dynamically create one<\/li><li>Max Depth: how deep should we dynamically crawl the site? We\u2019ll touch on this a little more in a bit<\/li><\/ul>\n\n\n\n<p>With these settings, we can have an idea on how the Action should run.<\/p>\n\n\n\n<p>If no sitemap is provided, we have the ability to create one.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"270\" src=\"https:\/\/app14743.cloudwayssites.com\/wp-content\/uploads\/2021\/03\/rss-feed-1024x270.jpg\" alt=\"RSS xml example\" class=\"wp-image-27321\" srcset=\"https:\/\/app14743.cloudwayssites.com\/wp-content\/uploads\/2021\/03\/rss-feed-1024x270.jpg 1024w, https:\/\/app14743.cloudwayssites.com\/wp-content\/uploads\/2021\/03\/rss-feed-300x79.jpg 300w, https:\/\/app14743.cloudwayssites.com\/wp-content\/uploads\/2021\/03\/rss-feed-768x203.jpg 768w, https:\/\/app14743.cloudwayssites.com\/wp-content\/uploads\/2021\/03\/rss-feed-1536x406.jpg 1536w, https:\/\/app14743.cloudwayssites.com\/wp-content\/uploads\/2021\/03\/rss-feed.jpg 1772w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><figcaption><em>Example sitemap<\/em><\/figcaption><\/figure>\n\n\n\n<p>Specifically, we can use a<a href=\"https:\/\/github.com\/lgraubner\/sitemap-generator\"> Sitemap Generator<\/a> package that&#8217;s available right on npm that will handle this for us.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>const generator = SitemapGenerator(url, {\n  stripQuerystring: false,\n  filepath,\n  maxDepth\n});<\/code><\/pre>\n\n\n\n<p>Once we plug in a URL, Sitemap Generator will find all of the links on our page and crawl the site just like Google would with it&#8217;s search robots.<\/p>\n\n\n\n<p>We need this crawling to be configurable though, which is where Max Depth comes in. We might not necessarily want our crawler to drill down link after link, which could cause performance issues, but it could also include pages or other websites that we aren\u2019t interested in including in our sitemap.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"532\" src=\"https:\/\/app14743.cloudwayssites.com\/wp-content\/uploads\/2021\/03\/applitools-sitemap-1024x532.jpg\" alt=\"Applitools sitemap diagram\" class=\"wp-image-27322\" srcset=\"https:\/\/app14743.cloudwayssites.com\/wp-content\/uploads\/2021\/03\/applitools-sitemap-1024x532.jpg 1024w, https:\/\/app14743.cloudwayssites.com\/wp-content\/uploads\/2021\/03\/applitools-sitemap-300x156.jpg 300w, https:\/\/app14743.cloudwayssites.com\/wp-content\/uploads\/2021\/03\/applitools-sitemap-768x399.jpg 768w, https:\/\/app14743.cloudwayssites.com\/wp-content\/uploads\/2021\/03\/applitools-sitemap-1536x798.jpg 1536w, https:\/\/app14743.cloudwayssites.com\/wp-content\/uploads\/2021\/03\/applitools-sitemap.jpg 1560w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><figcaption><em>Reduced sitemap of applitools.com<\/em><\/figcaption><\/figure>\n\n\n\n<p>With Max Depth, we can tell our Sitemap Generator how deep we want it to crawl. A value of 1 would only scrape the top level page, where a value of 2 would follow the links on the first page, and then follow the links on the second page, to find pages to include in our dynamically generated sitemap.<\/p>\n\n\n\n<p>But at this point, whether dynamically generated or provided to us with the Sitemap URL, we should now have a list of pages that we want to run our tests on.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-running-cypress-as-a-script-in-node\">Running Cypress as a script in node<\/h2>\n\n\n\n<p>Most of the time when we\u2019re running Cypress, we use the command line or include it as a script inside of our <code>package.json<\/code>. Because Cypress is available as a node package, we additionally have the ability to run it right inside of a node script just like we would any other function.<\/p>\n\n\n\n<p>Because we already have our environment configured and we\u2019ve determined the settings we want, we can plug these values directly into Cypress:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>const results = await cypress.run({\n  browser: cypressBrowser,\n  config: {\n\tbaseUrl\n  },\n  env: {\n\tAPPLITOOLS_APP_NAME: appName,\n\tAPPLITOOLS_BATCH_NAME: batchName,\n\tAPPLITOOLS_CONCURRENCY: concurrency,\n\tAPPLITOOLS_SERVER_URL: serverUrl,\n\tPAGES_TO_CHECK: pagesToCheck\n  },\n  headless: true,\n  record: false,\n}); <\/code><\/pre>\n\n\n\n<p>If you notice in the script though, we\u2019re setting a few environment variables.<\/p>\n\n\n\n<p>The trick with this is, we can\u2019t directly pass in arguments that we may need inside of Cypress itself, such as settings for Applitools Eyes.<\/p>\n\n\n\n<p>The way we can handle this is by creating Cypress environment variables, which end up roughly working the same as passing arguments into the function, we just need to access it slightly differently.<\/p>\n\n\n\n<p>But beyond some Applitools-specific configurations, the important bits here are that we have a basic headless configuration of Cypress, we turn recording off as ultimately we won\u2019t use that, and we pass in <code>PAGES_TO_CHECK<\/code> which is an array of pages that we&#8217;ll ultimately run through with Cypress and Applitools.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-using-cypress-with-github-actions-to-dynamically-run-visual-tests\">Using Cypress with GitHub Actions to dynamically run visual tests<\/h2>\n\n\n\n<p>Now that we\u2019re finally to the point where we\u2019re running Cypress, we can take advantage of the Applitools Eyes SDK for Cypress to easily check all of our pages.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>describe('Visual Regression Tests', () =&gt; {\n  const pagesToCheck = Cypress.env('PAGES_TO_CHECK');\n\n  pagesToCheck.forEach((route) =&gt; {\n\tit(`Visual Diff for ${route}`, () =&gt; {\n\n\t  cy.eyesOpen({\n\t\tappName: Cypress.env('APPLITOOLS_APP_NAME'),\n\t\tbatchName: Cypress.env('APPLITOOLS_BATCH_NAME'),\n\t\tconcurrency: Number(Cypress.env('APPLITOOLS_CONCURRENCY')),\n\t\tserverUrl: Cypress.env('APPLITOOLS_SERVER_URL'),\n\t  });\n\n\t  cy.visit(route);\n\t  \n\t  cy.eyesCheckWindow({\n\t\ttag: route\n\t  });\n\n\t  cy.eyesClose();\n\t});\n  });\n});<\/code><\/pre>\n\n\n\n<p>Back to the critical part of how we ran Cypress, we first grab the pages that we want to check. We can use Cypress.env to grab our <code>PAGES_TO_CHECK<\/code> variable which is what we&#8217;ll use for Eyes coverage.<\/p>\n\n\n\n<p>With that array, we can simply run a <code>forEach<\/code> loop, where for every page that we have defined, we&#8217;ll create a new assertion for that route.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"269\" src=\"https:\/\/app14743.cloudwayssites.com\/wp-content\/uploads\/2021\/03\/cypress-tests-applitools-1024x269.jpg\" alt=\"Applitools Visual Regression Tests in Cypress\" class=\"wp-image-27319\" srcset=\"https:\/\/app14743.cloudwayssites.com\/wp-content\/uploads\/2021\/03\/cypress-tests-applitools-1024x269.jpg 1024w, https:\/\/app14743.cloudwayssites.com\/wp-content\/uploads\/2021\/03\/cypress-tests-applitools-300x79.jpg 300w, https:\/\/app14743.cloudwayssites.com\/wp-content\/uploads\/2021\/03\/cypress-tests-applitools-768x202.jpg 768w, https:\/\/app14743.cloudwayssites.com\/wp-content\/uploads\/2021\/03\/cypress-tests-applitools-1536x403.jpg 1536w, https:\/\/app14743.cloudwayssites.com\/wp-content\/uploads\/2021\/03\/cypress-tests-applitools.jpg 1630w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><figcaption><em>Running Applitools Eyes on each page of the sitemap<\/em><\/figcaption><\/figure>\n\n\n\n<p>Inside of that assertion, we open up our Eyes, proceed to visit our active page, perform a check to grab a snapshot of that page, and finally close our Eyes.<\/p>\n\n\n\n<p>With that brief snippet of code, we\u2019re uploading a snapshot of each of our pages up to Applitools, where we\u2019ll now be able to test and monitor our web project for issues!<\/p>\n\n\n\n<p><strong>Configuring Applitools Eyes GitHub Action into a workflow<\/strong><\/p>\n\n\n\n<p>Now for the fun part, we can see how this Action actually works.<\/p>\n\n\n\n<p>To add the<a href=\"https:\/\/github.com\/colbyfayock\/applitools-eyes-action\"> Applitools Eyes GitHub Action<\/a> to a project, inside of an existing workflow, you can add the following as a new step:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>steps:\n- uses: colbyfayock\/applitools-eyes-action@main\n  with:\n\tAPPLITOOLS_API_KEY: ${{secrets.APPLITOOLS_API_KEY}}\n\tappName: Applitools\n\tbaseUrl: https:\/\/app14743.cloudwayssites.com<\/code><\/pre>\n\n\n\n<p>We first specify that we want to use the Action at its current location, then we pass in a few required input options such as an Applitools API Key (which is defined in a<a href=\"https:\/\/docs.github.com\/en\/actions\/reference\/encrypted-secrets#creating-encrypted-secrets-for-a-repository\"> Secret<\/a>), the name of our app, which will be used to label our tests in Applitools, and finally the base URL that we want our tests to run on (or we can optionally pass in a sitemap as noted before).<\/p>\n\n\n\n<p>With just these few lines, any time our steps are triggered by our workflow, our Action will create a new environment where it will run Cypress and use Applitools Eyes to add Visual Testing to the pages on our site!<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-what-s-next-for-applitools-eyes-github-action\">What&#8217;s next for Applitools Eyes GitHub Action?<\/h2>\n\n\n\n<p>We have a lot of flexibility with the current iteration of the custom GitHub Action, but it has a few limitations like having an environment already deployed that can be accessed by the script and generally not having some of the advanced Applitools feature customers would expect.<\/p>\n\n\n\n<p>Because we\u2019re using node inside of our own custom environment, we have the ability to provide advanced solutions for the project we want to run the tests on, such as providing an additional input for a static directory of files, which would allow our Action to spin up a local server and perform the tests on.<\/p>\n\n\n\n<p>As far as adding additional Applitools features, we&#8217;re only limited to what the SDK allows, as we can scale our input options and configuration to allow customers to use whatever features they&#8217;d like.<\/p>\n\n\n\n<p>This Action is still in an experimental stage as we try to figure out what direction we ultimately want to take it and what features could prove most useful for getting people up and running with Visual Testing, but even today, this Action can help immediately add broad coverage to a web project with a simple line in a GitHub Action workflow file.<br>To follow along with feature development, to report issues, or to help contribute, you can check out the<a href=\"https:\/\/github.com\/colbyfayock\/applitools-eyes-action\"> Action on GitHub<\/a> at<a href=\"https:\/\/github.com\/colbyfayock\/applitools-eyes-action\"> https:\/\/github.com\/colbyfayock\/applitools-eyes-action<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Applitools provides a number of SDKs that allows you to easily integrate it into your existing workflow. Using tools like Cypress, Espresso, Selenium, Appium, and a wide variety of others,&#8230;<\/p>\n","protected":false},"author":65,"featured_media":27413,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[10004],"tags":[10357,12691,10061,10272,10350,12688,12690,12686],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v24.5 (Yoast SEO v24.5) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How to Setup GitHub Actions with Cypress &amp; Applitools for a Better Automated Testing Workflow - Applitools Blog<\/title>\n<meta name=\"description\" content=\"Applitools provides a number of SDKs that allows you to easily integrate it into your existing workflow. Using tools like Cypress, Espresso, Selenium, Appium, and a wide variety of others,...\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/app14743.cloudwayssites.com\/blog\/github-actions-with-cypress-and-applitools\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Setup GitHub Actions with Cypress &amp; Applitools for a Better Automated Testing Workflow\" \/>\n<meta property=\"og:description\" content=\"Applitools provides a number of SDKs that allows you to easily integrate it into your existing workflow. Using tools like Cypress, Espresso, Selenium,\" \/>\n<meta property=\"og:url\" content=\"https:\/\/app14743.cloudwayssites.com\/blog\/github-actions-with-cypress-and-applitools\/\" \/>\n<meta property=\"og:site_name\" content=\"AI-Powered End-to-End Testing | Applitools\" \/>\n<meta property=\"article:published_time\" content=\"2021-03-01T20:37:37+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2021-03-03T21:11:28+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/app14743.cloudwayssites.com\/wp-content\/uploads\/2021\/03\/image-1.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1662\" \/>\n\t<meta property=\"og:image:height\" content=\"1084\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Colby Fayock\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Colby Fayock\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"11 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/app14743.cloudwayssites.com\/blog\/github-actions-with-cypress-and-applitools\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/app14743.cloudwayssites.com\/blog\/github-actions-with-cypress-and-applitools\/\"},\"author\":{\"name\":\"Colby Fayock\",\"@id\":\"https:\/\/app14743.cloudwayssites.com\/#\/schema\/person\/9e804c33885876e31fe8a1cd871c31c8\"},\"headline\":\"How to Setup GitHub Actions with Cypress &#038; Applitools for a Better Automated Testing Workflow\",\"datePublished\":\"2021-03-01T20:37:37+00:00\",\"dateModified\":\"2021-03-03T21:11:28+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/app14743.cloudwayssites.com\/blog\/github-actions-with-cypress-and-applitools\/\"},\"wordCount\":2051,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/app14743.cloudwayssites.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/app14743.cloudwayssites.com\/blog\/github-actions-with-cypress-and-applitools\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/app14743.cloudwayssites.com\/wp-content\/uploads\/2021\/03\/image-1.jpg\",\"keywords\":[\"Cypress\",\"Developers\",\"Functional Testing\",\"GitHub\",\"Shift Left\",\"Technical Leaders\",\"Test Engineers\",\"Visual Testing Strategies\"],\"articleSection\":[\"Advanced Topics\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/app14743.cloudwayssites.com\/blog\/github-actions-with-cypress-and-applitools\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/app14743.cloudwayssites.com\/blog\/github-actions-with-cypress-and-applitools\/\",\"url\":\"https:\/\/app14743.cloudwayssites.com\/blog\/github-actions-with-cypress-and-applitools\/\",\"name\":\"How to Setup GitHub Actions with Cypress & Applitools for a Better Automated Testing Workflow - Applitools Blog\",\"isPartOf\":{\"@id\":\"https:\/\/app14743.cloudwayssites.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/app14743.cloudwayssites.com\/blog\/github-actions-with-cypress-and-applitools\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/app14743.cloudwayssites.com\/blog\/github-actions-with-cypress-and-applitools\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/app14743.cloudwayssites.com\/wp-content\/uploads\/2021\/03\/image-1.jpg\",\"datePublished\":\"2021-03-01T20:37:37+00:00\",\"dateModified\":\"2021-03-03T21:11:28+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/app14743.cloudwayssites.com\/blog\/github-actions-with-cypress-and-applitools\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/app14743.cloudwayssites.com\/blog\/github-actions-with-cypress-and-applitools\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/app14743.cloudwayssites.com\/blog\/github-actions-with-cypress-and-applitools\/#primaryimage\",\"url\":\"https:\/\/app14743.cloudwayssites.com\/wp-content\/uploads\/2021\/03\/image-1.jpg\",\"contentUrl\":\"https:\/\/app14743.cloudwayssites.com\/wp-content\/uploads\/2021\/03\/image-1.jpg\",\"width\":1662,\"height\":1084},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/app14743.cloudwayssites.com\/blog\/github-actions-with-cypress-and-applitools\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/app14743.cloudwayssites.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Advanced Topics\",\"item\":\"https:\/\/app14743.cloudwayssites.com\/blog\/category\/advanced-topics\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"How to Setup GitHub Actions with Cypress &#038; Applitools for a Better Automated Testing Workflow\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/app14743.cloudwayssites.com\/#website\",\"url\":\"https:\/\/app14743.cloudwayssites.com\/\",\"name\":\"Applitools Visual AI\",\"description\":\"Applitools delivers full end-to-end test automation with AI infused at every step.\",\"publisher\":{\"@id\":\"https:\/\/app14743.cloudwayssites.com\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/app14743.cloudwayssites.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/app14743.cloudwayssites.com\/#organization\",\"name\":\"Applitools\",\"url\":\"https:\/\/app14743.cloudwayssites.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/app14743.cloudwayssites.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/app14743.cloudwayssites.com\/wp-content\/uploads\/2020\/03\/applitools.png\",\"contentUrl\":\"https:\/\/app14743.cloudwayssites.com\/wp-content\/uploads\/2020\/03\/applitools.png\",\"width\":156,\"height\":28,\"caption\":\"Applitools\"},\"image\":{\"@id\":\"https:\/\/app14743.cloudwayssites.com\/#\/schema\/logo\/image\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\/\/app14743.cloudwayssites.com\/#\/schema\/person\/9e804c33885876e31fe8a1cd871c31c8\",\"name\":\"Colby Fayock\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/app14743.cloudwayssites.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/c37c3688dcc3eedacf6d1351f1700ec4?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/c37c3688dcc3eedacf6d1351f1700ec4?s=96&d=mm&r=g\",\"caption\":\"Colby Fayock\"},\"url\":\"https:\/\/app14743.cloudwayssites.com\/blog\/author\/cfayock\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"How to Setup GitHub Actions with Cypress & Applitools for a Better Automated Testing Workflow - Applitools Blog","description":"Applitools provides a number of SDKs that allows you to easily integrate it into your existing workflow. Using tools like Cypress, Espresso, Selenium, Appium, and a wide variety of others,...","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/app14743.cloudwayssites.com\/blog\/github-actions-with-cypress-and-applitools\/","og_locale":"en_US","og_type":"article","og_title":"How to Setup GitHub Actions with Cypress & Applitools for a Better Automated Testing Workflow","og_description":"Applitools provides a number of SDKs that allows you to easily integrate it into your existing workflow. Using tools like Cypress, Espresso, Selenium,","og_url":"https:\/\/app14743.cloudwayssites.com\/blog\/github-actions-with-cypress-and-applitools\/","og_site_name":"AI-Powered End-to-End Testing | Applitools","article_published_time":"2021-03-01T20:37:37+00:00","article_modified_time":"2021-03-03T21:11:28+00:00","og_image":[{"width":1662,"height":1084,"url":"https:\/\/app14743.cloudwayssites.com\/wp-content\/uploads\/2021\/03\/image-1.jpg","type":"image\/jpeg"}],"author":"Colby Fayock","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Colby Fayock","Est. reading time":"11 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/app14743.cloudwayssites.com\/blog\/github-actions-with-cypress-and-applitools\/#article","isPartOf":{"@id":"https:\/\/app14743.cloudwayssites.com\/blog\/github-actions-with-cypress-and-applitools\/"},"author":{"name":"Colby Fayock","@id":"https:\/\/app14743.cloudwayssites.com\/#\/schema\/person\/9e804c33885876e31fe8a1cd871c31c8"},"headline":"How to Setup GitHub Actions with Cypress &#038; Applitools for a Better Automated Testing Workflow","datePublished":"2021-03-01T20:37:37+00:00","dateModified":"2021-03-03T21:11:28+00:00","mainEntityOfPage":{"@id":"https:\/\/app14743.cloudwayssites.com\/blog\/github-actions-with-cypress-and-applitools\/"},"wordCount":2051,"commentCount":0,"publisher":{"@id":"https:\/\/app14743.cloudwayssites.com\/#organization"},"image":{"@id":"https:\/\/app14743.cloudwayssites.com\/blog\/github-actions-with-cypress-and-applitools\/#primaryimage"},"thumbnailUrl":"https:\/\/app14743.cloudwayssites.com\/wp-content\/uploads\/2021\/03\/image-1.jpg","keywords":["Cypress","Developers","Functional Testing","GitHub","Shift Left","Technical Leaders","Test Engineers","Visual Testing Strategies"],"articleSection":["Advanced Topics"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/app14743.cloudwayssites.com\/blog\/github-actions-with-cypress-and-applitools\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/app14743.cloudwayssites.com\/blog\/github-actions-with-cypress-and-applitools\/","url":"https:\/\/app14743.cloudwayssites.com\/blog\/github-actions-with-cypress-and-applitools\/","name":"How to Setup GitHub Actions with Cypress & Applitools for a Better Automated Testing Workflow - Applitools Blog","isPartOf":{"@id":"https:\/\/app14743.cloudwayssites.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/app14743.cloudwayssites.com\/blog\/github-actions-with-cypress-and-applitools\/#primaryimage"},"image":{"@id":"https:\/\/app14743.cloudwayssites.com\/blog\/github-actions-with-cypress-and-applitools\/#primaryimage"},"thumbnailUrl":"https:\/\/app14743.cloudwayssites.com\/wp-content\/uploads\/2021\/03\/image-1.jpg","datePublished":"2021-03-01T20:37:37+00:00","dateModified":"2021-03-03T21:11:28+00:00","breadcrumb":{"@id":"https:\/\/app14743.cloudwayssites.com\/blog\/github-actions-with-cypress-and-applitools\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/app14743.cloudwayssites.com\/blog\/github-actions-with-cypress-and-applitools\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/app14743.cloudwayssites.com\/blog\/github-actions-with-cypress-and-applitools\/#primaryimage","url":"https:\/\/app14743.cloudwayssites.com\/wp-content\/uploads\/2021\/03\/image-1.jpg","contentUrl":"https:\/\/app14743.cloudwayssites.com\/wp-content\/uploads\/2021\/03\/image-1.jpg","width":1662,"height":1084},{"@type":"BreadcrumbList","@id":"https:\/\/app14743.cloudwayssites.com\/blog\/github-actions-with-cypress-and-applitools\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/app14743.cloudwayssites.com\/"},{"@type":"ListItem","position":2,"name":"Advanced Topics","item":"https:\/\/app14743.cloudwayssites.com\/blog\/category\/advanced-topics\/"},{"@type":"ListItem","position":3,"name":"How to Setup GitHub Actions with Cypress &#038; Applitools for a Better Automated Testing Workflow"}]},{"@type":"WebSite","@id":"https:\/\/app14743.cloudwayssites.com\/#website","url":"https:\/\/app14743.cloudwayssites.com\/","name":"Applitools Visual AI","description":"Applitools delivers full end-to-end test automation with AI infused at every step.","publisher":{"@id":"https:\/\/app14743.cloudwayssites.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/app14743.cloudwayssites.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/app14743.cloudwayssites.com\/#organization","name":"Applitools","url":"https:\/\/app14743.cloudwayssites.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/app14743.cloudwayssites.com\/#\/schema\/logo\/image\/","url":"https:\/\/app14743.cloudwayssites.com\/wp-content\/uploads\/2020\/03\/applitools.png","contentUrl":"https:\/\/app14743.cloudwayssites.com\/wp-content\/uploads\/2020\/03\/applitools.png","width":156,"height":28,"caption":"Applitools"},"image":{"@id":"https:\/\/app14743.cloudwayssites.com\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/app14743.cloudwayssites.com\/#\/schema\/person\/9e804c33885876e31fe8a1cd871c31c8","name":"Colby Fayock","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/app14743.cloudwayssites.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/c37c3688dcc3eedacf6d1351f1700ec4?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/c37c3688dcc3eedacf6d1351f1700ec4?s=96&d=mm&r=g","caption":"Colby Fayock"},"url":"https:\/\/app14743.cloudwayssites.com\/blog\/author\/cfayock\/"}]}},"_links":{"self":[{"href":"https:\/\/app14743.cloudwayssites.com\/wp-json\/wp\/v2\/posts\/27315"}],"collection":[{"href":"https:\/\/app14743.cloudwayssites.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/app14743.cloudwayssites.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/app14743.cloudwayssites.com\/wp-json\/wp\/v2\/users\/65"}],"replies":[{"embeddable":true,"href":"https:\/\/app14743.cloudwayssites.com\/wp-json\/wp\/v2\/comments?post=27315"}],"version-history":[{"count":0,"href":"https:\/\/app14743.cloudwayssites.com\/wp-json\/wp\/v2\/posts\/27315\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/app14743.cloudwayssites.com\/wp-json\/wp\/v2\/media\/27413"}],"wp:attachment":[{"href":"https:\/\/app14743.cloudwayssites.com\/wp-json\/wp\/v2\/media?parent=27315"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/app14743.cloudwayssites.com\/wp-json\/wp\/v2\/categories?post=27315"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/app14743.cloudwayssites.com\/wp-json\/wp\/v2\/tags?post=27315"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}