Consider you have a feature file containing a dataTable of field/value pairs:
If you want to read the table values out by keying on name, and description, there are a number of ways to achieve this, but one way is to transpose the dataTable:
Can create role:
Given I login as user TestUser1
When I create the role
| field | value |
| name | My First Role |
| description | Hello World |
If you want to read the table values out by keying on name, and description, there are a number of ways to achieve this, but one way is to transpose the dataTable:
What does "transpose" table mean?
"Transposing a dataset means swapping its rows and columns so that the rows become columns and the columns become rows"
my.steps.ts:
import { When } from '@cucumber/cucumber';
When('I create the role', async function (this: ICustomWorld, dataTable) {
dataTable.transpose().hashes().map((row) => {
console.log('name:', row.name);
console.log('description:', row.description);
});
Console output:
name: My First Role
description: Hello World
Last edited: