Skip to content

Commit 40a6f2b

Browse files
committed
Minor code and documentation updates.
1 parent c35ae2d commit 40a6f2b

File tree

2 files changed

+7
-15
lines changed

2 files changed

+7
-15
lines changed

README.md

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,17 @@ The `utils` functions are logically grouped in nested classes (namespaces) and i
2525

2626
* [**Folder level functions**](#folder-level-functions) for setting up tests
2727
* [**Primary test functions**](#primary-test-functions) for testing request results
28-
* [**Data validation function**s](#data-validation-functions) for checking data returned from requests
28+
* [**Data validation functions**](#data-validation-functions) for checking data returned from requests
2929
* [**Trace functions**](#trace-functions) for trace logging
3030
* [**General purpose functions**](#general-purpose-functions) for miscellaneour operations
3131

3232
## Folder level functions
3333
Before we get to the overview of the folder level functions, let's summarize how folder scripts work. Folder scripts can be defined for pre-requests and post-requests. For each request in the test collection being executed, Postman first runs pre-request scripts defined in all request parent folders starting from the top level folder. Then Postman runs request's pre-request script, executes the request, and runs all post-request scripts defined in the parent folder just as it did with folder pre-requests. Finally, it runs request tests. And it is worth repeating: this logic gets executed for every request in the test collection. You may not need to run any scripts for any or all folders, which is fine: you simple do not add any code to them; but when you do, you may need to run the code once per test collection execution or for every request in the collection.
3434

35-
Use folder level functions to run test or pre-request code attached to test collection folders (but not request scripts).
35+
Use folder level functions to run test or pre-request code attached to test collection folders (but not request scripts).
3636

3737
Folder level functions are grouped under the `utils.run` namespace and include:
38+
3839
* [utils.run.once](#utilsrunonce):
3940
Invokes code in the specified custom inline function once per test collection run.
4041
* [utils.run.always](#utilsrunalways):
@@ -45,10 +46,8 @@ The following parameters are common to all folder level functions:
4546

4647
* `name`:
4748
Unique name of the folder in the test collection. Because Postman API does not provide a way to determine the current folder, pass a unique name of the folder when calling these functions (the name may need to be unique in the collection) via the `name` parameter.
48-
4949
* `process`:
5050
Inline function containing the code to be executed once or always.
51-
5251
* `onerror`:
5352
Optional function containing code to be executed on error in the `process` function.
5453

@@ -105,10 +104,8 @@ The following parameters are common to all primary test functions:
105104

106105
* `name`:
107106
All primary test functions require the `name` parameter to hold the unique name of the request (or test). In most cases, instead of hard coding request (or test name), pass the `null` value and the functions will set the name to the global `pm.info.requestName` property holding the name of the request. You should only specify an explicitly defined name if you run multiple tests for a single request, so that you can differentiate between them in the test logs.
108-
109107
* `process`:
110108
Inline function containing the code to be executed (this function is optional for `utils.test.positive` and `utils.test.negative` functions because they already provide the minimal test functionality that may be sufficient for certain cases).
111-
112109
* `onerror`:
113110
The optional error handler that can be handy if you need to implement special logic (like stopping test execution or skipping to a specific test) on operation failure in the default or custom `process` function.
114111

@@ -179,11 +176,9 @@ utils.test.negative(pm, name, status, serviceCode, process, onerror)
179176
#### Parameters
180177
* `status`:
181178
Expected HTTP status code returned in HTTP response (default value: `400`; it is recommended to explicitly set the expected value).
182-
183179
* `serviceCode`:
184180
Optional string value of the property holding error code returned by the HTTP response. By default, the name of the property is expected to be `serviceCode`. To check a different property, add the name followed by the colon(`:`) or equal (`=`) character before the expected value, such as `'errorCode=IllegalOperation'`.
185181

186-
187182
#### Examples
188183
A negative test that only checks for the default `400 Bad Request` HTTP status code passed in the HTTP response.
189184
```JavaScript
@@ -483,6 +478,7 @@ Expects the named object property to end with the specified string value.
483478
Expects the named object property to match the specified regular expression.
484479

485480
### Parameters
481+
486482
* `data`:
487483
Data object which string property is being checked.
488484
* `name`:
@@ -605,16 +601,12 @@ To set the trace level (which will be stored in an environment variable for the
605601

606602
* `utils.trace.set.none(pm)`:
607603
Sets trace level to `0`.
608-
609604
* `utils.trace.set.minimal(pm)`:
610605
Sets trace level to `1`.
611-
612606
* `utils.trace.set.default`:
613607
Same as `utils.trace.set.all(pm)`.
614-
615608
* `utils.trace.set.all(pm)`:
616609
Sets trace level to `2`.
617-
618610
* `utils.trace.set.custom(pm, level)`:
619611
Use this to set any custom trace level (parameter `level` is expected to hold a positive integer value).
620612

utils.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@
101101

102102
utils = {
103103
// Version of this library.
104-
version: "1.0.0",
104+
version: "1.0.1",
105105

106106
// Default name of the problem details object property returning
107107
// application specific error code.
@@ -911,7 +911,7 @@ utils = {
911911
// Variable used for setting and checking trace level.
912912
variableName: "TRACE_LEVEL",
913913

914-
// Defualt trace level (start and end of functions).
914+
// Default trace level (start and end of functions).
915915
defaultLevel: 2,
916916

917917
// DESCRIPTION
@@ -972,7 +972,7 @@ utils = {
972972
}
973973

974974
if (traceLevel >= level) {
975-
console.info(message);
975+
console.log(message);
976976
}
977977
}
978978
// End of 'utils.trace' functions.

0 commit comments

Comments
 (0)