From dd7225fb2aac3726431f942ff4a3acb4156773f4 Mon Sep 17 00:00:00 2001 From: Jarred Sumner Date: Thu, 16 Dec 2021 18:14:41 -0800 Subject: Add regression test for try / catch with import & require --- integration/snippets/caught-require.js | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 integration/snippets/caught-require.js (limited to 'integration/snippets/caught-require.js') diff --git a/integration/snippets/caught-require.js b/integration/snippets/caught-require.js new file mode 100644 index 000000000..6111d2b10 --- /dev/null +++ b/integration/snippets/caught-require.js @@ -0,0 +1,31 @@ +// Since top-level await is Special, we run these checks in the top-level scope as well. +try { + require("this-package-should-not-exist"); +} catch (exception) {} + +try { + await import("this-package-should-not-exist"); +} catch (exception) {} + +import("this-package-should-not-exist").then( + () => {}, + () => {} +); + +export async function test() { + // none of these should error + try { + require("this-package-should-not-exist"); + } catch (exception) {} + + try { + await import("this-package-should-not-exist"); + } catch (exception) {} + + import("this-package-should-not-exist").then( + () => {}, + () => {} + ); + + return testDone(import.meta.url); +} -- cgit v1.2.3