You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+79-26Lines changed: 79 additions & 26 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,30 +3,6 @@
3
3
4
4
This project has created to relieve work load as SDET or Automation Test Engineer. In moderation, automation API code able to write with only run the script and generate from Postman collection. You just export the collection, and run the Generator to write the automation code.
5
5
6
-
## Table of Contents
7
-
-[Objectives](#objectives)
8
-
-[Prerequisite](#prerequisite)
9
-
-[Installation](#installation)
10
-
-[Important information](#important-information)
11
-
-[Lifecycle of Mocha Framework](#lifecycle-of-mocha-framework)
12
-
-[Folder Structure and Usage](#folder-structure-and-usage)
13
-
-[/runner](#runner)
14
-
-[/tests/data](#testsdata)
15
-
-[/tests/helper](#testshelper)
16
-
-[/tests/pages](#testspages)
17
-
-[/tests/scenarios](#testsscenarios)
18
-
-[/tests/schema](#testsschema)
19
-
-[Scenarios](#scenarios)
20
-
-[Default templates](#default-templates)
21
-
-[Default templates with body request](#default-templates-with-body-request)
22
-
-[Pages](#pages)
23
-
-[Default templates](#default-templates-1)
24
-
-[Default templates with JSON body](#default-templates-with-json-body)
25
-
-[Default templates with attachment body](#default-templates-with-attachment-body)
26
-
-[Implementation](#implementation)
27
-
-[Best Practices](#best-practices)
28
-
-[Common Error](#common-error)
29
-
30
6
## Objectives
31
7
32
8
1. Generate Postman collection with JSON format into Mocha-Chai template scripts
@@ -35,7 +11,29 @@ This project has created to relieve work load as SDET or Automation Test Enginee
35
11
4. Have default verification for status code and json-schema
36
12
5. Create scripts that easy to maintain
37
13
38
-
14
+
## Table of Contents
15
+
-[Prerequisite](#prerequisite)
16
+
-[Installation](#installation)
17
+
-[Important information](#important-information)
18
+
-[Lifecycle of Mocha Framework](#lifecycle-of-mocha-framework)
19
+
-[Folder Structure and Usage](#folder-structure-and-usage)
20
+
-[/runner](#runner)
21
+
-[/tests/data](#testsdata)
22
+
-[/tests/helper](#testshelper)
23
+
-[/tests/pages](#testspages)
24
+
-[/tests/scenarios](#testsscenarios)
25
+
-[/tests/schema](#testsschema)
26
+
-[Scenarios](#scenarios)
27
+
-[Default templates](#default-templates)
28
+
-[Default templates with body request](#default-templates-with-body-request)
29
+
-[Pages](#pages)
30
+
-[Default templates](#default-templates-1)
31
+
-[Default templates with JSON body](#default-templates-with-json-body)
32
+
-[Default templates with attachment body](#default-templates-with-attachment-body)
33
+
-[If You Need Other Arguments](#if-you-need-other-arguments)
34
+
-[Implementation](#implementation)
35
+
-[Best Practices](#best-practices)
36
+
-[Common Error](#common-error)
39
37
40
38
## Prerequisite
41
39
@@ -608,7 +606,7 @@ module.exports = request
608
606
609
607
From above, the request has body with `username` and `password` keys. The default value of each keys is `example`.
610
608
611
-
> You can define the constant or static value of key body request in this part of code and make changes to test-related data in your tests file.
609
+
> You can define the constant or static value of key body request in this part of code and make changes to test-related data in your scenarios file.
You can define the static of default value of request key in this variable. Also, you can use the relative or absolute path for the value, but it is recommended to use a relative path based on your project root.
760
758
- `objectMapping()` method of `requestHelper()` class will map the key-value defined in `objAtt` variable to the `args` variable of the arguments in `attach()` method.
761
759
760
+
### If You Need Other Arguments
761
+
762
+
In case you need to pass data (except the `datas.ddt` and `(err, ress)` function) from scenario file to page file, you can use the [concept of rest argument](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/rest_parameters) in method/function, which are location sensitive based on the value passed from method usage and method definition.
763
+
764
+
For example, you need to pass below data from scenario file to your request builder in page file:
765
+
- token
766
+
- id
767
+
- query
768
+
- path URL
769
+
- etc, something similar
770
+
771
+
you can use this configuration steps:
772
+
1. Define the value of argument in `request()` method in scenario file.
773
+
774
+
For example the token and id value:
775
+
```js
776
+
new Request().request(token_value, id_value,
777
+
(err, res) => {});
778
+
```
779
+
780
+
1. Map the argument passed in `request()` method from scenario file to your request builder in page file.
781
+
782
+
For above case, you want to map token and id value in your request API. The `request()` method in page file will look like this:
- arguments in first index (`args[0]`) is used to store the token value in scenario file, so you map it to the token value in your API request.
801
+
802
+
Code section:
803
+
```js
804
+
"Bearer " + args[0]
805
+
```
806
+
- arguments in second index (`args[1]`) is used to store the id value for URL path in scenario file, so you map it to the id value in your API request.
807
+
808
+
Code section:
809
+
```js
810
+
this.path + args[1]
811
+
```
812
+
813
+
> You can configure the scenario-related data needs in your scenario files and configure the data mapping in your page file.
0 commit comments