Do you find yourself on how to test different parts of your Angular or NestJs application?
Is your teacher asking for you to come up with various test cases?
Look no further, this app has a examples of all that
Unit tests in NestJs, E2E endpoints tests for the API, Frontend E2E tests with Cypress, and a mix of integration tests in the backend and frontend validating the components and services. Many test cases, many tests, all your heart desires.
- NestJs - api
- Angular - frontend
- NX - repository structure as a monorepo
- PostgreSql - data persistance
- And love 💖
The services are configured via a .env file, which is gitignored.
If you wish to connect to a database other than a locally hosted one, create a .env file based on the .env.template and store your data there.
cp .env.template .envBefore you can run this project, you need to have the following things installed:
-
Npm and Node - we recommend using NVM (Linux, MacOS) or NVM-Windows (Windows)
Use Node version
v16.14.0+ -
nx
npm install -g nxif you don't want to install NX globally, every NX command will have to be run through npx
We try to use the latest version of NX, but it is under active development and gets updated often. If the latest version of NX doesn't work, try an older version and submit a bug report.
Current NX version used by the project can be found in the package.json under any of thenrwl/dev dependencies
- Clone the repo
git clone https://github.com/Kwandes/teststore.git- Install NPM packages
npm install- Configure the app
Update the .env file if needed.
The app requires a PostgreSql database instance to connect to with an existing schema teststore
You can run one locally via Docker with:
docker run --name postgres --restart unless-stopped -e POSTGRES_USER=root -e POSTGRES_PASSWORD=root -e POSTGRES_DB=teststore -p 5432:5432 -d postgres
- [Optional] Populate (seed) the database with example data
npm run seed- Serve the apps
The system is composed of multiple apps, to get access to all of the functionalty all of them need to be running.
You can either serve apps individually with:
nx serve api
nx serve teststoreor serve multiple apps using:
nx run-many --maxParallel 2 --parallel true --projects api, teststore --target serveFind out more about how to use NX here
The repository includes Dockerfiles for building the API and frontend applications.
docker build -t test-api -f ./.deploy/API_Dockerfile .
docker run --name test-api --restart unless-stopped -dp 3333:3333 test-apidocker build -t test-teststore -f ./.deploy/TESTSTORE_Dockerfile .
docker run --name test-teststore --restart unless-stopped -dp 4200:80 test-teststoreThe API is documented using SwaggerUi, which you can access by runnign the api and navigating to localhost:3333/api
The documentation contains all of the available endpoints as well as how to call them and what they return.
Distributed under the MIT License. See LICENSE for more information.