From 5f93b04b620e590c0c6da9c7a8025d8b0cdd74ca Mon Sep 17 00:00:00 2001 From: vanilla-wave Date: Thu, 5 Jun 2025 19:43:11 +0200 Subject: [PATCH 1/3] feat: use separate assertion group for empty tests --- src/strategy.ts | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/src/strategy.ts b/src/strategy.ts index 55815f3..f3eb525 100644 --- a/src/strategy.ts +++ b/src/strategy.ts @@ -22,12 +22,23 @@ export class DefaultStrategy { const emptyTestsAssertion = this.loadEmptyTestAssertion(emptyTests); const pwTestsAssertion = this.loadPwTestFromAssertion(tests); - return [ - { + const groups = []; + + if (pwTestsAssertion.length > 0) { + groups.push({ title: this.getTitleFromPath(path), - assertions: [...pwTestsAssertion, ...emptyTestsAssertion], - }, - ]; + assertions: pwTestsAssertion, + }); + } + + if (emptyTestsAssertion.length > 0) { + groups.push({ + title: `${this.getTitleFromPath(path)} - Empty Tests`, + assertions: emptyTestsAssertion, + }); + } + + return groups; }; getAttributes = ({path}: StrategyOptions) => { From f63d09f492613fd6d07eed8c41efd1a7c9f52dec Mon Sep 17 00:00:00 2001 From: vanilla-wave Date: Thu, 5 Jun 2025 19:58:52 +0200 Subject: [PATCH 2/3] feat: use dir name in feature name for deep nested files --- src/strategy.ts | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/src/strategy.ts b/src/strategy.ts index f3eb525..4662ba7 100644 --- a/src/strategy.ts +++ b/src/strategy.ts @@ -15,6 +15,16 @@ export class DefaultStrategy { } getFeatureTitle = ({path}: StrategyOptions) => { + const attributes = this.parsePathToAttributes(path); + const levels = this.collectorOptions.levels || 3; + + if (attributes.length > levels) { + const excludedElements = attributes.slice(levels, -1); + const fileName = attributes[attributes.length - 1]; + const titleElements = [...excludedElements, fileName]; + return titleElements.map(this.formatPathElement).join(' / '); + } + return this.getTitleFromPath(path); }; @@ -42,12 +52,7 @@ export class DefaultStrategy { }; getAttributes = ({path}: StrategyOptions) => { - const {dir, name} = parsePath(path); - const pathArray = dir.split('/'); - - const editedFileName = this.formatFilename(name); - const attributes = [...pathArray, editedFileName].filter(Boolean) as string[]; - + const attributes = this.parsePathToAttributes(path); return attributes.slice(0, this.collectorOptions.levels || 3).map(this.formatPathElement); }; @@ -114,4 +119,11 @@ export class DefaultStrategy { return attributeWithoutDash[0]?.toUpperCase() + attributeWithoutDash.slice(1); }; + + private parsePathToAttributes = (path: string): string[] => { + const {dir, name} = parsePath(path); + const pathArray = dir.split('/'); + const editedFileName = this.formatFilename(name); + return [...pathArray, editedFileName].filter(Boolean) as string[]; + }; } From 6975cc17ff9dc0b9e2a63f7e94b15c9732b0c84a Mon Sep 17 00:00:00 2001 From: vanilla-wave Date: Thu, 5 Jun 2025 20:00:14 +0200 Subject: [PATCH 3/3] 0.1.0 --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 2181c9c..a4bd580 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@spec-box/spec-collector", - "version": "0.0.3", + "version": "0.1.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@spec-box/spec-collector", - "version": "0.0.3", + "version": "0.1.0", "license": "MIT", "dependencies": { "@playwright/test": "^1.52.0", diff --git a/package.json b/package.json index 4951f73..a77e54a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@spec-box/collector", - "version": "0.0.3", + "version": "0.1.0", "private": false, "description": "", "license": "MIT",