Deliverables - Hybrid Assignments
Unit Testing
Due Date
Due before 6:00 pm on Friday October 8, 2020.
# Preparation
- Read the backgrounder module on JavaScript Testing. 15 minutes
- Watch the video tutorial on React testing and debugging (opens new window) with Jest. 1.5 hours
# Instructions
You have been provided with a ZIP file containing two starter files:
robot.js
robot.test.js
1
2
2
The first, robot.js
, contains a working JavaScript module. Do not edit this file.
The second, robot.test.js
, contains the scaffolding for a Jest test suite. Following the comment instructions, you will write the designated tests for the robot.js
module.
# Steps
- Download the ZIP file with the starter code.
- Create a new private GitHub repository called mad9135-f21-h2-unit-testing.
- Clone that repo to your laptop and copy the two starter files to that folder.
- Create a
.gitignore
file with at least.DS_Store
andnode_modules
in it. - Initialize your package.json file with
npm init
oryarn init
. - Add
jest
as a dev-dependency using one of these commands.
yarn add --dev jest
npm i -D jest
1
2
2
- Update the scripts block of your
package.json
file to look like this ...
"scripts": {
"test": "jest"
}
1
2
3
2
3
- Follow the instructions inside
robot.test.js
to create 6 tests for the robot module. You will want to reference the Jest documentation on Using Matchers (opens new window) and the Expect API (opens new window). - Run your tests in the terminal with
yarn test
ornpm run test
. - As you successfully complete each test, create a git commit with a message that indicates which test was passed.
# Submission
- Compare the output report from your tests with this image. It should show 6 passed tests.
- After all your tests are working, push the commits up to GitHub.
- Invite GitHub user
prof3ssorSt3v3
as a collaborator on your private repo. - Submit the URL of the code repo to the Brightspace assignment page.