LTRAC-1583: Add a unit test harness to core - #3177
Conversation
core has never had one. `tests/` holds 63 Playwright specs run by `playwright test`; there was no `test` script, no runner, and no way to unit test anything under `lib/`. Scoped to `lib/**/*.spec.ts` deliberately. Playwright specs share the `*.spec.ts` suffix, so an unscoped Vitest would collect all 63 and fail on their fixture imports. Confirmed the scoping holds: a run in this commit reports zero files despite those 63 being present. Colocated rather than under `tests/`, matching how packages/catalyst already does unit tests -- build.spec.ts next to build.ts, and so on. `tests/` is Playwright's testDir, so specs placed there would need either a separate suffix or a testIgnore entry to keep the two runners apart; and `tests/lib/` already means "helpers for Playwright tests", which would make `tests/lib/kv` ambiguous. passWithNoTests because `turbo run test` invokes this in every package defining a `test` script, and Vitest treats an empty run as a failure. Nothing under `lib/` has specs until the PRs that build on this land, so without it this commit would fail the CI job it exists to enable. The `~` alias mirrors the tsconfig path alias so lib code importing `~/...` resolves the same way it does in the app. Split out of the Cloudflare KV adapter work so that adding a test runner -- which carries its own questions about layout, scoping and CI -- is reviewable and revertable on its own, and so the changes that need it aren't serialised behind each other. No changeset: dev tooling with no consumer-visible behaviour. Refs LTRAC-1583 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
|
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Bundle Size ReportComparing against baseline from No bundle size changes detected. |
chanceaclark
left a comment
There was a problem hiding this comment.
Do we have any unit tests in core?
No, only Playwright tests. I will fold this PR into another one that includes unit tests, to skip adding |
Linear: LTRAC-1583
Base for #3170 and #3176.
What/Why?
corehas never had a unit test runner.tests/holds 63 Playwright specs run byplaywright test; there was notestscript, no runner, and no way to unit test anything underlib/.This was originally bundled into #3170. Split out because "add a test runner to a package that has never had one" carries its own questions — layout, scoping, CI — that shouldn't be reviewed as a footnote to a caching change, and because two unrelated PRs needing it shouldn't be serialised behind each other.
include: ['lib/**/*.spec.ts']is the load-bearing part. Playwright specs share the*.spec.tssuffix, so an unscoped Vitest would collect all 63 and fail on their fixture imports. Verified the scoping holds: a run on this commit reports zero files despite those 63 being present.Colocated rather than under
tests/, matchingpackages/catalyst, wherebuild.spec.tssits next tobuild.ts. Putting them undertests/was considered — it would need either a separate suffix or atestIgnoreentry, sincetestDir: './tests'means Playwright collects anything.spec.tsthere, andtests/lib/already means "helpers for Playwright tests" sotests/lib/kvwould read ambiguously.passWithNoTestsbecauseturbo run testinvokes this in every package defining atestscript, and Vitest treats an empty run as a failure. Nothing underlib/has specs until the PRs building on this land, so without it this commit would fail the CI job it exists to enable. Reasonable to drop once specs are in — flagging it because it does mean a future brokenincludeglob would fail silently rather than loudly.The
~alias mirrors the tsconfig path alias solibcode importing~/...resolves as it does in the app.Testing
pnpm --filter @bigcommerce/catalyst-core testexits 0 withNo test files found.pnpm install --frozen-lockfilepasses, so the lockfile entry is consistent.The two PRs on top of this exercise it for real — #3170 adds 36 specs, #3176 adds 9.
Migration
None. No changeset: dev tooling with no consumer-visible behaviour.