Skip to content

Commit

Permalink
feat: add tags to test names for Vitest readouts
Browse files Browse the repository at this point in the history
  • Loading branch information
dnotes committed Oct 27, 2024
1 parent 42f425c commit 4e4a90f
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 18 deletions.
5 changes: 5 additions & 0 deletions .changeset/polite-rats-rest.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"quickpickle": minor
---

feat: add tags to test names for Vitest readouts
32 changes: 16 additions & 16 deletions packages/main/gherkin-example/example.feature.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions packages/main/src/render.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,8 @@ function renderScenario(child:FeatureChild, config:QuickPickleConfig, tags:strin
let isExploded = taglists.length > 1 ? true : false
return taglists.map((tags,explodedIdx) => {

let tagTextForVitest = tags.length ? ` (${tags.join(' ')})` : ''

// For Scenario Outlines with examples
if (child.scenario!.examples?.[0]?.tableHeader && child.scenario!.examples?.[0]?.tableBody) {

Expand All @@ -166,7 +168,7 @@ function renderScenario(child:FeatureChild, config:QuickPickleConfig, tags:strin

return `
${sp}test${attrs}.for(${JSON.stringify(paramValues)})(
${sp} '${q(child.scenario?.keyword || '')}: ${describe}',
${sp} '${q(child.scenario?.keyword || '')}: ${describe}${tagTextForVitest}',
${sp} async ({ ${paramNames?.join(', ')} }, context) => {
${sp} let state = await ${initFn}(context, \`${name}\`, ['${tags.join("', '") || ''}']);
${child.scenario?.steps.map((step,idx) => {
Expand All @@ -182,7 +184,7 @@ ${sp});
}

return `
${sp}test${attrs}('${q(child.scenario!.keyword)}: ${q(child.scenario!.name)}', async (context) => {
${sp}test${attrs}('${q(child.scenario!.keyword)}: ${q(child.scenario!.name)}${tagTextForVitest}', async (context) => {
${sp} let state = await ${initFn}(context, '${q(child.scenario!.name)}', ['${tags.join("', '") || ''}']);
${renderSteps(child.scenario!.steps as Step[], config, sp + ' ', isExploded ? `${explodedIdx+1}` : '')}
${sp} await afterScenario(state);
Expand Down

0 comments on commit 4e4a90f

Please sign in to comment.