Changing how we enforce backend JS.
This commit is contained in:
parent
68374bce29
commit
04a7878ce9
|
@ -50,11 +50,9 @@ import { JsTimeoutError } from "@budibase/string-templates"
|
|||
import { isDate } from "../../../utilities"
|
||||
import nock from "nock"
|
||||
import { mockChatGPTResponse } from "../../../tests/utilities/mocks/openai"
|
||||
import { setTestingBackendJS } from "@budibase/string-templates"
|
||||
|
||||
const timestamp = new Date("2023-01-26T11:48:57.597Z").toISOString()
|
||||
tk.freeze(timestamp)
|
||||
setTestingBackendJS()
|
||||
interface WaitOptions {
|
||||
name: string
|
||||
matchFn?: (event: any) => boolean
|
||||
|
|
|
@ -43,6 +43,7 @@ import {
|
|||
import TestConfiguration from "../../../tests/utilities/TestConfiguration"
|
||||
import * as setup from "../utilities"
|
||||
import { automations } from "@budibase/shared-core"
|
||||
import { setTestingBackendJS } from "@budibase/string-templates"
|
||||
|
||||
type TriggerOutputs =
|
||||
| RowCreatedTriggerOutputs
|
||||
|
|
|
@ -4,12 +4,17 @@ import {
|
|||
JsTimeoutError,
|
||||
setJSRunner,
|
||||
setOnErrorLog,
|
||||
setTestingBackendJS,
|
||||
} from "@budibase/string-templates"
|
||||
import { context, logging } from "@budibase/backend-core"
|
||||
import tracer from "dd-trace"
|
||||
import { IsolatedVM } from "./vm"
|
||||
|
||||
export function init() {
|
||||
// enforce that if we're using isolated-VM runner then we are running backend JS
|
||||
if (env.isTest()) {
|
||||
setTestingBackendJS()
|
||||
}
|
||||
setJSRunner((js: string, ctx: Record<string, any>) => {
|
||||
return tracer.trace("runJS", {}, () => {
|
||||
try {
|
||||
|
|
|
@ -1,9 +1,5 @@
|
|||
import { validate as isValidUUID } from "uuid"
|
||||
import {
|
||||
processStringSync,
|
||||
encodeJSBinding,
|
||||
setTestingBackendJS,
|
||||
} from "@budibase/string-templates"
|
||||
import { processStringSync, encodeJSBinding } from "@budibase/string-templates"
|
||||
|
||||
import { runJsHelpersTests } from "@budibase/string-templates/test/utils"
|
||||
|
||||
|
@ -11,7 +7,6 @@ import tk from "timekeeper"
|
|||
import { init } from ".."
|
||||
import TestConfiguration from "../../tests/utilities/TestConfiguration"
|
||||
|
||||
setTestingBackendJS()
|
||||
const DATE = "2021-01-21T12:00:00"
|
||||
tk.freeze(DATE)
|
||||
|
||||
|
|
|
@ -88,7 +88,7 @@ export function processJS(handlebars: string, context: any) {
|
|||
|
||||
let clonedContext: Record<string, any>
|
||||
if (isBackendService()) {
|
||||
// On the backned, values are copied across the isolated-vm boundary and
|
||||
// On the backend, values are copied across the isolated-vm boundary and
|
||||
// so we don't need to do any cloning here. This does create a fundamental
|
||||
// difference in how JS executes on the frontend vs the backend, e.g.
|
||||
// consider this snippet:
|
||||
|
|
Loading…
Reference in New Issue