n8n/packages/workflow/test/workflow-expression.test.ts
Iván Ovejero 5ee0e842b8
Some checks are pending
CI: Master (Build, Test, Lint) / Build for Github Cache (push) Waiting to run
CI: Master (Build, Test, Lint) / Unit tests (22.x) (push) Waiting to run
CI: Master (Build, Test, Lint) / Unit tests (24.13.1) (push) Waiting to run
CI: Master (Build, Test, Lint) / Unit tests (25.x) (push) Waiting to run
CI: Master (Build, Test, Lint) / Lint (push) Waiting to run
CI: Master (Build, Test, Lint) / Performance (push) Waiting to run
CI: Master (Build, Test, Lint) / Notify Slack on failure (push) Blocked by required conditions
feat(core): Add isolate pooling for VM expression engine (#27573)
2026-03-31 14:54:11 +00:00

49 lines
1.3 KiB
TypeScript

import * as Helpers from './helpers';
import type { NodeParameterValueType } from '../src';
import { Workflow } from '../src/workflow';
describe('WorkflowExpression', () => {
describe('getParameterValue()', () => {
const nodeTypes = Helpers.NodeTypes();
const workflow = new Workflow({
id: '1',
nodes: [
{
name: 'node',
typeVersion: 1,
type: 'test.set',
id: 'uuid-1234',
position: [0, 0],
parameters: {},
},
],
connections: {},
active: false,
nodeTypes,
});
const expression = workflow.expression;
beforeAll(async () => {
await expression.acquireIsolate();
});
afterAll(async () => {
await expression.releaseIsolate();
});
const evaluate = (value: NodeParameterValueType) =>
expression.getParameterValue(value, null, 0, 0, 'node', [], 'manual', {});
it('should resolve $parameter["&key"] sibling reference within an object', () => {
// n8n uses the `&`-prefixed syntax internally (e.g. in node parameter definitions)
// to reference sibling fields: `={{ $parameter["&key"].split("|")[1] }}`
// getParameterValue must pass the parent object as siblingParameters so these resolve.
const result = evaluate({
key: 'title|display',
type: '={{$parameter["&key"].split("|")[1]}}',
});
expect(result).toEqual({ key: 'title|display', type: 'display' });
});
});
});