@salesforce/apex-node
Version:
Salesforce JS library for Apex
118 lines (117 loc) • 5.47 kB
TypeScript
import { Connection } from '@salesforce/core';
import { ApexTestProgressValue, AsyncTestArrayConfiguration, AsyncTestConfiguration, OutputDirConfig, SyncTestConfiguration, TestLevel, TestResult, TestRunIdResult, TestSuiteMembershipRecord } from './types';
import { CancellationToken, Progress } from '../common';
import { AsyncTests } from './asyncTests';
import { Readable, Writable } from 'node:stream';
import { Duration } from '@salesforce/kit';
import { Transform } from 'stream';
/**
* Standalone function for writing test result files - easier to test
*/
export declare const writeResultFiles: (result: TestResult | TestRunIdResult, outputDirConfig: OutputDirConfig, codeCoverage: boolean, runPipeline: (readable: Readable, filePath: string, transform?: Transform) => Promise<string>) => Promise<string[]>;
export declare class TestService {
private readonly connection;
readonly asyncService: AsyncTests;
private readonly syncService;
constructor(connection: Connection);
/**
* Retrieve all suites in org
* @returns list of Suites in org
*/
retrieveAllSuites(): Promise<{
id: string;
TestSuiteName: string;
}[]>;
private retrieveSuiteId;
/**
* Retrive the ids for the given suites
* @param suitenames names of suites
* @returns Ids associated with each suite
*/
private getOrCreateSuiteIds;
/**
* Retrieves the test classes in a given suite
* @param suitename name of suite
* @param suiteId id of suite
* @returns list of test classes in the suite
*/
getTestsInSuite(suitename?: string, suiteId?: string): Promise<TestSuiteMembershipRecord[]>;
/**
* Returns the associated Ids for each given Apex class
* @param testClasses list of Apex class names
* @returns the associated ids for each Apex class
*/
getApexClassIds(testClasses: string[]): Promise<string[]>;
/**
* Builds a test suite with the given test classes. Creates the test suite if it doesn't exist already
* @param suitename name of suite
* @param testClasses
*/
buildSuite(suitename: string, testClasses: string[]): Promise<void>;
/**
* Synchronous Test Runs
* @param options Synchronous Test Runs configuration
* @param codeCoverage should report code coverage
* @param token cancellation token
*/
runTestSynchronous(options: SyncTestConfiguration, codeCoverage?: boolean, token?: CancellationToken): Promise<TestResult | TestRunIdResult>;
/**
* Asynchronous Test Runs
* @param options test options
* @param codeCoverage should report code coverage
* @param immediatelyReturn should not wait for test run to complete, return test run id immediately
* @param progress progress reporter
* @param token cancellation token
* @param timeout
*/
runTestAsynchronous(options: AsyncTestConfiguration | AsyncTestArrayConfiguration, codeCoverage?: boolean, immediatelyReturn?: boolean, progress?: Progress<ApexTestProgressValue>, token?: CancellationToken, timeout?: Duration, interval?: Duration): Promise<TestResult | TestRunIdResult>;
/**
* 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>;
/**
*
* @param result test result
* @param outputDirConfig config for result files
* @param codeCoverage should report code coverage
* @returns list of result files created
*/
writeResultFiles(result: TestResult | TestRunIdResult, outputDirConfig: OutputDirConfig, codeCoverage?: boolean): Promise<string[]>;
/**
* Utility function to help build payload for https://developer.salesforce.com/docs/atlas.en-us.api_tooling.meta/api_tooling/intro_rest_resources_testing_runner_sync.htm
*/
buildSyncPayload(testLevel: TestLevel, tests?: string, classnames?: string,
/**
* Category for this run, for Flow or Apex. Can be a single category or an array of categories.
*/
category?: string,
/**
* Specifies whether to opt out of collecting code coverage information during the test run ("true") or to collect code coverage information ("false").
* @default false
*/
skipCodeCoverage?: boolean): Promise<SyncTestConfiguration>;
/**
* Utility function to help build payload for https://developer.salesforce.com/docs/atlas.en-us.api_tooling.meta/api_tooling/intro_rest_resources_testing_runner_async.htm
*/
buildAsyncPayload(testLevel: TestLevel, tests?: string, classNames?: string, suiteNames?: string,
/**
* Category for this run, for Flow or Apex. Can be a single category or an array of categories.
*/
category?: string,
/**
* Specifies whether to opt out of collecting code coverage information during the test run ("true") or to collect code coverage information ("false").
* @default false
*/
skipCodeCoverage?: boolean): Promise<AsyncTestConfiguration | AsyncTestArrayConfiguration>;
private buildAsyncClassPayload;
private buildClassPayloadForFlow;
private buildTestPayload;
private processFlowTest;
private processApexTest;
private runPipeline;
createStream(filePath: string): Writable;
private hasCategory;
}