# alexa-skill-tester

> Unit testing framework for Amazon Alexa skills

Latest version **1.1.2** (published 2016-12-07) · MIT license · 0 weekly downloads

## Install

```sh
npm install alexa-skill-tester
pnpm add alexa-skill-tester
yarn add alexa-skill-tester
bun add alexa-skill-tester
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.2 |
| Published | 2016-12-07 |
| First published | 2016-12-01 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 4 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 5 |
| Author | Phillip Markert |
| Maintainers | pmarkert |
| Keywords | alexa, unit test, unit-test, unit-testing, unit testing, lambda, skill, alexa skill, alexa skill testing |

## Links

- npm: https://www.npmjs.com/package/alexa-skill-tester
- Repository: https://github.com/pmarkert/alexa-skill-tester
- Homepage: https://github.com/pmarkert/alexa-skill-tester#readme
- Issues: https://github.com/pmarkert/alexa-skill-tester/issues
- npm.io page: https://npm.io/package/alexa-skill-tester

## Dependencies (4)

- [chai](https://npm.io/package/chai.md) ^3.5.0
- [async](https://npm.io/package/async.md) ^2.1.4
- [mocha](https://npm.io/package/mocha.md) ^3.2.0
- [aws-lambda-mock-context](https://npm.io/package/aws-lambda-mock-context.md) ^3.0.1

## Alternatives

- [duck](https://npm.io/package/duck.md) — 4.2M weekly downloads
- [ava](https://npm.io/package/ava.md) — 560.2K weekly downloads
- [storybook-addon-module-mock](https://npm.io/package/storybook-addon-module-mock.md) — 71.7K weekly downloads
- [vest](https://npm.io/package/vest.md) — 50.1K weekly downloads
- [@ethereum-waffle/mock-contract](https://npm.io/package/@ethereum-waffle/mock-contract.md) — 40.0K weekly downloads

## Recent versions

- 1.1.2 (latest) — 2016-12-07
- 1.1.1 — 2016-12-06
- 1.1.0 — 2016-12-01
- 1.0.1 — 2016-12-01
- 1.0.0 — 2016-12-01

## README

# alexa-skill-tester
Unit testing framework for testing requests/responses for Amazon Alexa skills

The Alexa Skill Tester is a nice way to perform unit testing for Amazon Alexa skills that run in AWS lambda. 

This framework uses a data-driven approach. You create sample *.json files to represent the requests that should be sumitted to the skill.handler under test. The tester loads the request file, invokes the skill handler, and then compares the response to the contents of a matching *.response.json file.

To use the skill-tester follow these steps:
1. Install mocha (a popular unit-testing framework) and alexa-skill-tester as devDependencies.
    `npm install -D mocha alexa-skill-tester`
2. Create a ./test directory with a bootstrap module in it
    ```javascript
    var ast = require("alexa-skill-tester");
    var path = require("path");
    var module_under_test = require("../index");

    describe("Event tests", function(done) {
        ast(module_under_test.handler, path.resolve(__dirname, "./events"), done);
    });
    ````
3. Create a "./events" directory underneath the test directory.
4. Place requests .json files in the ./tests/events folder.
5. From the top-level directory of the project execute mocha
    ```
    $ node_modules/.bin/mocha
    ```

At this point, you should see errors telling you that no response files were available. You can either create the response file manually and save it as *.response.json or you can instruct alexa-skill-tester to auto-save the responses for you.

```
$ SAVE_RESPONSES=true node_modules/.bin/mocha
```

You will still get warnings the first time, however, the process wil save the response into the right location so that when you run the tests again, they should all pass.

The alexa-skill-tester will sets a global variable `global.TEST_MODE=true` when it runs your tests so that your application can choose to mock out other dependencies as necessary.

## Tips
I like to setup a sub-directory for each state supported by the Alexa skill I'm testing so that I can separate the events into those sub-directories.

---
_Source: https://npm.io/package/alexa-skill-tester · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
