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

actions-on-google-testing

v0.4.0

Published

This is an end-to-end testing library for developers building actions

Downloads

4

Readme

Actions on Google Testing Library

This library allows developers to write automated testing for their actions in Node.js.

NPM Version

Examples can be found in the /examples directory for two sample apps.

The Assistant SDK is used to give developers programmatic access to the Assistant and returns debug information about their actions that are in a test state.

Note: This library is currently in an alpha, experimental state. APIs may break between releases. Feedback and bugs can be provided by filing an issue in this repository.

How to get started

  1. Go to the Actions console
  2. Create a new project. This project can be independent of your other projects.
    • You can use this project to test any of your actions that are in a test state
  3. For this new project, enable the Google Assistant API
  4. Go to the Device Registration section.
  5. Click REGISTER MODEL
    1. Fill out the product and manufacturer name
    2. Set the Device type to Light, although the choice does not matter
  6. Download the credentials.json file
  7. Use this credentials file to generate test credentials:
node generate-credentials.js /path/to/credentials.json
  1. Copy and paste the URL and enter the authorization code. You will see a response similar to the following:

Saved user credentials in "test-credentials.json"

  1. Create a JavaScript file for your tests: test.js
'use strict';
const { ActionsOnGoogleAva } = require('actions-on-google-testing');
const { expect } = require('chai');
// Library will try to obtain credentials from environment variables in case
// credentials file is not specified
const action = new ActionsOnGoogleAva(require('./test/test-credentials.json'));

// Start out with giving a name to this test
action.startTest('Facts about Google - direct cat path', action => {
    // Return a promise that starts a conversation with your test app
    return action.start()
        .then(({ textToSpeech }) => {
            // Get a response back from your fulfillment.
            // To continue the conversation, you can send
            // a new text query. This starts the next
            // turn of the conversation.
            return action.send('cats');
        })
        .then(({ ssml }) => {
            // The entire set of responses are listed below.
            // You can use Chai to verify responses.
            expect(ssml[0]).to.have.string("Alright, here's a cat fact.")
        })
});
  1. Run yarn
  2. Update your package.json to add this test file to your test script.
"scripts": {
    "test": "./node_modules/.bin/ava -c 1 -s ./test.js"
},
  1. Run yarn test. You should see your test be executed.

NOTE You can also alternatively set the following environment variables - ACTIONS_TESTING_CLIENT_ID,ACTIONS_TESTING_CLIENT_SECRET, ACTIONS_TESTING_REFRESH_TOKEN - to authenticate your Actions project with the Assistant SDK.

Supported features

This library provides the following features to control your conversation:

  • action.start() - Start your conversation with your action using "my test app".
  • action.startWith() - Start your conversation with your action using the specified action name.
  • action.send() - Send some phrase to your action.
  • action.cancel() - End your conversation. This library says "cancel".
  • action.locale - Set a locale for your conversation.
  • action.location - Set an array of a latitude and a longitude.

Possible responses

These responses will come from your fulfillment, and will consist of whatever objects that you return.

res
  .micOpen - Boolean
  .textToSpeech - String[]
  .displayText - String[]
  .ssml - String[]
  .cards - Card[]
    .title - String
    .subtitle - String
    .text - String
    .imageUrl - String
    .imageAltText - String
    .buttons - Button[]
      .title - String
      .url - String
  .carousel - Array for Browse Carousel or Selection Carousel
    .title - String
    .description - String,
    .imageUrl - String,
    .imageAltText - String,
    .url - String
  .list
    .title - String
    .items - Item[]
      .title - String
      .description - String
      .imageUrl - String
      .imageAltText - String
  .mediaResponse
    .type - String
    .name - String
    .description - String
    .sourceUrl - String
    .icon - String
  .suggestions - String[]
  .linkOutSuggestion
    .url - String
    .name - String
  .table
    .headers - String[]
    .rows - Row[]
      .cells - String[]
      .divider - Boolean

Known Issues

  • Testing transactions does not work
  • Testing smart home fulfillment does not work
  • Unable to set surface capabilities
  • Selecting an item for a ListSelect and CarouselSelect do not work

License

See LICENSE