Socket
Socket
Sign inDemoInstall

@charisma-ai/event-emitter-tester

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@charisma-ai/event-emitter-tester

Tester for emitters with on/off interface


Version published
Maintainers
1
Created
Source

Event Emitter Tester

A utility to make testing event emitters simpler.

Usage

yarn add @charisma-ai/event-emitter-tester
import EventEmitterTester from "@charisma-ai/event-emitter-tester";

class MyTester extends EventEmitterTester {
  constructor(emitter, options = {}) {
    super(emitter, options);
  }

  reply(text: string): MyTester {
    this.addToQueue(() => {
      // do your event here...
    });
    return this;
  }

  awaitMessage(callback: (message: string) => void): MyTester {
    this.awaitEvent("message", callback);
    return this;
  }
}

async function run() {
  const tester = new MyTester(emitter, { timeout: 5000 });
  await tester
    .reply("Hello!")
    .reply("How are you?")
    .awaitMessage(message => expect(message).toEqual("Great thanks"))
    .reply("Ideal!")
    .awaitMessage(message => expect(message).toEqual("Indeed."))
    .run();
  console.log("Complete!");
}

FAQs

Package last updated on 27 Sep 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc