@happyvertical/smrt-vitest 0.60.17 → 0.61.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/AGENTS.md +2 -0
- package/agents/test-home.md +71 -0
- package/dist/.tsbuildinfo +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +39 -4
- package/dist/index.js.map +1 -1
- package/dist/setup.js +12 -4
- package/dist/setup.js.map +1 -1
- package/dist/smrt-knowledge.okf.md +8 -2
- package/dist/test-home-register.d.ts +2 -0
- package/dist/test-home-register.d.ts.map +1 -0
- package/dist/test-home-register.js +4 -0
- package/dist/test-home-register.js.map +1 -0
- package/dist/test-home.d.ts +10 -0
- package/dist/test-home.d.ts.map +1 -0
- package/dist/test-home.global-setup.d.ts +3 -0
- package/dist/test-home.global-setup.d.ts.map +1 -0
- package/dist/test-home.global-setup.js +6 -0
- package/dist/test-home.global-setup.js.map +1 -0
- package/dist/test-home.js +104 -0
- package/dist/test-home.js.map +1 -0
- package/package.json +13 -4
package/AGENTS.md
CHANGED
|
@@ -140,6 +140,8 @@ surface during development. Override with `SMRT_VITEST_RETRY=<n>`.
|
|
|
140
140
|
Packages that don't use `smrtVitestPlugin` (notably `cli`, plus `core`) set the
|
|
141
141
|
same `retry` policy inline in their own `vitest.config.ts`.
|
|
142
142
|
|
|
143
|
+
Test home/state isolation and the real-state-base guard: [agents/test-home.md](agents/test-home.md).
|
|
144
|
+
|
|
143
145
|
## Test Database Utilities
|
|
144
146
|
|
|
145
147
|
PostgreSQL isolated factories provision all canonical framework-owned system
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
# Test home and state isolation
|
|
2
|
+
|
|
3
|
+
`smrtVitestPlugin()` prepends `test-home.global-setup` to root and inline-project
|
|
4
|
+
`globalSetup`. It installs HOME, USERPROFILE, XDG state/data/config/cache homes,
|
|
5
|
+
LOCALAPPDATA and APPDATA
|
|
6
|
+
before test modules and workers start. Both profile-relative AppData bases are
|
|
7
|
+
created before publishing the environment: Windows `SHGetKnownFolderPath` verifies
|
|
8
|
+
these directories ([Win32 verification contract](https://learn.microsoft.com/en-us/windows/win32/api/shlobj_core/ne-shlobj_core-known_folder_flag)),
|
|
9
|
+
so a nonexistent redirected profile base makes Tauri's
|
|
10
|
+
`app_local_data_dir()` fail with `unknown path` before the wrapper reads resources.
|
|
11
|
+
Only directories within the newly owned test home are created; real OS bases and
|
|
12
|
+
the forbidden-state guard are preserved. The installed Playwright browser binary
|
|
13
|
+
cache is resolved before replacing HOME/XDG paths and retained through
|
|
14
|
+
`PLAYWRIGHT_BROWSERS_PATH`; an explicit caller path (including `0`) wins.
|
|
15
|
+
This preserves installed test prerequisites while app state stays isolated. Production-mode children inherit them,
|
|
16
|
+
including operator CLIs, launchers and sidecars. Do not drop these variables
|
|
17
|
+
when constructing a child environment. Do not use `userInfo().homedir` for
|
|
18
|
+
writable fixtures; `homedir()` reads the isolated HOME.
|
|
19
|
+
|
|
20
|
+
On POSIX the home is a unique directory in this package's
|
|
21
|
+
`node_modules/.cache/test-homes`, outside `/tmp` so custody tests that distrust
|
|
22
|
+
`/tmp` still exercise their original ancestry checks. On Windows it is a unique
|
|
23
|
+
directory directly under the OS `tmpdir()`: the checkout-relative profile on
|
|
24
|
+
GitHub Actions makes the generic wrapper's data root 136 UTF-16 units, exceeding
|
|
25
|
+
the runtime's unchanged 130-unit root budget (240 minus 110 reserved for derived
|
|
26
|
+
files). The shallow profile fits without relaxing path or DACL rules; AppData
|
|
27
|
+
bases still belong only to that disposable profile.
|
|
28
|
+
Teardown restores the caller's environment and recursively
|
|
29
|
+
removes only that owned directory. An exit hook is a fallback for normal process
|
|
30
|
+
exit; SIGKILL cannot run JavaScript cleanup.
|
|
31
|
+
|
|
32
|
+
`@happyvertical/smrt-vitest/test-home/global-setup` works in Vitest configs that
|
|
33
|
+
cannot use the manifest plugin, and in Playwright. `installTestHome()` from
|
|
34
|
+
`./test-home` provides the same lifecycle for another runner; call its returned
|
|
35
|
+
teardown after all children stop. The repository's Node script tests preload
|
|
36
|
+
`src/test-home-register.ts` under Node 26, so they work before building packages.
|
|
37
|
+
|
|
38
|
+
The coordinator records the replaced account/home platform bases and original
|
|
39
|
+
XDG_STATE_HOME, XDG_DATA_HOME and LOCALAPPDATA in `SMRT_FORBIDDEN_STATE_BASES`, a
|
|
40
|
+
JSON array of paths inherited unchanged by nested runners. The app-runtime state
|
|
41
|
+
resolver and default local-data custody refuse a matching base before creating
|
|
42
|
+
storage. Comparison uses existing platform path identity rules (case folding on
|
|
43
|
+
macOS/Windows and normalized separators). This opt-in refusal is inert when the
|
|
44
|
+
variable is absent; malformed configuration fails closed. Explicit resolver
|
|
45
|
+
`environment` options cannot hide the process-tree guard.
|
|
46
|
+
|
|
47
|
+
Use `testHomeEnvironment()` from `./test-home` to copy only the isolation settings
|
|
48
|
+
into a clean child environment, including official SDK stdio transports (whose
|
|
49
|
+
default inheritance is restricted). Keep test-owned HOME overrides within their
|
|
50
|
+
own lifecycle and supply the matching XDG/Windows homes. Native inference's
|
|
51
|
+
credential allow-list intentionally strips SMRT_*; the cookbook's fake CLI
|
|
52
|
+
restores the guard in its fixture prelude before spawning MCP; allowed home
|
|
53
|
+
settings already pass through the service.
|
|
54
|
+
|
|
55
|
+
There is no real-directory snapshot or cross-process filesystem comparison.
|
|
56
|
+
Other sessions' writes cannot fail this run. The guard covers runtime path
|
|
57
|
+
resolution, including production-mode descendants; arbitrary filesystem writes
|
|
58
|
+
that bypass these APIs are outside its scope. Never remove the guard from a
|
|
59
|
+
child that can resolve local application paths.
|
|
60
|
+
|
|
61
|
+
Coverage is shared across app-runtime, CLI, app-cli, desktop, local MCP,
|
|
62
|
+
MCP conformance/iolaus, template runtime-profile fixtures and e2e harnesses, as
|
|
63
|
+
well as ordinary plugin consumers. Non-plugin repository Vitest configs opt in
|
|
64
|
+
explicitly. A new runner must install the lifecycle too. Optional PostgreSQL
|
|
65
|
+
and browser suites retain their normal prerequisites.
|
|
66
|
+
|
|
67
|
+
Regression: `src/__tests__/test-home.test.ts` runs a real nested Vitest worker,
|
|
68
|
+
production-mode children and cleanup. Runtime operator regressions cover refusal,
|
|
69
|
+
platform rules, inherited children and unset behavior. Escape
|
|
70
|
+
fixtures use disposable mock state bases; they never deliberately pollute the
|
|
71
|
+
owner's real directories.
|