<?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: Costa Alexoglou</title>
    <description>The latest articles on Forem by Costa Alexoglou (@konsalex).</description>
    <link>https://forem.com/konsalex</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%2F787389%2F205adc79-247d-4b43-8692-bc9fcd84f2dc.jpeg</url>
      <title>Forem: Costa Alexoglou</title>
      <link>https://forem.com/konsalex</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/konsalex"/>
    <language>en</language>
    <item>
      <title>Quick &amp; Dirty Visual Testing 👁</title>
      <dc:creator>Costa Alexoglou</dc:creator>
      <pubDate>Mon, 18 Apr 2022 20:47:23 +0000</pubDate>
      <link>https://forem.com/konsalex/quick-dirty-visual-testing-53fk</link>
      <guid>https://forem.com/konsalex/quick-dirty-visual-testing-53fk</guid>
      <description>&lt;p&gt;Testing is essential, but the truth is that it is not always the case.&lt;/p&gt;

&lt;p&gt;I have caught myself and noticed many professional friends working on freelancing projects with tight deadlines, and dealing with frameworks not easy to test (Gatsby, Next.js etc), just ignoring the testing part.&lt;/p&gt;

&lt;p&gt;What can we do in cases like these, to ensure a good deliverable quality?&lt;br&gt;
Maybe we can set up E2E tests, but then we can easily miss important visual changes. Or set up visual-testing with services like Chromatic and visit their dashboards for approvals in every deployment?&lt;/p&gt;

&lt;p&gt;While the aforementioned options are totally valid, they can add more time in the &lt;strong&gt;develop-test-deploy&lt;/strong&gt; loop, and time is money 💸 Those are the reason I started a project, called &lt;strong&gt;Cyclopes 👁&lt;/strong&gt; to perform quick &amp;amp; dirty visual testing.&lt;/p&gt;
&lt;h3&gt;
  
  
  How Cyclopes Works
&lt;/h3&gt;

&lt;p&gt;Cyclopes is a minimal CLI tool to help you &lt;strong&gt;capture screenshots of important pages&lt;/strong&gt; of your web app, and then &lt;strong&gt;send them to the tools you love working&lt;/strong&gt; like Slack or Trello.&lt;/p&gt;

&lt;p&gt;So basically there are two main functionalities to help you:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;capture changes of your web app and then&lt;/li&gt;
&lt;li&gt;communicate them with your client, teammates, QA engineer etc.&lt;/li&gt;
&lt;/ol&gt;
&lt;h3&gt;
  
  
  How to use Cyclopes
&lt;/h3&gt;

&lt;p&gt;To start using cyclopes it’s really easy. All the code below is shared in the &lt;a href="https://github.com/konsalex/cyclopes-gatsby-demo" rel="noopener noreferrer"&gt;public repo here&lt;/a&gt; 👈&lt;/p&gt;
&lt;h4&gt;
  
  
  Install Cyclopes
&lt;/h4&gt;

&lt;p&gt;Let’s install &lt;strong&gt;cyclopes&lt;/strong&gt; with one of the following commands inside our repository. The first two will download the npm package which is very lightweight. This is because the binary of cyclopes will be downloaded in the first run if it is not found.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# npm&lt;/span&gt;
npm &lt;span class="nb"&gt;install &lt;/span&gt;cyclopes

&lt;span class="c"&gt;# yarn&lt;/span&gt;
yarn add cyclopes

&lt;span class="c"&gt;# golang (for Hugo folks)&lt;/span&gt;
go get &lt;span class="nt"&gt;-u&lt;/span&gt; github.com/konsalex/cyclopes
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Setting up Cyclopes
&lt;/h4&gt;

&lt;p&gt;To set up cyclopes we need to figure out some details first. Let’s create a &lt;code&gt;cyclops.yml&lt;/code&gt; file in the root of our repository and paste the following content&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Directory where the images will be saved&lt;/span&gt;
&lt;span class="c"&gt;# and/or retrieved from the channel adapters&lt;/span&gt;
imagesDir: &lt;span class="s2"&gt;"./images"&lt;/span&gt;

visual:
  &lt;span class="c"&gt;# Path where our web-app is built&lt;/span&gt;
  &lt;span class="c"&gt;# Useful in CI environments where we build&lt;/span&gt;
  &lt;span class="c"&gt;# the website and the artifacts are ready&lt;/span&gt;
  buildDir: &lt;span class="s2"&gt;"./public"&lt;/span&gt;
  &lt;span class="c"&gt;# Pages to visit and screenshot&lt;/span&gt;
  pages:
    &lt;span class="c"&gt;# Path of the page&lt;/span&gt;
    - path: &lt;span class="s2"&gt;"/"&lt;/span&gt;
      &lt;span class="c"&gt;# Type of device to screenshot&lt;/span&gt;
      device: &lt;span class="s2"&gt;"both"&lt;/span&gt;
      &lt;span class="c"&gt;# Delay after the page is loaded&lt;/span&gt;
      delay: 2000
      screenshot: &lt;span class="s2"&gt;"fullpage"&lt;/span&gt;
    - path: &lt;span class="s2"&gt;"/contact"&lt;/span&gt;
      device: &lt;span class="s2"&gt;"mobile"&lt;/span&gt;
    - path: &lt;span class="s2"&gt;"team/"&lt;/span&gt;
      device: &lt;span class="s2"&gt;"desktop"&lt;/span&gt;
      screenshot: &lt;span class="s2"&gt;"viewport"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So what is the above configuration doing? In simple terms:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Save all the images to &lt;code&gt;./images&lt;/code&gt;  folder&lt;/li&gt;
&lt;li&gt;Find the website to serve it in the &lt;code&gt;./public&lt;/code&gt; folder&lt;/li&gt;
&lt;li&gt;Now for every page in &lt;code&gt;pages&lt;/code&gt; iterate and screenshot&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;For more options, you can see the &lt;a href="https://github.com/konsalex/cyclopes#how-to-configure" rel="noopener noreferrer"&gt;README&lt;/a&gt; in the project’s repository, and also find the default values of the options.&lt;/p&gt;

&lt;h4&gt;
  
  
  Run the CLI
&lt;/h4&gt;

&lt;p&gt;Now let’s run cyclopes and check the results.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;yarn cyclopes
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If everything was successful, your &lt;code&gt;images&lt;/code&gt; folder should have 4 new images (one of them attached below) 🎊 &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fsxo66g8rmr1ylv71p750.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fsxo66g8rmr1ylv71p750.jpeg" alt="Example Screenshot"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Those are the screenshots we took of our web-app. It’s that easy!&lt;/p&gt;

&lt;h4&gt;
  
  
  Send the results to Slack (Optional)
&lt;/h4&gt;

&lt;p&gt;The ultimate reason for making this CLI, was a faster feedback loop between my clients and me, especially when I was breaking stuff 🤭  That’s why a Slack adapter is included out of the box, so we can send the screenshots to our Slack workspace &lt;/p&gt;

&lt;p&gt;To set the Slack adapter we can extend our configuration file with the following code (assuming you have created a Slack bot):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;adapters&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;slack&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;OAUTH_TOKEN&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;example-token&lt;/span&gt;
    &lt;span class="na"&gt;CHANNEL_ID&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;example-token&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And the result should look like the image below &lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fsmcmxv1l65rjcavrri62.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fsmcmxv1l65rjcavrri62.jpg" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>testing</category>
      <category>go</category>
      <category>javascript</category>
      <category>webdev</category>
    </item>
  </channel>
</rss>
