Create an AgentTest based on one of:
AgentTestConfig
Get the metadata content for this agent test.
Returns the AiEvaluationDefinition metadata if already generated. Otherwise it will get it by:
Optionalconnection: Connection<Schema>Org connection to use if this AgentTest only has an AiEvaluationDefinition API name.
Promise
Get the specification for this agent test.
Returns the test spec data if already generated. Otherwise it will generate the spec by:
Optionalconnection: Connection<Schema>Org connection to use if this AgentTest only has an AiEvaluationDefinition API name.
Promise
Write AiEvaluationDefinition metadata file.
The file path where the metadata file should be written.
Write a test specification file in YAML format.
The file path where the YAML test spec should be written.
StaticcreateCreates and deploys a test definition from a specification file.
Two metadata types are supported, selected via options.testRunner:
'testing-center' (default) — legacy AiEvaluationDefinition. Filename <apiName>.aiEvaluationDefinition-meta.xml.
'agentforce-studio' — new AiTestingDefinition (NGT). Filename <apiName>.aiTestingDefinition-meta.xml.
Requires Metadata API v66.0 or later on the target org; the server gates this and the lib does not preflight.
Connection to the org where the agent test will be created.
The API name of the test definition to create.
The path to the YAML specification file.
Configuration options for creating the definition.
The directory where the metadata file will be written.
Optionalpreview?: booleanIf true, writes the metadata file to <apiName>-preview-<timestamp>.xml in the current working directory and does not deploy.
OptionaltestRunner?: TestRunnerTypeWhich test runner to author for. Defaults to 'testing-center'.
Promise containing:
StaticlistList the AiEvaluationDefinitions and AiTestingDefinitions metadata in the org.
A client side representation of an agent test (AiEvaluationDefinition) within an org. Also provides utilities such as creating and listing agent tests, and converting between agent test spec and AiEvaluationDefinition.
Examples
Create a new instance from an agent test spec:
const agentTest = new AgentTest({ specPath: path/to/specfile });Get the metadata content of an agent test:
const metadataContent = await agentTest.getMetadata();Write the metadata content to a file:
await agentTest.writeMetadata('path/to/metadataFile');