Skip to content

Commit

Permalink
docs: update docs for docker support in express-postgresql-prisma app (
Browse files Browse the repository at this point in the history
  • Loading branch information
Abbhiishek authored Oct 28, 2024
1 parent eb9de8a commit 9ed54ac
Showing 1 changed file with 37 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,34 +43,35 @@ git clone https://github.com/keploy/samples-typescript.git
cd samples-typescript/express-postgresql-prisma
```

### Install the dependencies
### Running App Locally on Linux/WSL
#### Install the dependencies

```bash
npm install
```

### Set up environment variables:
#### Set up environment variables:

```bash
cp .env.example .env
```

### Start PostgreSQL Container
#### Start PostgreSQL Container

```bash
docker run --name my-postgres -e POSTGRES_PASSWORD=mysecretpassword -p 5432:5432 -d postgres
```

> Note: PostgreSQL Password is `mysecretpassword`
### Update the `.env` file with your PostgreSQL connection string:
#### Update the `.env` file with your PostgreSQL connection string:

```bash
PORT=3000
DATABASE_URL="postgresql://postgres:mysecretpassword@localhost:5432/postgres"
```

### Migrate the database:
#### Migrate the database:

```bash
npm run generate
Expand Down Expand Up @@ -112,7 +113,7 @@ nt in 50ms
└─────────────────────────────────────────────────────────┘
```

### Start the application:
#### Start the application:

```bash
npm run dev
Expand All @@ -129,7 +130,7 @@ Server is listening at PORT 3000
Now we walkthrough how to leverage Keploy to automatically generate test cases for the application, and later test the application using Keploy.

### Generate Test Cases
#### Generate Test Cases

> Note: Build the application first using `npm run build`
Expand Down Expand Up @@ -173,6 +174,25 @@ The above command will start recording the API calls made to the application and
> 💡 You can use Postman or any other API testing tool to test the API calls. Additionally, the application will run a swagger UI on `http://localhost:3000/api/docs` to visualize the API calls.
### Running App using Docker Compose 🐳
We will be using Docker compose to run the application as well as PostreSql on Docker container.
Lights, Camera, Record! 🎥
Fire up the application and mongoDB instance with Keploy. Keep an eye on the two key flags: -c: Command to run the app (e.g., docker compose up).
--container-name: The container name in the docker-compose.yml for traffic interception.
```bash
keploy record -c "docker compose up" --container-name "express-postgresql-prisma-app" --build-delay 50
```
**🔥 Challenge time!** Generate some test cases. How? Just make some API calls. Postman, Hoppscotch or even curl - take your pick!
### Interact with Application
Make API Calls using [Hoppscotch](https://hoppscotch.io/), [Postman](https://www.postman.com/) or [cURL](https://curl.se/) command. Keploy with capture those calls to generate the test-suites containing testcases and data mocks.
Expand Down Expand Up @@ -317,10 +337,20 @@ curl -X 'DELETE' \
### Test the Application using Keploy
#### on Linux/WSL
```bash
keploy test -c "npm start"
```
#### On Docker Compose 🐳
```bash
keploy test -c "docker compose up" --container-name "nodeMongoApp" --build-delay 50 --delay 10
```
> The **--delay** flag? Oh, that's just giving your app a little breather (in seconds) before the test cases come knocking.
Keploy will replay the recorded interactions and validate the responses against the expected results.
```bash
Expand Down

0 comments on commit 9ed54ac

Please sign in to comment.