Giter Site home page Giter Site logo

christafaye / jest-practice Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jrmykolyn/jest-practice

0.0 0.0 0.0 163 KB

A CLI exercise created for the 'Tools and Workflow for the Web' course, part of Humber College's Web Design and Development (WDDM) program.

JavaScript 100.00%

jest-practice's Introduction

Jest Practice

Introduction

This repository contains the starter files for the 'Jest Practice' exercise.

In this exercise we'll introduce Jest-based tests for a pre-existing cookbook program. This program consists of the core logic (cookbook.js), a CLI that 'sits' between the core logic and the user (cookbook-cli.js), and a small script that connects the two (index.js). We will write a series of tests to ensure that the core logic and the CLI work as expected.

This exercise will build on the concepts and techniques that we've explored in this course, as well as some of the material that you have covered in the other WDDM courses.

Learning Objectives

  • To learn more about JavaScript and Node, including packages and module resolution.
  • To continue building familiarity with testing in general and the Jest testing framework in particular.

Prerequisites

To complete today's exercise you should have an understanding of the following:

  • JavaScript fundamentals, including variables, functions, conditional statements, errors, and events.

You must also have Node installed on your local system. See the resources section below for download information.

Goals

At a minimum, your submission should include the following:

  • Passing implementations of the tests defined within the test/cookbook.test.js file.
  • Passing implementations of the tests defined within the test/cookbook-cli.test.js file.

Stretch Goals

If you are interested in going above-and-beyond the minimum requirements of the assignment, try implementing one or more of the stretch goals outlined below:

  1. Integration tests for the CookbookCli to ensure that it is correctly interacting with the underlying Cookbook. These tests have not been defined or implemented. This means that you must figure out what the tests cases should be and how to implement them.
  2. Update the CookbookCli to return a special message when the cookbook does not include any recipes. This update should be accompanied by a test. The message should be clear and descriptive, but the content is up to you.
  3. Update the CookbookCli to display a warning message when the user attempts to add a recipe that already exists. This update should be accompanied by a test. The message should be clear and descriptive, but the content is up to you.
  4. Update the CookbookCli to display a warning message when the user attempts to retrieve a recipe that does not exist. This update should should be accompanied by a test. The message should be clear and descriptive, but the content is up to you.
  5. Update the CookbookCli to display a warning message when the user attempts to delete a recipe that does not exist. This update should should be accompanied by a test. The message should be clear and descriptive, but the content is up to you.

Before You Begin

  • Fork this repository to your personal GitHub account.

Approach

This exercise focuses primarily on testing, but each of the stretch goals requires an update to the source code as well (ie. the cookbook.js and/or cookbook-cli.js files).

As usual, you are free to approach this exercise however you see fit. If you would like some additional help, feel free to use the following approach:

  • Start by familiarizing yourself with the index.js, cookbook-cli.js, and cookbook.js files. The logic of the program is distributed across all three files, so understanding what they do and the relationships that exist between them is essential.
  • Manually test/explore the CLI by interacting with the index.js file.
  • Review the test cases defined in the cookbook-cli.test.js and cookbook.test.js files. Are the test cases clear? Do you understand their intentions?
  • When you're ready to begin, install the project's dependencies (including Jest) by running the following command from the root of the repository: npm install.
  • Confirm that you can successfully execute the tests by running the following command: npm run test. Although you haven't actually written any tests yet, you should see a success message in your terminal application.
  • Pick one of the test files and implement each of the tests cases within. Make sure to run the tests each time you implement a new test case. Getting frequent feedback helps to identify errors early.
  • Commit frequently (for example: each time you successfully implement a new test case). Having a Git history made up of many small commits makes it easy to step backwards in cases where something goes wrong.

Resources

Node

Testing

jest-practice's People

Contributors

jrmykolyn avatar christafaye avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.