Coder Social home page Coder Social logo

api-testing's Introduction

Setup

  • fork and clone this repo
  • npm install
  • make sure postgres.app is open and running in the background
  • open postico and create a new database called 'testing-db'
  • in the db.js file be sure to change the username in the sequelize connection string to your username
  • run your tests by running mocha from the command line

Docs

Part 1: User Tests

  1. In the user-tests.js file, write the following five tests. Complete all five BEFORE you start creating any of the actual api routes in your server.js file. The first one is provided for you as an example:
  • /users GET all users (this test is already provided for you as an example)
  • /users/:id GET individual user by id
  • /users/:username GET individual user by username
  • /users/sort/a-z GET users sorted a-z by username
  • /users POST a new user
  1. AFTER you've created all five tests, start adding the api endpoints in your server.js file. Add each route one at a time, and run your mocha tests after you create each individual route. You can run the tests by running mocha from the command line

Part 2: Song Tests

  1. create a Song model in the song-model.js file in the models folder that has the following fields:
  • artist
  • title
  • userId (this should be created by making an association with the User model, in order to keep track of which user submits which song)
  1. In the song-tests.js file, write the following five tests. Complete all five BEFORE you start creating any of the actual api routes in your server.js file:
  • /songs GET all songs
  • /songs/:id GET individual song by id
  • /songs/:title GET individual song by title
  • /songs/sort/z-a GET songs sorted a-z by artist
  • /songs POST a new song
  1. AFTER you've created all five tests, start adding the api endpoints in your server.js file. Add each route one at a time, and run your mocha tests after you create each individual route. You can run the tests by running mocha from the command line

Part 3: Playlist App Tests

Add API route tests to your playlist app (or another project of your choice)

api-testing's People

Contributors

jung8027 avatar nmadd avatar

Watchers

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