playwright-cucumber-ts-steps 1.1.2 → 1.1.4

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
@@ -95,30 +95,43 @@ Feature: User Authentication
95
95
  ### 4. Run Tests
96
96
 
97
97
  ```bash
98
- npx playwright test demo.spec.ts --headed
98
+ npx playwright test
99
99
  ```
100
100
 
101
101
  ---
102
102
 
103
- ## 🏷️ Tags & Filtering
103
+ ## 🏷️ Tag Filtering (New!)
104
104
 
105
- You can use tags to organize your tests and run specific subsets (e.g., only Smoke tests).
105
+ We support a **Friendly Syntax** for filtering tests via the `TAGS` environment variable.
106
106
 
107
- **In your Feature file:**
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`. |
108
112
 
109
- ```gherkin
110
- Feature: Checkout
113
+ **Usage:**
114
+
115
+ ```bash
116
+ # Run only smoke tests
117
+ TAGS='@smoke' npx playwright test
118
+ npx playwright test -g "@smoke"
119
+
120
+ # Run smoke tests that are also critical
121
+ TAGS='@smoke+@critical' npx playwright test
122
+ npx playwright test -g "(?=.*@smoke)(?=.*@critical)"
111
123
 
112
- @smoke @critical
113
- Scenario: Guest Checkout
114
- ...
124
+ # Run login OR regression tests
125
+ TAGS='@login,@regression' npx playwright test
115
126
 
116
- @regression
117
- Scenario: Registered User Checkout
118
- ...
127
+ npx playwright test -g "@login|@regression"
119
128
 
120
129
  ```
121
130
 
131
+ _(On Windows PowerShell, use `$env:TAGS="@smoke"; npx playwright test`)_
132
+
133
+ ````
134
+
122
135
  **In your Test Runner (`tests/bdd.spec.ts`):**
123
136
 
124
137
  ```typescript
@@ -129,7 +142,7 @@ import { runTests } from "playwright-cucumber-ts-steps";
129
142
 
130
143
  // OPTION 2: Run only Smoke tests
131
144
  runTests("features/*.feature", { tags: "@smoke" });
132
- ```
145
+ ````
133
146
 
134
147
  ---
135
148
 
@@ -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,QA2GpE"}
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,QAgHpE"}
@@ -52,8 +52,8 @@ function runTests(featureGlob, options) {
52
52
  state_1.dbState.setAdapter(options.dbQuery);
53
53
  }
54
54
  const files = (0, glob_1.globSync)(featureGlob);
55
- // SUPPORT ENV VAR TAGS (Alternative to -g)
56
- // If user runs: TAGS='@login' npx playwright test
55
+ // SUPPORT ENV VAR TAGS
56
+ // Usage: TAGS='@smoke,@api' npx playwright test
57
57
  const envTag = process.env.TAGS;
58
58
  for (const file of files) {
59
59
  const content = fs.readFileSync(file, "utf8");
@@ -62,25 +62,27 @@ function runTests(featureGlob, options) {
62
62
  ? featureMatch[1].trim()
63
63
  : "Unnamed Feature";
64
64
  test_1.test.describe(featureName, () => {
65
+ // SAFER REGEX
65
66
  const scenarioRegex = /(?:(@[^:\r\n]+)\s+)?Scenario:\s*(.+)/g;
66
67
  let match;
67
68
  while ((match = scenarioRegex.exec(content)) !== null) {
68
69
  const foundTags = match[1] || "";
69
70
  const scenarioName = match[2].trim();
70
- // 🔥 1. APPEND TAGS TO TITLE
71
- // This allows 'npx playwright test -g @login' to work natively
71
+ // 1. APPEND TAGS TO TITLE (Crucial for -g flag)
72
72
  const fullName = foundTags
73
73
  ? `${scenarioName} ${foundTags}`
74
74
  : scenarioName;
75
- // 🔥 2. FILTER LOGIC
76
- // Filter by Code Options OR Env Variable
75
+ // 2. FILTER LOGIC (Supports multiple tags)
77
76
  const activeFilter = options?.tags || envTag;
78
77
  if (activeFilter) {
79
- // Allow comma separated tags (OR logic): "@login,@regression"
78
+ // Logic: If user passes "@smoke,@regression", we check if the scenario has EITHER
79
+ // Split by comma, trim spaces
80
80
  const targetTags = activeFilter.split(",").map((t) => t.trim());
81
- const hasMatch = targetTags.some((t) => foundTags.includes(t));
82
- if (!hasMatch)
83
- continue;
81
+ // Check if at least one tag matches (OR Logic)
82
+ const isMatch = targetTags.some((t) => foundTags.includes(t));
83
+ if (!isMatch) {
84
+ continue; // Skip this test if it doesn't have any of the requested tags
85
+ }
84
86
  }
85
87
  const startIndex = match.index + match[0].length;
86
88
  const nextMatchIndex = content.slice(startIndex).search(/Scenario:/);
@@ -98,7 +100,6 @@ function runTests(featureGlob, options) {
98
100
  stepText.startsWith("@") ||
99
101
  stepText === "")
100
102
  continue;
101
- // Handle Data Tables
102
103
  const tableData = [];
103
104
  while (i + 1 < lines.length && lines[i + 1].startsWith("|")) {
104
105
  i++;
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.2",
4
+ "version": "1.1.4",
5
5
  "private": false,
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",