diff --git a/packages/validations/features/json.feature b/packages/validations/features/json.feature index 013d997..2fe71b9 100644 --- a/packages/validations/features/json.feature +++ b/packages/validations/features/json.feature @@ -320,3 +320,14 @@ Feature: Validations: JSON manipulation Then "${myJSON[0].mno.convertToString}" is equal to "123" And "${myJSON[1].mno.convertToString}" is equal to "456" + Scenario: JSON Apply Example + Given set "body" to: + """ + { + "alpha": "string", + "beta": "1234567" + } + """ + And "1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111115467" is applied to item "body" on JSON path "$.beta" + Then "${body.alpha}" is equal to "string" + And "${body.beta}" is equal to "1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111115467" \ No newline at end of file diff --git a/packages/validations/index.js b/packages/validations/index.js index a3a4582..12124fd 100644 --- a/packages/validations/index.js +++ b/packages/validations/index.js @@ -280,7 +280,9 @@ When('{string} is applied to item {string} on JSON path {string}', function (val if (value.trim() !== '') { try { const tmp = JSON.parse(value) - value = tmp + if (typeof tmp === 'object') { + value = tmp + } } catch (e) { } } jp.apply(fileContents, jsonPath, function () { return value }) diff --git a/packages/validations/package.json b/packages/validations/package.json index 9563c30..c64a217 100644 --- a/packages/validations/package.json +++ b/packages/validations/package.json @@ -3,7 +3,7 @@ "publishConfig": { "access": "public" }, - "version": "2.0.5", + "version": "2.0.6", "description": "", "main": "index.js", "scripts": {