@cinnabun/testing 0.0.1 → 0.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +70 -0
  2. package/package.json +1 -1
package/README.md ADDED
@@ -0,0 +1,70 @@
1
+ # @cinnabun/testing
2
+
3
+ Testing utilities for Cinnabun. Bootstrap test apps with HTTP helpers and provider overrides.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ bun add -D @cinnabun/testing (or @cinnabun/core workspace:*)
9
+ ```
10
+
11
+ ## createTestApp
12
+
13
+ Full HTTP server on a random port with `get`, `post`, `put`, `delete` helpers:
14
+
15
+ ```typescript
16
+ import { describe, it, expect, afterEach } from "bun:test";
17
+ import { resolveModuleTree } from "@cinnabun/core";
18
+ import { createTestApp, type TestApp } from "@cinnabun/testing";
19
+ import { DevDashboardModule } from "@cinnabun/dev-dashboard";
20
+
21
+ describe("Dashboard", () => {
22
+ let app: TestApp;
23
+
24
+ afterEach(async () => {
25
+ await app.close();
26
+ });
27
+
28
+ it("GET /__cinnabun returns HTML", async () => {
29
+ const mod = DevDashboardModule.forRoot({ enabled: true, path: "/__cinnabun" });
30
+ const { controllers, providers } = await resolveModuleTree(mod);
31
+ app = await createTestApp({ controllers, providers });
32
+
33
+ const res = await app.get("/__cinnabun");
34
+ expect(res.status).toBe(200);
35
+ expect(res.headers.get("Content-Type")).toContain("text/html");
36
+ });
37
+ });
38
+ ```
39
+
40
+ ## createTestingModule
41
+
42
+ DI-only bootstrap (no HTTP). Useful for unit testing services:
43
+
44
+ ```typescript
45
+ import { createTestingModule } from "@cinnabun/testing";
46
+
47
+ const { container, resolve } = await createTestingModule({
48
+ providers: [UserService, MockUserRepository],
49
+ overrides: [
50
+ { provide: UserRepository, useValue: mockRepo },
51
+ ],
52
+ });
53
+
54
+ const userService = resolve(UserService);
55
+ ```
56
+
57
+ ## mockProviders
58
+
59
+ Generate stub overrides for providers:
60
+
61
+ ```typescript
62
+ import { mockProviders } from "@cinnabun/testing";
63
+
64
+ const overrides = mockProviders(EmailService, NotificationService);
65
+ // Use with createTestingModule overrides
66
+ ```
67
+
68
+ ## License
69
+
70
+ MIT
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cinnabun/testing",
3
- "version": "0.0.1",
3
+ "version": "0.0.7",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",