@tracetest/client
v0.2.1
Published
Tracetest JS client libraries
Downloads
10,374
Readme
@tracetest/client
About
This module provides a way to integrate trace-based testing into your existing Typescript or Javascript code. It allows you to create, run, and orchestrate Tracetest Tests.
To find a detailed step-by-step tutorial on how to use this module head out to the main integration page in our docs.
Usage
Import and Create the Tracetest Instance
import Tracetest from '@tracetest/client';
const { TRACETEST_API_TOKEN = '' } = process.env;
const tracetestClient = await Tracetest({ apiToken: TRACETEST_API_TOKEN });
Follow the guide in the Tracetest documentation website to generate the
TRACETEST_API_TOKEN
Create your Test
const definition: TestResource = {
type: 'Test',
spec: {
id: 'my-test',
name: 'My Test',
skipTraceCollection: true,
trigger: {
type: 'http',
httpRequest: {
method: 'GET',
url: 'google.com',
},
},
}
}
const test = await tracetestClient.newTest(definition);
Run your Test
const run = await tracetestClient.runTest(test);
await tracetestClient.wait();
Log the Trace-Based Tests Summary
// Optional: You can add this to the code to fail the execution based on the trace-based tests results
console.log(await tracetestClient.getSummary());
Output
Successful: 1
Failed: 0
[✔️ My Test] #1 - https://app.tracetest.io/organizations/ttorg_ced62e34638d965e/environments/ttenv_b42fa137465c6e04/test/my-test/run/1
Useful Links
- For a detailed step-by-step tutorial on how to use this module: visit https://docs.tracetest.io/tools-and-integrations/typescript
- If you want to get in touch with the Tracetest team: visit https://dub.sh/tracetest-community