In this automation best practices workshop you will learn the latest and greatest tools and techniques to drastically improve your testing!
We will focus on a holistic approach of testing front-end and back-end, web and APIs, functional testing, component testing, and many other things in between 😁
✅What is an automated atomic test
✅How to code automated atomic tests
✅How to login without a UI using a HTML web forms
✅How to login without a UI using JWT
✅How to write a component test
✅How to add a test id to our web app
✅How to correctly test a link and a tab
✅How to replace e2e tests with component tests
✅visual e2e tests
✅visual cross-browser tests
✅CICD with Github Actions
- ReactJS
- Cypress
- WebdriverIO
- React testing library
- Jest
- Screener visual E2E testing
- Sauce Labs
- Github Actions
- Use NVM for this installation by following instructions
- It should be just a single command to run in our terminal
- !Don't forget to restart your terminal!
- After installation, confirm install was correct by running
nvm
and seeing an output - Intall Node 14 with
nvm install 14
Here's what the output would look like:
Downloading and installing node v14.16.1...
Downloading https://nodejs.org/dist/v14.16.1/node-v14.16.1-darwin-x64.tar.xz...
######################################################################### 100.0%
Computing checksum with shasum -a 256
Checksums matched!
Now using node v14.16.1 (npm v6.14.12)
Creating default alias: default -> 14 (-> v14.16.1)
- Confirm node installation with
node --version
and seeingv14.16.1
or similar - Confirm NVM is set to 14 for default by running the following commands:
nvm list #will show all versions
nvm use 14 #to use 14
nvm alias default 14.16.x #to set it to the default
- Sign up for a free Github account
- Fork this respository
- Make sure you are logged into Github
- click the Fork in the upper right of the Github.
- Clone your fork of the repository to your machine. Must have Git installed
git clone URL_OF_YOUR_FORK
- Navigate to the directory of where you cloned your repo
cd YOUR_FORK_DIR/automation-best-practices
cd my-react-app
npm install
npm run start
Expected Output:
Your output should look similar to this
Compiled successfully!
You can now view my-react-app in the browser.
Local: http://localhost:3000
On Your Network: http://172.20.10.2:3000
Note that the development build is not optimized.
To create a production build, use npm run build.
Don't worry about fixing any warnings that may appear during npm install
Once the app is running, kill the server by executing Ctrl + C
in command line. We don't need the app running right now.
4.Have an IDE installed that can handle NodeJS (We will use VSCode)
We will have a 2nd repo from which we work from only for login testing.
- Fork https://github.com/nadvolod/cypress-example-recipes
- Clone this repo to another directory (we will open it as a separate project later in the workshop)
- Install everything
cd cypress-example-recipes
npm i
5.Sign up for a free Sauce account
-
Copy your Sauce Labs username and accessKey in the User Settings section of the Sauce Labs Dashboard.
-
Open a Terminal window (command prompt for Windows) and set your Sauce Labs Environment variables:
$ export SAUCE_USERNAME="username" $ export SAUCE_ACCESS_KEY="accessKey"
> set SAUCE_USERNAME="username" > set SAUCE_ACCESS_KEY="accessKey"
To set an environment variables permanently in Windows, you must append it to the
PATH
variable.Go to Control Panel > System > Windows version > Advanced System Settings > Environment Variables > System Variables > Edit > New
Then set the "Name" and "Value" for each variable
-
Test the environment variables
$ echo $SAUCE_USERNAME $ echo $SAUCE_ACCESS_KEY
WARNING FOR UNIX USERS!: If you have problems setting your environment variables, run the following commands in your terminal:
$ launchctl setenv SAUCE_USERNAME $SAUCE_USERNAME $ launchctl setenv SAUCE_ACCESS_KEY $SAUCE_ACCESS_KEY
> echo %SAUCE_USERNAME% > echo %SAUCE_ACCESS_KEY%
💡 this is a tip
🏋️♀️ this is an exercise for you to do
❓ this is a question for us to think and talk about. Try not to scroll beyond this question before we discuss