Code Monkey home page Code Monkey logo

sprint-challenge--testing's Introduction

Testing Sprint Challenge

For this project you will use TDD to create a simple Web API using Node.js and Express. The basic requirements for the endpoints are listed below. Create any files and folders you need to finish the project, you have complete freedom to structure your solution to make it easier to test and extend in the future.

Assignments

  • Open the Review.md file and answer the questions inside.
  • Use Test Driven Development to build a RESTful API using Node.js and Express to create and list games. Data can be stored in memory using a simple JS array. No need to keep track of incrementing ids for this project's MVP, that is part of the Stretch Problem.

Download Project and Install Dependencies

  1. fork and clone this repository.
  2. CD into the folder where you downloaded the repository.
  3. run yarn or npm i to download all dependencies.
  4. type yarn test or npm test to run the tests. The test script is already configured.

Requirements

  1. use jest and supertest to write the tests.
  2. Write the tests BEFORE writing the route handlers.
  3. Your API must be have POST and GET endpoints for /games.
  4. Write a minimum of three tests per endpoint.

POST /games

  • The POST /games endpoint should take in an object that looks like this

    {
      title: 'Pacman', // required
      genre: 'Arcade', // required
      releaseYear: 1980 // not required
    }
    • in the route handler, validate that the required fields are included inside the body. If the information is incomplete, return a 422 status code.
    • write tests to verify that the endpoint returns the correct HTTP status code when receiving correct and incorrect game data.

GET /games

  • The GET /games endpoint should return the list of games and HTTP status code 200.
  • Write a test to make sure this endpoint always returns an array, even if there are no games stored. If there are no games to return, the endpoint should return an empty array.

Stretch Problem

The following exercises are optional, but we suggest that you tackle them if you finish the MVP early.

  • validate that the game title is unique. If the client tries to create a duplicate game, return a status code 405 (Not Allowed). Write a test that checks for this.
  • add an id property to the game schema and write code in the server to increment it automatically. After implementing this functionality work on the following:
    • Write a GET /games/:id endpoint that returns the information about a single game. Respond with a 404 status code when a game is not found for the provided id. Add the corresponding tests for it.
    • add a DELETE /games/:id endpoint that can remove the corresponding game. If the game does not exists return a 404 status code. Write tests for this endpoint.

Remember you can use any resources you want to solve these problems, but avoid copying/pasting solutions you've previously written. Also if you don't finish all of the challenges, that's fine! Just do what you can and submit your challenges in the end! HAVE FUN!

sprint-challenge--testing's People

Contributors

luishrd avatar ryan-hamblin avatar codejoncode avatar mixelpixel avatar frankfaustino avatar nandotheessen avatar seanchen1991 avatar

Watchers

James Cloos 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.