aboutsummaryrefslogtreecommitdiff
path: root/test/js
diff options
context:
space:
mode:
Diffstat (limited to 'test/js')
-rw-r--r--test/js/bun/globals.test.js8
-rw-r--r--test/js/node/vm/vm.test.ts8
2 files changed, 16 insertions, 0 deletions
diff --git a/test/js/bun/globals.test.js b/test/js/bun/globals.test.js
index 3dd129e6a..63927b2b1 100644
--- a/test/js/bun/globals.test.js
+++ b/test/js/bun/globals.test.js
@@ -87,6 +87,14 @@ describe("File", () => {
}
});
+ it("constructor without new", () => {
+ const result = () => File();
+ expect(result).toThrow({
+ name: "TypeError",
+ message: "Class constructor File cannot be invoked without 'new'",
+ });
+ });
+
it("instanceof", () => {
const file = new File(["foo"], "bar.txt", { type: "text/plain;charset=utf-8" });
expect(file instanceof File).toBe(true);
diff --git a/test/js/node/vm/vm.test.ts b/test/js/node/vm/vm.test.ts
index 99ec07ce2..982d5eed9 100644
--- a/test/js/node/vm/vm.test.ts
+++ b/test/js/node/vm/vm.test.ts
@@ -39,6 +39,14 @@ describe("Script", () => {
return script.runInThisContext(context);
});
});
+ test("can throw without new", () => {
+ // @ts-ignore
+ const result = () => Script();
+ expect(result).toThrow({
+ name: "TypeError",
+ message: "Class constructor Script cannot be invoked without 'new'",
+ });
+ });
});
function testRunInContext(