Skip to content

Commit

Permalink
Merge pull request #4 from mascam97/feature/e2e-testing
Browse files Browse the repository at this point in the history
Feature/e2e testing
  • Loading branch information
mascam97 authored Jul 6, 2022
2 parents 7e48e7a + 4a1f681 commit 2843b0e
Show file tree
Hide file tree
Showing 7 changed files with 2,308 additions and 1,755 deletions.
9 changes: 9 additions & 0 deletions .env.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
API_KEY=123abc
JWT_SECRET=abc123

MONGO_INITDB_ROOT_USERNAME=root
MONGO_INITDB_ROOT_PASSWORD=root
MONGO_DB=nestjs-store-test
MONGO_PORT=27018
MONGO_HOST=localhost
MONGO_CONNECTION=mongodb
29 changes: 20 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Nestjs API Store ![Stable](https://img.shields.io/badge/stable-1.0.0-blue) ![Status](https://img.shields.io/badge/status-refactoring-yellow) ![Passing](https://img.shields.io/badge/build-passing-green) ![Docker build](https://img.shields.io/badge/docker_build-passing-green)
# Nestjs API Store ![Stable](https://img.shields.io/badge/stable-1.1.0-blue) ![Status](https://img.shields.io/badge/status-refactoring-yellow) ![Passing](https://img.shields.io/badge/build-passing-green) ![Coverage](https://img.shields.io/badge/coverage-33%-red) ![Docker build](https://img.shields.io/badge/docker_build-passing-green)

_Minimal store products_

Expand All @@ -14,12 +14,16 @@ As Backend with **PHP - Laravel** I knew about APIs. So I developed the project
- Configured **NoSQL with MongoDB for the Database** and **Mongoose as a ODM**
- Implemented **Authentication with Passport.js - JWT**
- Implemented **Authorization with Guards**
- Added some **e2e Testing** for basic features

Then I made a [Project definition](project.definition.md) to define the main business logic with a scope that allows scalability. Defining only the necessary resources to fit the **Project goal**.

### TODOS

- **Testing**: After to improve and refactor the project, the testing is essential
- **Improve testing e2e**: Add fixtures to make some data, test for seller and administrator role
- **Add unit testing**: There are some files made by default for some components, these does not work
- **Add Continuous Integration**: Add some GitHub Actions for the testing
- **Add Docker container for the Nodejs project**: The project is run in a local environment, it should in a container as database in a the same network

## Getting Started :rocket:

Expand Down Expand Up @@ -76,17 +80,22 @@ NODE_ENV=prod npm run start:dev

## Testing

TODO
There are a special container for testing, the following commands are used to manage it

```bash
# unit tests
$ npm run test
$ npm run db:test:up

# e2e tests
$ npm run test:e2e
$ npm run db:test:rm

$ npm run db:test:restart
```

Note: there are a `.env.test` file with the credentials for that testing database

# test coverage
$ npm run test:cov
Finally run the e2e testing with

```bash
$ npm run test:e2e
```

---
Expand All @@ -97,6 +106,7 @@ $ npm run test:cov
- [Swagger](https://swagger.io/): API Documentation & Design Tools for Teams
- [Passport.js with Nestjs](https://docs.nestjs.com/security/authentication): Authentication middleware for Node.js
- [Mongoose with Nestjs](https://docs.nestjs.com/techniques/mongodb): Elegant mongodb object modeling for node.js
- [PactumJS](https://pactumjs.github.io/): Free & OpenSource REST API Testing Tool for all levels in a Test Pyramid

### Authors

Expand All @@ -108,6 +118,7 @@ You're free to contribute to this project by submitting [issues](https://github.

### References :books:

- [NestJs Course for Beginners - Create a REST API > e2e tests with pactumJs](https://youtu.be/GHTA143_b-s?t=8848)
- [NestJS Course: Authentication with Passport and JWT](https://platzi.com/cursos/nestjs-auth/)
- [NestJS Course: Data Persistence with MongoDB](https://platzi.com/cursos/nestjs-mongodb/)
- [NestJS Course: Modular Programming, Documentation with Swagger and Deploy](https://platzi.com/cursos/nestjs-modular/)
Expand Down
7 changes: 7 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@ services:
- 27017:27017
volumes:
- ./mongo_data:/data/db
mongo-test:
image: mongo:4.4
environment:
MONGO_INITDB_ROOT_USERNAME: root
MONGO_INITDB_ROOT_PASSWORD: root
ports:
- 27018:27017
express:
image: mongo-express
restart: always
Expand Down
Loading

0 comments on commit 2843b0e

Please sign in to comment.