0.0.3 • Published 1 year ago

metallicize v0.0.3

Weekly downloads
-
License
-
Repository
github
Last release
1 year ago

metallicize

Simple test runner for tRPC.

npm i metallicize -g
metallicize test sequence.json

Build

npm run build
npm i -g
metallicize test <test-sequence-file> [output-csv-file]

Options

metallicize test

OptionDescription
-p --print <properties...>Print additional information about each test. Values: url, headers, data.
-r --run <names...>Run only the specified tests in the sequence.
-t --timePrint the duration of each test's web request. Time data is always recorded and always included in CSV output.

Syntax

Sequences

A sequence is a series of tests which are executed in order.

KeyDescription
name:stringThe name of the sequence
url:stringThe URL of a tRPC API
vars:any\|stringAn object with variable names (keys) and values, or a path to a JSON file. Variables can be used in input or data objects (e.g.: "text": "{{ name }}").
tests:test[]A list of tests

Tests

Tests consist of a single query, mutation, or batch to a tRPC route, as well as a success state.

KeyDescription
name:stringThe name of the test
query?:queryA tRPC query
mutation?:mutationA tRPC mutation
queries?:query[]A batch of tRPC queries
mutations?:mutation[]A batch of tRPC mutations
success:successThe tests' success state

Note: each test must include exactly one query, mutation, queries, or mutations.

Query/Mutation

Queries and mutations define tRPC API calls and work like useQuery() and useMutation(). They have the same structure but are distinct internally.

KeyDescription
route:stringA public tRPC query or mutation route
input:any\|stringAn object to be passed as input to the route, or a path to a JSON file

Queries and mutations can also be batched together by defining them in a list using tests.queries or tests.mutations.

Note: all API calls are automatically batched internally for compatibility with create-t3-app's AppRouter settings.

Success

Success states define the conditions that must be met for a test to pass. Any number of conditions may be included, and they must all match exactly.

KeyDescription
status?:numberThe HTTP status code
code?:stringThe TRPCError code (e.g.: NOT_FOUND)
errorMessage?:stringThe custom message attached to a TRPCError
dataStrict?:booleanWhen true, data must match the response object exactly to pass. Otherwise, only the keys specified in data must match.
data?:any\|stringThe JSON object expected for a successful request, or a path to a JSON file
headers?:anyThe response headers. Any headers specified within must match exactly.

Note: if every field is omitted, the test will always pass.

0.0.3

1 year ago

0.0.2

1 year ago

0.0.1

1 year ago