@ekairos/testing 1.22.4-beta.feature-core-thread-registry-sync.0 → 1.22.5-beta.development.0
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.
- package/README.md +16 -130
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,141 +1,27 @@
|
|
|
1
1
|
# @ekairos/testing
|
|
2
2
|
|
|
3
|
-
Testing
|
|
3
|
+
Testing helpers for Ekairos packages and apps.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
## What it provides
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
- temporary InstantDB apps
|
|
8
|
+
- schema push helpers
|
|
9
|
+
- perms push helpers
|
|
10
|
+
- runtime-oriented test bootstrapping
|
|
8
11
|
|
|
9
|
-
|
|
10
|
-
- Tests compose `appDomain + testDomain`.
|
|
11
|
-
- Runtime resolution in tests uses the same resolver contract.
|
|
12
|
-
- Test schema is never pushed to production apps.
|
|
12
|
+
## Main helpers
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
- `createTestApp(...)`
|
|
15
|
+
- `pushTestSchema(...)`
|
|
16
|
+
- `pushTestPerms(...)`
|
|
17
|
+
- `destroyTestApp(...)`
|
|
15
18
|
|
|
16
|
-
|
|
19
|
+
## Typical flow
|
|
17
20
|
|
|
18
21
|
```ts
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
export const appTestingDomain = domain("my-app.testing")
|
|
24
|
-
.includes(appDomain)
|
|
25
|
-
.includes(ekairosTestDomain)
|
|
26
|
-
.schema({ entities: {}, links: {}, rooms: {} });
|
|
27
|
-
|
|
28
|
-
export default appTestingDomain.toInstantSchema();
|
|
29
|
-
```
|
|
30
|
-
|
|
31
|
-
This keeps testing explicit: import real app domain, re-compose for test.
|
|
32
|
-
|
|
33
|
-
Think of tests as a separate runtime bootstrap:
|
|
34
|
-
|
|
35
|
-
- do not depend on app `src/runtime.ts`,
|
|
36
|
-
- define test schema in `tests/instant.schema.ts`,
|
|
37
|
-
- resolve runtime with explicit `domain` per test run.
|
|
38
|
-
|
|
39
|
-
## Runtime APIs
|
|
40
|
-
|
|
41
|
-
### `getEkairosRuntime(...)`
|
|
42
|
-
|
|
43
|
-
Resolve runtime with explicit domain and explicit resolver.
|
|
44
|
-
|
|
45
|
-
```ts
|
|
46
|
-
import { getEkairosRuntime } from "@ekairos/testing/runtime";
|
|
47
|
-
|
|
48
|
-
const rt = await getEkairosRuntime({
|
|
49
|
-
env: { orgId: "org_test_1" },
|
|
50
|
-
domain: appDomain,
|
|
51
|
-
resolveRuntime: ({ env, domain }) => getAppRuntime({ env, domain }),
|
|
52
|
-
});
|
|
53
|
-
```
|
|
54
|
-
|
|
55
|
-
### `getEkairosTestRuntime(...)`
|
|
56
|
-
|
|
57
|
-
Compose `appDomain + testDomain` and resolve runtime in one call.
|
|
58
|
-
|
|
59
|
-
```ts
|
|
60
|
-
import { getEkairosTestRuntime } from "@ekairos/testing/runtime";
|
|
61
|
-
|
|
62
|
-
const { runtime, domain } = await getEkairosTestRuntime({
|
|
63
|
-
env: { orgId: "org_test_1" },
|
|
64
|
-
appDomain,
|
|
65
|
-
resolveRuntime: ({ env, domain }) => getAppRuntime({ env, domain }),
|
|
66
|
-
});
|
|
67
|
-
```
|
|
68
|
-
|
|
69
|
-
### `configureTestRuntime(...)`
|
|
70
|
-
|
|
71
|
-
Install a global test runtime resolver for suites that call `resolveRuntime(domain, env)` directly.
|
|
72
|
-
|
|
73
|
-
```ts
|
|
74
|
-
import { configureTestRuntime } from "@ekairos/testing/runtime";
|
|
75
|
-
|
|
76
|
-
beforeAll(() => {
|
|
77
|
-
configureTestRuntime({
|
|
78
|
-
resolveRuntime: ({ env, domain }) => getAppRuntime({ env, domain }),
|
|
79
|
-
});
|
|
80
|
-
});
|
|
22
|
+
const app = await createTestApp({ name, token, schema });
|
|
23
|
+
// run tests
|
|
24
|
+
await destroyTestApp({ appId: app.appId, token });
|
|
81
25
|
```
|
|
82
26
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
- injects `ekairosTestDomain` by default,
|
|
86
|
-
- can be customized with `testDomain`, `composeDomain`, `shouldInject`,
|
|
87
|
-
- keeps domain explicit per call.
|
|
88
|
-
|
|
89
|
-
## Provision APIs
|
|
90
|
-
|
|
91
|
-
`@ekairos/testing/provision`:
|
|
92
|
-
|
|
93
|
-
- `createTestApp({ name, token, schema?, perms?, orgId? })`
|
|
94
|
-
- `pushTestSchema({ appId, token, schema })`
|
|
95
|
-
- `pushTestPerms({ appId, token, perms })`
|
|
96
|
-
- `destroyTestApp({ appId, token })`
|
|
97
|
-
|
|
98
|
-
Uses Instant Platform API directly.
|
|
99
|
-
|
|
100
|
-
Typical flow:
|
|
101
|
-
|
|
102
|
-
1. `createTestApp(...)` for an ephemeral app.
|
|
103
|
-
2. `pushTestSchema(...)` with composed testing schema.
|
|
104
|
-
3. run vitest/playwright against that app runtime.
|
|
105
|
-
4. optional `destroyTestApp(...)`.
|
|
106
|
-
|
|
107
|
-
No Clerk wiring is required for this flow unless your tests explicitly validate Clerk behavior.
|
|
108
|
-
|
|
109
|
-
## Test domain entities
|
|
110
|
-
|
|
111
|
-
`ekairosTestDomain` includes:
|
|
112
|
-
|
|
113
|
-
- `test_runs`
|
|
114
|
-
- `test_cases`
|
|
115
|
-
- `test_events`
|
|
116
|
-
- `test_artifacts`
|
|
117
|
-
- `test_code_refs`
|
|
118
|
-
|
|
119
|
-
These hold run evidence (timeline, images, attachments, code links) without contaminating production domain schema.
|
|
120
|
-
|
|
121
|
-
## Reporter integration
|
|
122
|
-
|
|
123
|
-
Playwright:
|
|
124
|
-
|
|
125
|
-
```ts
|
|
126
|
-
export default defineConfig({
|
|
127
|
-
reporter: [["list"], ["@ekairos/testing/playwright"]],
|
|
128
|
-
});
|
|
129
|
-
```
|
|
130
|
-
|
|
131
|
-
Vitest:
|
|
132
|
-
|
|
133
|
-
```ts
|
|
134
|
-
import { ekairosVitestReporter } from "@ekairos/testing/vitest";
|
|
135
|
-
|
|
136
|
-
export default defineConfig({
|
|
137
|
-
test: {
|
|
138
|
-
reporters: ["default", ekairosVitestReporter()],
|
|
139
|
-
},
|
|
140
|
-
});
|
|
141
|
-
```
|
|
27
|
+
Use this package when tests need a real InstantDB app instead of mocks.
|
package/package.json
CHANGED