Skip to content

Commit

Permalink
feat(scenario): add options to runScenario fn
Browse files Browse the repository at this point in the history
  • Loading branch information
jost-s committed May 31, 2022
1 parent 192a22c commit 9a5aef8
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 9 deletions.
1 change: 1 addition & 0 deletions docs/tryorama.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ TryCP stands for Tryorama Control Protocol (TryCP) and is a protocol to enable r
| [RequestSaveDna](./tryorama.requestsavedna.md) | Request to save a DNA to the server's file system. |
| [RequestShutdown](./tryorama.requestshutdown.md) | Request shutdown of a conductor. |
| [RequestStartup](./tryorama.requeststartup.md) | Request startup of a conductor. |
| [ScenarioOptions](./tryorama.scenariooptions.md) | Options when creating a scenario. |
| [TryCpConductorOptions](./tryorama.trycpconductoroptions.md) | |
| [TryCpPlayer](./tryorama.trycpplayer.md) | A player tied to a [TryCpConductor](./tryorama.trycpconductor.md)<!-- -->. |

Expand Down
2 changes: 1 addition & 1 deletion docs/tryorama.runscenario.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ A wrapper function to create and run a scenario. A scenario is created and all i
<b>Signature:</b>

```typescript
runScenario: (testScenario: (scenario: Scenario) => Promise<void>, cleanUp?: boolean) => Promise<void>
runScenario: (testScenario: (scenario: Scenario) => Promise<void>, cleanUp?: boolean, options?: ScenarioOptions) => Promise<void>
```
6 changes: 2 additions & 4 deletions docs/tryorama.scenario._constructor_.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,12 @@ Scenario constructor.
<b>Signature:</b>

```typescript
constructor(options?: {
timeout?: number;
});
constructor(options?: ScenarioOptions);
```

## Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| options | { timeout?: number; } | <i>(Optional)</i> Timeout for requests to Admin and App API calls. |
| options | [ScenarioOptions](./tryorama.scenariooptions.md) | <i>(Optional)</i> Timeout for requests to Admin and App API calls. |

20 changes: 20 additions & 0 deletions docs/tryorama.scenariooptions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [@holochain/tryorama](./tryorama.md) &gt; [ScenarioOptions](./tryorama.scenariooptions.md)

## ScenarioOptions interface

Options when creating a scenario.

<b>Signature:</b>

```typescript
export interface ScenarioOptions
```

## Properties

| Property | Type | Description |
| --- | --- | --- |
| [timeout?](./tryorama.scenariooptions.timeout.md) | number | <i>(Optional)</i> |

11 changes: 11 additions & 0 deletions docs/tryorama.scenariooptions.timeout.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [@holochain/tryorama](./tryorama.md) &gt; [ScenarioOptions](./tryorama.scenariooptions.md) &gt; [timeout](./tryorama.scenariooptions.timeout.md)

## ScenarioOptions.timeout property

<b>Signature:</b>

```typescript
timeout?: number;
```
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@holochain/tryorama",
"description": "Toolset to manage Holochain conductors and facilitate running test scenarios",
"version": "0.5.1",
"version": "0.5.2",
"author": "Holochain Foundation",
"keywords": [
"holochain",
Expand Down
17 changes: 14 additions & 3 deletions ts/src/local/scenario.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,16 @@ export interface Player extends IPlayer {
conductor: Conductor;
}

/**
* Options when creating a scenario.
*
* @public
*/
export interface ScenarioOptions {
// Timeout for requests to Admin and App API calls.
timeout?: number;
}

/**
* An abstraction of a test scenario to write tests against Holochain hApps,
* running on a local conductor.
Expand All @@ -34,7 +44,7 @@ export class Scenario implements IScenario {
*
* @param options - Timeout for requests to Admin and App API calls.
*/
constructor(options?: { timeout?: number }) {
constructor(options?: ScenarioOptions) {
this.timeout = options?.timeout;
this.uid = uuidv4();
this.conductors = [];
Expand Down Expand Up @@ -180,9 +190,10 @@ export class Scenario implements IScenario {
*/
export const runScenario = async (
testScenario: (scenario: Scenario) => Promise<void>,
cleanUp = true
cleanUp = true,
options?: ScenarioOptions
) => {
const scenario = new Scenario();
const scenario = new Scenario(options);
try {
await testScenario(scenario);
} finally {
Expand Down

0 comments on commit 9a5aef8

Please sign in to comment.