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

@open-game-system/app-bridge-testing

v0.20250411.3

Published

Testing utilities for the app-bridge ecosystem

Readme

@open-game-system/app-bridge-testing

Testing utilities for the app-bridge ecosystem.

Installation

npm install @open-game-system/app-bridge-testing --save-dev
# or
yarn add @open-game-system/app-bridge-testing --dev
# or
pnpm add @open-game-system/app-bridge-testing --save-dev

API Reference

createMockBridge

/**
 * Creates a mock bridge for testing purposes
 * This implementation mimics the behavior of a real bridge but allows
 * for more control and inspection during tests
 * @template TStores Store definitions for the bridge
 * @param config Configuration options for the mock bridge
 * @returns A MockBridge instance with additional testing utilities
 */
export function createMockBridge<TStores extends BridgeStores>(
  config?: {
    /**
     * Whether the bridge is supported in the current environment
     */
    isSupported?: boolean;

    /**
     * Initial state for stores in the bridge
     * When provided, stores will be pre-initialized with these values
     */
    initialState?: Partial<{
      [K in keyof TStores]: TStores[K]["state"];
    }>;
  }
): MockBridge<TStores>;

MockBridge Interface

/**
 * Extended Bridge interface with additional testing utilities
 */
export interface MockBridge<TStores extends BridgeStores> extends Omit<Bridge<TStores>, "getSnapshot"> {
  /**
   * Get a store by its key.
   * Always returns a store (creating one if it doesn't exist)
   */
  getStore: <K extends keyof TStores>(
    storeKey: K
  ) => MockStore<TStores[K]["state"], TStores[K]["events"]> | undefined;

  /**
   * Get all events that have been dispatched to a store
   * Creates an empty event history array if one doesn't exist
   */
  getHistory: <K extends keyof TStores>(storeKey: K) => TStores[K]["events"][];

  /**
   * Reset a store's state and clear its event history
   * If no storeKey is provided, resets all stores
   */
  reset: (storeKey?: keyof TStores) => void;

  /**
   * Set the state of a store
   * Creates the store if it doesn't already exist
   */
  setState: <K extends keyof TStores>(
    storeKey: K,
    state: TStores[K]["state"]
  ) => void;

  /**
   * Check if the bridge is supported
   */
  isSupported: () => boolean;
}

MockStore Interface

/**
 * Interface for a mock store that includes testing utilities
 */
export interface MockStore<TState extends State, TEvent extends Event>
  extends Store<TState, TEvent> {
  /**
   * Directly modify the state using a producer function
   * Only available in mock bridge
   */
  produce: (producer: (state: TState) => void) => void;

  /**
   * Reset the store's state to undefined and notify listeners
   */
  reset: () => void;

  /**
   * Set the store's complete state and notify listeners
   */
  setState: (state: TState) => void;
}

Usage

import { createMockBridge } from '@open-game-system/app-bridge-testing';
import type { AppStores } from './types';

// Create a mock bridge with initial state
const bridge = createMockBridge<AppStores>({
  isSupported: true,
  initialState: {
    counter: { value: 0 }
  }
});

// Get a store
const counterStore = bridge.getStore('counter');

if (counterStore) {
  // Test state changes
  counterStore.setState({ value: 5 });
  expect(counterStore.getSnapshot().value).toBe(5);

  // Test event dispatching
  counterStore.dispatch({ type: "INCREMENT" });
  expect(bridge.getHistory('counter')).toEqual([
    { type: "INCREMENT" }
  ]);

  // Test state updates
  counterStore.produce(state => {
    state.value += 1;
  });
  expect(counterStore.getSnapshot().value).toBe(6);

  // Reset the store
  counterStore.reset();
  expect(counterStore.getSnapshot().value).toBe(0);
  expect(bridge.getHistory('counter')).toEqual([]);
}