Skip to content

Shared fixture tests#15739

Draft
matthewp wants to merge 7 commits intomainfrom
mega-int
Draft

Shared fixture tests#15739
matthewp wants to merge 7 commits intomainfrom
mega-int

Conversation

@matthewp
Copy link
Contributor

@matthewp matthewp commented Mar 3, 2026

Summary

This PR implements a shared fixture test system to significantly reduce test execution time by allowing multiple test files to share the same fixture builds and server instances.

Changes

New Shared Fixture System

  • Created shared-fixture.js utility that provides:
    • Fixture caching across test files in the same process
    • Shared build state (only builds once when multiple tests call build())
    • Shared dev server and preview server instances

Test Migration

  • Migrated astro-basic.test.js → split into:
    • static-basic.test.js - Basic HTML, markdown, and page features
    • static-spread.test.js - Spread attributes and scoped styles tests
  • Migrated ssr-script.test.js → split into:
    • ssr-inline-scripts.test.js - Inline script handling in SSR

Fixture Reorganization

  • Renamed fixtures to simpler names:
    • astro-basic/static/
    • ssr-script/ssr/

Tests can be run in multiple ways:

# Run all tests (fixtures are shared)
pnpm test

# Run specific test file (uses shared fixture if available)
node packages/astro/test/static-basic.test.js

# Run with test runner
pnpm -C packages/astro exec astro-scripts test "test/static-*.test.js"

Notes

This is the foundation for a larger effort to consolidate and optimize the test suite. More test files can be migrated to this pattern to further reduce test execution time.

- Created shared-fixture.js utility to cache fixtures and servers across test files
- Fixtures are loaded once and reused, but only built when explicitly requested
- Dev servers and preview servers are shared across test files
- Migrated astro-basic and ssr-script tests to new system
- Split tests into focused files that share fixtures:
  - static-basic.test.js - Basic HTML and markdown tests
  - static-spread.test.js - Spread attribute tests
  - ssr-inline-scripts.test.js - SSR inline script tests
- Renamed fixtures to simpler names: static/ and ssr/
- Tests can still run individually with 'node path/to/test.js' for development
@changeset-bot
Copy link

changeset-bot bot commented Mar 3, 2026

⚠️ No Changeset found

Latest commit: ec1a78a

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@github-actions github-actions bot added the pkg: astro Related to the core `astro` package (scope) label Mar 3, 2026
@matthewp matthewp changed the title feat: implement shared fixture test system for faster test execution Shared fixture tests Mar 3, 2026
matthewp added 6 commits March 3, 2026 13:14
- Remove unused exports from shared-fixture.js
- Fix ESLint variable shadowing issues in ssr.test.js
- Remove unused test-prerenderer.js file
- Remove unused previewServer and devServer variables
- Shared servers are managed internally by the shared-fixture module
- Update config-server.test.js to use 'static' fixture
- Update config-mode.test.js to use 'static' fixture
- Update astro-sync.test.js to use 'static' fixture
- These tests were still pointing to the old 'astro-basic' fixture
- Remove assetsInlineLimit config that was forcing inline scripts to be external
- Remove external script tests that were incompatible with shared fixtures
- Clean up SSR test structure since only inline script tests remain
- Update shared fixture documentation to clarify limitations
- Remove unused external script fixture files

The original 'external scripts' tests were actually testing inline scripts
with different build configurations, which isn't supported with shared
fixtures that require identical configs across all tests.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pkg: astro Related to the core `astro` package (scope)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant