playwright-cucumber-ts-steps 1.1.4 → 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/dist/core/runner.d.ts.map +1 -1
- package/dist/core/runner.js +29 -18
- 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,QA2HpE"}
|
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,37 +51,49 @@ 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;
|
|
58
55
|
for (const file of files) {
|
|
59
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();
|
|
60
63
|
const featureMatch = content.match(/Feature:\s*(.+)/);
|
|
61
64
|
const featureName = featureMatch
|
|
62
65
|
? featureMatch[1].trim()
|
|
63
66
|
: "Unnamed Feature";
|
|
64
67
|
test_1.test.describe(featureName, () => {
|
|
65
|
-
//
|
|
66
|
-
|
|
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
|
|
73
|
+
const rawScenarioTags = match[1] || "";
|
|
74
|
+
const scenarioTags = rawScenarioTags.replace(/[\r\n]+/g, " ").trim();
|
|
70
75
|
const scenarioName = match[2].trim();
|
|
71
|
-
//
|
|
72
|
-
|
|
73
|
-
|
|
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
|
-
//
|
|
86
|
+
// 5. CUSTOM FILTERING (Optional - if using TAGS env var)
|
|
76
87
|
const activeFilter = options?.tags || envTag;
|
|
77
88
|
if (activeFilter) {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
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));
|
|
94
|
+
});
|
|
95
|
+
if (!isMatch)
|
|
96
|
+
continue;
|
|
86
97
|
}
|
|
87
98
|
const startIndex = match.index + match[0].length;
|
|
88
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.
|
|
4
|
+
"version": "1.1.5",
|
|
5
5
|
"private": false,
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"types": "dist/index.d.ts",
|