The backend
Your project arrives with a fully configured testing environment for backend testing. The generator wrote specs for both APIs, and an Admin API integration spec that also documents the endpoints:server/spec/models/spree/size_guide_spec.rb
The dashboard
This is where most of your own code lives, so it is where most of your tests belong. Vitest and Playwright come configured, so there is nothing to set up:What is worth a unit test
Not components. Rendering a card to assert it shows a size guide’s name tests React, not your feature, and breaks every time the markup moves. Test the logic between the UI and the API — the parts with decisions in them. The size guides client from step 2 is the clearest example. Whether a filter reaches the API insideq[...] decides whether search works, and when it goes wrong the API does not fail: it ignores the filter and returns every size guide. Nothing on screen tells you, so a test has to. Give the client a fetch that records each URL instead of sending it:
apps/dashboard/src/hooks/use-size-guides.test.ts
useResourceKey, so one store’s rows never show in another after a switch), a function mapping form values to an API payload, a permission predicate deciding whether a nav entry shows. Each is a pure function, each is a short test.
What is not worth a unit test
- Components. Asserting a card renders text is testing React.
- That the endpoint answers. The test above checks the request your code builds, not the response. Mocking a response and asserting on it proves nothing about whether
/size_guidesexists. - Anything the compiler already catches. A wrong prop type is a build failure, not a test case.
/size_guides actually return size guides” cannot be answered by a unit test at all. It needs the real API, which is the next section.
End to end, through the browser
Everything above tests a layer in isolation. One Playwright spec proves the layers are actually connected — a size guide created through the Admin API reaches the dashboard screen you built:apps/dashboard/e2e/size-guides.spec.ts
/:storeId/size-guides), which is why the spec reads the store from the URL the dashboard redirects to instead of hardcoding it.
Once you add a create form, replace the API call with the form itself — filling it and asserting the new row is the stronger test, because it covers the write path too.
Two conventions matter here:
- Drive the UI, assert on the UI. Fill labels, click buttons, check visible text. Avoid waiting on API responses —
expect(...).toBeVisible()polls until the condition holds, which covers nearly every case and keeps the test from breaking when the API shape changes. - Suffix names with
Date.now(). Specs share a database, and a fixed name collides with whatever an earlier run left behind.
E2E_ADMIN_EMAIL=… E2E_ADMIN_PASSWORD=… pnpm test:e2e from apps/dashboard, with the API running (spree dev).
What to run before you push
Run what you changed, not everything:You’re done
You have built one feature through every layer of Spree:- A model with a Store API and an Admin API, generated in one command
- A dashboard screen giving staff a place to manage it
- A storefront product page showing it through typed SDK calls
- Lifecycle events other systems react to
- Tests at each layer, plus one pass across all of them

