diff options
author | 2021-12-16 18:14:41 -0800 | |
---|---|---|
committer | 2021-12-16 18:14:41 -0800 | |
commit | dd7225fb2aac3726431f942ff4a3acb4156773f4 (patch) | |
tree | 9abdff9dae4459df4bc77f6bf87dfc978b70faf7 /integration/snippets | |
parent | 134748a2389e20559ae201d95aef0ecf7da5985a (diff) | |
download | bun-dd7225fb2aac3726431f942ff4a3acb4156773f4.tar.gz bun-dd7225fb2aac3726431f942ff4a3acb4156773f4.tar.zst bun-dd7225fb2aac3726431f942ff4a3acb4156773f4.zip |
Add regression test for try / catch with import & require
Diffstat (limited to 'integration/snippets')
-rw-r--r-- | integration/snippets/caught-require.js | 31 |
1 files changed, 31 insertions, 0 deletions
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); +} |