Deliverables - Hybrid Assignments

Unit Testing

Due Date

Due before 6:00 pm on Friday October 8, 2020.

Back to Hybrid main page

# Preparation

  1. Read the backgrounder module on JavaScript Testing. 15 minutes
  2. 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

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

  1. Download the ZIP file with the starter code.
  2. Create a new private GitHub repository called mad9135-f21-h2-unit-testing.
  3. Clone that repo to your laptop and copy the two starter files to that folder.
  4. Create a .gitignore file with at least .DS_Store and node_modules in it.
  5. Initialize your package.json file with npm init or yarn init.
  6. Add jest as a dev-dependency using one of these commands.
yarn add --dev jest
npm i -D jest
1
2
  1. Update the scripts block of your package.json file to look like this ...
"scripts": {
    "test": "jest"
}
1
2
3
  1. 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).
  2. Run your tests in the terminal with yarn test or npm run test.
  3. 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.

screenshot of completed jest report

  • 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.
Last Updated: : 9/4/2021, 9:57:06 AM