expect to throw

This commit is contained in:
Martin McKeaveney 2025-01-31 17:23:36 +00:00
parent 6999bdf57e
commit b0e38be844
1 changed files with 5 additions and 4 deletions

View File

@ -111,10 +111,11 @@ describe("Test isolated vm directly", () => {
it("should ensure error results are cleared between runs", () => {
const context = {}
// throw error
const result = runJSWithIsolatedVM(`test.foo.bar = 123`, context)
expect(result).toEqual({})
// ensure error not persisted across vms
const secondResult = runJSWithIsolatedVM(`return {}`, context)
// Ensure the first execution throws an error
expect(() => runJSWithIsolatedVM(`test.foo.bar = 123`, context)).toThrow();
// Ensure the error is not persisted across VMs
const secondResult = runJSWithIsolatedVM(`return {}`, context);
expect(secondResult).toEqual({})
})
})