Charles' third Mocha demo project.
- Create a server using node.js
- Use a local MongoDB to store the data on the server
- Use Postman to send http request to the server
- Write some API in the routes folder
Chai, a BDD-style assertion library for Node. To install it:
npm install chai --save-dev
npm install chai-http --save-dev
- Set up the MongoDB environment. MongoDB requires a data directory to store all data. MongoDB’s default data directory path is the absolute path \data\db on the drive from which you start MongoDB. Create this folder
- Start MongoDB.
~\MongoDB\Server\3.6\bin\mongod.exe
- Start the MongoDB as mentioned above
- Start the server by running
npm start
in the CLI - Simply input the request, e.g.
localhost:8080/book
, in the Postman.
- Start the MongoDB as mentioned above
- Start the tests by running
npm test
in the CLI
- Click here to read the main tutorial: Test a Node RESTful API with Mocha and Chai
- Click here to know see how to install and setup for MongoDB Community Edition.
- Click here to solve the error "DeprecationWarning:
open()
is deprecated in mongoose" - Click here to know more about MongoDB connections
- Click here to know more about MongoDB Connection String URI Format