Closed ascheucher-shopify-partner closed 4 months ago
@ascheucher-shopify-partner I am checking the repro you shared, and I can see correctly the URL:
de PATH: https://githubyoalk6-ikdi--4321--12d46890.local-credentialless.webcontainer.io/astro-blog-tutorial/en/path/post-name-1/
Hello @ascheucher-shopify-partner. Please provide a minimal reproduction using a GitHub repository or StackBlitz. Issues marked with needs repro
will be closed if they have no activity within 3 days.
Hi @ematipico,
where did you see it correctly? On the pages it works flawless, only in the vitest it fails.
Steps to reproduce the problem:
Astro Info
If this issue only occurs in one browser, which browser is a problem?
not browser related
Describe the Bug
I am new to Astro and also learning TS along the way. Maybe it's just me. But I assume it's related with vite test setup, maybe also a bug.
To learn more about the
getAbsoluteLocaleUrl()
, I created a vitest.Given my astro.config.mjs file:
Called like this:
I would expect:
But when I run the function in a vitest src/lib/i18n/utils.test.ts, they become (missing the astro-blog-tutorial base URL part, but includes the site configuration):
I read loads of the Vite & Astro documentation and also dove into the source of Astro to see how the astro.config.mjs is loaded, but could not figure it out for the vitest bootstrapping.
But I really don't understand it's respecting the site config value, but not the base value.
An example can be found in the linked StackBlitz
Relevant files are:
To see the working example in the web pages, press the 'astro-blog-tutorial' link shown in the error message in the browser window. Wait for the redirect to finish. Then, you can click the links generated by getAbsoluteLocaleUrl and shown on the page.
To see the failing test:
npm test
What's the expected result?
I would expect to respect base & site astro.config.mjs values by
getAbsoluteLocaleUrl(...)
when run in a vitest, or none of the config.Link to Minimal Reproducible Example
https://stackblitz.com/edit/github-yoalk6?file=src%2Fpages%2Fde%2Fpath%2Fpost-name-1%2Findex.astro
Participation