Dashboard › craft › Craft src/index.ts has top-level side e…
019f8985-3aa7-7638-b114-dcab725c307c| Project | Hits | Last recalled |
|---|---|---|
| cli | 2 | 6d ago |
Trap: extracting a testable helper (e.g. --workspace flag parsing) into src/index.ts and importing it directly in a test file looks convenient. But index.ts ends with withTracing(main, {...})() executed at module load — importing it anywhere runs the actual CLI as a side effect. Fix: don't export helpers from index.ts for direct unit testing; instead verify behavior through a lower-level module (e.g. assert getConfiguration().targets resolves correctly post-setActiveWorkspace in config.test.ts) or verify end-to-end via the built binary (node build.mjs then run dist/craft ...). Found during getsentry/craft PR #848 (feat/workspaces-schema) review.