From c7e9292bede81d495b94f66aae87f9e5bdb93b27 Mon Sep 17 00:00:00 2001 From: David Hunt Date: Tue, 8 Oct 2024 22:28:00 +1300 Subject: [PATCH] fix: ensure all tags in config are normalized --- .changeset/small-peas-judge.md | 5 +++++ packages/main/src/index.ts | 7 +++++-- packages/main/tests/renderer.test.ts | 4 ++-- 3 files changed, 12 insertions(+), 4 deletions(-) create mode 100644 .changeset/small-peas-judge.md diff --git a/.changeset/small-peas-judge.md b/.changeset/small-peas-judge.md new file mode 100644 index 0000000..324eb05 --- /dev/null +++ b/.changeset/small-peas-judge.md @@ -0,0 +1,5 @@ +--- +"quickpickle": patch +--- + +Fixed ensure all tags configs are normalized diff --git a/packages/main/src/index.ts b/packages/main/src/index.ts index 52450d9..a1c7395 100644 --- a/packages/main/src/index.ts +++ b/packages/main/src/index.ts @@ -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}`) } @@ -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 => { if (featureRegex.test(id)) { diff --git a/packages/main/tests/renderer.test.ts b/packages/main/tests/renderer.test.ts index acee3d7..fe52394 100644 --- a/packages/main/tests/renderer.test.ts +++ b/packages/main/tests/renderer.test.ts @@ -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')})) }) \ No newline at end of file