

HAR to POSTMAN
source link: https://github.com/javieraviles/har2postman
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Har2Postman
Javascript Har to Postman converter. Try it out
Purpose
The main goal of the project is the creation of a JS library to convert .har
files to Postman requests/collection in .JSON
format.
HTTP Archive format
or HAR
files are a JSON-formatted archive file format for logging of a web browser's interaction with a site (HTTP transactions).
On the other hand Postman
is a testing API client tool, allowing us to test a request against a specific environment.
The intended audience is, therefore, anybody who finds a use case where this library is useful in any way.
Getting Started
Install package
npm install har2postman
Example
var Har2Postman = require('har2postman'); var includeTests = true; harToPostman.createPostmanCollection(stringifiedHarFile, includeTests);
Options
-
includeTests
: defaultfalse
, set totrue
for including test assertions in requests
Authors
- Rafael Paez - rafapaezbas
- Javier Aviles - javieraviles
Roadmap
Please note every version should include a suite of test cases ensuring new requirements are working. The last test case of the suite should check the library produces a JSON
output matching the content of the file /test/x.x.x/output.json
given a JSON
input matching the content of the file /test/x.x.x/input.json
.
v0.1.0 - Convert simplest GET request from HAR to Postman
- Create a first basic JS
createPostmanCollection
function able to produce a valid postman collection including the expectedfile
(postman metadata) anditem
(request itself) objects out of ahar
file. - Create a CI pipeline, executing jasmine tests on every push and updating the
Har2Postman
in npm if new tag is released.
v0.2.0 - Create simple postman test for a GET request
- The output file should also include basic test assertions in GET requests for postman based on the response section from
har
file (response code, maybe id if path param?). - The
createPostmanCollection
function should include a second optionalboolean
argument to decide whether the output should include the test section or not. By default, the behaviour of the boolean flag should befalse
. - Include basic usage example for the lib in docs.
v0.3.0 - GET request might include query params
query params
v0.4.0 - Support multiple requests within one har file
har
v0.5.0 - POST, PUT and DELETE methods should also be supported
Content-Type
v0.6.0 - Any status code must be supported
- Status code such as 200, 204, 400, 401, 403 or 404 must have specific assertions.
- Non-json responses should even not tried to be analysed.
v0.7.0 - Relevant headers should be included
- Include relevant headers for each request, only the necessary ones.
- Make library compatible for Browser.
- Demo page automatically getting lib from cdn.
v0.7.5 - Add cli execution
- Include the option for converting a har file into a collection from the command line.
Future features still to be planned
xml id
var generateItem = function(){ var item = [{ name: generateItemName(harRequest.method, harRequestUrl.pathname, harResponse.status, generateTest), event: generateItemEvent(harResponse, harRequestUrl), request: { method: harRequest.method, url: { raw: harRequestUrl.toString(), protocol: harRequestUrl.protocol.slice(0, -1), host: harRequestUrl.hostname.split('.'), path: harPathnameArray.slice(1) } } }]; }
The right way for this function would be:
var generateItem = function(){ return [{ name: generateItemName(harRequest.method, harRequestUrl.pathname, harResponse.status, generateTest), event: generateItemEvent(harResponse, harRequestUrl), request: generateRequest(harRequest, harRequestUrl); }]; } var generateRequest = function(){ return { method: harRequest.method, url: generateUrl(harRequestUrl); } } //var generateUrl = function() ...
Also importanthave a look at the functions returning arrays instead of objects, this will have to change in the future if those arrays need more than one element.
License
This project is licensed under the MIT License - see the LICENSE file for details
Recommend
-
101
-
56
Postman is a very powerful tool to have while developing REST APIs. Postman lets you very easily run the HTTP verbs GET, POST, PUT and DELETE to your API.
-
30
-
51
前言 之前的一篇文章《你应该学会的Postman用法》,主要介绍了postman的一些高级的用法,便于日常开发和调试使用,本文的基础是对postman的基本使用以及一些高级用法有一定的了解,如对此不太了解的同学,建议移步:《你应该学会的Postman用法》了解
-
42
Just over a year ago I was emphatically singing the praises of Postman . Before that, I’d been using Fiddle...
-
44
最近公司要引入API测试工具,经过调查和了解,最终决定在SoupUI 和 Postman两种工具之间做一个选择,两种工具在业界都很有名,相信很多人两种工具也都曾使用过。下面我们对这两个工具通过多种维度
-
15
Nu har även jag blivit med en blog May 25, 2011 Jag har varit rätt sugen på att starta en blog. Inte för att jag har så mycket att skriva om för det mesta, men ibland vill jag dela med mig av lite datanördigheter jag hå...
-
6
Mbappés drag chockerade – har han bränt sista bron alicesandra posted @ 2022年8月05日 17:59 in
-
5
England har tagit EM-guld i fotboll för första gången alicesandra posted @ 2022年8月12日 23:10 in
-
8
Introducing HAR Sanitizer: secure HAR sharing 10/26/2023 5 min read
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK