diff options
Diffstat (limited to 'packages/integrations/deno/test')
-rw-r--r-- | packages/integrations/deno/test/basics.test.js | 20 | ||||
-rw-r--r-- | packages/integrations/deno/test/fixtures/basics/src/pages/index.astro | 2 |
2 files changed, 22 insertions, 0 deletions
diff --git a/packages/integrations/deno/test/basics.test.js b/packages/integrations/deno/test/basics.test.js index bc7322067..4a368e32d 100644 --- a/packages/integrations/deno/test/basics.test.js +++ b/packages/integrations/deno/test/basics.test.js @@ -5,6 +5,12 @@ async function startApp(cb) { await runBuildAndStartApp('./fixtures/basics/', cb); } +// this needs to be here and not in the specific test case, because +// the variables are loaded in the global scope of the built server +// module, which is only executed once upon the first load +const varContent = 'this is a value stored in env variable'; +Deno.env.set('SOME_VARIABLE', varContent); + Deno.test({ name: 'Basics', async fn() { @@ -39,3 +45,17 @@ Deno.test({ }); }, }); + +Deno.test({ + name: 'Correctly loads run-time env variables', + async fn() { + await startApp(async () => { + const resp = await fetch('http://127.0.0.1:8085/'); + const html = await resp.text(); + + const doc = new DOMParser().parseFromString(html, `text/html`); + const p = doc.querySelector('p#env-value'); + assertEquals(p.innerText, varContent); + }); + }, +}); diff --git a/packages/integrations/deno/test/fixtures/basics/src/pages/index.astro b/packages/integrations/deno/test/fixtures/basics/src/pages/index.astro index 4eb15f2f0..29fce0190 100644 --- a/packages/integrations/deno/test/fixtures/basics/src/pages/index.astro +++ b/packages/integrations/deno/test/fixtures/basics/src/pages/index.astro @@ -1,5 +1,6 @@ --- import ReactComponent from '../components/React.jsx'; +const envValue = import.meta.env.SOME_VARIABLE; --- <html> <head> @@ -8,6 +9,7 @@ import ReactComponent from '../components/React.jsx'; </head> <body> <h1>Basic App on Deno</h1> + <p id="env-value">{envValue}</p> <ReactComponent /> </body> </html> |