Karate Embedded Expression not being considered when data is loaded form csv

Viewed 113

In the mentioned scenario I am using embedded expression based on expression empty values are ignored while constructing the request payload. (Note: Not arrays and JSONs) But when I do the same using .csv file data is not being consumed for constructing request payload.

I have posted all the details in the below link .

https://gist.github.com/Avinash9969/31c7709ba1344410ce098620dcbc06f0

Please suggest

1 Answers

The CSV option will not automatically convert blanks to null, they will be empty strings. You will need to do a transformation step for the ##() markers to work:

Background:
* def emptyToNull = function(x){ karate.forEach(x, function(k, v){ if (v == '') x[k] = null }); return x }

Scenario Outline:
* def row = emptyToNull(__row)
# now use row.col as embedded expressions

Examples:
| read('data.csv') |
Related