Convert Postman Script
- Below is a comprehensive guide for converting Postman scripts to Thunder Client scripts.
- You can find the complete Thunder Client Scripting API here.
Global Variables
The following global variables available in the scripting.
| Postman Variable | Thunder Client Variable |
|---|---|
| pm | tc |
| pm.expect | expect |
| pm.assert | assert |
| btoa | btoa |
| atob | atob |
Built in Libraries
The following built-in libraries are available in the scripting
| Postman Library | Thunder Client Library |
|---|---|
| ajv | ajv |
| --- | ajv-formats |
| --- | axios |
| atob | atob |
| btoa | btoa |
| buffer | buffer |
| chai | chai |
| cheerio | tc.loadModule('cheerio') |
| crypto-js | crypto-js |
| csv-parse/lib/sync (opens in a new tab) | papaparse or use tc.loadModule('csv-parse') |
| --- | fs |
| --- | http |
| --- | https |
| lodash | tc.loadModule('lodash') |
| moment | tc.loadModule('moment') |
| stream | stream |
| --- | tough-cookie |
| tv4 | tc.loadModule('tv4') |
| url | url |
| util | util |
| uuid | uuid |
| xml2js | fast-xml-parser |
Request
Request object available properties and methods.
| Postman Property | Thunder Client Property |
|---|---|
| --- | tc.request.id |
| --- | tc.request.name |
| pm.request.url | tc.request.url |
| pm.request.method | tc.request.method |
| pm.request.headers | tc.request.headers |
| pm.request.body | tc.request.body |
| --- | tc.request.getHeader() |
| pm.request.headers.add() | tc.request.setHeader() |
| pm.request.headers.remove() | --- |
| --- | tc.request.setBody() |
Response
Response object available properties and methods.
| Postman Property | Thunder Client Property |
|---|---|
| pm.response.code | tc.response.status |
| pm.response.status | --- |
| pm.response.responseTime | tc.response.time |
| pm.response.responseSize | tc.response.size |
| --- | tc.response.contentType |
| pm.response.json() | tc.response.json |
| pm.response.text() | tc.response.text |
| pm.response.headers | tc.response.headers |
| --- | tc.response.cookies |
| --- | tc.response.getHeader() |
Info
Get the additional information of the current executing request
| Postman Property | Thunder Client Property |
|---|---|
| pm.info.eventName | --- |
| pm.info.iteration | tc.info.currentIteration |
| pm.info.iterationCount | tc.info.totalIterations |
| pm.info.requestId | tc.request.id |
| pm.info.requestName | tc.info.requestName |
| pm.environment.name | tc.info.environmentName |
| --- | tc.info.collectionName |
| --- | tc.info.folderName |
Environments
Please see the available Environment methods between Postman and Thunder Client.
| Postman Methods | Thunder Client Methods |
|---|---|
| pm.variables.get() | tc.getVar() |
| pm.variables.set() | tc.setVar() |
| pm.variables.replaceIn() | tc.replaceVars() |
| pm.collectionVariables.get() | tc.getVar() |
| pm.collectionVariables.set() | tc.setVar() |
| pm.environment.get() | tc.getVar() |
| pm.environment.set() | tc.setVar() |
| pm.globals.get() | tc.getVar() |
| pm.globals.set() | tc.setVar() |
| pm.iterationData.get() | tc.getVar() |
Methods
Please see the available methods between Postman and Thunder Client.
| Postman Methods | Thunder Client Methods |
|---|---|
| pm.cookies.has() | --- |
| pm.cookies.get() | tc.getCookies() |
| pm.cookies.jar().set() | tc.setCookie() |
| pm.cookies.jar().getAll() | tc.getCookies() |
| pm.cookies.jar().unset() | tc.clearCookies() |
| pm.cookies.jar().clear() | tc.clearCookies() |
| pm.sendRequest() | axios or tc.runRequest() |
| pm.execution.skipRequest() | tc.skipRequest() |
| postman.setNextRequest() | try using tc.skipRequest() |
| pm.visualizer.set() | tc.chartView() |
| pm.test() | tc.test() |
| pm.expect() | expect() |
Feedback
- If you have feedback or need additional features, please contact us on our Github (opens in a new tab) page.