aboutsummaryrefslogtreecommitdiff
path: root/integration/snippets/caught-require.js
blob: 6111d2b1093d0ab746355ed661b9573ad7c411b1 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
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);
}