npm

Need private packages and team management tools?Check out npm Orgs. »

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

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();
                });
        });
    });
});

install

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

Downloadsweekly downloads

4

version

0.1.0-alpha

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability