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

@effit/testing

v0.1.0-alpha.7

Published

Testing primitives for the Effit framework.

Downloads

1,124

Readme

@effit/testing

Testing primitives for the Effit framework.

  • Testing.layer(layer) + it.effect / it.scopednode:test adapter that runs each test under an Effect program with a shared layer (modeled after @effect/vitest)
  • TestContainers.Postgres.Default / TestContainers.Redis.DefaultEffect.Services that boot real containers via testcontainers and expose PG* / REDIS_* env vars to the rest of the layer
  • MigrateDatabase.Default — runs knex migrate:latest inside the test scope (requires Knex to be provided)
  • CleanState.knex(config) / CleanState.redis({ host, port }) — truncate DB + flush Redis between tests
  • JobRunner.run(Job, data) — execute a @effit/workers Job's handler in-process against an integration test layer
  • ProcessorRunner.run(Processor, event) — run a projector or reactor against the event store inside a test scope

Installation

pnpm add -D @effit/testing @effit/event-sourcing @effit/workers @effit/knex @effit/core effect \
  @testcontainers/postgresql @testcontainers/redis ioredis

Wiring a full integration layer

Set NODE_ENV=test once (either via the test script or at the top of the file that exports your integration helper) so AppConfig selects the test branch. Put everything else test-specific inside that test-branch EnvironmentConfig layer — it builds only when NODE_ENV='test', so the side effects are scoped to actual test runs:

// src/_config/environments/test.ts
import { Effect, Layer } from 'effect';
import { EnvironmentConfig } from './EnvironmentConfig.js';

export const TestConfig = Layer.effect(
  EnvironmentConfig,
  Effect.sync(() => {
    process.env.JWT_SECRET = 'test-jwt-secret';
    process.env.EMAIL_FROM = '[email protected]';
    // ... any other test-only env

    return {
      nodeEnv: 'test',
      server: { secureCookies: false },
      database: { debug: false },
    };
  })
);
// src/_lib/testing/integration/IntegrationTestLayer.ts
import { Layer, pipe } from 'effect';
import { TestContainers } from '@effit/testing/TestContainers.js';
import { MigrateDatabase } from '@effit/testing/MigrateDatabase.js';
import { ApplicationLive } from '#app/container.js';
import { Knex } from '#app/infra/knex/Knex.js';

process.env.NODE_ENV = 'test';

export const IntegrationTestLayer = pipe(
  Layer.mergeAll(ApplicationLive, MigrateDatabase.Default),
  Layer.provide(Knex.Default),
  Layer.provide(TestContainers.Postgres.Default),
  Layer.provide(TestContainers.Redis.Default),
);

Testcontainers write PG* / REDIS_* during layer construction — don't hard-code those inside TestConfig; they'd just be overwritten.

// src/_lib/testing/integration/IntegrationTestCleanState.ts
import { Effect } from 'effect';
import { CleanState } from '@effit/testing/CleanState.js';
import knexConfig from '#app/infra/knex/knexfile.js';

export namespace IntegrationTestCleanState {
  // Effect.suspend ensures process.env.REDIS_* is read at execution time
  // (after testcontainers boot), not at module load.
  export const clean = Effect.suspend(() =>
    Effect.all(
      [
        CleanState.knex(knexConfig.test),
        CleanState.redis({
          host: process.env.REDIS_HOST!,
          port: Number(process.env.REDIS_PORT),
        }),
      ],
      { concurrency: 'unbounded' },
    ),
  );
}

Writing a test

import { Effect } from 'effect';
import { Testing } from '@effit/testing/Testing.js';
import { IntegrationTestLayer } from './IntegrationTestLayer.js';
import { IntegrationTestCleanState } from './IntegrationTestCleanState.js';

const integration = Testing.layer(IntegrationTestLayer);

integration('CreateTodo', (it) => {
  it.beforeEach.effect(() => IntegrationTestCleanState.clean);

  it.scoped('appends TodoCreated to the aggregate stream', () =>
    Effect.gen(function* () {
      const createTodo = yield* CreateTodo;
      const { todoId } = yield* createTodo({ title: 'Try effit' });
      // assert against the event store or a projection
    }),
  );
});

License

MIT © Talysson de Oliveira Cassiano