You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+84-5Lines changed: 84 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,7 +2,7 @@
2
2
3
3
This repository contains a small backend server built with **Bun**, **Hono**, **Redis**, and **TypeScript**, designed as a playground for exploring different testing strategies.
4
4
5
-
The goal of this project is to provide clear, practical examples of **unit tests**, **integration tests**, and **end-to-end (E2E) tests** while experimenting with modern backend tools.
5
+
The project demonstrates how to structure a backend with singleton services and how to write unit, integration, and end-to-end (E2E) tests using real-world tools.
6
6
7
7
## `🚀 Tech Stack`
8
8
@@ -18,7 +18,84 @@ This project is intended as a **testing playground**, where you can:
18
18
- Write and run **unit tests** for isolated logic
19
19
- Build **integration tests** that interact with Redis and other services
20
20
- Run **end-to-end tests** that exercise the entire API
21
-
- Experiment with backend techniques using Bun and Hono
21
+
- Experiment with backend design patterns like singleton services
22
+
- Learn modern testing patterns in a minimal, modular codebase
23
+
24
+
## `🔹 Singleton services`
25
+
26
+
Both RedisService and HttpServer are implemented as singletons:
27
+
28
+
- Ensures only one instance of Redis or HTTP server exists
29
+
- Makes it easier to test, since you can start/stop them globally
30
+
- Avoids conflicts when running multiple tests or endpoints simultaneously
31
+
32
+
## `🧪 How tests work in this project`
33
+
34
+
### `Unit tests`
35
+
36
+
- Test individual services or functions in isolation, without starting HTTP server or connecting to Redis.
37
+
- Focused on logic correctness.
38
+
Example: Testing `RedisService.lpush` with a mocked Redis client.
39
+
40
+
```ts
41
+
test("should call lPush on the client", async () => {
0 commit comments