Import
Signature
createHarness wraps a complete component definition and exposes convenience methods for invoking its actions, triggers, and data sources by key. It also handles input default values and clean functions automatically.
Parameters
The component definition created with
component().Return value
Returns aComponentTestHarness instance with the following methods:
harness.action
clean functions defined on inputs run before perform is called.
The key of the action within
component.actions.Input values to pass. Unspecified inputs fall back to their
default values.Optional context overrides.
harness.trigger
defaultTriggerPayload().
The key of the trigger within
component.triggers.Partial trigger payload override.
Input values for the trigger.
Optional context overrides.
harness.triggerOnInstanceDeploy
onInstanceDeploy lifecycle hook. Throws if the trigger does not define onInstanceDeploy.
harness.triggerOnInstanceDelete
onInstanceDelete lifecycle hook. Throws if the trigger does not define onInstanceDelete.
harness.dataSource
The key of the data source within
component.dataSources.Input values for the data source.
Optional context overrides.
harness.connectionValue
ConnectionValue from the PRISMATIC_CONNECTION_VALUE environment variable and injects the connection’s key. Throws if the environment variable is not set.
The connection definition whose
key should be applied to the parsed value.Complete example
Input defaults and clean functions
createHarness applies input default values automatically when a param is not provided. If an input defines a clean function, it is called on the raw value before the perform function receives it:
Related
- createConnection — create a
ConnectionValuewithout using an env var - invoke — invoke a single action definition directly
- invokeTrigger — invoke a single trigger definition directly
- loggerMock — the mock logger
