Skip to content

Commit

Permalink
Merge pull request #39 from pactumjs/fix-empty-api-pages
Browse files Browse the repository at this point in the history
Fix empty api pages
  • Loading branch information
leelaprasadv authored Sep 13, 2023
2 parents f80912e + 6d169ca commit 8bbcb7d
Show file tree
Hide file tree
Showing 5 changed files with 209 additions and 5 deletions.
2 changes: 1 addition & 1 deletion docs/api/assertions/expectJsonSnapshot.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Snapshot testing is a type of **output comparison** which will be very useful wh

A typical snapshot test in pactum will fetch the api response, then compares it to a reference snapshot file stored alongside the test. The test will fail if the two snapshots do not match: either the change is unexpected, or the reference snapshot needs to be updated to the new version of the API response.

If you are running the test for the first time, pactum will save the api response body at `./pactum/snapshots` directory. For the next test runs, pactum will compare the actual response with the local reference file.
If you are running the test for the first time, pactum will save the api response body at `.pactum/snapshots` directory. For the next test runs, pactum will compare the actual response with the local reference file.

> A snapshot needs a unique name & it can be defined through `spec().name("<unique name>")` or `expectJsonSnapshot("<name>")`.
Expand Down
45 changes: 44 additions & 1 deletion docs/api/settings/setReporterAutoRun.md
Original file line number Diff line number Diff line change
@@ -1 +1,44 @@
# setReporterAutoRun
---
tags:
- reporter autorun
- reporter
---
# setReporterAutoRun

sets reporter auto run option. Allows to disable reporter run after spec toss.

> Defaults to `true`
## Syntax

```js
setReporterAutoRun(boolean)
```

## Usage

### ✅ Correct Usage

```js
settings.setReporterAutoRun(false)
```

## Arguments

#### > option (boolean)

Reporter auto run toggle.

## Examples

### Normal

```js
const { spec, request } = require('pactum');

settings.setReporterAutoRun(false);

await spec()
.get('/api/users/1')
.expectStatus(200);
```
51 changes: 50 additions & 1 deletion docs/api/settings/setRequestDefaultRetryCount.md
Original file line number Diff line number Diff line change
@@ -1 +1,50 @@
# setRequestDefaultRetryCount
---
tags:
- retry count
- request retry count
---

# setRequestDefaultRetryCount

sets default retry count for requests.

> Defaults to retry count 1
## Syntax

```js
setRequestDefaultRetryCount(count)
```

## Usage

### ✅ Correct Usage

```js
settings.setRequestDefaultRetryCount(2)
```

## Arguments

#### > count (number)

retry count.

## Examples

### Normal

```js
const { spec, settings } = require('pactum');

settings.setRequestDefaultRetryCount(2);

await spec()
.get('https://randomuser.me/api')
.expectStatus(200);
```

## See Also

- [retry](/api/requests/retry)
- [setRequestDefaultRetryDelay](/api/settings/setRequestDefaultRetryDelay)
65 changes: 64 additions & 1 deletion docs/api/settings/setRequestDefaultRetryDelay.md
Original file line number Diff line number Diff line change
@@ -1 +1,64 @@
# setRequestDefaultRetryDelay
---
tags:
- retry delay
- request retry delay
---

# setRequestDefaultRetryDelay

sets default retry delay for requests with retry enabled.

> Defaults to 1000 milliseconds
## Syntax

```js
setRequestDefaultRetryDelay(milliseconds)
```

## Usage

### ✅ Correct Usage

```js
settings.setRequestDefaultRetryDelay(3000)
```

## Arguments

#### > milliseconds (number)

delay in milliseconds.

## Examples

### Normal

```js
const { spec, settings } = require('pactum');

settings.setRequestDefaultRetryCount(2);
settings.setRequestDefaultRetryDelay(2000);

await spec()
.get('https://randomuser.me/api')
.expectStatus(200);
```


With retry
```js
const { spec, settings } = require('pactum');

settings.setRequestDefaultRetryDelay(2000);

await spec()
.get('https://randomuser.me/api')
.retry(2)
.expectStatus(200);
```

## See Also

- [retry](/api/requests/retry)
- [setRequestDefaultRetryCount](/api/settings/setRequestDefaultRetryCount)
51 changes: 50 additions & 1 deletion docs/api/settings/setSnapshotDirectoryPath.md
Original file line number Diff line number Diff line change
@@ -1 +1,50 @@
# setSnapshotDirectoryPath
---
tags:
- snapshot directory path
- snapshot
---
# setSnapshotDirectoryPath

sets snapshots directory path.

> Defaults to `.pactum/snapshots` path
## Syntax

```js
setSnapshotDirectoryPath(path)
```

## Usage

### ✅ Correct Usage

```js
settings.setSnapshotDirectoryPath('new/path')
```

## Arguments

#### > path (string)

Snapshot directory path url.

## Examples

### Normal

```js
const { spec, request } = require('pactum');

settings.setSnapshotDirectoryPath('new/path');

await spec()
.name('snapshot directory test')
.get('/api/users/1')
.expectStatus(200)
.expectJsonSnapshot();
```

## See Also

- [expectJsonSnapshot](/api/assertions/expectJsonSnapshot)

0 comments on commit 8bbcb7d

Please sign in to comment.