Test-driven development (TDD) is an evolutionary approach to development which combines test-first development where you write a test before you write just enough production code to fulfill that test and refactoring. In simple terms, test cases are created before code is written.
In this approach we are using Express as a backend server and mongo-db as a database.
For testing purposes we are using mocha & chais.
Mocha: Mocha is a feature-rich JavaScript test framework running on Node.js and in the browser, making asynchronous testing simple and fun.
Chai:Chai is a BDD / TDD assertion library for node and the browser that can be delightfully paired with any javascript testing framework.
What we have implemented in this project?
- User login via email and password.
Node is installed (v 16.16.0)
npm is installed (v 8.11.0)
mongodb is installed
Git is installed
Express
Understanding of rest api
Idea for working in backend technology.
Go to the pre-start folder and env>development.env file directory
NODE_ENV=development
jwt_secret_key=""
MONGO_URI=""
Api path - src/controllers/admin/
path - src/test
Express
Mongoose
Dotenv
Bcryptjs
Mocha: npm install mocha
Chai: npm install chai
Chai-http: npm install chai-http
use mongodb so go to mongodb create the cluster and get the url from connection and add in .env file.
DB_URL = "****"
PORT=3009
HOST=localhost
npm install
npm run start:dev
npm i @types/mocha
npm i @types/chai
npm i @types/request
"test": "mocha -r ts-node/register src/test/**/*_spec.ts"
npm test
// Run command in Terminal