https://github.com/adrianomonteiroweb/e2e-tests-with-nodejs-and-prisma
Repositório de estudos de testes E2E e unitários no Node.js com uso do Prisma.
https://github.com/adrianomonteiroweb/e2e-tests-with-nodejs-and-prisma
api e2e nodejs prisma tests typescript unit-testing
Last synced: 8 months ago
JSON representation
Repositório de estudos de testes E2E e unitários no Node.js com uso do Prisma.
- Host: GitHub
- URL: https://github.com/adrianomonteiroweb/e2e-tests-with-nodejs-and-prisma
- Owner: adrianomonteiroweb
- Created: 2022-09-18T17:33:44.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2022-09-20T23:06:18.000Z (about 3 years ago)
- Last Synced: 2025-01-22T08:12:30.812Z (10 months ago)
- Topics: api, e2e, nodejs, prisma, tests, typescript, unit-testing
- Language: TypeScript
- Homepage:
- Size: 332 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# E2E TESTS WITH NODEJS AND PRISMA
Study repository of E2E tests and units tests with Node.js and Prisma.
### TECHNOLOGIES
- NPM;
- Node.js.
- Dependencies:
- Express;
- dotenv;
- prisma/client.
- DevDependencies:
- @swc/core;
- @swc/jest;
- @types/express;
- @types/jest;
- @types/node;
- @types/supertest;
- @types/pg;
- jest;
- nodemon;
- prisma;
- supertest;
- ts-node;
- pg;
- typescript.
# PATTERNS
### REPOSITORY PATTERN, IN-MEMORY DATABASE AND COMMAND/QUERY SEGREGATION
- Abstract communication with the database in repositories.
### DATABASE
```bash
...
src/
database/
prisma.ts
depositories/
server/
services/
...
```
### REPOSITORES
- Interfaces
- ILessonsRepository;
- Repositories
- PrismaLessonsRepository;
```bash
...
src/
database/
depositories/
prisma/
PrismaLessonsRepository.ts
ILessonsRepository.ts
server/
services/
...
```
### EXPRESS SERVER
```bash
...
src/
database/
depositories/
server/
app.ts
server.ts
services/
...
```
### SERVICES
```bash
...
src/
database/
depositories/
server/
services/
createLesson.spec.ts
CreateLesson.ts
...
```
### RUNNING THE APPLICATION
- Development
```bash
npm run dev
```
- Production
```bash
npm start
```
### RUNNING TESTS
- The tests are using an in-memory database so there is no knowledge of external layers in unit tests.
```bash
...
prisma/
src/
tests/
repositories/
inMemoryLessonsRepository.ts
...
```
- All tests
```bash
npm test
```
- E2e tests
```bash
npm run test:e2e
```
### LOCAL DEVELOPMENT
- Database: dev
- Models:
- Lesson
- .env
- Rename the ".env.example" file to ".env" and replace the necessary values such as:
example: myuser to admin
- And, the ".env.testing.example" file to ".env.testing" and replace the database testing values such as:
example: myuser to admin