playwright-cucumber-ts-steps 1.1.4 → 1.1.6
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/dist/core/runner.d.ts.map +1 -1
- package/dist/core/runner.js +39 -19
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runner.d.ts","sourceRoot":"","sources":["../../src/core/runner.ts"],"names":[],"mappings":"
|
|
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"}
|
package/dist/core/runner.js
CHANGED
|
@@ -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");
|
|
@@ -52,40 +51,55 @@ function runTests(featureGlob, options) {
|
|
|
52
51
|
state_1.dbState.setAdapter(options.dbQuery);
|
|
53
52
|
}
|
|
54
53
|
const files = (0, glob_1.globSync)(featureGlob);
|
|
55
|
-
// SUPPORT ENV VAR TAGS
|
|
56
|
-
// Usage: TAGS='@smoke,@api' npx playwright test
|
|
57
54
|
const envTag = process.env.TAGS;
|
|
55
|
+
if (files.length === 0) {
|
|
56
|
+
console.log(`⚠️ No Feature files found for: ${featureGlob}`);
|
|
57
|
+
}
|
|
58
58
|
for (const file of files) {
|
|
59
59
|
const content = fs.readFileSync(file, "utf8");
|
|
60
|
+
// 1. CAPTURE FEATURE TAGS
|
|
61
|
+
// Loose Regex: Matches any lines starting with @ above "Feature:"
|
|
62
|
+
const featureTagMatch = content.match(/((?:@\S+\s*)+)Feature:/);
|
|
63
|
+
const rawFeatureTags = featureTagMatch ? featureTagMatch[1] : "";
|
|
64
|
+
const featureTags = rawFeatureTags.replace(/[\r\n]+/g, " ").trim();
|
|
60
65
|
const featureMatch = content.match(/Feature:\s*(.+)/);
|
|
61
66
|
const featureName = featureMatch
|
|
62
67
|
? featureMatch[1].trim()
|
|
63
68
|
: "Unnamed Feature";
|
|
64
69
|
test_1.test.describe(featureName, () => {
|
|
65
|
-
//
|
|
66
|
-
|
|
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;
|
|
67
74
|
let match;
|
|
75
|
+
let foundCount = 0;
|
|
68
76
|
while ((match = scenarioRegex.exec(content)) !== null) {
|
|
69
|
-
|
|
77
|
+
foundCount++;
|
|
78
|
+
const rawScenarioTags = match[1] || "";
|
|
79
|
+
const scenarioTags = rawScenarioTags.replace(/[\r\n]+/g, " ").trim();
|
|
70
80
|
const scenarioName = match[2].trim();
|
|
71
|
-
//
|
|
72
|
-
const
|
|
73
|
-
|
|
81
|
+
// 3. MERGE TAGS
|
|
82
|
+
const combinedTags = `${featureTags} ${scenarioTags}`.trim();
|
|
83
|
+
const fullName = combinedTags
|
|
84
|
+
? `${scenarioName} ${combinedTags}`
|
|
74
85
|
: scenarioName;
|
|
75
|
-
//
|
|
86
|
+
// DEBUG LOG: See what we found
|
|
87
|
+
// console.log(` 👉 Found: "${scenarioName}" [Tags: ${combinedTags}]`);
|
|
88
|
+
// 4. ENV FILTERING (Optional)
|
|
76
89
|
const activeFilter = options?.tags || envTag;
|
|
77
90
|
if (activeFilter) {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
if (!isMatch)
|
|
84
|
-
continue;
|
|
85
|
-
}
|
|
91
|
+
const targetGroups = activeFilter.split(",").map((t) => t.trim());
|
|
92
|
+
const isMatch = targetGroups.some((group) => {
|
|
93
|
+
const requiredTags = group.split("+").map((t) => t.trim());
|
|
94
|
+
return requiredTags.every((t) => combinedTags.includes(t));
|
|
95
|
+
});
|
|
96
|
+
if (!isMatch)
|
|
97
|
+
continue;
|
|
86
98
|
}
|
|
87
99
|
const startIndex = match.index + match[0].length;
|
|
88
|
-
const nextMatchIndex = content
|
|
100
|
+
const nextMatchIndex = content
|
|
101
|
+
.slice(startIndex)
|
|
102
|
+
.search(/(?:Scenario|Scenario Outline):/);
|
|
89
103
|
const blockEnd = nextMatchIndex === -1 ? content.length : startIndex + nextMatchIndex;
|
|
90
104
|
const scenarioBlock = content.slice(startIndex, blockEnd);
|
|
91
105
|
(0, test_1.test)(fullName, async ({ page }, testInfo) => {
|
|
@@ -100,6 +114,7 @@ function runTests(featureGlob, options) {
|
|
|
100
114
|
stepText.startsWith("@") ||
|
|
101
115
|
stepText === "")
|
|
102
116
|
continue;
|
|
117
|
+
// Handle Data Tables
|
|
103
118
|
const tableData = [];
|
|
104
119
|
while (i + 1 < lines.length && lines[i + 1].startsWith("|")) {
|
|
105
120
|
i++;
|
|
@@ -138,6 +153,11 @@ function runTests(featureGlob, options) {
|
|
|
138
153
|
}
|
|
139
154
|
});
|
|
140
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
|
+
}
|
|
141
161
|
});
|
|
142
162
|
}
|
|
143
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.
|
|
4
|
+
"version": "1.1.6",
|
|
5
5
|
"private": false,
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"types": "dist/index.d.ts",
|