Skip to content

Commit

Permalink
fix: ensure all tags in config are normalized
Browse files Browse the repository at this point in the history
  • Loading branch information
dnotes committed Oct 8, 2024
1 parent 99fe7bf commit c7e9292
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changeset/small-peas-judge.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"quickpickle": patch
---

Fixed ensure all tags configs are normalized
7 changes: 5 additions & 2 deletions packages/main/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,8 @@ interface ResolvedConfig {
};
}

function normalizeTags(tags:string|string[]):string[] {
tags = Array.isArray(tags) ? tags : [tags]
export function normalizeTags(tags:string|string[]):string[] {
tags = Array.isArray(tags) ? tags : tags.split(/\s*,\s*/g)
return tags.filter(Boolean).map(tag => tag.startsWith('@') ? tag : `@${tag}`)
}

Expand All @@ -148,8 +148,11 @@ export const quickpickle = function() {
defaultConfig,
get(resolvedConfig, 'test.quickpickle')
) as QuickPickleConfig;
config.todoTags = normalizeTags(config.todoTags)
config.skipTags = normalizeTags(config.skipTags)
config.failTags = normalizeTags(config.failTags)
config.concurrentTags = normalizeTags(config.concurrentTags)
config.sequentialTags = normalizeTags(config.sequentialTags)
},
transform: async (src: string, id: string): Promise<string | undefined> => {
if (featureRegex.test(id)) {
Expand Down
4 changes: 2 additions & 2 deletions packages/main/tests/renderer.test.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { expect, test } from 'vitest'
import { renderGherkin } from '../src/render'
import { defaultConfig } from '../src'
import { defaultConfig, normalizeTags } from '../src'
import fs from 'node:fs'

const featureFile = fs.readFileSync(__dirname + '/../gherkin-example/example.feature', 'utf8')
const jsFile = fs.readFileSync(__dirname + '/../gherkin-example/example.feature.js', 'utf8')

test('rendering the example feature file', () => {
expect(jsFile).toEqual(renderGherkin(featureFile, defaultConfig))
expect(jsFile).toEqual(renderGherkin(featureFile, {...defaultConfig, failTags: normalizeTags('fail, fails')}))
})

0 comments on commit c7e9292

Please sign in to comment.