npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@othree.io/chisel-lens

v3.0.0

Published

Integration testing utilities for event-sourced projections

Readme

@othree.io/chisel-lens

Integration testing utilities for event-sourced projections. Provides a fluent API for sending commands (or SNS messages), waiting for eventual consistency, validating projection state, and cleaning up test data.

Supported Data Sources

  • DynamoDB
  • OpenSearch
  • RDS Aurora Serverless (with auto-pause warm-up)

Installation

npm install @othree.io/chisel-lens

vitest is a peer dependency and must be installed separately.

API

when -- Command-driven projection tests

Sends commands to Lambda command handlers, waits for the projection to materialize, validates the result, then cleans up both the projection and the triggered events. The .and() method accepts a function (contextId: Optional<string>) => TestCommand, where contextId is extracted from the previous command's result events — useful when chained commands need to target the same aggregate created by the first command (e.g. auto-generated IDs).

import { when, ProjectionTestConfiguration } from '@othree.io/chisel-lens'

const config: ProjectionTestConfiguration<MyProjection> = {
    eventualConsistencyTimeout: 10000,
    pollingInterval: 2000,
    dataSourceConfiguration: {
        type: ProjectionDataSourceType.Dynamo,
        configuration: { tableName: 'my-projection-table' }
    },
    commandHandlers: [{
        bc: 'users',
        commandHandlerArn: 'arn:aws:lambda:...:my-command-handler',
        eventsTableName: 'my-events-table'
    }]
}

const sendCommand = when<MyProjection>(config, credentials)

// Validate projection exists with expected values
await sendCommand({ bc: 'users', command: syncNameCommand })
    .and((_contextId) => ({ bc: 'users', command: syncLastNameCommand }))
    .expectProjection({ name: 'Chuck', lastName: 'Norris' })
    .toExist()

// Use the previous command's contextId for chained commands (e.g. auto-generated IDs)
await sendCommand({ bc: 'users', command: createUserCommand })
    .and((contextId) => ({ bc: 'users', command: { ...updateNameCommand, contextId: contextId.orElse('') } }))
    .expectProjection({ name: 'Chuck', lastName: 'Norris' })
    .toExist()

// Validate projection was NOT created
await sendCommand({ bc: 'users', command: invalidCommand })
    .toBeEmpty()

whenSNS -- SNS message-driven projection tests

Publishes arbitrary messages to an SNS topic, waits for the projection to materialize, validates the result, then cleans up the projection. Designed for projections that subscribe directly to SNS topics rather than being triggered by command handler events.

import { whenSNS, SNSProjectionTestConfiguration } from '@othree.io/chisel-lens'

const config: SNSProjectionTestConfiguration<MyProjection, MyMessage> = {
    eventualConsistencyTimeout: 10000,
    topicArn: 'arn:aws:sns:...:my-topic',
    getKeys: (messages) => ({ id: messages[0].id }),
    dataSourceConfiguration: {
        type: ProjectionDataSourceType.Dynamo,
        configuration: { tableName: 'my-projection-table' }
    },
    // Optional FIFO topic support:
    getMessageGroupId: (msg) => msg.id,
    getMessageDeduplicationId: (msg) => msg.eventId,
    getMessageAttributes: (msg) => ({
        eventType: { DataType: 'String', StringValue: msg.type }
    })
}

const sendMessage = whenSNS<MyProjection, MyMessage>(config, credentials)

await sendMessage({ id: '001', type: 'Created', body: { name: 'Chuck' } })
    .and({ id: '001', type: 'Updated', body: { lastName: 'Norris' } })
    .expectProjection({ name: 'Chuck', lastName: 'Norris' })
    .toExist()

warmUp

Warms up the data source before running tests. For RDS Aurora Serverless, this handles auto-pause resume with retry logic. For DynamoDB and OpenSearch, this is a no-op.

import { warmUp } from '@othree.io/chisel-lens'

await warmUp(config, credentials)()

waitForProjection

Polls the data source until a projection appears (and optionally matches expected values).

import { waitForProjection } from '@othree.io/chisel-lens'

const wait = waitForProjection<MyProjection>(config, credentials)
const projection = await wait({ id: '001' }, expectedProjection)

pollForResult

Generic polling utility. Polls an async function until the result satisfies a predicate, or until timeout.

import { pollForResult } from '@othree.io/chisel-lens'

const result = await pollForResult(
    () => fetchSomething(),
    (value) => value.status === 'READY',
    10000,
    2000
)

Low-level API

All low-level building blocks are available under the lowLevel namespace for custom compositions:

import { lowLevel } from '@othree.io/chisel-lens'

// lowLevel.when, lowLevel.whenMessage, lowLevel.runAndValidate,
// lowLevel.runAndValidateMessage, lowLevel.pollForProjection, etc.

Development

npm install        # Install dependencies
npm run build      # Compile TypeScript
npm test           # Run tests (vitest) with 100% coverage thresholds
npm run docs       # Generate JSDoc documentation

Architecture

src/
  index.ts              # High-level API (when, whenSNS, warmUp, etc.)
  projection-utils.ts   # Core builder pattern, polling, run-and-validate, cleanup logic
  datasource-utils.ts   # Data source adapters (DynamoDB, OpenSearch, RDS)
test/
  projection-utils.test.ts
  datasource-utils.test.ts
  index.test.ts