@tracetest/client
TypeScript icon, indicating that this package has built-in type declarations

0.0.37 • Public • Published

@tracetest/client

NPM Published Version

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 tracetest = await Tracetest(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 tracetest.newTest(definition);

Run your Test

const run = await tracetest.runTest(test);
await run.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 tracetest.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

Package Sidebar

Install

npm i @tracetest/client

Repository

tracetest.io

Homepage

tracetest.io

Weekly Downloads

1,292

Version

0.0.37

License

ISC

Unpacked Size

581 kB

Total Files

93

Last publish

Collaborators

  • xoscar
  • olensmar