ObjectStackObjectStack

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

PropertyTypeRequiredDescription
typeEnum<'create_record' | 'update_record' | 'delete_record' | 'read_record' | 'query_records' | 'api_call' | 'run_script' | 'wait'>The action type to execute
targetstringTarget Object, API Endpoint, or Function Name
payloadRecord<string, any>optionalData to send or use
userstringoptionalRun as specific user/role for impersonation testing

TestActionType

Type of test action to perform

Allowed Values

  • create_record
  • update_record
  • delete_record
  • read_record
  • query_records
  • api_call
  • run_script
  • wait

TestAssertion

A test assertion that validates the result of a test action

Properties

PropertyTypeRequiredDescription
fieldstringField path in the result to check, resolved against the parsed response body root — no "body." prefix (e.g. "data.0.status")
operatorEnum<'equals' | 'not_equals' | 'contains' | 'not_contains' | 'is_null' | 'not_null' | 'gt' | 'gte' | 'lt' | 'lte' | 'error'>Comparison operator to use
expectedValueanyExpected value to compare against

TestAssertionType

Comparison operator for test assertions

Allowed Values

  • equals
  • not_equals
  • contains
  • not_contains
  • is_null
  • not_null
  • gt
  • gte
  • lt
  • lte
  • error

TestContext

Initial context or variables for the test

Type: Record<string, any>


TestScenario

A complete test scenario with setup, execution steps, and teardown

Properties

PropertyTypeRequiredDescription
idstringUnique scenario identifier
namestringScenario name for test reports
descriptionstringoptionalDetailed description of the test scenario
tagsstring[]optionalTags for filtering and categorization (e.g. "critical", "regression", "crm")
setup{ name: string; description?: string; action: object; assertions?: object[]; … }[]optionalSteps 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[]; … }[]optionalSteps to cleanup after test execution
requires{ params?: string[]; plugins?: string[] }optionalEnvironment requirements for this scenario

TestStep

A single step in a test scenario, consisting of an action and optional assertions

Properties

PropertyTypeRequiredDescription
namestringStep name for identification in test reports
descriptionstringoptionalHuman-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 }[]optionalAssertions to validate after the action completes
captureRecord<string, string>optionalMap 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

PropertyTypeRequiredDescription
namestringTest suite name
scenarios{ id: string; name: string; description?: string; tags?: string[]; … }[]List of test scenarios in this suite

On this page