diff --git a/packages/string-templates/test/javascript.spec.js b/packages/string-templates/test/javascript.spec.js index 30ce9bbd60..07cc72c298 100644 --- a/packages/string-templates/test/javascript.spec.js +++ b/packages/string-templates/test/javascript.spec.js @@ -4,7 +4,21 @@ const processJS = (js, context) => { return processStringSync(encodeJSBinding(js), context) } +describe("Test the JavaScript helper in Node", () => { + it("should not execute JS in Node", () => { + const output = processJS(`return 1`) + expect(output).toBe("JS bindings are not executed in a Node environment") + }) +}) + describe("Test the JavaScript helper", () => { + // JS bindings do not get evaluated on the server for safety. + // Since we want to run SJ for tests, we fake a window object to make + // it think that we're in the browser + beforeEach(() => { + window = {} + }) + it("should execute a simple expression", () => { const output = processJS(`return 1 + 2`) expect(output).toBe("3")