Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add test for astro:route:setup hook #11889

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Fryuni
Copy link
Member

@Fryuni Fryuni commented Aug 31, 2024

Changes

To ensure it doesn't break with future work regarding routing and route data.

Testing

It's the entire PR 😜

@Fryuni Fryuni requested a review from bluwy August 31, 2024 03:48
@Fryuni Fryuni self-assigned this Aug 31, 2024
Copy link

changeset-bot bot commented Aug 31, 2024

⚠️ No Changeset found

Latest commit: a6465c2

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 Aug 31, 2024
@bluwy
Copy link
Member

bluwy commented Aug 31, 2024

I'm not really sure this is a usecase we want to explicitly support and test for. It's kinda hacky where you're collecting routes (which doesn't work well in dev because routes can be updated), and the data is saved to globalThis and shared to the endpoint (which will only work if that endpoint is prerendered). I think if you're doing something like that, you'd be accepting some risk that it'll break one day.

@Fryuni
Copy link
Member Author

Fryuni commented Aug 31, 2024

The test is not for how it is being used, it is just to test that the value is called correctly.

It is just a safeguard for the changes planned for v5 and RFCs regarding routing and RouteData.
Even if some change does break the particular implementation of the test, it is better than silently breaking the behavior for integrations.

@bluwy
Copy link
Member

bluwy commented Aug 31, 2024

I guess I'm confused that we already had a test in #11657, but it's in @astrojs/node which we're moving it to another repo.

In that case, could we simplify the test that injects an integration inline at here so that it tracks the route in a variable within the describe block? That way we're not relying on globalThis for the 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.

2 participants