summaryrefslogtreecommitdiff
path: root/packages/integrations/deno/test/basics.test.js
diff options
context:
space:
mode:
authorGravatar Matěj Volf <mat.volfik@gmail.com> 2022-05-31 17:41:33 +0200
committerGravatar GitHub <noreply@github.com> 2022-05-31 11:41:33 -0400
commitb795a085f0d20abe83c5ada1e7ba89ec4444c2d5 (patch)
treec2fb20dd72e15e0c57534190983c60ee9a501bb1 /packages/integrations/deno/test/basics.test.js
parent1aeb1d0a0004fc72a9fcfb61f78e37460437a49a (diff)
downloadastro-b795a085f0d20abe83c5ada1e7ba89ec4444c2d5.tar.gz
astro-b795a085f0d20abe83c5ada1e7ba89ec4444c2d5.tar.zst
astro-b795a085f0d20abe83c5ada1e7ba89ec4444c2d5.zip
Load environment variables in deno SSR (#3483)
* Properly shim env in Deno * Add test for loading env vars in Deno * Add changeset
Diffstat (limited to 'packages/integrations/deno/test/basics.test.js')
-rw-r--r--packages/integrations/deno/test/basics.test.js20
1 files changed, 20 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);
+ });
+ },
+});