diff --git a/packages/string-templates/src/helpers/javascript.ts b/packages/string-templates/src/helpers/javascript.ts index 4d53fe335d..61fe872103 100644 --- a/packages/string-templates/src/helpers/javascript.ts +++ b/packages/string-templates/src/helpers/javascript.ts @@ -64,7 +64,11 @@ const getContextValue = (path: string, context: any) => { if (isBackendService()) { return data } else { - return cloneDeep(data) + if (typeof data === "object") { + return cloneDeep(data) + } else { + return data + } } } diff --git a/packages/string-templates/test/manifest.spec.ts b/packages/string-templates/test/manifest.spec.ts index de0e3355fd..2d09bc7871 100644 --- a/packages/string-templates/test/manifest.spec.ts +++ b/packages/string-templates/test/manifest.spec.ts @@ -1,5 +1,3 @@ -import vm from "vm" - jest.mock("@budibase/handlebars-helpers/lib/math", () => { const actual = jest.requireActual("@budibase/handlebars-helpers/lib/math") @@ -17,7 +15,7 @@ jest.mock("@budibase/handlebars-helpers/lib/uuid", () => { } }) -import { processString, setJSRunner } from "../src/index" +import { defaultJSSetup, processString } from "../src/index" import tk from "timekeeper" import { getParsedManifest, runJsHelpersTests } from "./utils" @@ -32,9 +30,7 @@ describe("manifest", () => { const manifest = getParsedManifest() beforeAll(() => { - setJSRunner((js, context) => { - return vm.runInNewContext(js, context, { timeout: 1000 }) - }) + defaultJSSetup() }) describe("examples are valid", () => {