Read 27 ~ React Testing and Deployment
By Abdallah obaid
NAME | URL |
---|---|
Home | Home. |
Prep | Prep: Engineering Topics. |
Read 01 | Node Ecosystem, TDD, CI/CD. |
Read 02 | Classes, Inheritance, Functional. |
Read 03 | Data Modeling & NoSQL Databases. |
Read 04 | Advanced Mongo/Mongoose. |
Read 05 | Linked Lists. |
Read 06 | HTTP and REST. |
Read 07 | Express. |
Read 08 | Express Routing & Connected API. |
Read 09 | API Server. |
Read 10 | Stacks and Queues. |
Read 11 | Authentication. |
Read 12 | OAuth. |
Read 13 | Bearer Authorization. |
Read 14 | Access Control (ACL). |
Read 15 | Trees. |
Read 16 | Event Driven Applications. |
Read 17 | TCP Servers. |
Read 18 | Socket.io. |
Read 19 | Message Queues. |
Read 26 | Component Based UI. |
Read 27 | React Testing and Deployment. |
React Testing
## Snapshots :
- Its make a shot for the exact rendered tree dom and use it to be compared with later versions.
## Render Testing:
- Using react-test-renderer module
- Similar to snapshots, but allows for jQuery-like inspection of the virtual DOM tree.
## Shallow Testing :
- Allows us to test the parent component without testing their children.
## Mounting:
- Allows us to test the parent component and also testing their children.
React Deployment
React, remember is an index.html file that uses Javascript to render components in the browser. The node server is only there to aid in your development.
npm run build
output a static website containing no more than theindex.html
,.js
and.css
files required to open your app.
## Deploying to GitHub Pages:
- Enable GitHub Pages on your domain, using the gh-pages branch
- Create a Personal Access Token in your GitHub account
- Add this token as a “Secret” called PERSONAL_TOKEN in the repository housing your react app
- Add the react workflow .yml file to your repository (in .github/workflows)
## Deploying to AWS (s3):
- Create a new Bucket
- Storage containers for static assets
- Essentially, these are “folders”
- Objects
- These are the things in the buckets (your files)
- Upload the contents of your React application build folder to your bucket
- Set up to serve websites
- Properties Tab “Static Web Hosting” option
## Deploying to AWS Amplify:
- Create a new Amplify Workflow
- Point the workflow at your GitHub repository (master branch)
- Merge your code to master on GitHub
- That’s it … Amplify will monitor your repository for changes, pull, build, and deploy your React app automatically
- Eventually, there’s a usage charge for the service, depending on your traffic level ## Deploying to Netlify:
- Create a netlify.com account
- Create a new application
- Point the application at your GitHub repository (master branch)
- Merge your code to master on GitHub
- That’s it … Netlify will monitor your repository for changes, pull, build, and deploy your React app automatically
## Deploying to an “old school” host, such as godaddy.com:
- Create your account
- Open an FTP connection to your hosting company with a tool like Transmit or FileZilla
- Navigate to the web root folder
- Upload the contents of your react application’s build folder