You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Important bits from reduced test case called out below:
tests/component/test.ts
import{test,expect}from'@playwright/experimental-ct-svelte';importFoofrom'$lib/Foo.svelte';test('should work',async({ mount })=>{constcomponent=awaitmount(Foo);awaitexpect(component).toContainText('Vite + Svelte');});
src/variable.ts
import{VITE_APP_NAME}from'$env/static/public';// the old way still works// const variables = {// appName: import.meta.env.VITE_APP_NAME// };// the new way does not workconstvariables={appName: VITE_APP_NAME};exportdefaultvariables;
Describe the bug
Above fails in supplied reduced test case, which is the Svelte boilerplate generated today with a single Environment variable added by following SvelteKit. Open src/variable.ts to the difference in the failing scenario and a working scenario. Use of functionality is security-related in SvelteKit and, as such, should enjoy first-class support in Playwright.
There's a workaround for this problem and that's to add a .env.production (used during build time) and drop in some empty env variables. This prevents playwright ct from failing to build using the new $env module in SK. More info in Kit docs here: https://kit.svelte.dev/docs/modules#$env-static-public.
Context:
"@playwright/experimental-ct-svelte": "^1.27.1"
Reduced Test Case
https://github.com/vhscom/playwright-ct-env-reduced-test
Important bits from reduced test case called out below:
tests/component/test.ts
src/variable.ts
Describe the bug
Above fails in supplied reduced test case, which is the Svelte boilerplate generated today with a single Environment variable added by following SvelteKit. Open
src/variable.ts
to the difference in the failing scenario and a working scenario. Use of functionality is security-related in SvelteKit and, as such, should enjoy first-class support in Playwright.More background
This is likely related to sveltejs/kit#1485
The text was updated successfully, but these errors were encountered: