@apideck/postman-to-k6
Advanced tools
Comparing version
@@ -10,2 +10,7 @@ # Changelog | ||
## [1.10.0] - 2024-06-13 | ||
- Bump minimal Node version to 18.x | ||
- Code refactoring with optional chaining to provide JS safe code | ||
## [1.9.0] - 2024-04-01 | ||
@@ -12,0 +17,0 @@ |
@@ -10,5 +10,5 @@ const aid = require('../aid'); | ||
if (params.get('in') === 'header') { | ||
this.logic = '' + `config.headers['${key}'] = ${value};`; | ||
this.logic = `config.headers['${key}'] = ${value};`; | ||
} else { | ||
this.logic = '' + `config.options['${key}'] = ${value};`; | ||
this.logic = `config.options['${key}'] = ${value};`; | ||
} | ||
@@ -15,0 +15,0 @@ } |
@@ -9,5 +9,3 @@ const aid = require('../aid'); | ||
this.imports = new Map().set('URI', './libs/urijs.js'); | ||
this.logic = | ||
'' + | ||
`const address = new URI(config.address); | ||
this.logic = `const address = new URI(config.address); | ||
address.username(${username}); | ||
@@ -14,0 +12,0 @@ address.password(${password}); |
@@ -8,3 +8,3 @@ const aid = require('../aid'); | ||
const value = aid.evalString(`Bearer ${token}`); | ||
this.logic = '' + `config.headers.Authorization = ${value};`; | ||
this.logic = `config.headers.Authorization = ${value};`; | ||
} | ||
@@ -11,0 +11,0 @@ } |
@@ -9,5 +9,3 @@ const aid = require('../aid'); | ||
this.imports = new Map().set('URI', './libs/urijs.js'); | ||
this.logic = | ||
'' + | ||
`const address = new URI(config.address); | ||
this.logic = `const address = new URI(config.address); | ||
address.username(${username}); | ||
@@ -14,0 +12,0 @@ address.password(${password}); |
@@ -9,5 +9,3 @@ const aid = require('../aid'); | ||
this.imports = new Map().set('URI', './libs/urijs.js'); | ||
this.logic = | ||
'' + | ||
`const address = new URI(config.address); | ||
this.logic = `const address = new URI(config.address); | ||
address.username(${username}); | ||
@@ -14,0 +12,0 @@ address.password(${password}); |
@@ -7,7 +7,3 @@ function detectFeature(logic, result) { | ||
let cheerioPath = './libs/shim/cheerio.js'; | ||
if ( | ||
result.setting && | ||
result.setting.separate && | ||
result.setting.separate === true | ||
) { | ||
if (result?.setting?.separate === true) { | ||
// Request is in a Postman folder | ||
@@ -26,7 +22,3 @@ const pathDepth = renderDirectoryPathGroup(result.group); | ||
let cryptoPath = './libs/shim/crypto-js.js'; | ||
if ( | ||
result.setting && | ||
result.setting.separate && | ||
result.setting.separate === true | ||
) { | ||
if (result?.setting?.separate === true) { | ||
// Request is in a Postman folder | ||
@@ -41,7 +33,3 @@ const pathDepth = renderDirectoryPathGroup(result.group); | ||
let lodashPath = './libs/shim/lodash.js'; | ||
if ( | ||
result.setting && | ||
result.setting.separate && | ||
result.setting.separate === true | ||
) { | ||
if (result?.setting?.separate === true) { | ||
// Request is in a Postman folder | ||
@@ -56,7 +44,3 @@ const pathDepth = renderDirectoryPathGroup(result.group); | ||
let expectPath = './libs/shim/expect.js'; | ||
if ( | ||
result.setting && | ||
result.setting.separate && | ||
result.setting.separate === true | ||
) { | ||
if (result?.setting?.separate === true) { | ||
// Request is in a Postman folder | ||
@@ -71,7 +55,3 @@ const pathDepth = renderDirectoryPathGroup(result.group); | ||
let jsonSchemaPath = './libs/shim/jsonSchema.js'; | ||
if ( | ||
result.setting && | ||
result.setting.separate && | ||
result.setting.separate === true | ||
) { | ||
if (result?.setting?.separate === true) { | ||
// Request is in a Postman folder | ||
@@ -86,7 +66,3 @@ const pathDepth = renderDirectoryPathGroup(result.group); | ||
let xml2JsonPath = './libs/shim/xml2Json.js'; | ||
if ( | ||
result.setting && | ||
result.setting.separate && | ||
result.setting.separate === true | ||
) { | ||
if (result?.setting?.separate === true) { | ||
// Request is in a Postman folder | ||
@@ -103,3 +79,3 @@ const pathDepth = renderDirectoryPathGroup(result.group); | ||
function renderDirectoryPathGroup(group) { | ||
let depthLevel = group && group.level ? group.level + 1 : 1; // +1 starting in the "requests folder | ||
let depthLevel = group?.level ? group.level + 1 : 1; // +1 starting in the "requests folder | ||
return `../`.repeat(depthLevel); | ||
@@ -106,0 +82,0 @@ } |
@@ -12,7 +12,7 @@ const aid = require('../aid'); | ||
for (const event of posts) { | ||
if (event.disabled) { | ||
if (event?.disabled) { | ||
continue; | ||
} | ||
const exec = event.script.exec; | ||
if (exec.disabled) { | ||
const exec = event.script?.exec; | ||
if (exec?.disabled) { | ||
continue; | ||
@@ -34,5 +34,5 @@ } | ||
function shouldIncludePost(result) { | ||
return !result.setting.skip || !result.setting.skip.post; | ||
return !result.setting?.skip?.post; | ||
} | ||
module.exports = readPost; |
@@ -12,14 +12,16 @@ const aid = require('../aid'); | ||
for (const event of pres) { | ||
if (event.disabled) { | ||
if (event?.disabled) { | ||
continue; | ||
} | ||
const exec = event.script.exec; | ||
if (exec.disabled) { | ||
continue; | ||
const exec = event?.script?.exec; | ||
if (Array.isArray(exec)) { | ||
if (exec?.disabled) { | ||
continue; | ||
} | ||
const logic = exec.join('\n').trim(); | ||
if (!logic) { | ||
continue; | ||
} | ||
sections.push(logic); | ||
} | ||
const logic = exec.join('\n').trim(); | ||
if (!logic) { | ||
continue; | ||
} | ||
sections.push(logic); | ||
} | ||
@@ -34,5 +36,5 @@ } | ||
function shouldIncludePre(result) { | ||
return !result.setting.skip || !result.setting.skip.pre; | ||
return !result?.setting?.skip?.pre; | ||
} | ||
module.exports = readPre; |
{ | ||
"name": "@apideck/postman-to-k6", | ||
"version": "1.9.0", | ||
"version": "1.10.0", | ||
"description": "Convert a Postman collection to k6 JavaScript", | ||
@@ -49,2 +49,3 @@ "keywords": [ | ||
"test-unit": "cross-env NODE_PATH=lib:test ava test/unit/**/*.js", | ||
"test-jest": "jest --colors --verbose --reporters=default --collectCoverage --no-cache", | ||
"prepare": "husky install", | ||
@@ -84,4 +85,5 @@ "release": "yarn format && yarn lint && yarn bundle && np --branch main" | ||
"ava": "^2.4.0", | ||
"cross-env": "^6.0.3", | ||
"cross-env": "^7.0.3", | ||
"husky": "^7.0.4", | ||
"jest": "^29.7.0", | ||
"mock-require": "^3.0.3", | ||
@@ -95,3 +97,3 @@ "np": "^7.6.2", | ||
"engines": { | ||
"node": ">= 0.10.0" | ||
"node": ">=18" | ||
}, | ||
@@ -98,0 +100,0 @@ "preferGlobal": true, |
1466658
-0.01%14
7.69%9711
-0.29%