Testing – astrojs-wp-integration
14 Stars
View on GitHub
Testing
Section titled “Testing”This package uses integration-first testing against a real local WordPress instance.
Actions overview How action factories map auth and error handling in integration tests.
Auth bridge JWT bridge behavior and action auth wiring covered by integration tests.
Caching How route caching, cache hints, and invalidation actions are exercised end to end.
Post actions Examples of action behavior validated through Astro RPC endpoints.
Test Projects
Section titled “Test Projects”integration: Loader runtime, action RPC, auth bridge, meta, ACF, ability coverage, and route-caching coverage through the shared Astro fixture.static-build: Realastro buildvalidation for static loader content collections.
The shared Astro fixture in tests/fixtures/astro-site/ includes both:
src/content.config.tsfor build-time collections used by static loader coverage.src/live.config.tsfor runtime collections used bygetLiveCollection()andgetLiveEntry()SSR coverage.
Local Workflow
Section titled “Local Workflow”Start local WordPress first:
npm run wp:startnpm run wp:statuswp-env is configured with automatic port selection. If 8888 is unavailable, run npm run wp:status to see the active local WordPress URL and ports.
Run tests:
npm run test:integrationnpm run test:build# or run both projectsnpm testStop or reset local WordPress:
npm run wp:stopnpm run wp:cleanAuth Bridge Coverage
Section titled “Auth Bridge Coverage”Auth bridge behavior is covered by the integration project against wp-env.
- Action integration tests call real
/_actions/*endpoints from the shared fixture intests/fixtures/astro-site/. tests/setup/global-setup.tsprovisions auth fixtures (application password, JWT, cookie+nonce) before integration suites run.- Live loader runtime tests call real Astro pages in the same fixture to verify
defineLiveCollection()wiring, schema validation, and SSR rendering for posts, pages, categories, and CPT content. - Route-caching tests build the same fixture with
@astrojs/node, start the standalone server entry, and verify cache hints plus the packaged invalidation actions end to end.