Files
cms-website/docs/adr/ADR-015-globalSetup临时库.md
T
浅念 07483b5ae2 docs: ADR 001–015 落档 + README
Co-Authored-By: Claude Code <noreply@anthropic.com>
2026-10-20 20:56:26 +08:00

7 lines
879 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# ADR-015:globalSetup 临时测试库 + vitest 2 具名导出陷阱
- **状态**:已采纳(Task 13 实施发现,阶段 1)
- **决策**:集成测试库由 vitest globalSetup 供给:setup 用开发库凭据连维护库 postgres,`CREATE DATABASE sf_test_<ts>` → 程序化跑全量迁移 → 写 `process.env.DATABASE_URL_TEST`;teardown `DROP DATABASE ... WITH (FORCE)`。彻底消除"测试碰开发库"与"清场残留"两类问题。
- **理由**:每次运行拿到完好空库且全量迁移被真实验收;开发库零写入,无需预迁移。
- **权衡/陷阱**:① vitest 2 的 globalSetup 加载器在有 default 导出时只取 default 作 setup、**不捕获具名 teardown**——必须用具名 `setup`/`teardown` 双导出且不写 default,teardown 才会注册执行。② worker 在 setup 之后派生,env 注入才对测试生效。