DEV Community

Dennis Zhang
Dennis Zhang

Posted on

解析feature和csv文件插件

npm i gherkin-parse csv-parse
Enter fullscreen mode Exit fullscreen mode
const parse = require("gherkin-parse")
const fs = require("fs")

const jsonObject = parse.convertFeatureFileToJson(featurePath)

const featureString = parse.convertJSONToFeatureFile(jsonObject)// 没有包含comment

const comment =jsonObject.comments.map(item=>item.text).join("\n")

// update feature file
fs.writeFileSync(featurePath,`${featureString}\n\n\n${comment}` )

Enter fullscreen mode Exit fullscreen mode

Top comments (0)