Trying to Convert a cucumber DataTable as a string of array/list in Typescript

huangapple go评论73阅读模式
英文:

Trying to Convert a cucumber DataTable as a string of array/list in Typescript

问题

我想在TypeScript中将Cucumber中的数据表用作列表。

// 当用户选择以下步骤时
const steps = [
  ["a"],
  ["b"],
  ["c"]
];

// 如果问题已经回答,请分享指引
TIA
英文:

I want to utilise the data table in cucumber as list in Typescript

<!-- language: lang-css -->

When user select these
    |Steps| 
    |a| 
    |b|
    |c|

<!-- end snippet -->

I want the steps to be utilised something like
const steps = dataTable.asLists(String.class)

If question already answered, please share pointers
TIA

答案1

得分: 0

这是我在TypeScript中实现Cucumber数据表的列表/数组的方式。

var steps = [];
for (let i = 0; i < dataTable.rows().length; i++) {
  steps.push(dataTable.rows()[i][0]);
}
英文:

This is how I have achieved list/array in typescript from the cucumber datatable

<!-- language: lang-js -->

var steps = [];
    for (let i = 0; i &lt; dataTable.rows().length; i++) {
      steps.push(dataTable.rows()[i][0]);
    }

<!-- end snippet -->

huangapple
  • 本文由 发表于 2023年7月6日 20:23:14
  • 转载请务必保留本文链接:https://go.coder-hub.com/76628801.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定