-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: setState setDataDirectory withJson file
- Loading branch information
1 parent
5594ebf
commit d1ad8e0
Showing
6 changed files
with
144 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
--- | ||
tags: | ||
- state | ||
- set state | ||
--- | ||
|
||
# setState | ||
|
||
**State Handlers** helps us to run specific asynchronous code that puts our application in a specific state. We can use these state handlers in our tests to reset/set state before each test case. | ||
|
||
## Syntax | ||
|
||
```js | ||
setState(name, data?); | ||
``` | ||
### ✅ Correct Usage | ||
```js | ||
setState('admin user'); | ||
setState('admin user', { data: 'some data' }); | ||
``` | ||
## Arguments | ||
#### > name *(string)* | ||
Name of the state handler | ||
#### > data *(object)* | ||
Data that will be passed to the state handler | ||
## Examples | ||
### Normal | ||
```js | ||
const { spec, handler } = require('pactum'); | ||
|
||
handler.addStateHandler('fix earth', async (ctx) => { | ||
const { data } = ctx; | ||
// code to add data in database | ||
// or code to reset redis | ||
// or custom code to centering a div | ||
}); | ||
|
||
await spec | ||
.setState('fix earth') | ||
.get('/users') | ||
.expectStatus(200); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
--- | ||
tags: | ||
- data directory path | ||
- data folder path | ||
--- | ||
|
||
# setDataDirectory | ||
|
||
sets data directory path. | ||
|
||
> Defaults to `./data` path | ||
## Syntax | ||
|
||
```js | ||
setDataDirectory(path) | ||
``` | ||
|
||
## Usage | ||
|
||
### ✅ Correct Usage | ||
|
||
```js | ||
settings.setDataDirectory('new/path') | ||
``` | ||
|
||
## Arguments | ||
|
||
#### > path (string) | ||
|
||
Data directory path. | ||
|
||
## Examples | ||
|
||
### Normal | ||
|
||
```js | ||
const { settings } = require('pactum'); | ||
|
||
settings.setDataDirectory('new/path'); | ||
``` | ||
|
||
## See Also | ||
|
||
- [withJson](/api/requests/withJson) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters