playwright-cucumber-ts-steps 1.1.3 → 1.1.5

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
@@ -115,13 +115,17 @@ We support a **Friendly Syntax** for filtering tests via the `TAGS` environment
115
115
  ```bash
116
116
  # Run only smoke tests
117
117
  TAGS='@smoke' npx playwright test
118
+ npx playwright test -g "@smoke"
118
119
 
119
120
  # Run smoke tests that are also critical
120
121
  TAGS='@smoke+@critical' npx playwright test
122
+ npx playwright test -g "(?=.*@smoke)(?=.*@critical)"
121
123
 
122
124
  # Run login OR regression tests
123
125
  TAGS='@login,@regression' npx playwright test
124
126
 
127
+ npx playwright test -g "@login|@regression"
128
+
125
129
  ```
126
130
 
127
131
  _(On Windows PowerShell, use `$env:TAGS="@smoke"; npx playwright test`)_
@@ -1 +1 @@
1
- {"version":3,"file":"runner.d.ts","sourceRoot":"","sources":["../../src/core/runner.ts"],"names":[],"mappings":"AAOA,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,QAqHpE"}
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"}
@@ -34,7 +34,6 @@ var __importStar = (this && this.__importStar) || (function () {
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
36
  exports.runTests = runTests;
37
- // src/core/runner.ts
38
37
  const test_1 = require("@playwright/test");
39
38
  const fs = __importStar(require("fs"));
40
39
  const glob_1 = require("glob");
@@ -53,40 +52,48 @@ function runTests(featureGlob, options) {
53
52
  }
54
53
  const files = (0, glob_1.globSync)(featureGlob);
55
54
  const envTag = process.env.TAGS;
56
- if (files.length === 0) {
57
- console.warn(`⚠️ No feature files found for pattern: ${featureGlob}`);
58
- }
59
55
  for (const file of files) {
60
56
  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
+ const rawFeatureTags = featureTagMatch ? featureTagMatch[1] : "";
61
+ // Normalize newlines to spaces
62
+ const featureTags = rawFeatureTags.replace(/[\r\n]+/g, " ").trim();
61
63
  const featureMatch = content.match(/Feature:\s*(.+)/);
62
64
  const featureName = featureMatch
63
65
  ? featureMatch[1].trim()
64
66
  : "Unnamed Feature";
65
67
  test_1.test.describe(featureName, () => {
66
- const scenarioRegex = /(?:(@[^:\r\n]+)\s+)?Scenario:\s*(.+)/g;
68
+ // 2. CAPTURE SCENARIO-LEVEL TAGS
69
+ // Looks for optional tags above "Scenario:"
70
+ const scenarioRegex = /(?:((?:@[\w-]+\s*)+))?Scenario:\s*(.+)/g;
67
71
  let match;
68
72
  while ((match = scenarioRegex.exec(content)) !== null) {
69
- const foundTags = match[1] || "";
73
+ const rawScenarioTags = match[1] || "";
74
+ const scenarioTags = rawScenarioTags.replace(/[\r\n]+/g, " ").trim();
70
75
  const scenarioName = match[2].trim();
71
- // 1. APPEND TAGS TO TITLE (Keeps -g working if needed)
72
- const fullName = foundTags
73
- ? `${scenarioName} ${foundTags}`
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"
79
+ 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
+ const fullName = combinedTags
84
+ ? `${scenarioName} ${combinedTags}`
74
85
  : scenarioName;
75
- // 2. 🔥 FRIENDLY TAG FILTERING 🔥
86
+ // 5. CUSTOM FILTERING (Optional - if using TAGS env var)
76
87
  const activeFilter = options?.tags || envTag;
77
88
  if (activeFilter) {
78
- // Logic:
79
- // ',' = OR (e.g., "@login, @smoke")
80
- // '+' = AND (e.g., "@login+@smoke")
81
- const orGroups = activeFilter.split(","); // Split into OR groups
82
- const isMatch = orGroups.some((group) => {
83
- // For each group, check if ALL tags (joined by +) are present
84
- const andTags = group.split("+").map((t) => t.trim());
85
- return andTags.every((t) => foundTags.includes(t));
89
+ const targetGroups = activeFilter.split(",").map((t) => t.trim());
90
+ const isMatch = targetGroups.some((group) => {
91
+ const requiredTags = group.split("+").map((t) => t.trim());
92
+ // Check against the COMBINED list
93
+ return requiredTags.every((t) => combinedTags.includes(t));
86
94
  });
87
- if (!isMatch) {
88
- continue; // Skip if no groups matched
89
- }
95
+ if (!isMatch)
96
+ continue;
90
97
  }
91
98
  const startIndex = match.index + match[0].length;
92
99
  const nextMatchIndex = content.slice(startIndex).search(/Scenario:/);
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.3",
4
+ "version": "1.1.5",
5
5
  "private": false,
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",