Skip to content

Commit

Permalink
fix(runner): update and add examples (#238)
Browse files Browse the repository at this point in the history
* doc: example csv use for collection runner

* fix: incorrect after-response script example

* fix: add an example for iterationData

---------

Co-authored-by: Filipe Freire <[email protected]>
  • Loading branch information
ihexxa and filfreire authored Oct 22, 2024
1 parent b986734 commit 7e094b2
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion docs/insomnia/after-response-script.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ For tests and assertions you can use `insomnia.test` and `insomnia.expect` funct

```js
insomnia.test('Check if status is 200', () => {
insomnia.expect(insomnia.response.status).to.eql(200);
insomnia.expect(insomnia.response.code).to.eql(200);
});
```

Expand Down
14 changes: 14 additions & 0 deletions docs/insomnia/collection-runner.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ And when running the collection runner they will be replaced in place.
![example collection run variables results](/assets/images/example-result-collection-runner-variables.png)

{:.alert .alert-primary}

**Note**: It is also allowed to reference values from CSV or JSON in the same manner as referencing [environment variables](/insomnia/environment-variables/). And variables from data files will take precedence over [environment variables](/insomnia/environment-variables/).


Expand All @@ -58,6 +59,19 @@ JSON also works with runner, this is an example:
]
```

#### Accessing CSV or JSON data from Scripts

It is allowed to access values from custom CSV or JSON file. For each row, you can access values through `insomnia.iterationData`.

For example, if the above JSON file has been uploaded, you can access `id` and `deviceName` in this way:

```javascript
const id = insomnia.iterationData.get('id');
const deviceName = insomnia.iterationData.get('deviceName');
```

And most of methods of `insomnia.environment` also work for `insomnia.iterationData`.

## Test Results in the Collection Tab

With the Collection Runner, we have also introduced a new **Test Results** section.
Expand Down

0 comments on commit 7e094b2

Please sign in to comment.