Skip to content

Commit

Permalink
docs(README.md): add Tests section
Browse files Browse the repository at this point in the history
Add `Tests` section to `README.md` file to show how
to set up testing environment and run tests with bun.
  • Loading branch information
AbdulrhmanGoni committed Oct 29, 2024
1 parent 0e2b443 commit e3ae1e1
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,3 +81,37 @@ cp .env.example .env.production
The server should now be available at `http://localhost:9000` (or the port you specified).
# Tests :test_tube:
I use [Bun](https://bun.sh/)'s built-in and Jest-compatible [test runner](https://bun.sh/docs/cli/test) for writing and running tests.
> Note:
> Don't forget to set the environment variables of .env.test` file before running the tests
You can copy the following template for quick start :point_down:
```
NODE_ENV=test
PORT=9100
DB_NAME=test
DB_HOST=127.0.0.1 # Default host of testing database
DB_PORT=270111 # Default port of testing database
DB_URL="mongodb://$DB_HOST:$DB_PORT/$DB_NAME?directConnection=true"
TESTING_USER_ID="user_Xm3A5q9gd3ghR73oh975bA" # Random user id for test
MUTE_LOGS=true
```
To run all tests use the following command:
```
bun test
```
To run a specific type of tests (unit, integration or e2e) use the following command:
```
bun test tests/<unit|integration|e2e>
```
To run a specific tests file just use the name of the file:
```
bun test <test-file-name>
```

0 comments on commit e3ae1e1

Please sign in to comment.