Files
n8n-enterprise-unlocked/packages/nodes-base/test/nodes/Helpers.ts
कारतोफ्फेलस्क्रिप्ट™ 979f9e6327 refactor: Overhaul nodes-testing setup - Part 3 (no-changelog) (#14967)
2025-04-29 17:42:21 +02:00

30 lines
811 B
TypeScript

import { get } from 'lodash';
import { constructExecutionMetaData } from 'n8n-core';
import type { IDataObject, IExecuteFunctions, IGetNodeParameterOptions, INode } from 'n8n-workflow';
export const createMockExecuteFunction = <T = IExecuteFunctions>(
nodeParameters: IDataObject,
nodeMock: INode,
continueBool = false,
) =>
({
getNodeParameter(
parameterName: string,
_itemIndex: number,
fallbackValue?: IDataObject | undefined,
options?: IGetNodeParameterOptions | undefined,
) {
const parameter = options?.extractValue ? `${parameterName}.value` : parameterName;
return get(nodeParameters, parameter, fallbackValue);
},
getNode() {
return nodeMock;
},
continueOnFail() {
return continueBool;
},
helpers: {
constructExecutionMetaData,
},
}) as unknown as T;