Your goal is to get to this:
$ yarn test
> mocha ./test/setup.js --recursive test/
HTTP Server
GET /ping
✓ should respond with "pong"
POST /api/books
✓ should create a book
when missing title
✓ should render 400 bad request
with fixture data
GET /api/books
✓ should render 10 books
GET /api/books?page=2
✓ should render the next 10 books
GET /api/books?author=phILip
✓ should render books with authors named "Philip" (case insensitive)
GET /api/books?title=wORld
✓ should render books with a title including "world" (case insensitive)
GET /api/books?year=1953
✓ should render books published in 1953
GET /api/books?year=1953&title=th
✓ should render books published in 1953 and with a title that includes the string "th"
GET /api/authors
✓ should render 10 authors
GET /api/authors?page=2
✓ should render the next 10 authors
GET /api/books/12
when the book exists
✓ should render book 12
when the book doesn't exist
✓ should render nothing with status 404
GET /api/genres
✓ should render up to 10 genres
POST /api/book/12
✓ should update the book
POST /api/book/12/delete
✓ should delete the book
16 passing (4s)
Get All The Tests To Pass! :D
Your task is to make all these tests pass by designing a database schema and writing code within /server
.
npm i -g yarn
yarn
yarn test
# Identify one broken test
# Change the code in /server to make the test pass
# Refactor your code (clean it up)
# Rinse and repeat until all tests pass
WARNING: DO NOT EDIT ANY FILES WITHIN /test
- You must use an express server
- Feel free to
yarn add
any packages you might need - You should use a database of some kind
- You need to make the HTTP endpoint for resetting your database
- The tests only interact with your code via HTTP requests to your express app
yarn test -- --watch
to run your tests after any change
Jared wrote this :P