Skip to main content
Version: 4.7.28

Test cases - Get multiple

Get all test cases for a given pipeline with getTestCases().

You can also get test cases for a specific dataset within a pipeline using getTestCasesForDataset().

Example

typescript
const cases = await getTestCases('example-pipeline');
 
for (const testCase of cases) {
console.log('Case: ', testCase.name, testCase.id);
}
 
const datasetId = '123e4567-e89b-12d3-a456-426614174000';
const datasetCases = await getTestCasesForDataset(datasetId);
 
for (const testCase of datasetCases) {
console.log('Case in dataset: ', testCase.name, testCase.id);
}

Arguments

getTestCases()

pipelineSlug?: string

The slug of the pipeline to retrieve test cases for. Learn about pipelines here. Create a new pipeline here. If this is the only parameter specified, Gentrace will use the pipeline's golden dataset.

pipelineId?: string

The ID of the pipeline to retrieve test cases for. If this is the only parameter specified, Gentrace will use the pipeline's golden dataset.

Note: If both pipelineSlug and pipelineId are provided, pipelineId will take precedence.

getTestCasesForDataset()

datasetId: string

The ID of the dataset to retrieve test cases for.

Note: getTestCasesForDataset() is used specifically for retrieving test cases from a dataset, while getTestCases() is used for retrieving test cases from a pipeline.

Return value

Returns an array of TestCases.

🛠️ TestCase

The TestCase type represents the structure of a test case. Below are the fields of the TestCase type.

id: string (UUID)

createdAt: string (ISO 8601)

archivedAt?: string (ISO 8601)

updatedAt: string (ISO 8601)

expectedOutputs?: object An object representing the expected outputs for the test case.

inputs: object An object containing input data for the test case.

name: string

pipelineId: string (UUID)

datasetId: string (UUID)