Skip to content

Instantly share code, notes, and snippets.

@wrburgess
Last active July 15, 2017 15:26
Show Gist options
  • Save wrburgess/8e194c22a86b17f2323332b1223dd018 to your computer and use it in GitHub Desktop.
Save wrburgess/8e194c22a86b17f2323332b1223dd018 to your computer and use it in GitHub Desktop.
Unit Test Activity using Jest

Unit Test Activity with Jest

Objective

Write a simple function that takes two numbers as arguments and multiplies them with 100% test coverage using TDD

Steps

  1. Create a new directory called calculator-app and cd into it
  2. Set up your git repo correctly with the proper npm entries in .gitignore
  3. Create a new project with npm init
  4. Install thejest project into your node development dependencies
  5. In your package.json file, create a script that runs jest for the script command
  6. In the root of your app, create a test file called multiplyStuff.test.js
  7. In your test file, import the not-yet-created file multiplyStuff.js
  8. In your test file, write a test that expects the multiplyStuff function to return the product of two arguments
  9. Run your test with npm run test (It should fail)
  10. Create a file called multiplyStuff.js
  11. Write the code (remember module.exports) to make the test pass!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment