<?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: Feralamillo</title>
    <description>The latest articles on Forem by Feralamillo (@feralamillo).</description>
    <link>https://forem.com/feralamillo</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%2F140123%2F60558027-b222-43e2-8534-649f3a276c9d.jpeg</url>
      <title>Forem: Feralamillo</title>
      <link>https://forem.com/feralamillo</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/feralamillo"/>
    <language>en</language>
    <item>
      <title>Deploy a React App to AWS S3 with GitHub Actions: A Step-By-Step Guide</title>
      <dc:creator>Feralamillo</dc:creator>
      <pubDate>Mon, 08 Aug 2022 16:02:16 +0000</pubDate>
      <link>https://forem.com/feralamillo/deploy-a-react-app-to-aws-s3-with-github-actions-a-step-by-step-guide-3kf4</link>
      <guid>https://forem.com/feralamillo/deploy-a-react-app-to-aws-s3-with-github-actions-a-step-by-step-guide-3kf4</guid>
      <description>&lt;h4&gt;
  
  
  In this beginner-friendly article, you can find out how to deploy your React App to AWS S3 using GitHub Actions.
&lt;/h4&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Yk3NFbSV--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1024/0%2AAuN2sfBI0OqSp4mA" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Yk3NFbSV--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1024/0%2AAuN2sfBI0OqSp4mA" alt="" width="880" height="586"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;Photo by Lautaro Andreani on Unsplash&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;After reading different articles, it was a little bit difficult to get all the pieces of the puzzle together so I have decided to create a step-by-step guide for beginners so you can deploy your app in less than 10 minutes.&lt;/p&gt;

&lt;p&gt;This is what is covered in case you want to jump to a particular section:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Create React App&lt;/li&gt;
&lt;li&gt;AWS: Create IAM user&lt;/li&gt;
&lt;li&gt;AWS: Create S3 Bucket&lt;/li&gt;
&lt;li&gt;GitHub Actions&lt;/li&gt;
&lt;/ol&gt;
&lt;h3&gt;
  
  
  1. Create React App
&lt;/h3&gt;

&lt;p&gt;From your favourite terminal, run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;yarn create react-app test-aws-github-actions --template typescript
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For more information about the script, you can &lt;a href="https://create-react-app.dev/docs/adding-typescript/"&gt;visit the documentation of create react app&lt;/a&gt;. If you run the project with yarn start you should be able to see the classic template.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--SKB-G3kS--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1024/1%2ARv8sPMXOQjoCSevCu2Gd1w.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--SKB-G3kS--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1024/1%2ARv8sPMXOQjoCSevCu2Gd1w.png" alt="" width="880" height="579"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;Create React App Template&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;I also want to cover how to use environment variables so I’m going to add a .env file and update the main text. The environment variable is:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;REACT_APP_MAIN_TEXT="Testing AWS"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It’s a very simple text but it will help us understand the process. You can see the change in the git history in the image. It’s just displaying the text on the main screen.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--GugzRvQP--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1024/1%2AOJ6filz6St_aivVw9WzxjQ.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--GugzRvQP--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1024/1%2AOJ6filz6St_aivVw9WzxjQ.png" alt="" width="880" height="516"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As you can see, the text from the environment variable is displayed on the main page below the React icon.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ZVwPq6_1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1024/1%2Ax3Z4uAAiqsVGQljtiSNkJQ.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ZVwPq6_1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1024/1%2Ax3Z4uAAiqsVGQljtiSNkJQ.png" alt="" width="880" height="518"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;React with environment variable&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Now you can push the code to a Github repository and let’s start looking at the AWS side of things.&lt;/p&gt;
&lt;h3&gt;
  
  
  2. AWS: Create IAM user
&lt;/h3&gt;

&lt;p&gt;The first thing that you need is a user in AWS. From the IAM console, add a user. There are 5 steps in the process of creation&lt;/p&gt;
&lt;h4&gt;
  
  
  Create User Step 1
&lt;/h4&gt;

&lt;p&gt;Name the user as you want. I’m creating a user only for this project so I have named it the same way. In GitHub actions, we need a key so you can select it in the initial screen.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--kFUFhrWY--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1024/1%2AohTs0DyKe16ck2ytAXHW8w.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--kFUFhrWY--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1024/1%2AohTs0DyKe16ck2ytAXHW8w.png" alt="" width="880" height="798"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;IAM create user 1&lt;/em&gt;&lt;/p&gt;
&lt;h4&gt;
  
  
  Create User Step 2
&lt;/h4&gt;

&lt;p&gt;The second step is to provide permissions to the user. You can select AdminsitratorAccess&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--48qqe4aa--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1024/1%2AVTtEmal0MoQx6qnAFMJK0w.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--48qqe4aa--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1024/1%2AVTtEmal0MoQx6qnAFMJK0w.png" alt="" width="880" height="819"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;IAM create user 2&lt;/em&gt;&lt;/p&gt;
&lt;h4&gt;
  
  
  Create User Step 3
&lt;/h4&gt;

&lt;p&gt;This step allows you to add tags. Feel free to add any relevant things that can be useful for your admin.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--5RBnNQXy--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1024/1%2AsMXlgMJ6uBn5SX9MEtb4-w.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--5RBnNQXy--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1024/1%2AsMXlgMJ6uBn5SX9MEtb4-w.png" alt="" width="880" height="816"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;IAM create user 3&lt;/em&gt;&lt;/p&gt;
&lt;h4&gt;
  
  
  Create User Step 4
&lt;/h4&gt;

&lt;p&gt;Now you can review the information provided in the previous steps. This will create the user for you so check the details to ensure it’s all correct.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--NOtR8vqb--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1024/1%2A3kyNp6IG926-a4Q0WLykYg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--NOtR8vqb--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1024/1%2A3kyNp6IG926-a4Q0WLykYg.png" alt="" width="880" height="831"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;IAM create user 4&lt;/em&gt;&lt;/p&gt;
&lt;h4&gt;
  
  
  Create User Step 5
&lt;/h4&gt;

&lt;p&gt;This is the summary of the user. You’ll see an access key and a secret that you need to save as it will be used by the GitHub actions.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--0A7VzQSg--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1024/1%2AbXP2r8IAkR-d6fEZjEITSw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--0A7VzQSg--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1024/1%2AbXP2r8IAkR-d6fEZjEITSw.png" alt="" width="880" height="256"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;IAM create user 5&lt;/em&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  3. AWS: Create S3 Bucket
&lt;/h3&gt;

&lt;p&gt;In AWS, create an S3 bucket: &lt;a href="https://s3.console.aws.amazon.com/s3/bucket/create"&gt;https://s3.console.aws.amazon.com/s3/bucket/create&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here, it’s important to enable the ACLs; otherwise, you’ll get an error from GitHub actions.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ZdSBUQVI--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1024/1%2AxeDlgIlYk1V5z9vH1qPaTg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ZdSBUQVI--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1024/1%2AxeDlgIlYk1V5z9vH1qPaTg.png" alt="" width="880" height="958"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;Create AWS S3&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;And unblock the public access.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--zoiYwn9I--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1024/1%2APTbuZhGjFWJCDpqr1ThTcQ.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--zoiYwn9I--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1024/1%2APTbuZhGjFWJCDpqr1ThTcQ.png" alt="" width="880" height="754"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;Create AWS S3&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;In the properties area, you can find a section for static website hosting. Enable the static website hosting and update the Index document and Error document to index.html.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--_bIu3xfy--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1024/1%2ADqfucOfjdcQG5inbhn59_w.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--_bIu3xfy--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1024/1%2ADqfucOfjdcQG5inbhn59_w.png" alt="" width="880" height="840"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After you save the changes, you will see the URL for the hosting.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--sXdUOVit--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1024/1%2A3pmrjUaZ0ZQd4ga8c3PGEw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--sXdUOVit--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1024/1%2A3pmrjUaZ0ZQd4ga8c3PGEw.png" alt="" width="880" height="580"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;Static Website Hosting AWS S3&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;That is all with AWS.&lt;/p&gt;
&lt;h3&gt;
  
  
  4. GitHub actions
&lt;/h3&gt;

&lt;p&gt;In the repo, create a new file.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;name: Deploy AWS
on:
  push:
    branches:
      - main

env:
  REACT_APP_MAIN_TEXT: "Successfully deployed in AWS"
  AWS_S3_BUCKET: ${{ secrets.AWS_BUCKET_NAME }}
  AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
  AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
  AWS_REGION: ${{ secrets.AWS_REGION }}
  SOURCE_DIR: "build"

jobs:
  build:
    runs-on: ubuntu-latest

strategy:
      matrix:
        node-version: [16.x]

steps:
    - uses: actions/checkout@v1
    - name: Use Node.js ${{ matrix.node-version }}
      uses: actions/setup-node@v1
      with:
        node-version: ${{ matrix.node-version }}

- name: Yarn Install
      run: yarn install

- name: Staging Build
      run: yarn build

- name: Deploy to S3
      uses: jakejarvis/s3-sync-action@master
      with:
        args: --acl public-read --follow-symlinks --delete
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In GitHub, update the &lt;a href="https://docs.github.com/en/actions/security-guides/encrypted-secrets"&gt;action secrets&lt;/a&gt; including:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;AWS_BUCKET_NAME&lt;/li&gt;
&lt;li&gt;AWS_ACCESS_KEY_ID&lt;/li&gt;
&lt;li&gt;AWS_SECRET_ACCESS_KEY&lt;/li&gt;
&lt;li&gt;AWS_REGION&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--A8oeA34G--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1024/1%2AynRDWdOqDxoPuxivLDsPRA.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--A8oeA34G--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1024/1%2AynRDWdOqDxoPuxivLDsPRA.png" alt="" width="880" height="507"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;GitHub secrets&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Once you commit and push, you’ll see the action running:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--8lv0dZ5j--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1024/1%2AZ_MJGMdfVZoAcbZRkz3w_g.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--8lv0dZ5j--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1024/1%2AZ_MJGMdfVZoAcbZRkz3w_g.png" alt="" width="880" height="693"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;GitHub Action&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;If you check your S3 bucket, you’ll see all the files from the build folder:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--kLnBvdOZ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1024/1%2AOb2THT2eSdle53eVcPPmig.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--kLnBvdOZ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1024/1%2AOb2THT2eSdle53eVcPPmig.png" alt="" width="880" height="385"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;AWS S3 Files deployed from GitHub Actions&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;And you’ll be able to see your React app working:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--01pQDrCi--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1024/1%2AoUg2m-sRJGgoo1elBfXzSw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--01pQDrCi--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1024/1%2AoUg2m-sRJGgoo1elBfXzSw.png" alt="" width="880" height="829"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;React App Deployed in AWS&lt;/em&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  Troubleshooting
&lt;/h3&gt;
&lt;h4&gt;
  
  
  Issues with paths
&lt;/h4&gt;

&lt;p&gt;If you haven’t set up the hosting, you will see an issue with some paths. This is because the bucket will manage the URLs and with React, as it’s a single-page app, it needs all the routes pointing at the index.html so React can manage the routing by itself.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;This XML file does not appear to have any style information associated with it. The document tree is shown below.
&amp;lt;Error&amp;gt;
&amp;lt;Code&amp;gt;AccessDenied&amp;lt;/Code&amp;gt;
&amp;lt;Message&amp;gt;Access Denied&amp;lt;/Message&amp;gt;
&amp;lt;/Error&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--tpAAI87k--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1024/1%2AsWdu8ItKqfalp1bZsDj_tw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--tpAAI87k--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1024/1%2AsWdu8ItKqfalp1bZsDj_tw.png" alt="" width="880" height="247"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To fix it, you need to make a small update in the S3 configuration in the area of Website Hosting. See the step.&lt;/p&gt;

&lt;h4&gt;
  
  
  Issues with ACL
&lt;/h4&gt;

&lt;p&gt;If you are getting an error related to ACL in your GitHub actions, it is because ACLs are disabled. You need to enable them in the AWS S3 config.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;upload failed: build/asset-manifest.json to s3://***/asset-manifest.json An error occurred (AccessControlListNotSupported) when calling the PutObject operation: The bucket does not allow ACLs
upload failed: build/robots.txt to s3://***/robots.txt An error occurred (AccessControlListNotSupported) when calling the PutObject operation: The bucket does not allow ACLs
upload failed: build/logo512.png to s3://***/logo512.png An error occurred (AccessControlListNotSupported) when calling the PutObject operation: The bucket does not allow ACLs
upload failed: build/static/js/787.e67aebaf.chunk.js.map to s3://***/static/js/787.e67aebaf.chunk.js.map An error occurred (AccessControlListNotSupported) when calling the PutObject operation: The bucket does not allow ACLs
upload failed: build/static/css/main.e6c13ad2.css to s3://***/static/css/main.e6c13ad2.css An error occurred (AccessControlListNotSupported) when calling the PutObject operation: The bucket does not allow ACLs
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--hDGpij-g--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1024/1%2Ai461ReBNfVJcmnfpzlLY6w.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--hDGpij-g--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1024/1%2Ai461ReBNfVJcmnfpzlLY6w.png" alt="" width="880" height="275"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To fix it, you need to make a small update on the AWS S3 config enabling ACLs.&lt;/p&gt;

&lt;p&gt;That’s it, thank you.&lt;/p&gt;




</description>
      <category>javascript</category>
      <category>react</category>
      <category>aws</category>
      <category>programming</category>
    </item>
    <item>
      <title>Mocking date.now() with jest.</title>
      <dc:creator>Feralamillo</dc:creator>
      <pubDate>Thu, 01 Oct 2020 10:18:28 +0000</pubDate>
      <link>https://forem.com/feralamillo/mocking-date-now-with-jest-32k2</link>
      <guid>https://forem.com/feralamillo/mocking-date-now-with-jest-32k2</guid>
      <description>&lt;p&gt;Mocking &lt;code&gt;Date.now()&lt;/code&gt; in a jest unit test.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;jest
 .spyOn(global.Date, 'now')
 .mockImplementationOnce(() =&amp;gt;
    new Date('2010-10-10T10:10:10.100Z').valueOf()
  );
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



</description>
      <category>jest</category>
    </item>
    <item>
      <title>Gatsby Typescript and Sass conf</title>
      <dc:creator>Feralamillo</dc:creator>
      <pubDate>Wed, 01 Apr 2020 18:01:01 +0000</pubDate>
      <link>https://forem.com/feralamillo/gatsby-typescript-and-sass-conf-1ac0</link>
      <guid>https://forem.com/feralamillo/gatsby-typescript-and-sass-conf-1ac0</guid>
      <description>&lt;p&gt;&lt;a href="https://medium.com/@feralamillo/gatsby-typescript-and-sass-conf-a7ba527cfba9?source=rss-2a4e1f350138------2"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--6z1n1LY2--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1842/1%2Aohtd4_SJjGIuIpgAG_eF7A.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you are also very fan of React with Typescript and you want to start working with Gatsby this post is for you. I'm going to cover how to setup the basic environment including Typescript, Sass, linting and prettier for Gatsby.&lt;br&gt;
I have been using React mainly with create-react-app as it is a nice tool that comes ready to use specially with npx create-react-app  --template typescript. Recently I see that Gatsby is getting more and more importance so I'm very eager to try it.&lt;/p&gt;
&lt;h3&gt;
  
  
  Gatsby typescript
&lt;/h3&gt;

&lt;p&gt;The create react app templates are called starters in Gatsby. I have been checking 2 typescript starters comparing with the javascript version and don't provide as much value as the original version:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Gatsby starter typescript&lt;/li&gt;
&lt;li&gt;Gatsby starter typescript plus&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Until these projects don't evolve a little bit I'm going to do small modifications to the basic Gatsby. These also has the benefit that the core version is usually better maintained. We are going to set it up in less than 5 minutes with these 3 steps:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Install Gatsby&lt;/li&gt;
&lt;li&gt;Install typescript and update configuration&lt;/li&gt;
&lt;li&gt;Update files&lt;/li&gt;
&lt;/ol&gt;
&lt;h4&gt;
  
  
  1. Install Gatsby
&lt;/h4&gt;

&lt;p&gt;Gatsby can be installed globally in your computer and then using the cli commands or you can just use directly npx. I prefer to avoid installing more things so I'll go with the second one. From the terminal:&lt;br&gt;
&lt;code&gt;npx gatsby new &amp;lt;project-name&amp;gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;This will take a couple of minutes and install all the necessary stuff. When opening the project, you can see inside the srcfolder:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;| src
| -- components
| -- images
| -- pages
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Components and pages have some javascript files. To verify that everything works you can run &lt;code&gt;npm start&lt;/code&gt; and you'll see the app in &lt;code&gt;localhost:8080&lt;/code&gt;.&lt;br&gt;
If you want, as Gatsby doesn't come with a git, I suggest that you initialize it at this point.&lt;/p&gt;
&lt;h4&gt;
  
  
  2. Install typescript and update configuration
&lt;/h4&gt;

&lt;p&gt;To have typescript in gatsby you need to install &lt;code&gt;gatsby-plugin-typescript&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm i -E gatsby-plugin-typescript
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;After it's installed, you'll need to update the gatsby config (&lt;code&gt;gatsby-config.js&lt;/code&gt; ) including the plugin. The file should look something like this.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// gatsby-config.js
module.exports = {
  siteMetadata: {
    title: `Gatsby Default Starter`,
    description: `Kick off your next, great Gatsby project with this default starter. This barebones starter ships with the main Gatsby configuration files you might need.`,
    author: `@gatsbyjs`,
  },
  plugins: [
    `gatsby-plugin-react-helmet`,
    {
      resolve: `gatsby-source-filesystem`,
      options: {
        name: `images`,
        path: `${__dirname}/src/images`,
      },
    },
    `gatsby-plugin-typescript`,
    `gatsby-transformer-sharp`,
    `gatsby-plugin-sharp`,
    {
      resolve: `gatsby-plugin-manifest`,
      options: {
        name: `gatsby-starter-default`,
        short_name: `starter`,
        start_url: `/`,
        background_color: `#663399`,
        theme_color: `#663399`,
        display: `minimal-ui`,
        icon: `src/images/gatsby-icon.png`, // This path is relative to the root of the site.
      },
    },
    // this (optional) plugin enables Progressive Web App + Offline functionality
    // To learn more, visit: https://gatsby.dev/offline
    // `gatsby-plugin-offline`,
  ],
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Create the file &lt;code&gt;tsconfig.json&lt;/code&gt; in the root of the project to include the typescript configuration:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// tsconfig.json
{
  "compilerOptions": {
    "experimentalDecorators": true,
    "emitDecoratorMetadata": true,
    "target": "es5",
    "lib": ["dom", "dom.iterable", "esnext"],
    "allowJs": true,
    "skipLibCheck": true,
    "esModuleInterop": true,
    "allowSyntheticDefaultImports": true,
    "strict": true,
    "forceConsistentCasingInFileNames": true,
    "module": "esnext",
    "moduleResolution": "node",
    "resolveJsonModule": true,
    "isolatedModules": true,
    "noEmit": true,
    "jsx": "preserve",
    "baseUrl": "src",
    "paths": {
      "src/*" : ["*"],
    }
  },
  "include": ["src"]
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;As before, to verify that everything works, just run npm start and it should work as before. The files are still in javascript so we haven't done much that can break for now.&lt;/p&gt;

&lt;h4&gt;
  
  
  3. Update files
&lt;/h4&gt;

&lt;p&gt;At this stage, you can just update the &lt;code&gt;.js/.jsx&lt;/code&gt; files to &lt;code&gt;.ts/.tsx&lt;/code&gt; or, if you have already initialize git, update the filenames using git. Don't worry, here is the code:&lt;br&gt;
Using git:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git mv src/components/header.js src/components/header.tsx
git mv src/components/image.js src/components/image.tsx
git mv src/components/layout.js src/components/layout.tsx
git mv src/components/seo.js src/components/seo.tsx
git mv src/pages/404.js src/pages/404.tsx
git mv src/pages/index.js src/pages/index.tsx
git mv src/pages/page-2.js src/pages/page-2.tsx
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Updating the name directly:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;mv src/components/header.js src/components/header.tsx
mv src/components/image.js src/components/image.tsx
mv src/components/layout.js src/components/layout.tsx
mv src/components/seo.js src/components/seo.tsx
mv src/pages/404.js src/pages/404.tsx
mv src/pages/index.js src/pages/index.tsx
mv src/pages/page-2.js src/pages/page-2.tsx
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Last thing, for the formatting with prettier, you also need to update the scripts section in package.json:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"scripts": {
    "build": "gatsby build",
    "develop": "gatsby develop",
    "format": "prettier --write \"**/*.{tsx,ts,js,jsx,json,md}\"",
    "start": "npm run develop",
    "serve": "gatsby serve",
    "clean": "gatsby clean",
    "test": "echo \"Write tests! -&amp;gt; https://gatsby.dev/unit-testing\" &amp;amp;&amp;amp; exit 1"
  },
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Now you can do &lt;code&gt;npm start&lt;/code&gt; to verify that everything works as expected.&lt;/p&gt;

&lt;h3&gt;
  
  
  Gatsby with Sass
&lt;/h3&gt;

&lt;h4&gt;
  
  
  1. Install dependencies
&lt;/h4&gt;

&lt;p&gt;We need to install &lt;code&gt;node-sass&lt;/code&gt; and the plugin &lt;code&gt;gatsby-plugin-sass&lt;/code&gt; so it can work.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm i -E gatsby-plugin-sass node-sass
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h4&gt;
  
  
  2. Update gatsby config
&lt;/h4&gt;

&lt;p&gt;Include the plugin &lt;code&gt;gatsby-plugin-sass&lt;/code&gt; in the gatsby configuration.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// gatsby-config.js
module.exports = {
  siteMetadata: {
    title: `Gatsby Default Starter`,
    description: `Kick off your next, great Gatsby project with this default starter. This barebones starter ships with the main Gatsby configuration files you might need.`,
    author: `@gatsbyjs`,
  },
  plugins: [
    `gatsby-plugin-sass`,
    `gatsby-plugin-react-helmet`,
    {
      resolve: `gatsby-source-filesystem`,
      options: {
        name: `images`,
        path: `${__dirname}/src/images`,
      },
    },
    `gatsby-plugin-typescript`,
    `gatsby-transformer-sharp`,
    `gatsby-plugin-sharp`,
    {
      resolve: `gatsby-plugin-manifest`,
      options: {
        name: `gatsby-starter-default`,
        short_name: `starter`,
        start_url: `/`,
        background_color: `#663399`,
        theme_color: `#663399`,
        display: `minimal-ui`,
        icon: `src/images/gatsby-icon.png`, // This path is relative to the root of the site.
      },
    },
    // this (optional) plugin enables Progressive Web App + Offline functionality
    // To learn more, visit: https://gatsby.dev/offline
    // `gatsby-plugin-offline`,
  ],
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h4&gt;
  
  
  3. Update files
&lt;/h4&gt;

&lt;p&gt;Once the configuration has updated, we can change the .css files to .scss. In the initial installation of gatsby there is only one file which is the layout:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git mv src/components/layout.css src/components/layout.scss
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Remeber to also update the import of this file. It only shows in &lt;code&gt;src/components/layout.tsx&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/**
 * Layout component that queries for data
 * with Gatsby's useStaticQuery component
 *
 * See: https://www.gatsbyjs.org/docs/use-static-query/
 */
import React from "react"
import PropTypes from "prop-types"
import { useStaticQuery, graphql } from "gatsby"
import Header from "./header"
import "./layout.scss"
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Bob's your uncle! You can verify that everything works doing npm start&lt;/p&gt;

&lt;h3&gt;
  
  
  Improvements
&lt;/h3&gt;

&lt;p&gt;As usual, there is always room for improvement. If you have any ideas or suggestions please leave a comment below.&lt;/p&gt;

</description>
      <category>typescript</category>
      <category>sass</category>
      <category>react</category>
      <category>gatsby</category>
    </item>
    <item>
      <title>Bootstrap in Create React App Typescript</title>
      <dc:creator>Feralamillo</dc:creator>
      <pubDate>Wed, 11 Mar 2020 10:16:02 +0000</pubDate>
      <link>https://forem.com/feralamillo/bootstrap-in-create-react-app-typescript-1mjl</link>
      <guid>https://forem.com/feralamillo/bootstrap-in-create-react-app-typescript-1mjl</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--nIburKUv--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1024/1%2Aw8VvSwO0HR3r8d210u1Vog.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--nIburKUv--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1024/1%2Aw8VvSwO0HR3r8d210u1Vog.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After setting up the basic configuration for linting and testing is time to start working on the proper project. To make the development faster, the best is to use some frontend component library so we can have a good styling.&lt;/p&gt;

&lt;p&gt;Bootstrap is one of the most extended options out there, there is plenty of documentation so I’m going to cover how to set it up including a custom colour template. As usual, my aim is to have it working in less than 10 minutes.&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Install dependencies
&lt;/h3&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm i bootstrap node-sass --exact
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;As a clarification, we are installing bootstrap for the library and node-sass to be able to work with .scss files.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Display some elements
&lt;/h3&gt;

&lt;p&gt;To verify if we are doing things properly, let’s add a screen. To showcase the configuration I’m using the &lt;a href="https://getbootstrap.com/docs/4.0/examples/album/"&gt;Album example from bootstrap&lt;/a&gt; mostly updatingclass for className and splitting the bits into components for easier readability.&lt;/p&gt;

&lt;p&gt;Using App as the initial component that will have different components inside.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// src/App.tsx

import React from 'react';

import { Header } from './components/header';
import { Main } from './components/main';
import { Footer } from './components/footer';

import './styles.css';

export const App = () =&amp;gt; {
 return (
  &amp;lt;&amp;gt;
   &amp;lt;Header /&amp;gt;
   &amp;lt;Main /&amp;gt;
   &amp;lt;Footer /&amp;gt;
  &amp;lt;/&amp;gt;
 );
};

export default App;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Header&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// src/components/header.tsx

/* eslint-disable jsx-a11y/anchor-is-valid */
import React from 'react';

export const Header = () =&amp;gt; {
 return (
  &amp;lt;header&amp;gt;
   &amp;lt;div className="collapse bg-dark" id="navbarHeader"&amp;gt;
    &amp;lt;div className="container"&amp;gt;
     &amp;lt;div className="row"&amp;gt;
      &amp;lt;div className="col-sm-8 col-md-7 py-4"&amp;gt;
       &amp;lt;h4 className="text-white"&amp;gt;About&amp;lt;/h4&amp;gt;
       &amp;lt;p className="text-muted"&amp;gt;
        Add some information about the album below, the author, or any
        other background context. Make it a few sentences long so folks
        can pick up some informative tidbits. Then, link them off to
        some social networking sites or contact information.
       &amp;lt;/p&amp;gt;
      &amp;lt;/div&amp;gt;
      &amp;lt;div className="col-sm-4 offset-md-1 py-4"&amp;gt;
       &amp;lt;h4 className="text-white"&amp;gt;Contact&amp;lt;/h4&amp;gt;
       &amp;lt;ul className="list-unstyled"&amp;gt;
        &amp;lt;li&amp;gt;
         &amp;lt;a href="#" className="text-white"&amp;gt;
          Follow on Twitter
         &amp;lt;/a&amp;gt;
        &amp;lt;/li&amp;gt;
        &amp;lt;li&amp;gt;
         &amp;lt;a href="#" className="text-white"&amp;gt;
          Like on Facebook
         &amp;lt;/a&amp;gt;
        &amp;lt;/li&amp;gt;
        &amp;lt;li&amp;gt;
         &amp;lt;a href="#" className="text-white"&amp;gt;
          Email me
         &amp;lt;/a&amp;gt;
        &amp;lt;/li&amp;gt;
       &amp;lt;/ul&amp;gt;
      &amp;lt;/div&amp;gt;
     &amp;lt;/div&amp;gt;
    &amp;lt;/div&amp;gt;
   &amp;lt;/div&amp;gt;
   &amp;lt;div className="navbar navbar-dark bg-dark box-shadow"&amp;gt;
    &amp;lt;div className="container d-flex justify-content-between"&amp;gt;
     &amp;lt;a href="#" className="navbar-brand d-flex align-items-center"&amp;gt;
      &amp;lt;svg
       xmlns="[http://www.w3.org/2000/svg](http://www.w3.org/2000/svg)"
       width="20"
       height="20"
       viewBox="0 0 24 24"
       fill="none"
       stroke="currentColor"
       strokeWidth="2"
       strokeLinecap="round"
       strokeLinejoin="round"
       className="mr-2"
      &amp;gt;
       &amp;lt;path d="M23 19a2 2 0 0 1-2 2H3a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h4l2-3h6l2 3h4a2 2 0 0 1 2 2z" /&amp;gt;
       &amp;lt;circle cx="12" cy="13" r="4" /&amp;gt;
      &amp;lt;/svg&amp;gt;
      &amp;lt;strong&amp;gt;Album&amp;lt;/strong&amp;gt;
     &amp;lt;/a&amp;gt;
     &amp;lt;button
      className="navbar-toggler"
      type="button"
      data-toggle="collapse"
      data-target="#navbarHeader"
      aria-controls="navbarHeader"
      aria-expanded="false"
      aria-label="Toggle navigation"
     &amp;gt;
      &amp;lt;span className="navbar-toggler-icon" /&amp;gt;
     &amp;lt;/button&amp;gt;
    &amp;lt;/div&amp;gt;
   &amp;lt;/div&amp;gt;
  &amp;lt;/header&amp;gt;
 );
};
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Main&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// src/components/main.tsx

import React from 'react';

import { Jumbotron } from './jumbotron';
import { Card } from './card';

export const Main = () =&amp;gt; {
 return (
  &amp;lt;main role="main"&amp;gt;
   &amp;lt;Jumbotron /&amp;gt;
   &amp;lt;div className="album py-5 bg-light"&amp;gt;
    &amp;lt;div className="container"&amp;gt;
     &amp;lt;div className="row"&amp;gt;
      &amp;lt;Card /&amp;gt;
      &amp;lt;Card /&amp;gt;
      &amp;lt;Card /&amp;gt;
      &amp;lt;Card /&amp;gt;
      &amp;lt;Card /&amp;gt;
      &amp;lt;Card /&amp;gt;
      &amp;lt;Card /&amp;gt;
      &amp;lt;Card /&amp;gt;
      &amp;lt;Card /&amp;gt;
     &amp;lt;/div&amp;gt;
    &amp;lt;/div&amp;gt;
   &amp;lt;/div&amp;gt;
  &amp;lt;/main&amp;gt;
 );
};
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Jumbotron&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// src/components/jumbotron.tsx

/\* eslint-disable jsx-a11y/anchor-is-valid \*/
import React from 'react';

export const Jumbotron = () =&amp;gt; {
 return (
  &amp;lt;section className="jumbotron text-center mb-0 bg-white"&amp;gt;
   &amp;lt;div className="container"&amp;gt;
    &amp;lt;h1 className="jumbotron-heading"&amp;gt;Album example&amp;lt;/h1&amp;gt;
    &amp;lt;p className="lead text-muted"&amp;gt;
     Something short and leading about the collection below—its contents,
     the creator, etc. Make it short and sweet, but not too short so folks
     don't simply skip over it entirely.
    &amp;lt;/p&amp;gt;
    &amp;lt;p&amp;gt;
     &amp;lt;a href="#" className="btn btn-primary m-2"&amp;gt;
      Main call to action
     &amp;lt;/a&amp;gt;
     &amp;lt;a href="#" className="btn btn-secondary m-2"&amp;gt;
      Secondary action
     &amp;lt;/a&amp;gt;
    &amp;lt;/p&amp;gt;
   &amp;lt;/div&amp;gt;
  &amp;lt;/section&amp;gt;
 );
};
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Card&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// src/components/card.tsx

/\* eslint-disable jsx-a11y/anchor-is-valid \*/
import React from 'react';

export const Card = () =&amp;gt; {
 return (
  &amp;lt;div className="col-md-4"&amp;gt;
   &amp;lt;div className="card mb-4 box-shadow"&amp;gt;
    &amp;lt;img
     className="card-img-top"
     src="[http://picsum.photos/200/200](http://picsum.photos/200/200)"
     alt="Card"
    /&amp;gt;
    &amp;lt;div className="card-body"&amp;gt;
     &amp;lt;p className="card-text"&amp;gt;
      This is a wider card with supporting text below as a natural lead-in
      to additional content. This content is a little bit longer.
     &amp;lt;/p&amp;gt;
     &amp;lt;div className="d-flex justify-content-between align-items-center"&amp;gt;
      &amp;lt;div className="btn-group"&amp;gt;
       &amp;lt;button
        type="button"
        className="btn btn-sm btn-outline-secondary"
       &amp;gt;
        View
       &amp;lt;/button&amp;gt;
       &amp;lt;button
        type="button"
        className="btn btn-sm btn-outline-secondary"
       &amp;gt;
        Edit
       &amp;lt;/button&amp;gt;
      &amp;lt;/div&amp;gt;
      &amp;lt;small className="text-muted"&amp;gt;9 mins&amp;lt;/small&amp;gt;
     &amp;lt;/div&amp;gt;
    &amp;lt;/div&amp;gt;
   &amp;lt;/div&amp;gt;
  &amp;lt;/div&amp;gt;
 );
};
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Footer&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// src/components/footer.tsx

/\* eslint-disable jsx-a11y/anchor-is-valid \*/
import React from 'react';

export const Footer = () =&amp;gt; {
 return (
  &amp;lt;footer className="text-muted py-5"&amp;gt;
   &amp;lt;div className="container"&amp;gt;
    &amp;lt;p className="float-right"&amp;gt;
     &amp;lt;a href="#"&amp;gt;Back to top&amp;lt;/a&amp;gt;
    &amp;lt;/p&amp;gt;
    &amp;lt;p&amp;gt;
     Album example is &amp;amp;copy; Bootstrap, but please download and customize
     it for yourself!
    &amp;lt;/p&amp;gt;
   &amp;lt;/div&amp;gt;
  &amp;lt;/footer&amp;gt;
 );
};
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;If you have copied and pasted the code your app should look something like this.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--dHjDfm-U--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1024/1%2A4Ul09wdMOeCsRwgyQdaHjA.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--dHjDfm-U--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1024/1%2A4Ul09wdMOeCsRwgyQdaHjA.png" alt=""&gt;&lt;/a&gt;App without bootstrap&lt;/p&gt;

&lt;p&gt;As you can see the html is there but there is no styling at all. That makes sense as we haven’t included bootstrap yet. Let’s do it!&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Bootstrap configuration
&lt;/h3&gt;

&lt;h4&gt;
  
  
  2.A. Full version
&lt;/h4&gt;

&lt;p&gt;This is the easy way of importing bootstrap in case you are happy with the default variables such as colours and measures. It’s very straightforward and easy to configure.&lt;/p&gt;

&lt;p&gt;First of all, you need to import bootstrap at the beginning of the project so it can be overridden with your customization. The first file from your project is usually src/index.tsx so we just need to add a line.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import 'bootstrap/dist/css/bootstrap.css';
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;So the file should look like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import 'bootstrap/dist/css/bootstrap.css';
import \* as React from 'react';
import { render } from 'react-dom';

import App from './App';

const rootElement = document.getElementById('root');
render(&amp;lt;App /&amp;gt;, rootElement);
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;And that small line has a big impact.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--bE-0mLNi--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1024/1%2APfISJKRijMupyFKFZyuYeg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--bE-0mLNi--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1024/1%2APfISJKRijMupyFKFZyuYeg.png" alt=""&gt;&lt;/a&gt;App with bootstrap&lt;/p&gt;

&lt;h4&gt;
  
  
  2.B Bootstrap Themes
&lt;/h4&gt;

&lt;p&gt;If you are interested in a proper customization overwriting bootstrap defaults, the good news is that it can be done!&lt;/p&gt;

&lt;p&gt;In order to do that, you just need to create a custom scss file &lt;a href="https://getbootstrap.com/docs/4.1/getting-started/theming/#theme-colors"&gt;changing the bootstrap variables values&lt;/a&gt; and after import the bootstrap file. I usually place it in src/css/bootstrap.scss. Let’s start by only importing the bootstrap styling.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// src/css/bootstrap.scss

// Import Bootstrap and its default variables
[@import](http://twitter.com/import) "node\_modules/bootstrap/scss/bootstrap";
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Now we import the custom styling in index.tsx and everything is still working.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// src/index.tsx

import './css/bootstrap.scss';

import \* as React from 'react';
import { render } from 'react-dom';

import App from './App';

const rootElement = document.getElementById('root');
render(&amp;lt;App /&amp;gt;, rootElement);
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Let’s update the main colours of the app for the ones in the palette that I have generated randomly using the brilliant tool &lt;a href="https://coolors.co/app"&gt;coolors&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--VWl6wiej--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/892/1%2AMx6EXgWaqrj60gNFJKd-tQ.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--VWl6wiej--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/892/1%2AMx6EXgWaqrj60gNFJKd-tQ.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Usually the variables should go in their own file but to make it easier to read in this example, I’m going to include them directly on the bootstrap file. So the file should look like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// src/css/bootstrap.scss

$darkLiver: rgba(84, 73, 75, 1);
$isabelline: rgba(241, 247, 237, 1);
$etonBlue: rgba(145, 199, 177, 1);
$dingyDungeon: rgba(179, 57, 81, 1);
$flax: rgba(227, 208, 129, 1);

$theme-colors: (
  "primary": $isabelline,
  "secondary": $darkLiver,
  "light": $etonBlue,
  "dark": $dingyDungeon
);

$white: $flax;

$grid-breakpoints: (
  xs: 0,
  sm: 700px,
  md: 900px,
  lg: 1200px,
  xl: 1500px,
  xxl: 2300px
);

$container-max-widths: (
  sm: 600px,
  md: 800px,
  lg: 1100px,
  xl: 1300px,
  xxl: 2000px
);

[@import](http://twitter.com/import) "node\_modules/bootstrap/scss/bootstrap";
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;And the page reloads looking different&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--aCAoYOSg--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1024/1%2A84ABZNRbuE1_q37t0mmaWg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--aCAoYOSg--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1024/1%2A84ABZNRbuE1_q37t0mmaWg.png" alt=""&gt;&lt;/a&gt;App with bootstrap and custom variables&lt;/p&gt;

&lt;p&gt;Let’s see how the breakpoints have changed the visual also. As the card is set to change on breakpoints and we have increased the value to 900px we can clearly see the difference.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--8x5BIuAx--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1024/1%2Awv5Okh9SKJ5neZ5f-GSHdw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--8x5BIuAx--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1024/1%2Awv5Okh9SKJ5neZ5f-GSHdw.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Improvements
&lt;/h3&gt;

&lt;p&gt;As usual, there is always room for improvement. If you have any comments or suggestions please leave a comment below.&lt;/p&gt;

</description>
      <category>react</category>
      <category>typescript</category>
      <category>sass</category>
      <category>createreactapp</category>
    </item>
    <item>
      <title>Create react app typescript: testing with jest and enzyme</title>
      <dc:creator>Feralamillo</dc:creator>
      <pubDate>Wed, 26 Feb 2020 16:11:02 +0000</pubDate>
      <link>https://forem.com/feralamillo/create-react-app-typescript-testing-with-jest-and-enzyme-2hch</link>
      <guid>https://forem.com/feralamillo/create-react-app-typescript-testing-with-jest-and-enzyme-2hch</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--FPdLnxYP--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/791/1%2AzE6WyFAE-JCsfb8bMogieQ.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--FPdLnxYP--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/791/1%2AzE6WyFAE-JCsfb8bMogieQ.png" alt=""&gt;&lt;/a&gt;Istanbul coverage report&lt;/p&gt;

&lt;p&gt;Get your unit testing configuration ready in less than 10 minutes. In this article, you can find how to get jest and enzyme ready for your tests and Istanbul to collect the coverage.&lt;/p&gt;

&lt;h3&gt;
  
  
  Pre-requisite
&lt;/h3&gt;

&lt;p&gt;As a first step, I’m going to install create react app with the typescript template.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npx create-react-app my-project --template typescript
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;It will take some time installing. I have included two versions, one for non-ejected versions of create-react-app and one for the ejected versions. I think the best is to avoid ejecting create-react-app as all the webpack config is taken care of. So, if you haven’t ejected, don’t do it!&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 1: Install dependencies
&lt;/h3&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm i -D ts-jest jest-fetch-mock enzyme enzyme-adapter-react-16 enzyme-to-json [@types/enzyme](http://twitter.com/types/enzyme) [@types/enzyme-adapter-react-16](http://twitter.com/types/enzyme-adapter-react-16) --save-exact
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h3&gt;
  
  
  &lt;strong&gt;Step 2: Include config files&lt;/strong&gt;
&lt;/h3&gt;

&lt;h4&gt;
  
  
  Without ejecting
&lt;/h4&gt;

&lt;p&gt;package.json&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"jest": {
    "collectCoverageFrom": [
      "src/\*\*/\*.{js,jsx,ts,tsx}",
      "!src/\*\*/\*.d.ts",
      "!src/index.tsx",
      "!src/serviceWorker.ts"
    ],
    "coveragePathIgnorePatterns": [
      "./src/\*/\*.types.{ts,tsx}",
      "./src/index.tsx",
      "./src/serviceWorker.ts"
    ],
    "coverageReporters": [
      "json",
      "lcov",
      "text-summary",
      "clover"
    ],
    "coverageThreshold": {
      "global": {
        "statements": 95,
        "branches": 95,
        "lines": 95,
        "functions": 95
      }
    },
    "snapshotSerializers": [
      "enzyme-to-json/serializer"
    ],
    "transform": {
      "^.+\\.(js|jsx|ts|tsx)$": "&amp;lt;rootDir&amp;gt;/node\_modules/ts-jest"
    },
    "transformIgnorePatterns": [
      "[/\\\\]node\_modules[/\\\\].+\\.(js|jsx|ts|tsx)$",
      "^.+\\.module\\.(css|sass|scss)$"
    ],
    "moduleNameMapper": {
      "^react-native$": "react-native-web",
      "^.+\\.module\\.(css|sass|scss)$": "identity-obj-proxy",
      "src/(.\*)$": "&amp;lt;rootDir&amp;gt;/src/$1"
    }
  }
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;src/setupTests.ts&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import Enzyme from 'enzyme';
import ReactSixteenAdapter from 'enzyme-adapter-react-16';

Enzyme.configure({ adapter: new ReactSixteenAdapter() });
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h4&gt;
  
  
  Ejected version
&lt;/h4&gt;

&lt;p&gt;In case you decide to eject create-react-app&lt;/p&gt;

&lt;p&gt;config/jest/setupEnzyme.ts&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import Enzyme from 'enzyme';
import ReactSixteenAdapter from 'enzyme-adapter-react-16';

Enzyme.configure({ adapter: new ReactSixteenAdapter() });
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;config/jest/setupJest.ts&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { GlobalWithFetchMock } from 'jest-fetch-mock';

const customGlobal: GlobalWithFetchMock = global as GlobalWithFetchMock;
customGlobal.fetch = require('jest-fetch-mock');
customGlobal.fetchMock = customGlobal.fetch;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;config/jest/typescriptTransform.js&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Copyright 2004-present Facebook. All Rights Reserved.
'use strict';
const tsJestPreprocessor = require('ts-jest/preprocessor');

module.exports = tsJestPreprocessor;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;jest.config.js&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;module.exports = {
  roots: ['&amp;lt;rootDir&amp;gt;/src'],
  preset: 'ts-jest',
  globals: {
    'ts-jest': {
      diagnostics: true,
    },
  },
  collectCoverageFrom: [
    'src/\*\*/\*.{js,jsx,ts,tsx}',
    '!src/\*\*/\*.d.ts',
    '!src/serviceWorker.ts',
    '!src/setupTests.ts',
    '!src/index.tsx',
  ],
  setupFiles: ['./config/jest/setupJest.ts', './config/jest/setupEnzyme.ts'],  
  coveragePathIgnorePatterns: ['./src/\*/\*.types.{ts,tsx}'],
  coverageReporters: ['json', 'lcov', 'text-summary', 'clover'],
  coverageThreshold: {
    global: {
      statements: 95,
      branches: 95,
      lines: 95,
      functions: 95,
    },
  },
  snapshotSerializers: ['enzyme-to-json/serializer'],
  testMatch: ['&amp;lt;rootDir&amp;gt;/src/\*\*/\*.test.{js,jsx,ts,tsx}'],
  automock: false,
  transform: {
    '^.+\\.(js|jsx|ts|tsx)$': '&amp;lt;rootDir&amp;gt;/node\_modules/ts-jest',
    '^.+\\.css$': '&amp;lt;rootDir&amp;gt;/config/jest/cssTransform.js',
    '^(?!.\*\\.(js|jsx|ts|tsx|css|json)$)':
      '&amp;lt;rootDir&amp;gt;/config/jest/fileTransform.js',
  },
  transform: {
    '^.+\\.(js|jsx|ts|tsx)$': '&amp;lt;rootDir&amp;gt;/node\_modules/ts-jest',
    '^.+\\.css$': '&amp;lt;rootDir&amp;gt;/config/jest/cssTransform.js',
    '^(?!.\*\\.(js|jsx|ts|tsx|css|json)$)':
      '&amp;lt;rootDir&amp;gt;/config/jest/fileTransform.js',
  },
  modulePaths: [],
  moduleNameMapper: {
    '^react-native$': 'react-native-web',
    '^.+\\.module\\.(css|sass|scss)$': 'identity-obj-proxy',
    'src/(.\*)$': '&amp;lt;rootDir&amp;gt;/src/$1',
  },
  moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'],
};
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h3&gt;
  
  
  Step 3:  &lt;strong&gt;scripts&lt;/strong&gt;
&lt;/h3&gt;

&lt;h4&gt;
  
  
  Without ejecting
&lt;/h4&gt;

&lt;p&gt;package.json&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
**"test:coverage": "react-scripts test --coverage --runInBand --watchAll=false",**
    "eject": "react-scripts eject",
    "lint": "eslint --ext .js,.jsx,.ts,.tsx src --color",
    "format": "prettier --write src/\*\*/\*.{ts,tsx,scss,css,json}",
    "isready": "npm run format &amp;amp;&amp;amp; npm run lint &amp;amp;&amp;amp; **npm run test:coverage** &amp;amp;&amp;amp; npm run build"
  },
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h4&gt;
  
  
  Ejected version
&lt;/h4&gt;

&lt;p&gt;package.json&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  "scripts": {
    "start": "node scripts/start.js",
    "build": "node scripts/build.js",
    "test": "node scripts/test.js",
**"test:coverage": "node scripts/test.js --env=jsdom --coverage --runInBand --watchAll=false",**
    "lint": "eslint --ext .js,.jsx,.ts,.tsx src --color",
    "format": "prettier --write src/\*\*/\*.{ts,tsx,scss,css,json}",
    "isready": "npm run format &amp;amp;&amp;amp; npm run lint &amp;amp;&amp;amp; **npm run test:coverage** &amp;amp;&amp;amp; yarn build"
  },
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h3&gt;
  
  
  Step 4: Creating first tests
&lt;/h3&gt;

&lt;p&gt;As we already have the  component with a test let’s just update that one. I prefer to always create a folder called tests to separate them from the components.&lt;/p&gt;

&lt;p&gt;tests/App.test.tsx&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import React from 'react';
import { shallow } from 'enzyme';

import App from '../App';

test('renders the component', () =&amp;gt; {
  const component = shallow(&amp;lt;App /&amp;gt;);

  expect(component).toMatchSnapshot();
});
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;When running npm run test a new snapshot will be created and there will be a new folder generated __snapshots__ with it.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--vh0nfYeK--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1006/1%2Avj8MxGqO8LK4Tp1q8LRP7w.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--vh0nfYeK--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1006/1%2Avj8MxGqO8LK4Tp1q8LRP7w.png" alt=""&gt;&lt;/a&gt;running tests&lt;/p&gt;

&lt;h3&gt;
  
  
  Improvements
&lt;/h3&gt;

&lt;p&gt;I’m always looking for feedback so please leave any suggestions or recommendations below.&lt;/p&gt;

</description>
      <category>unittesting</category>
      <category>createreactapp</category>
      <category>enzyme</category>
      <category>jest</category>
    </item>
    <item>
      <title>Create react app typescript: eslint and prettier</title>
      <dc:creator>Feralamillo</dc:creator>
      <pubDate>Wed, 12 Feb 2020 15:11:01 +0000</pubDate>
      <link>https://forem.com/feralamillo/create-react-app-typescript-eslint-and-prettier-1e6g</link>
      <guid>https://forem.com/feralamillo/create-react-app-typescript-eslint-and-prettier-1e6g</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--l_v0MsFC--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1024/1%2A0u7hGTZzMzL42Gk_mE_V-Q.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--l_v0MsFC--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1024/1%2A0u7hGTZzMzL42Gk_mE_V-Q.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Take your typescript create-react-app to the next level with a nice code format.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;If you follow these steps, you’ll have linting and prettier set up in less than 10 minutes.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;I’m just setting up a project and thought it could be helpful for others to have a small guide with the main steps. Create-react-app is quite awesome to be honest and including some extra configuration can take it even further. I’ll be creating some posts covering nice features without ejecting.&lt;/p&gt;

&lt;p&gt;As always, there is always room for improvement. I’m using the predefined configurations form airbnb, react-app and prettier in order to go faster. If you prefer to have your own rules go ahead.&lt;/p&gt;

&lt;p&gt;Let’s cut to the chase!&lt;/p&gt;

&lt;h3&gt;
  
  
  Pre-requisite
&lt;/h3&gt;

&lt;p&gt;As a first step, I’m going to install create react app with the typescript template.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npx create-react-app formatting-project --template typescript
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;It will take some time installing.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 1: Install dependencies
&lt;/h3&gt;

&lt;p&gt;For linting:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm i -D --save-exact eslint eslint-config-airbnb eslint-config-airbnb-typescript eslint-config-prettier eslint-config-react-app eslint-import-resolver-typescript eslint-loader eslint-plugin-flowtype eslint-plugin-import eslint-plugin-jsx-a11y eslint-plugin-react eslint-plugin-react-hooks babel-eslint [@typescript](http://twitter.com/typescript)-eslint/parser [@typescript](http://twitter.com/typescript)-eslint/eslint-plugin
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;For prettier:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm i -D --save-exact prettier prettier-eslint prettier-eslint-cli eslint-plugin-prettier
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h3&gt;
  
  
  Step 2: create config files
&lt;/h3&gt;

&lt;p&gt;All these files go on the root level.&lt;/p&gt;

&lt;p&gt;.eslintrc&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// .eslintrc
{
  "plugins": ["prettier"],
  "extends": ["airbnb-typescript", "react-app", "prettier"],
  "settings": {
    "import/resolver": {
      "typescript": {
        "alwaysTryTypes": true
      }
    }
  },
  "rules": {
    "object-curly-spacing": ["warn", "always"],
    "no-unused-vars": [
      "warn",
      {
        "vars": "all",
        "args": "none"
      }
    ],
    "[@typescript](http://twitter.com/typescript)-eslint/no-unused-vars": [
      "warn",
      {
        "vars": "all",
        "args": "none"
      }
    ],
    "[@typescript](http://twitter.com/typescript)-eslint/no-explicit-any": [
      "error",
      {
        "ignoreRestArgs": true
      }
    ],
    "max-len": [
      "warn",
      {
        "code": 80,
        "ignoreStrings": true,
        "ignoreTemplateLiterals": true,
        "ignoreComments": true
      }
    ],
    "no-plusplus": [
      "error",
      {
        "allowForLoopAfterthoughts": true
      }
    ],
    "react/jsx-key": "error",
    "import/no-extraneous-dependencies": [
      "error",
      {
        "devDependencies": [
          "\*\*/\*.test.js",
          "\*\*/\*.test.jsx",
          "\*\*/\*.test.ts",
          "\*\*/\*.test.tsx",
          "src/tests/\*\*/\*"
        ]
      }
    ],
    "react/jsx-props-no-spreading": "off",
    "import/prefer-default-export": "off",
    "react/jsx-boolean-value": "off",
    "react/prop-types": "off",
    "react/no-unescaped-entities": "off",
    "react/jsx-one-expression-per-line": "off",
    "react/jsx-wrap-multilines": "off",
    "react/destructuring-assignment": "off",
  }
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;.eslintignore&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// .eslintignore
build/\*
public/\*
src/react-app-env.d.ts
src/serviceWorker.ts
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;.prettierrc&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
  "printWidth": 80,
  "singleQuote": true,
  "trailingComma": "es5",
  "tabWidth": 2
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h3&gt;
  
  
  Step 3: Add the running scripts
&lt;/h3&gt;

&lt;p&gt;Look for the scripts area in package.json and include these:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject",
    "lint": "eslint --ext .js,.jsx,.ts,.tsx src --color",  
    "format": "prettier --write src/\*\*/\*.{ts,tsx,scss,css,json}",  
    "isready": "npm run format &amp;amp;&amp;amp; npm run lint &amp;amp;&amp;amp; npm run build"**  
  },
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;The first one npm run lint will run the linting and tell you what is wrong. The second one npm run format will format all the code based on your prettier and linting configuration. At last, a script that is very useful to run before committing and pushing code to git.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 4: Lint and format your code
&lt;/h3&gt;

&lt;p&gt;Once you start running the scripts you will start getting errors.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ npm run lint
$ npm run format
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Some of them you may want to ignore so here the way to do it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/* eslint-disable no-console, no-param-reassign */ For one or multiple lines
/* eslint-disable-next-line no-console */ For next line
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Bob’s your uncle!!&lt;/p&gt;

&lt;h3&gt;
  
  
  Improvements
&lt;/h3&gt;

&lt;p&gt;As I commented previously, there is room for improvement. If you have any comments or suggestions please leave a comment below.&lt;/p&gt;

</description>
      <category>react</category>
      <category>eslint</category>
      <category>createreactapp</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Hello World!! This is a Junior Contributor</title>
      <dc:creator>Feralamillo</dc:creator>
      <pubDate>Wed, 10 Apr 2019 13:18:31 +0000</pubDate>
      <link>https://forem.com/feralamillo/hello-world-this-is-a-junior-contributor-45nm</link>
      <guid>https://forem.com/feralamillo/hello-world-this-is-a-junior-contributor-45nm</guid>
      <description>&lt;p&gt;After 6 months of commercial experience as a Junior Developer and a coding bootcamp, I feel there is still a long path to ahead. I really love developers that share because it is a great way to learn. In this sense, although I'm not an expert, I feel I can still contribute to the community in some sort of way. &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%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Flh7t98w0dpglgb5q8afd.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%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Flh7t98w0dpglgb5q8afd.jpeg" alt="Hello World"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Since uni, I have been involved with startups which is where I have met incredible people. Individuals that want to create an impact in the world improving how things are done. I have been in different roles related to business, sales, growth, project management, product and I have always felt that coding is a key skill. A couple of years ago, it was my time to focus on it. I joined a bootcamp and just when I finished, I landed a job in an upscale startup. &lt;/p&gt;

&lt;p&gt;There is still a long journey and I'm doing great progress step by step. &lt;strong&gt;I would appreciate feedback from people on what are the best ways to contributing&lt;/strong&gt;. Tips related to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Generating content: what sites or tips to take into account?&lt;/li&gt;
&lt;li&gt;Getting involved in open source projects.&lt;/li&gt;
&lt;li&gt;Other alternatives to consider.&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>coding</category>
      <category>contributing</category>
      <category>community</category>
      <category>opensource</category>
    </item>
  </channel>
</rss>
