playwright-cucumber-ts-steps 1.1.5 → 1.1.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -104,34 +104,29 @@ npx playwright test
104
104
 
105
105
  We support a **Friendly Syntax** for filtering tests via the `TAGS` environment variable.
106
106
 
107
- | Logic | Symbol | Example | Description |
108
- | ------- | ------- | ---------------- | ----------------------------------------------------- |
109
- | **OR** | `,` | `@login,@signup` | Run tests that have `@login` **OR** `@signup`. |
110
- | **AND** | `+` | `@smoke+@api` | Run tests that have **BOTH** `@smoke` **AND** `@api`. |
111
- | **MIX** | `,` `+` | `@a+@b, @c` | Run tests with (`@a` AND `@b`) **OR** just `@c`. |
107
+ | Logic | Symbol | Example | Description |
108
+ | ------- | ------ | ---------------- | ------------------------------------------------ |
109
+ | **AND** | `,` | `@login,@signup` | Run tests that have `@login` **AND** `@signup`. |
110
+ | |
111
+ | **MIX** | `,` | `@a,@b, @c` | Run tests with (`@a` AND `@b`) **OR** just `@c`. |
112
112
 
113
113
  **Usage:**
114
114
 
115
115
  ```bash
116
116
  # Run only smoke tests
117
117
  TAGS='@smoke' npx playwright test
118
+ OR
118
119
  npx playwright test -g "@smoke"
119
120
 
120
121
  # Run smoke tests that are also critical
121
- TAGS='@smoke+@critical' npx playwright test
122
- npx playwright test -g "(?=.*@smoke)(?=.*@critical)"
123
-
124
- # Run login OR regression tests
125
- TAGS='@login,@regression' npx playwright test
126
-
127
- npx playwright test -g "@login|@regression"
122
+ TAGS='@smoke,@critical' npx playwright test
123
+ OR
124
+ npx playwright test -g "@smoke|@critical"
128
125
 
129
126
  ```
130
127
 
131
128
  _(On Windows PowerShell, use `$env:TAGS="@smoke"; npx playwright test`)_
132
129
 
133
- ````
134
-
135
130
  **In your Test Runner (`tests/bdd.spec.ts`):**
136
131
 
137
132
  ```typescript
@@ -142,7 +137,7 @@ import { runTests } from "playwright-cucumber-ts-steps";
142
137
 
143
138
  // OPTION 2: Run only Smoke tests
144
139
  runTests("features/*.feature", { tags: "@smoke" });
145
- ````
140
+ ```
146
141
 
147
142
  ---
148
143
 
@@ -1 +1 @@
1
- {"version":3,"file":"runner.d.ts","sourceRoot":"","sources":["../../src/core/runner.ts"],"names":[],"mappings":"AAMA,OAAO,0BAA0B,CAAC;AAClC,OAAO,6BAA6B,CAAC;AACrC,OAAO,2BAA2B,CAAC;AACnC,OAAO,sBAAsB,CAAC;AAC9B,OAAO,uBAAuB,CAAC;AAE/B,OAAO,qBAAqB,CAAC;AAE7B,UAAU,aAAa;IACrB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,GAAG,CAAC,CAAC;CAC3C;AAED,wBAAgB,QAAQ,CAAC,WAAW,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,aAAa,QA2HpE"}
1
+ {"version":3,"file":"runner.d.ts","sourceRoot":"","sources":["../../src/core/runner.ts"],"names":[],"mappings":"AAMA,OAAO,0BAA0B,CAAC;AAClC,OAAO,6BAA6B,CAAC;AACrC,OAAO,2BAA2B,CAAC;AACnC,OAAO,sBAAsB,CAAC;AAC9B,OAAO,uBAAuB,CAAC;AAE/B,OAAO,qBAAqB,CAAC;AAE7B,UAAU,aAAa;IACrB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,GAAG,CAAC,CAAC;CAC3C;AAED,wBAAgB,QAAQ,CAAC,WAAW,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,aAAa,QAyIpE"}
@@ -52,51 +52,54 @@ function runTests(featureGlob, options) {
52
52
  }
53
53
  const files = (0, glob_1.globSync)(featureGlob);
54
54
  const envTag = process.env.TAGS;
55
+ if (files.length === 0) {
56
+ console.log(`⚠️ No Feature files found for: ${featureGlob}`);
57
+ }
55
58
  for (const file of files) {
56
59
  const content = fs.readFileSync(file, "utf8");
57
- // 1. CAPTURE FEATURE-LEVEL TAGS (Inheritance)
58
- // Looks for lines starting with @ above "Feature:"
59
- const featureTagMatch = content.match(/((?:@[\w-]+\s*)+)Feature:/);
60
+ // 1. CAPTURE FEATURE TAGS
61
+ // Loose Regex: Matches any lines starting with @ above "Feature:"
62
+ const featureTagMatch = content.match(/((?:@\S+\s*)+)Feature:/);
60
63
  const rawFeatureTags = featureTagMatch ? featureTagMatch[1] : "";
61
- // Normalize newlines to spaces
62
64
  const featureTags = rawFeatureTags.replace(/[\r\n]+/g, " ").trim();
63
65
  const featureMatch = content.match(/Feature:\s*(.+)/);
64
66
  const featureName = featureMatch
65
67
  ? featureMatch[1].trim()
66
68
  : "Unnamed Feature";
67
69
  test_1.test.describe(featureName, () => {
68
- // 2. CAPTURE SCENARIO-LEVEL TAGS
69
- // Looks for optional tags above "Scenario:"
70
- const scenarioRegex = /(?:((?:@[\w-]+\s*)+))?Scenario:\s*(.+)/g;
70
+ // 2. LOOSE SCENARIO REGEX
71
+ // Matches: Optional Tags -> (Scenario OR Scenario Outline) -> Name
72
+ // Change: @\S+ allows dots/dashes. "Scenario|Scenario Outline" supports outlines.
73
+ const scenarioRegex = /(?:((?:@\S+\s*)+))?(?:Scenario|Scenario Outline):\s*(.+)/g;
71
74
  let match;
75
+ let foundCount = 0;
72
76
  while ((match = scenarioRegex.exec(content)) !== null) {
77
+ foundCount++;
73
78
  const rawScenarioTags = match[1] || "";
74
79
  const scenarioTags = rawScenarioTags.replace(/[\r\n]+/g, " ").trim();
75
80
  const scenarioName = match[2].trim();
76
- // 3. MERGE ALL TAGS
77
- // We combine Feature Tags + Scenario Tags into one master list
78
- // e.g. "@smoke @regression" + "@api" = "@smoke @regression @api"
81
+ // 3. MERGE TAGS
79
82
  const combinedTags = `${featureTags} ${scenarioTags}`.trim();
80
- // 4. APPEND TO TITLE
81
- // Now the test title contains EVERYTHING.
82
- // Playwright's -g can now "see" the feature tags on this specific test.
83
83
  const fullName = combinedTags
84
84
  ? `${scenarioName} ${combinedTags}`
85
85
  : scenarioName;
86
- // 5. CUSTOM FILTERING (Optional - if using TAGS env var)
86
+ // DEBUG LOG: See what we found
87
+ // console.log(` 👉 Found: "${scenarioName}" [Tags: ${combinedTags}]`);
88
+ // 4. ENV FILTERING (Optional)
87
89
  const activeFilter = options?.tags || envTag;
88
90
  if (activeFilter) {
89
91
  const targetGroups = activeFilter.split(",").map((t) => t.trim());
90
92
  const isMatch = targetGroups.some((group) => {
91
93
  const requiredTags = group.split("+").map((t) => t.trim());
92
- // Check against the COMBINED list
93
94
  return requiredTags.every((t) => combinedTags.includes(t));
94
95
  });
95
96
  if (!isMatch)
96
97
  continue;
97
98
  }
98
99
  const startIndex = match.index + match[0].length;
99
- const nextMatchIndex = content.slice(startIndex).search(/Scenario:/);
100
+ const nextMatchIndex = content
101
+ .slice(startIndex)
102
+ .search(/(?:Scenario|Scenario Outline):/);
100
103
  const blockEnd = nextMatchIndex === -1 ? content.length : startIndex + nextMatchIndex;
101
104
  const scenarioBlock = content.slice(startIndex, blockEnd);
102
105
  (0, test_1.test)(fullName, async ({ page }, testInfo) => {
@@ -111,6 +114,7 @@ function runTests(featureGlob, options) {
111
114
  stepText.startsWith("@") ||
112
115
  stepText === "")
113
116
  continue;
117
+ // Handle Data Tables
114
118
  const tableData = [];
115
119
  while (i + 1 < lines.length && lines[i + 1].startsWith("|")) {
116
120
  i++;
@@ -149,6 +153,11 @@ function runTests(featureGlob, options) {
149
153
  }
150
154
  });
151
155
  }
156
+ // SAFETY CHECK
157
+ if (foundCount === 0) {
158
+ console.warn(`⚠️ File matched but 0 Scenarios found in: ${file}`);
159
+ console.warn(` Check if you are using 'Scenario Outline' or strange spacing.`);
160
+ }
152
161
  });
153
162
  }
154
163
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "playwright-cucumber-ts-steps",
3
3
  "description": "A collection of reusable Playwright step definitions for Cucumber in TypeScript, designed to streamline end-to-end testing across web, API, and mobile applications.",
4
- "version": "1.1.5",
4
+ "version": "1.1.7",
5
5
  "private": false,
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",