Unit Test and Integration Test
Build a simple unit test and integration test with Jest and Supertest.
Binar Challenge - Backend JavaScript - Chapter 6
This project is one of Challenge from Binar Academy Kampus Merdeka.
The challenge is to create a simple unit test and integration test with Jest and Supertest.
This challenge is a continuation of the previous challenge, which is Postman Collection Documentation.
Requirements
- Unit Test
- Integration Test
- CI/CD with GitHub Actions
Features
- User Game CRUD
- User Game Biodata CRUD
- User Game History CRUD
- Authentication
- Generate documentation from Postman collection
- Unit Test
- Integration Test
- CI/CD with GitHub Actions, not working due Vercel's serverless function.
Tech Stack
- NodeJS
- ExpressJS
- pg - PostgreSQL client for Node.js
- sequelize - ORM
- bcrypt - Password hashing
- jsonwebtoken - JWT Authentication
- dotenv - Environment variables
- joi - Validation schema
- joi-password-complexity - Password complexity validation
- morgan - HTTP request logger
- helmet - Security HTTP headers
- compression - HTTP compression
- postman-collection - Generate documentation from Postman collection
- jest - Unit Test
- supertest - Integration Test
- chai - Assertion library
- cross-env - Set environment variables
Prerequisites
- NodeJS
- PostgreSQL
- sequelize-cli - Sequelize command line interface, make sure you install it globally.
- nodemon - Nodemon will watch the files in the directory in which nodemon was started, and if any files change, nodemon will automatically restart your node application. Make sure you install it globally.
Installation and Usage
Clone the repository
1git clone https://github.com/raprmdn/binar-chapter6.git
bash
Install dependencies
1npm install
bash
Copy .env.example
to .env
1cp .env.example .env
bash
Configure the required environment variables in .env
file
Create database
1sequelize db:create
bash
Run migration
1sequelize db:migrate
bash
Run the Unit Test and Integration Test
1npm test
bash
Screenshots
Next Challenge
The next challenge is integration with Google and Facebook OAuth and Upload Image/File. Check it out here.