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 🙏

© 2024 – Pkg Stats / Ryan Hefner

bm-test-framework

v1.0.1

Published

Simple Integration testing framework for your Business Messages integration

Downloads

1

Readme

Google's Business Messages: Test Framework

Business Messages is a mobile conversational channel that combines entry points on Google Maps, Search, and brand websites to create rich, asynchronous messaging experiences.

This NPM package is the fastest way to test your webhook endpoint. You can use it to send all of the Business Messages payloads to your test or production webhook and see if anything breaks. It takes 5 seconds to start using it. It's easily expandable and you can integrate it with your CI/CD process.

Quick start

Install this package as global:

npm install -g bm-test-framework

Now you can test your endpoint with an environment variable like so:

BMTF_ENDPOINT_URL=http://localhost:3000/callback bm-test-framework

You will need to replace http://localhost:3000/callback in the command above with the URL of your test or production webhook.

Once you run this command, your console will show something like:

  Test the endpoint
    Sending payloads to http://localhost:3000/callback
      ✔ authentication-request.json should return 200
      ✔ event-receive.json should return 200
      ✔ image-message.json should return 200 (862ms)
      ✔ read-receipt.json should return 200
      ✔ suggestion-message.json should return 200
      ✔ text-message.json should return 200 (134ms)
      ✔ text-with-dialogflow-response.json should return 200 (128ms)
      ✔ user-receipt.json should return 200

Usage in your NodeJS project

If you are using NodeJS for your project, you can use this package from inside your Mocha test suite or inside your code. To do so, first install it as a local dev-dependency like so:

npm install --save-dev bm-test-framework

Now you can initialize the object like so:

const BmTestFramework = require('bm-test-framework');
const bmTestFramework = new BmTestFramework({endpointURL: YOUR_ENDPOINT_URL_HERE});

//Once initialized, you can access an array containing the names of the different payloads here:
let payloads = bmTestFramework.payloads; //[ 'image-message.json', 'text-message.json', etc]

//To send a payload, call .sendPayload using the name of the payload:
bmTestFramework.sendPayload(payloads[0]) //sends the first payload

Usage in your CI/CD pipeline (Coming soon)

This repository will contain a Dockerfile that dockerizes this test and allows you to use it in your CI/CD pipeline. This feature is coming, so please leave an issue on Github if you have any question.

Customizing your tests

Realistic UUID

By default, the conversation-id of the tests will be CONVERSATION-ID. This is not a very realistic ID, as the best practice for conversation-ids is to use a UUID. In order to have your tests run with realistic UUID as conversation-ids, you can run your test with this environment variable:

BMTF_RANDOM_UUID=true

Which will switch the conversation-ids used in your tests to realistic-looking UUID. Please note that these IDs will not be valid, but they are formatted as if they were. The complete command will be:

BMTF_ENDPOINT_URL=http://localhost:3000/callback BMTF_RANDOM_UUID=true bm-test-framework

Changing the timeout

You can change the timeout settings by adding this environment variable: BMTF_TIMEOUT So for example, to set it to 4000 milliseconds, your command will be:

BMTF_ENDPOINT_URL=http://localhost:3000/callback BMTF_TIMEOUT=4000 bm-test-framework

Contributing

Contributions welcome! See the Contributing Guide.

License

Apache Version 2.0

See LICENSE