Testing
Testing protocol schemas
Source: packages/spec/src/qa/testing.zod.ts
TypeScript Usage
import { TestActionSchema, TestActionTypeSchema, TestAssertionSchema, TestAssertionTypeSchema, TestContextSchema, TestScenarioSchema, TestStepSchema, TestSuiteSchema } from '@objectstack/spec/qa';
import type { TestAction, TestActionType, TestAssertion, TestAssertionType, TestContext, TestScenario, TestStep, TestSuite } from '@objectstack/spec/qa';
// Validate data
const result = TestActionSchema.parse(data);TestAction
A single test action to execute against the system
Properties
| Property | Type | Required | Description |
|---|---|---|---|
| type | Enum<'create_record' | 'update_record' | 'delete_record' | 'read_record' | 'query_records' | 'api_call' | 'run_script' | 'wait'> | ✅ | The action type to execute |
| target | string | ✅ | Target Object, API Endpoint, or Function Name |
| payload | Record<string, any> | optional | Data to send or use |
| user | string | optional | Run as specific user/role for impersonation testing |
TestActionType
Type of test action to perform
Allowed Values
create_recordupdate_recorddelete_recordread_recordquery_recordsapi_callrun_scriptwait
TestAssertion
A test assertion that validates the result of a test action
Properties
| Property | Type | Required | Description |
|---|---|---|---|
| field | string | ✅ | Field path in the result to check, resolved against the parsed response body root — no "body." prefix (e.g. "data.0.status") |
| operator | Enum<'equals' | 'not_equals' | 'contains' | 'not_contains' | 'is_null' | 'not_null' | 'gt' | 'gte' | 'lt' | 'lte' | 'error'> | ✅ | Comparison operator to use |
| expectedValue | any | ✅ | Expected value to compare against |
TestAssertionType
Comparison operator for test assertions
Allowed Values
equalsnot_equalscontainsnot_containsis_nullnot_nullgtgteltlteerror
TestContext
Initial context or variables for the test
Type: Record<string, any>
TestScenario
A complete test scenario with setup, execution steps, and teardown
Properties
| Property | Type | Required | Description |
|---|---|---|---|
| id | string | ✅ | Unique scenario identifier |
| name | string | ✅ | Scenario name for test reports |
| description | string | optional | Detailed description of the test scenario |
| tags | string[] | optional | Tags for filtering and categorization (e.g. "critical", "regression", "crm") |
| setup | { name: string; description?: string; action: object; assertions?: object[]; … }[] | optional | Steps to run before main test (preconditions) |
| steps | { name: string; description?: string; action: object; assertions?: object[]; … }[] | ✅ | Main test sequence to execute |
| teardown | { name: string; description?: string; action: object; assertions?: object[]; … }[] | optional | Steps to cleanup after test execution |
| requires | { params?: string[]; plugins?: string[] } | optional | Environment requirements for this scenario |
TestStep
A single step in a test scenario, consisting of an action and optional assertions
Properties
| Property | Type | Required | Description |
|---|---|---|---|
| name | string | ✅ | Step name for identification in test reports |
| description | string | optional | Human-readable description of what this step tests |
| action | { type: Enum<'create_record' | 'update_record' | 'delete_record' | 'read_record' | … +4 more>; target: string; payload?: Record<string, any>; user?: string } | ✅ | The action to execute in this step |
| assertions | { field: string; operator: Enum<'equals' | 'not_equals' | 'contains' | 'not_contains' | 'is_null' | 'not_null' | … +5 more>; expectedValue: any }[] | optional | Assertions to validate after the action completes |
| capture | Record<string, string> | optional | Map result fields to context variables, paths resolved against the response body root (e.g. { "newId": "data.id" }) |
TestSuite
A collection of test scenarios grouped into a test suite
Properties
| Property | Type | Required | Description |
|---|---|---|---|
| name | string | ✅ | Test suite name |
| scenarios | { id: string; name: string; description?: string; tags?: string[]; … }[] | ✅ | List of test scenarios in this suite |