# scenario-generator

> From input recipes generate json file containing HTTP requests and responses

Latest version **1.0.10** (published 2022-09-22) · 0 weekly downloads

## Install

```sh
npm install scenario-generator
pnpm add scenario-generator
yarn add scenario-generator
bun add scenario-generator
```

Provides the commands `scenario-flatten`, `scenario-generate`.

## Health

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

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.10 |
| Published | 2022-09-22 |
| First published | 2022-04-20 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | ESM |
| Dependencies | 2 |
| Unpacked size | 34.3 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Knut-Helge Vik |
| Maintainers | intact.software.systems |
| Keywords | test, black-box, generator |

## Links

- npm: https://www.npmjs.com/package/scenario-generator
- Repository: https://github.com/intact-software-systems/scenario-generator
- Homepage: https://github.com/intact-software-systems/scenario-generator#readme
- Issues: https://github.com/intact-software-systems/scenario-generator/issues
- npm.io page: https://npm.io/package/scenario-generator

## Dependencies (2)

- [uuid](https://npm.io/package/uuid.md) ^8.3.2
- [commander](https://npm.io/package/commander.md) ^9.0.0

## 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.0.10 (latest) — 2022-09-22
- 1.0.9 — 2022-05-18
- 1.0.8 — 2022-05-12
- 1.0.7 — 2022-05-03
- 1.0.6 — 2022-04-27
- 1.0.5 — 2022-04-27
- 1.0.4 — 2022-04-26
- 1.0.3 — 2022-04-25
- 1.0.2 — 2022-04-25
- 1.0.1 — 2022-04-22
- 1.0.0 — 2022-04-20

## README

# Generate scenario

The command line tool `scenario-generate` generates a json file with requests to be executed by the
tool `scenario-black-box-execute` or `scenario-execute`

## Nodejs Installation

Requires Nodejs to be installed: https://nodejs.org/en/download/

Make sure the command `npm` is available in terminals (npm = node package manager). More documentation can be found
here https://docs.npmjs.com/

```shell
npm upgrade -g
````

### Install requirements

Clone git repository

```shell
git clone https://github.com/intact-software-systems/scenario-generator.git

cd scenario-generator
```

and from the `scenario-generator` folder execute:

```shell
npm install
npm link
```

### Run the scenario-generate command line tool

Run the example test scenario:

```shell
scenario-generate -c config.json
```

where config can have these properties with examples:

```json
{
  "outputFile": "scenario.json",
  "headerTemplateFile": {
    "HTTP": "./templates/http-header-template.json"
  },
  "replace": {
    "url": "http://localhost:8080"
  },
  "generateForEach": [
    "amount"
  ],
  "numOfScenarios": "2",
  "interactions": [
    {
      "entryName": "createResource",
      "templateFile": "./templates/create-resource-template.json",
      "numOfInteractions": "A positive integer. Default 1",
      "technology": "To match an existing key in template file. Default HTTP.",
      "replace": {
        "branchCondition": "All {branchCondition} in template are replaced with this value",
        "branch": "All {branch} in template are replaced with this value"
      },
      "generateForEach": [
        "uuid"
      ]
    },
    {
      "entryName": "createAnotherResource",
      "templateFile": "./templates/create-another-resource-template.json",
      "replace": {
        "twigs": "All {twigs} in template are replaced with this value"
      },
      "generateForEach": [
        "uuid",
        "date",
        "amount"
      ]
    }
  ]
}
```

Check the terminal for status.

### Template files standard layout

Template file layout

```json
{
  "HTTP": {
    "request": {
      "path": "{url}/api/v1/path/to/resource/{brand}",
      "method": "POST",
      "body": {
        "code": "{sublet}"
      }
    },
    "response": {
      "body": {
      },
      "statusCode": "200"
    }
  }
}
```

### HTTP header template

Can have any key value pairs

```json
{
  "Content-Type": "application/json",
  "Accept": "*/*",
  "x-company-header": "{company}"
}
```

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