Welcome! This project was bootstrapped with Create React App. With that it comes with the Jest testing framework built in. We will be using that to practice unit testing. For automated testing we will be using Cypress which was added.
- Make sure Node.js is installed on your computer. You can download that here and make sure to select the right one for Windows or Mac.
- In the terminal, clone the project to your computer. I would do this in the folder where you are putting your Tech Moms projects, so make sure you
cd
into that before running this. It should then prompt you for your password.
git clone https://github.com/mdamian322/calculator.git
- Do
cd calculator
to get into the project folder - Run
npm install
to install all the dependencies needed for this project like Cypress, etc. This should also install yarn as well so you can run the yarn scripts below
If you are getting a yarn command not found
error when trying to do yarn start
or other yarn commands, you will need to install yarn manually (it should have installed when doing that npm install
command but, yay life!).
To do that you do:
npm install --global yarn
in the terminal.
If you get a Missing write access
error or something like that when doing that, you will need to do
sudo chown -R $USER /usr/local/lib/node_modules
This is just giving you permission to write in that directory.
After doing that, do npm install --global yarn
again.
Here's the explanation for fixing the "Missing write access" error.
To know if it installed successfully you can do yarn --version
and it should return the version number.
Runs the app in the development mode. Open http://localhost:3000 to view it in the browser.
The page will reload if you make changes.
Launches the test runner to run all the unit tests in the __tests__
folder. You can also do yarn test a
to run all tests.
Launches Cypress so you can run the automated tests
You have to have the app running in order to run these tests, so make sure you have done yarn start
in a separate terminal tab/window before doing this.
Manual Testing is where test cases are executed manually by a tester without using any automated tools. So clicking through and using the app as a user would.
Unit Testing is where individual units or components of a software are tested. In short, unit tests are testing the actual code. In this project, our unit tests are in the __tests__
folder and the operations.test.js test file is testing the operations.js file functions. Note how the test name is the same name as the Javascript file we are testing.
Automated Testing is using an automated process where you are testing the behavior of the app. It simulates manual testing. In this project we are using Cypress. The tests for this calculator app are in the cypress/integreations/calculator
folder. I left the default examples folder that Cypress autoatically generates so you can play around with those and see more examples of using Cypress for automated testing.
- Cypress commands
- Jest docs
- Get paid to do user testing with User Testing
- To learn React, check out the React documentation.
I would love for you to add additional tests for practice! Feel free to make a Pull Request (PR) with any tests you add and I'll be more than happy to take a look or answer any questions!
To make a Pull Request:
- Make a new branch off of
main
by doinggit checkout -b your_name_branch
. This just makes a new branch that is a copy ofmain
. Make sure you dogit pull
before doing this to make sure you have the most recent changes frommain
. - Make your changes and then commit them to your branch.
- This adds all of the files you changed to be saved/commited
git add -A
- This saves/commits your changes to the files so you don't loose them locally with your message being in the ""
git commit -m "added tests"
- Push your changes so they show up here under pull requests
git push