# @tracetest/client

> Tracetest JS client libraries

Latest version **0.2.1** (published 2024-10-03) · ISC license · 0 weekly downloads

## Install

```sh
npm install @tracetest/client
pnpm add @tracetest/client
yarn add @tracetest/client
bun add @tracetest/client
```

## Health

**Score 35/100 (D)** — status: maintenance-mode.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support; pre 1.0.

Negative: stale; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.1 |
| Published | 2024-10-03 |
| First published | 2024-01-25 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 8 |
| Unpacked size | 688.4 KB |
| Known vulnerabilities | 0 (+3 in 3 direct dependencies) |
| Install scripts | no |
| Author | Oscar Reyes |
| Maintainers | xoscar, olensmar |
| Keywords | tracetest, trace-based-testing, client, openTelemetry |

## Links

- npm: https://www.npmjs.com/package/@tracetest/client
- Repository: https://tracetest.io
- Issues: https://github.com/kubeshop/tracetest-js/issues
- npm.io page: https://npm.io/package/@tracetest/client

## Dependencies (8)

- [uuid](https://npm.io/package/uuid.md) ^9.0.1
- [axios](https://npm.io/package/axios.md) ^1.6.7
- [env-ci](https://npm.io/package/env-ci.md) 9.1.0
- [js-yaml](https://npm.io/package/js-yaml.md) ^4.1.0
- [tsimportlib](https://npm.io/package/tsimportlib.md) ^0.0.5
- [@opentelemetry/sdk-node](https://npm.io/package/@opentelemetry/sdk-node.md) ^0.53.0
- [@opentelemetry/exporter-trace-otlp-grpc](https://npm.io/package/@opentelemetry/exporter-trace-otlp-grpc.md) ^0.53.0
- [@opentelemetry/auto-instrumentations-node](https://npm.io/package/@opentelemetry/auto-instrumentations-node.md) ^0.50.0

## Alternatives

- [launchdarkly-js-client-sdk](https://npm.io/package/launchdarkly-js-client-sdk.md) — 2.5M weekly downloads
- [@elastic/elasticsearch](https://npm.io/package/@elastic/elasticsearch.md) — 2.1M weekly downloads
- [@c8y/client](https://npm.io/package/@c8y/client.md) — 15.3K weekly downloads
- [@signaldb/maverickjs](https://npm.io/package/@signaldb/maverickjs.md) — 1.7K weekly downloads
- [@bbc/http-transport-cache](https://npm.io/package/@bbc/http-transport-cache.md) — 1.2K weekly downloads

## Recent versions

- 0.2.1 (latest) — 2024-10-03
- 0.2.0 — 2024-09-13
- 0.1.33 — 2024-08-15
- 0.1.32 — 2024-08-15
- 0.1.0 — 2024-07-03
- 0.0.41 — 2024-06-07
- 0.0.40 — 2024-06-05
- 0.0.39 — 2024-06-04
- 0.0.38 — 2024-05-27
- 0.0.37 — 2024-04-16
- 0.0.36 — 2024-04-02
- 0.0.35 — 2024-04-02
- 0.0.34 — 2024-03-26
- 0.0.33 — 2024-03-07
- 0.0.32 — 2024-03-06
- … 5 more at https://npm.io/package/@tracetest/client/versions

## README

# `@tracetest/client`

[![NPM Published Version][npm-img]][npm-url]

## 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](https://docs.tracetest.io/tools-and-integrations/typescript).

## Usage

### Import and Create the Tracetest Instance

```typescript
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](https://docs.tracetest.io/concepts/environment-tokens) to generate the `TRACETEST_API_TOKEN`

### Create your Test

```typescript
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

```typescript
const run = await tracetestClient.runTest(test);
await tracetestClient.wait();
```

### Log the Trace-Based Tests Summary

```typescript
// 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

```bash
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>

[npm-url]: https://www.npmjs.com/package/@tracetest/client
[npm-img]: https://badge.fury.io/js/%40tracetest%2Fclient.svg

---
_Source: https://npm.io/package/@tracetest/client · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
