From 20c1728fcb3b6ed27f7a68ed3e9fc8bf8e7ce57a Mon Sep 17 00:00:00 2001 From: snek Date: Wed, 11 Sep 2024 18:28:37 -0700 Subject: [PATCH] fix: add test ensuring als works across dynamic import Fixes: https://github.com/denoland/deno/issues/25275 Signed-off-by: snek --- tests/unit_node/async_hooks_test.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tests/unit_node/async_hooks_test.ts b/tests/unit_node/async_hooks_test.ts index 91130972c51e3e..d14f1a58203464 100644 --- a/tests/unit_node/async_hooks_test.ts +++ b/tests/unit_node/async_hooks_test.ts @@ -160,3 +160,14 @@ Deno.test(async function worksWithAsyncAPIs() { test(); }); }); + +Deno.test(async function worksWithDynamicImports() { + const store = new AsyncLocalStorage(); + globalThis.alsDynamicImport = () => store.getStore(); + const dataUrl = + `data:application/javascript,export const data = alsDynamicImport()`; + await store.run("data", async () => { + const { data } = await import(dataUrl); + assertEquals(data, "data"); + }); +});