Skip to content

Commit

Permalink
fix: step line number on report
Browse files Browse the repository at this point in the history
  • Loading branch information
deblockt committed Mar 21, 2024
1 parent 3f2d9ec commit 7dadd5e
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 3 deletions.
15 changes: 14 additions & 1 deletion dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12182,6 +12182,7 @@ const EMPTY_GLOBAL_INFO = {
module.exports.reader = (reportString) => {
const features = []
const scenario = {}
const steps = {}
const pickles = {}
const picklesSteps = {}
const testCases = {}
Expand All @@ -12208,6 +12209,17 @@ module.exports.reader = (reportString) => {
scenario[sc.id] = sc
scenarios.push(sc)
})
feature.children
.filter(it => "background" in it || "scenario" in it)
.forEach(it => {
const scenarioSteps = it.background?.steps ?? it.scenario?.steps
scenarioSteps.forEach(step => {
steps[step.id] = {
location: step.location
}
})
})

features.push({
name: feature.name,
location: feature.location,
Expand All @@ -12222,7 +12234,8 @@ module.exports.reader = (reportString) => {
pk.steps = element.pickle.steps.map(it => ({
id: it.id,
name: it.text,
pickle: pk
pickle: pk,
location: steps[it.astNodeIds[0]].location.line
}))
pk.steps.forEach(it => picklesSteps[it.id] = it)
scenario[element.pickle.astNodeIds[0]].pickles[element.pickle.id] = pk
Expand Down
2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

15 changes: 14 additions & 1 deletion reportReader-ndjson.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const EMPTY_GLOBAL_INFO = {
module.exports.reader = (reportString) => {
const features = []
const scenario = {}
const steps = {}
const pickles = {}
const picklesSteps = {}
const testCases = {}
Expand All @@ -43,6 +44,17 @@ module.exports.reader = (reportString) => {
scenario[sc.id] = sc
scenarios.push(sc)
})
feature.children
.filter(it => "background" in it || "scenario" in it)
.forEach(it => {
const scenarioSteps = it.background?.steps ?? it.scenario?.steps
scenarioSteps.forEach(step => {
steps[step.id] = {
location: step.location
}
})
})

features.push({
name: feature.name,
location: feature.location,
Expand All @@ -57,7 +69,8 @@ module.exports.reader = (reportString) => {
pk.steps = element.pickle.steps.map(it => ({
id: it.id,
name: it.text,
pickle: pk
pickle: pk,
location: steps[it.astNodeIds[0]].location.line
}))
pk.steps.forEach(it => picklesSteps[it.id] = it)
scenario[element.pickle.astNodeIds[0]].pickles[element.pickle.id] = pk
Expand Down

0 comments on commit 7dadd5e

Please sign in to comment.