# @event-scout/client

> EventScout client

Latest version **0.8.0** (published 2025-03-05) · MIT license · 0 weekly downloads

## Install

```sh
npm install @event-scout/client
pnpm add @event-scout/client
yarn add @event-scout/client
bun add @event-scout/client
```

## Health

**Score 55/100 (C)** — status: stable.

Positive: has types; esm support; no vulnerabilities; high maintenance score; high quality score.

Warnings: low downloads; pre 1.0.

Negative: stale.

## Facts

| | |
|---|---|
| Version | 0.8.0 |
| Published | 2025-03-05 |
| First published | 2022-12-19 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 6 |
| Unpacked size | 320.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 27 |
| Author | fargito |
| Maintainers | fargito |
| Keywords | CDK, CDK Constructs, EventBridge, Serverless |

## Links

- npm: https://www.npmjs.com/package/@event-scout/client
- Repository: https://github.com/fargito/event-scout
- Issues: https://github.com/fargito/event-scout/issues
- npm.io page: https://npm.io/package/@event-scout/client

## Dependencies (6)

- [axios](https://npm.io/package/axios.md) ^1.6.8
- [@aws-sdk/types](https://npm.io/package/@aws-sdk/types.md) ^3.489.0
- [@smithy/signature-v4](https://npm.io/package/@smithy/signature-v4.md) ^5.0.0
- [@aws-crypto/sha256-js](https://npm.io/package/@aws-crypto/sha256-js.md) ^5.2.0
- [@swarmion/serverless-contracts](https://npm.io/package/@swarmion/serverless-contracts.md) ^0.33.0
- [@event-scout/construct-contracts](https://npm.io/package/@event-scout/construct-contracts.md) ^0.8.0

## Alternatives

- [async-exit-hook](https://npm.io/package/async-exit-hook.md) — 3.7M weekly downloads
- [evnty](https://npm.io/package/evnty.md) — 7.2K weekly downloads
- [eleventy-plugin-asciidoc](https://npm.io/package/eleventy-plugin-asciidoc.md) — 3.5K weekly downloads
- [@jswork/next-get2get](https://npm.io/package/@jswork/next-get2get.md) — 945 weekly downloads
- [@dashersw/axon](https://npm.io/package/@dashersw/axon.md) — 934 weekly downloads

## Recent versions

- 0.8.0 (latest) — 2025-03-05
- 0.7.7 — 2024-11-09
- 0.7.6 — 2024-06-21
- 0.7.5 — 2024-05-14
- 0.7.4 — 2024-05-14
- 0.7.3 — 2024-05-12
- 0.7.2 — 2024-05-03
- 0.7.1 — 2024-04-29
- 0.7.0 — 2024-04-29
- 0.6.1 — 2024-04-18
- 0.6.0 — 2024-04-18
- 0.5.6 — 2024-03-26
- 0.5.5 — 2024-01-17
- 0.5.4 — 2023-11-20
- 0.5.3 — 2023-11-19
- … 19 more at https://npm.io/package/@event-scout/client/versions

## README

# @event-scout/client

Create and query event trails using EventScout.

This repository is part of [EventScout](https://github.com/fargito/event-scout).

## Installation

```bash
pnpm add -D @event-scout/client
```

or if using yarn

```
yarn add --dev @event-scout/client
```

or if using npm

```
npm install --save-dev @event-scout/client
```

## Use EventScout in your tests

### Create a client

In order to use the EventScout client, you will need:

- the `endpoint` exported by [@event-scout/construct](https://github.com/fargito/event-scout/main/packages/construct/README.md)
- the AWS `region` in which you run your tests
- valid AWS `credentials`. Check out [the AWS SDK v3 docs on how to build credentials](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/modules/_aws_sdk_credential_providers.html).

Instantiate the client:

```ts
import { EventScoutClient } from '@event-scout/client';

const eventScoutClient = new EventScoutClient({
  credentials,
  region,
  endpoint: eventScoutEndpoint,
});
```

### Start an events trail

A trail is a list of events with a certain patterns, that you can dynamically create.

At the beginning of the test, start a trail with a custom pattern:

```ts
beforeAll(
  async () => {
    await eventScoutClient.start({
      eventPattern: {
        source: ['my-pattern'],
        'detail-type': ['MY_DETAIL_TYPE'],
      },
    });
  },
  30 * 1000, // 30s timeout
);
```

You can put any valid EventBridge pattern here, including content filtering. Check [the AWS docs](https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-event-patterns.html) for more details.

⚠ In order for the resources to be properly activated, the EventScout client will wait for 20 seconds before returning. We advise to set a **30 seconds timeout** on the `beforeAll` method.

### Query the trail messages

In your tests, simply call the `.query()` method to retrieve events in the trail.

```ts
const messages = await eventScoutClient.query();
```

This will return all the events in the trail! You are then free to make assertions on them.

### Cleanup

At the end of the test, call the `.stop()` method in `afterAll`:

```ts
afterAll(async () => {
  await eventScoutClient.stop();
});
```

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