Skip to content

Latest commit

 

History

History
80 lines (56 loc) · 2.09 KB

File metadata and controls

80 lines (56 loc) · 2.09 KB

Eden in Express/Postgres/Jest/Supertest

Open in Visual Studio Code Quality Gate Status

Eden is a mock plant shop. It is an example of a very basic REST API with integration tests. My hope is to make a test framework that can be scaled.

Installation

Ensure you have Node & NPM installed.

npm install
docker-compose up -d

Usage

See the package.json for all available commands

# Set up the database

# Create the sb
npm run db:create

# Set up the tables
npm run migrate

# Set up some very basic seeded data 
npm run seed
# General server use

# Start the server using nodemon
npm start 

# returns all plants
curl localhost:3000/api/plants

# returns a specific plant
curl localhost:3000/api/plants/1

# Adds a plant to the db
curl -X POST localhost:3000/api/plants\
    -H 'Content-Type: application/json'\
   -d '{"species": "Boston Fern","colour": "Green","size": "S","season": true}'

# Update a plant in the db
curl -X PUT localhost:3000/api/plants/1\
    -H 'Content-Type: application/json'\
   -d '{"species": "Cactus","colour": "Purple","size": "L","season": false}'

# Delete a plant in the db
curl -X DELETE localhost:3000/api/plants/1
# Using the test suite

# Run all tests
npm test

# Update the snapshots
npm test -- -u

# Start Jest in interactive watch mode
npm test -- --watch

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

License

MIT