@salesforce/apex-node
Version:
Salesforce JS library for Apex
94 lines (93 loc) • 4.54 kB
TypeScript
import { Connection } from '@salesforce/core';
import { CancellationToken, Progress } from '../common';
import { AsyncTestRun } from '../streaming';
import { ApexTestProgressValue, ApexTestQueueItem, ApexTestQueueItemRecord, ApexTestResult, ApexTestRunResult, AsyncTestArrayConfiguration, AsyncTestConfiguration, TestResult, TestRunIdResult } from './types';
import { Duration } from '@salesforce/kit';
/**
* Standalone function for writing async test results to file - easier to test
*/
export declare const writeAsyncResultsToFile: (formattedResults: TestResult, runId: string) => Promise<void>;
export declare class AsyncTests {
readonly connection: Connection;
private readonly codecoverage;
private readonly logger;
constructor(connection: Connection);
/**
* Asynchronous Test Runs
* @param options test options
* @param codeCoverage should report code coverage
* @param exitOnTestRunId should not wait for test run to complete, return test run id immediately
* @param progress progress reporter
* @param token cancellation token
* @param timeout Duration to wait before returning a TestRunIdResult. If the polling client times out,
* the method will return the test run ID so you can retrieve results later.
*/
runTests(options: AsyncTestConfiguration | AsyncTestArrayConfiguration, codeCoverage?: boolean, exitOnTestRunId?: boolean, progress?: Progress<ApexTestProgressValue>, token?: CancellationToken, timeout?: Duration, interval?: Duration): Promise<TestResult | TestRunIdResult>;
private writeResultsToFile;
/**
* Report Asynchronous Test Run Results
* @param testRunId test run id
* @param codeCoverage should report code coverages
* @param token cancellation token
*/
reportAsyncResults(testRunId: string, codeCoverage?: boolean, token?: CancellationToken): Promise<TestResult>;
checkRunStatus(testRunId: string, progress?: Progress<ApexTestProgressValue>): Promise<{
testsComplete: boolean;
testRunSummary: ApexTestRunResult;
}>;
/**
* Format the results of a completed asynchronous test run
* @param asyncRunResult TestQueueItem and RunId for an async run
* @param commandStartTime start time for the async test run
* @param codeCoverage should report code coverages
* @param testRunSummary test run summary
* @param progress progress reporter
* @returns
*/
formatAsyncResults(asyncRunResult: AsyncTestRun, commandStartTime: number, codeCoverage: boolean, testRunSummary: ApexTestRunResult, progress?: Progress<ApexTestProgressValue>): Promise<TestResult>;
getAsyncTestResults(testQueueResult: ApexTestQueueItem): Promise<ApexTestResult[]>;
/**
* @returns Convert FlowTest result to ApexTestResult type
*/
private convertFlowTestResult;
private buildAsyncTestResults;
/**
* Abort test run with test run id
* @param testRunId
* @param progress
*/
abortTestRun(testRunId: string, progress?: Progress<ApexTestProgressValue>): Promise<void>;
private getTestRunRequestAction;
/**
* @returns A boolean indicating if the org's api version supports the test setup feature.
*/
supportsTestSetupFeature(): Promise<boolean>;
/**
* @returns A boolean indicating if this is running FlowTest.
*/
isJobIdForFlowTestRun(testRunId: string): Promise<boolean>;
/**
* @returns A connection based on the current api version and the max api version.
*/
defineApiVersion(): Promise<Connection>;
/**
* @returns A new connection similar to the current one but with a new api version.
*/
cloneConnectionWithNewVersion(newVersion: string): Promise<Connection>;
/**
* Maps test results by category (Apex vs Flow tests)
*/
mapTestResultsByCategory(records: ApexTestQueueItemRecord[]): {
apexTestIds: string[];
flowTestIds: string[];
};
getFlowTestResults(recordIds: string[]): Promise<ApexTestResult[]>;
getApexTestResults(recordIds: string[], isTestSetup: boolean): Promise<ApexTestResult[]>;
/**
* Splits record IDs into multiple queries to respect Salesforce query limits
* @param queryTemplate SOQL query template with %s placeholder for IDs
* @param recordIds Array of record IDs to include in queries
* @returns Array of complete SOQL queries ready to execute
*/
buildChunkedQueries(queryTemplate: string, recordIds: string[]): string[];
}