@fmeuman/actions-on-google-nodejs-testbench
TypeScript icon, indicating that this package has built-in type declarations

0.1.0-alpha • Public • Published

Actions on Google integration tests library

A simple integration testing tool for Actions on google webhooks. Currently support only dialogflow webhooks.

Full example :

// index.js
import { dialogflow } from 'actions-on-google';
import * as functions from 'firebase-functions';

const app = dialogflow({ debug: false });

app.intent('welcome', (conv) => {
    conv.ask('Hi! How can I help you ?');
});

exports.myAgent = functions.https.onRequest(app);
// index.spec.js
const { DialogflowTestBench } = require('actions-on-google-nodejs-testbench');

const { myAgent } = require('./index');

describe('MyAgent', () => {

    let testBench;

    beforeAll(() => {
        testBench = new DialogflowTestBench(myAgent);
    });

    afterAll(() => {
        testBench.close();
    });

    describe('welcome intent', () => {
        it('should say hi', (done) => {
            testBench.triggerIntent('welcome')
                .then(response => {
                    const textToSpeech = response.textToSpeech.join('\n');
                    expect(textToSpeech).toMatch(/hi/i);
                    done();
                });
        });
    });
});

Dependencies (3)

Dev Dependencies (7)

Package Sidebar

Install

npm i @fmeuman/actions-on-google-nodejs-testbench

Weekly Downloads

0

Version

0.1.0-alpha

License

MIT

Unpacked Size

47.8 kB

Total Files

15

Last publish

Collaborators

  • fmeuman