playwright-cucumber-ts-steps 1.1.2 → 1.1.3
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 +22 -13
- package/dist/core/runner.d.ts.map +1 -1
- package/dist/core/runner.js +17 -12
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -95,30 +95,39 @@ Feature: User Authentication
|
|
|
95
95
|
### 4. Run Tests
|
|
96
96
|
|
|
97
97
|
```bash
|
|
98
|
-
npx playwright test
|
|
98
|
+
npx playwright test
|
|
99
99
|
```
|
|
100
100
|
|
|
101
101
|
---
|
|
102
102
|
|
|
103
|
-
## 🏷️
|
|
103
|
+
## 🏷️ Tag Filtering (New!)
|
|
104
104
|
|
|
105
|
-
|
|
105
|
+
We support a **Friendly Syntax** for filtering tests via the `TAGS` environment variable.
|
|
106
106
|
|
|
107
|
-
|
|
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
|
-
|
|
110
|
-
|
|
113
|
+
**Usage:**
|
|
114
|
+
|
|
115
|
+
```bash
|
|
116
|
+
# Run only smoke tests
|
|
117
|
+
TAGS='@smoke' npx playwright test
|
|
111
118
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
...
|
|
119
|
+
# Run smoke tests that are also critical
|
|
120
|
+
TAGS='@smoke+@critical' npx playwright test
|
|
115
121
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
...
|
|
122
|
+
# Run login OR regression tests
|
|
123
|
+
TAGS='@login,@regression' npx playwright test
|
|
119
124
|
|
|
120
125
|
```
|
|
121
126
|
|
|
127
|
+
_(On Windows PowerShell, use `$env:TAGS="@smoke"; npx playwright test`)_
|
|
128
|
+
|
|
129
|
+
````
|
|
130
|
+
|
|
122
131
|
**In your Test Runner (`tests/bdd.spec.ts`):**
|
|
123
132
|
|
|
124
133
|
```typescript
|
|
@@ -129,7 +138,7 @@ import { runTests } from "playwright-cucumber-ts-steps";
|
|
|
129
138
|
|
|
130
139
|
// OPTION 2: Run only Smoke tests
|
|
131
140
|
runTests("features/*.feature", { tags: "@smoke" });
|
|
132
|
-
|
|
141
|
+
````
|
|
133
142
|
|
|
134
143
|
---
|
|
135
144
|
|
|
@@ -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,
|
|
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"}
|
package/dist/core/runner.js
CHANGED
|
@@ -52,9 +52,10 @@ 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
|
|
57
55
|
const envTag = process.env.TAGS;
|
|
56
|
+
if (files.length === 0) {
|
|
57
|
+
console.warn(`⚠️ No feature files found for pattern: ${featureGlob}`);
|
|
58
|
+
}
|
|
58
59
|
for (const file of files) {
|
|
59
60
|
const content = fs.readFileSync(file, "utf8");
|
|
60
61
|
const featureMatch = content.match(/Feature:\s*(.+)/);
|
|
@@ -67,20 +68,25 @@ function runTests(featureGlob, options) {
|
|
|
67
68
|
while ((match = scenarioRegex.exec(content)) !== null) {
|
|
68
69
|
const foundTags = match[1] || "";
|
|
69
70
|
const scenarioName = match[2].trim();
|
|
70
|
-
//
|
|
71
|
-
// This allows 'npx playwright test -g @login' to work natively
|
|
71
|
+
// 1. APPEND TAGS TO TITLE (Keeps -g working if needed)
|
|
72
72
|
const fullName = foundTags
|
|
73
73
|
? `${scenarioName} ${foundTags}`
|
|
74
74
|
: scenarioName;
|
|
75
|
-
//
|
|
76
|
-
// Filter by Code Options OR Env Variable
|
|
75
|
+
// 2. 🔥 FRIENDLY TAG FILTERING 🔥
|
|
77
76
|
const activeFilter = options?.tags || envTag;
|
|
78
77
|
if (activeFilter) {
|
|
79
|
-
//
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
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));
|
|
86
|
+
});
|
|
87
|
+
if (!isMatch) {
|
|
88
|
+
continue; // Skip if no groups matched
|
|
89
|
+
}
|
|
84
90
|
}
|
|
85
91
|
const startIndex = match.index + match[0].length;
|
|
86
92
|
const nextMatchIndex = content.slice(startIndex).search(/Scenario:/);
|
|
@@ -98,7 +104,6 @@ function runTests(featureGlob, options) {
|
|
|
98
104
|
stepText.startsWith("@") ||
|
|
99
105
|
stepText === "")
|
|
100
106
|
continue;
|
|
101
|
-
// Handle Data Tables
|
|
102
107
|
const tableData = [];
|
|
103
108
|
while (i + 1 < lines.length && lines[i + 1].startsWith("|")) {
|
|
104
109
|
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.
|
|
4
|
+
"version": "1.1.3",
|
|
5
5
|
"private": false,
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"types": "dist/index.d.ts",
|