Skip to content

Testing – astrojs-wp-integration

This package uses integration-first testing against a real local WordPress instance.

  • integration: Loader runtime, action RPC, auth bridge, meta, ACF, ability coverage, and route-caching coverage through the shared Astro fixture.
  • static-build: Real astro build validation for static loader content collections.

The shared Astro fixture in tests/fixtures/astro-site/ includes both:

  • src/content.config.ts for build-time collections used by static loader coverage.
  • src/live.config.ts for runtime collections used by getLiveCollection() and getLiveEntry() SSR coverage.

Start local WordPress first:

Terminal window
npm run wp:start
npm run wp:status

wp-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:

Terminal window
npm run test:integration
npm run test:build
# or run both projects
npm test

Stop or reset local WordPress:

Terminal window
npm run wp:stop
npm run wp:clean

Auth bridge behavior is covered by the integration project against wp-env.

  • Action integration tests call real /_actions/* endpoints from the shared fixture in tests/fixtures/astro-site/.
  • tests/setup/global-setup.ts provisions 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.
  • TypeScript88%
  • PHP11%
  • Astro1%