playwright-cucumber-ts-steps 1.3.2 → 1.3.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.
Files changed (81) hide show
  1. package/README.md +358 -671
  2. package/dist/backend/actions/click.d.ts +29 -29
  3. package/dist/backend/actions/click.js +29 -29
  4. package/dist/backend/actions/form.d.ts +2 -2
  5. package/dist/backend/actions/form.js +2 -2
  6. package/dist/backend/actions/formTable.d.ts +1 -1
  7. package/dist/backend/actions/formTable.js +1 -1
  8. package/dist/backend/actions/frames.d.ts +3 -3
  9. package/dist/backend/actions/frames.js +3 -3
  10. package/dist/backend/actions/inputs.d.ts +14 -14
  11. package/dist/backend/actions/inputs.js +14 -14
  12. package/dist/backend/actions/interactions.d.ts +7 -7
  13. package/dist/backend/actions/interactions.js +7 -7
  14. package/dist/backend/actions/keyboard.d.ts +6 -6
  15. package/dist/backend/actions/keyboard.js +6 -6
  16. package/dist/backend/actions/misc.d.ts +15 -15
  17. package/dist/backend/actions/misc.js +15 -15
  18. package/dist/backend/actions/mobile.d.ts +7 -7
  19. package/dist/backend/actions/mobile.js +7 -7
  20. package/dist/backend/actions/mouse.d.ts +9 -9
  21. package/dist/backend/actions/mouse.js +9 -9
  22. package/dist/backend/actions/navigation.d.ts +5 -5
  23. package/dist/backend/actions/navigation.js +5 -5
  24. package/dist/backend/actions/visual.d.ts +6 -6
  25. package/dist/backend/actions/visual.js +6 -6
  26. package/dist/backend/actions/waits.d.ts +6 -6
  27. package/dist/backend/actions/waits.js +6 -6
  28. package/dist/backend/api/assertions.d.ts +64 -4
  29. package/dist/backend/api/assertions.d.ts.map +1 -1
  30. package/dist/backend/api/assertions.js +205 -5
  31. package/dist/backend/api/mock.d.ts +3 -3
  32. package/dist/backend/api/mock.js +3 -3
  33. package/dist/backend/api/network.d.ts +6 -6
  34. package/dist/backend/api/network.js +6 -6
  35. package/dist/backend/api/requests.d.ts +4 -4
  36. package/dist/backend/api/requests.js +4 -4
  37. package/dist/backend/assertions/document.d.ts +10 -10
  38. package/dist/backend/assertions/document.js +10 -10
  39. package/dist/backend/assertions/elements.d.ts +28 -28
  40. package/dist/backend/assertions/elements.js +28 -28
  41. package/dist/backend/assertions/expectVisible.d.ts +1 -1
  42. package/dist/backend/assertions/expectVisible.js +1 -1
  43. package/dist/backend/assertions/forms.d.ts +7 -7
  44. package/dist/backend/assertions/forms.js +7 -7
  45. package/dist/backend/assertions/pageState.d.ts +4 -4
  46. package/dist/backend/assertions/pageState.js +4 -4
  47. package/dist/backend/assertions/storage.d.ts +11 -11
  48. package/dist/backend/assertions/storage.js +11 -11
  49. package/dist/backend/assertions/text.d.ts +17 -17
  50. package/dist/backend/assertions/text.js +17 -17
  51. package/dist/backend/assertions/visibility.d.ts +15 -15
  52. package/dist/backend/assertions/visibility.js +15 -15
  53. package/dist/backend/auth/index.d.ts +2 -2
  54. package/dist/backend/auth/index.js +2 -2
  55. package/dist/backend/db/steps.d.ts +9 -9
  56. package/dist/backend/db/steps.js +9 -9
  57. package/dist/backend/elements/alerts.d.ts +3 -3
  58. package/dist/backend/elements/alerts.js +3 -3
  59. package/dist/backend/elements/find.d.ts +15 -15
  60. package/dist/backend/elements/find.js +15 -15
  61. package/dist/backend/elements/forms.d.ts +4 -4
  62. package/dist/backend/elements/forms.js +4 -4
  63. package/dist/backend/elements/frames.d.ts +3 -3
  64. package/dist/backend/elements/frames.js +3 -3
  65. package/dist/backend/utils/faker.d.ts +2 -0
  66. package/dist/backend/utils/faker.d.ts.map +1 -0
  67. package/dist/backend/utils/faker.js +510 -0
  68. package/dist/backend/utils/fixtures.d.ts +44 -2
  69. package/dist/backend/utils/fixtures.d.ts.map +1 -1
  70. package/dist/backend/utils/fixtures.js +321 -5
  71. package/dist/backend/utils/resolver.d.ts +13 -0
  72. package/dist/backend/utils/resolver.d.ts.map +1 -1
  73. package/dist/backend/utils/resolver.js +55 -0
  74. package/dist/core/runner.d.ts +1 -0
  75. package/dist/core/runner.d.ts.map +1 -1
  76. package/dist/core/runner.js +1 -0
  77. package/dist/index.d.ts +1 -0
  78. package/dist/index.d.ts.map +1 -1
  79. package/dist/index.js +4 -1
  80. package/dist/metadata.json +49 -1
  81. package/package.json +4 -2
@@ -1,38 +1,260 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ var __importDefault = (this && this.__importDefault) || function (mod) {
36
+ return (mod && mod.__esModule) ? mod : { "default": mod };
37
+ };
2
38
  Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.setFixtureConfig = setFixtureConfig;
40
+ exports.resolveEnvVariable = resolveEnvVariable;
3
41
  exports.loadFixture = loadFixture;
4
42
  exports.getFixtureValue = getFixtureValue;
43
+ exports.resolveAliasInValue = resolveAliasInValue;
5
44
  //src/backend/utils/fixtures.ts
6
45
  const fs_1 = require("fs");
7
46
  const path_1 = require("path");
47
+ const dotenv_1 = __importDefault(require("dotenv"));
48
+ /**
49
+ * Global fixture configuration.
50
+ * Can be overridden via setFixtureConfig() from playwright.config.ts
51
+ */
52
+ let fixtureConfig = {
53
+ projectRoot: undefined,
54
+ fixturesDir: "fixtures",
55
+ };
56
+ /**
57
+ * Cached environment variables loaded from .env file
58
+ */
59
+ let envVariables = {};
60
+ /**
61
+ * Sets the fixture configuration from playwright.config.ts
62
+ * @param config - The fixture configuration object
63
+ */
64
+ function setFixtureConfig(config) {
65
+ if (config.projectRoot) {
66
+ fixtureConfig.projectRoot = config.projectRoot;
67
+ }
68
+ if (config.fixturesDir) {
69
+ fixtureConfig.fixturesDir = config.fixturesDir;
70
+ }
71
+ if (config.selectorsFile) {
72
+ fixtureConfig.selectorsFile = config.selectorsFile;
73
+ }
74
+ if (config.textsFile) {
75
+ fixtureConfig.textsFile = config.textsFile;
76
+ }
77
+ if (config.valuesFile) {
78
+ fixtureConfig.valuesFile = config.valuesFile;
79
+ }
80
+ if (config.optionsFile) {
81
+ fixtureConfig.optionsFile = config.optionsFile;
82
+ }
83
+ if (config.endpointsFile) {
84
+ fixtureConfig.endpointsFile = config.endpointsFile;
85
+ }
86
+ if (config.filesFile) {
87
+ fixtureConfig.filesFile = config.filesFile;
88
+ }
89
+ if (config.pathsFile) {
90
+ fixtureConfig.pathsFile = config.pathsFile;
91
+ }
92
+ if (config.responsesFile) {
93
+ fixtureConfig.responsesFile = config.responsesFile;
94
+ }
95
+ if (config.queriesFile) {
96
+ fixtureConfig.queriesFile = config.queriesFile;
97
+ }
98
+ if (config.columnsFile) {
99
+ fixtureConfig.columnsFile = config.columnsFile;
100
+ }
101
+ if (config.typesFile) {
102
+ fixtureConfig.typesFile = config.typesFile;
103
+ }
104
+ if (config.titlesFile) {
105
+ fixtureConfig.titlesFile = config.titlesFile;
106
+ }
107
+ if (config.urlsFile) {
108
+ fixtureConfig.urlsFile = config.urlsFile;
109
+ }
110
+ if (config.attributesFile) {
111
+ fixtureConfig.attributesFile = config.attributesFile;
112
+ }
113
+ if (config.promptsFile) {
114
+ fixtureConfig.promptsFile = config.promptsFile;
115
+ }
116
+ if (config.envFile) {
117
+ fixtureConfig.envFile = config.envFile;
118
+ // Load environment variables from custom .env file
119
+ const baseDir = fixtureConfig.projectRoot || process.cwd();
120
+ const envPath = (0, path_1.resolve)(baseDir, config.envFile);
121
+ try {
122
+ const envConfig = dotenv_1.default.config({ path: envPath });
123
+ if (envConfig.parsed) {
124
+ // Filter out undefined values
125
+ envVariables = Object.entries({ ...process.env, ...envConfig.parsed })
126
+ .reduce((acc, [key, value]) => {
127
+ if (value !== undefined) {
128
+ acc[key] = value;
129
+ }
130
+ return acc;
131
+ }, {});
132
+ console.log(`✅ Loaded environment variables from "${envPath}"`);
133
+ }
134
+ }
135
+ catch (_error) {
136
+ console.warn(`⚠️ Failed to load .env file from "${envPath}". Using process.env only.`);
137
+ // Filter out undefined values
138
+ envVariables = Object.entries(process.env)
139
+ .reduce((acc, [key, value]) => {
140
+ if (value !== undefined) {
141
+ acc[key] = value;
142
+ }
143
+ return acc;
144
+ }, {});
145
+ }
146
+ }
147
+ else {
148
+ // Load default .env file from project root
149
+ const baseDir = fixtureConfig.projectRoot || process.cwd();
150
+ const defaultEnvPath = (0, path_1.resolve)(baseDir, ".env");
151
+ try {
152
+ const envConfig = dotenv_1.default.config({ path: defaultEnvPath });
153
+ if (envConfig.parsed) {
154
+ // Filter out undefined values
155
+ envVariables = Object.entries({ ...process.env, ...envConfig.parsed })
156
+ .reduce((acc, [key, value]) => {
157
+ if (value !== undefined) {
158
+ acc[key] = value;
159
+ }
160
+ return acc;
161
+ }, {});
162
+ }
163
+ else {
164
+ // Filter out undefined values
165
+ envVariables = Object.entries(process.env)
166
+ .reduce((acc, [key, value]) => {
167
+ if (value !== undefined) {
168
+ acc[key] = value;
169
+ }
170
+ return acc;
171
+ }, {});
172
+ }
173
+ }
174
+ catch (_error) {
175
+ // Filter out undefined values
176
+ envVariables = Object.entries(process.env)
177
+ .reduce((acc, [key, value]) => {
178
+ if (value !== undefined) {
179
+ acc[key] = value;
180
+ }
181
+ return acc;
182
+ }, {});
183
+ }
184
+ }
185
+ }
186
+ /**
187
+ * Resolves environment variable placeholders in a string.
188
+ * Supports {{VARIABLE_NAME}} syntax for environment variables.
189
+ * Also supports @alias syntax for runtime variables stored in page state.
190
+ * @param value - The value that may contain placeholders
191
+ * @returns The resolved value with placeholders replaced
192
+ */
193
+ function resolveEnvVariable(value) {
194
+ if (typeof value !== 'string') {
195
+ return value;
196
+ }
197
+ // Match {{VARIABLE_NAME}} pattern
198
+ const envVarPattern = /\{\{([^}]+)\}\}/g;
199
+ return value.replace(envVarPattern, (match, varName) => {
200
+ const trimmedVarName = varName.trim();
201
+ const envValue = envVariables[trimmedVarName];
202
+ if (envValue === undefined) {
203
+ console.warn(`⚠️ Environment variable "${trimmedVarName}" not found. Using literal value.`);
204
+ return match; // Return original placeholder if not found
205
+ }
206
+ return envValue;
207
+ });
208
+ }
209
+ /**
210
+ * Resolves the actual file name for a given fixture type.
211
+ * Uses custom file name if configured, otherwise defaults to the standard name.
212
+ * @param fileName - The default/standard fixture file name
213
+ * @returns The configured file name or the default if not configured
214
+ */
215
+ function resolveFileName(fileName) {
216
+ const configKey = fileName.replace(".json", "") + "File";
217
+ const customFile = fixtureConfig[configKey];
218
+ return customFile || fileName;
219
+ }
8
220
  /**
9
221
  * Loads a JSON fixture file from the test project's fixtures directory.
10
- * Looks in the current working directory (test project root).
222
+ * Looks in the current working directory (test project root) or custom projectRoot if configured.
11
223
  * @param fileName - Name of the fixture file (e.g., "selectors.json").
12
224
  * @returns Parsed JSON object.
13
225
  */
14
226
  function loadFixture(fileName) {
15
227
  try {
16
- const fixturePath = (0, path_1.resolve)(process.cwd(), "fixtures", fileName);
228
+ const actualFileName = resolveFileName(fileName);
229
+ // Use projectRoot if configured (for monorepo support), otherwise use cwd
230
+ const baseDir = fixtureConfig.projectRoot || process.cwd();
231
+ const fixturePath = (0, path_1.resolve)(baseDir, fixtureConfig.fixturesDir, actualFileName);
17
232
  const content = (0, fs_1.readFileSync)(fixturePath, "utf8");
18
233
  return JSON.parse(content);
19
234
  }
20
235
  catch (_error) {
21
236
  // Return empty object for optional fixtures
22
- console.warn(`⚠️ Fixture "${fileName}" not found in project root. Proceeding with empty object.`);
237
+ const baseDir = fixtureConfig.projectRoot || process.cwd();
238
+ console.warn(`⚠️ Fixture "${fileName}" not found in "${baseDir}/${fixtureConfig.fixturesDir}". Proceeding with empty object.`);
23
239
  return {};
24
240
  }
25
241
  }
26
242
  /**
27
243
  * Retrieves a specific value from a loaded fixture.
28
244
  * Returns the raw key if fixture or key is not found (fallback to raw selector).
245
+ * Also resolves environment variable placeholders {{VARIABLE_NAME}} in the returned value.
246
+ * For @alias resolution, use resolveAliasInValue() after getting the value.
29
247
  * @param fixture - The loaded fixture object.
30
248
  * @param keyPath - Dot-separated path to the desired value (e.g., "login.usernameField").
31
- * @returns The value at the specified key path, or the keyPath itself if not found.
249
+ * @returns The value at the specified key path with env vars resolved, or the keyPath itself if not found.
32
250
  */
33
251
  function getFixtureValue(fixture, keyPath) {
34
- // If fixture is empty, return the keyPath as-is (fallback to raw selector)
252
+ // If fixture is empty, check if keyPath is an env variable placeholder
35
253
  if (Object.keys(fixture).length === 0) {
254
+ // Check if it's an env variable placeholder {{VAR}}
255
+ if (keyPath.includes('{{') && keyPath.includes('}}')) {
256
+ return resolveEnvVariable(keyPath);
257
+ }
36
258
  return keyPath;
37
259
  }
38
260
  const keys = keyPath.split(".");
@@ -42,10 +264,104 @@ function getFixtureValue(fixture, keyPath) {
42
264
  value = value[key];
43
265
  }
44
266
  else {
267
+ // If key not found in fixture, check if keyPath is an env variable
268
+ if (keyPath.includes('{{') && keyPath.includes('}}')) {
269
+ return resolveEnvVariable(keyPath);
270
+ }
45
271
  // If key not found in fixture, return the original keyPath (fallback)
46
272
  console.warn(`⚠️ Key "${keyPath}" not found in fixture. Using raw value.`);
47
273
  return keyPath;
48
274
  }
49
275
  }
276
+ // Resolve environment variable placeholders in the value (supports strings, objects, and arrays)
277
+ return resolveEnvVarsInValue(value);
278
+ }
279
+ /**
280
+ * Resolves environment variables in a value recursively (supports strings, objects, and arrays).
281
+ * @param value - The value to resolve
282
+ * @returns The value with {{ENV_VAR}} placeholders resolved
283
+ */
284
+ function resolveEnvVarsInValue(value) {
285
+ // Handle strings
286
+ if (typeof value === 'string') {
287
+ return resolveEnvVariable(value);
288
+ }
289
+ // Handle arrays
290
+ if (Array.isArray(value)) {
291
+ return value.map(item => resolveEnvVarsInValue(item));
292
+ }
293
+ // Handle objects
294
+ if (value !== null && typeof value === 'object') {
295
+ const resolved = {};
296
+ for (const [key, val] of Object.entries(value)) {
297
+ resolved[key] = resolveEnvVarsInValue(val);
298
+ }
299
+ return resolved;
300
+ }
301
+ // Return primitives as-is
302
+ return value;
303
+ }
304
+ /**
305
+ * Resolves @alias references in a string value using runtime variables from page state.
306
+ * This should be called after getFixtureValue() when you need @alias support.
307
+ * @param value - The value that may contain @alias references
308
+ * @param page - The Playwright page object
309
+ * @returns The value with @alias placeholders resolved
310
+ */
311
+ async function resolveAliasInValue(value, page) {
312
+ // Handle strings
313
+ if (typeof value === 'string') {
314
+ // Match @alias pattern (word characters after @)
315
+ const aliasPattern = /@([a-zA-Z_][a-zA-Z0-9_]*)/g;
316
+ const matches = [...value.matchAll(aliasPattern)];
317
+ let result = value;
318
+ // Process in reverse to preserve indices
319
+ for (const match of matches.reverse()) {
320
+ const aliasKey = match[1];
321
+ let replacement = null;
322
+ // Try to get from page state
323
+ try {
324
+ const stateModule = await Promise.resolve().then(() => __importStar(require('./state')));
325
+ const storedValue = stateModule.getVariable(page, aliasKey);
326
+ if (storedValue !== undefined) {
327
+ replacement = String(storedValue);
328
+ }
329
+ }
330
+ catch (_error) {
331
+ // Continue with env var check
332
+ }
333
+ // Check environment variables if not found in page state
334
+ if (replacement === null) {
335
+ const envValue = envVariables[aliasKey];
336
+ if (envValue !== undefined) {
337
+ replacement = envValue;
338
+ }
339
+ }
340
+ // Replace if found
341
+ if (replacement !== null) {
342
+ result = result.substring(0, match.index) +
343
+ replacement +
344
+ result.substring(match.index + match[0].length);
345
+ }
346
+ }
347
+ return result;
348
+ }
349
+ // Handle arrays
350
+ if (Array.isArray(value)) {
351
+ const resolvedArray = [];
352
+ for (const item of value) {
353
+ resolvedArray.push(await resolveAliasInValue(item, page));
354
+ }
355
+ return resolvedArray;
356
+ }
357
+ // Handle objects
358
+ if (value !== null && typeof value === 'object') {
359
+ const resolved = {};
360
+ for (const [key, val] of Object.entries(value)) {
361
+ resolved[key] = await resolveAliasInValue(val, page);
362
+ }
363
+ return resolved;
364
+ }
365
+ // Return primitives as-is
50
366
  return value;
51
367
  }
@@ -1,6 +1,19 @@
1
1
  /**
2
2
  * Resolves a parameter by checking if it's a key in a fixture file.
3
3
  * If the fixture doesn't exist or the key isn't found, it returns the raw string.
4
+ * Also resolves environment variable placeholders {{VARIABLE_NAME}}.
5
+ * For @alias resolution, use resolveAliasInParam() instead.
6
+ * @param key - The key to resolve (can be a fixture key or {{ENV_VAR}})
7
+ * @param fixtureFile - The fixture file to load (e.g., "selectors.json")
8
+ * @returns The resolved value
4
9
  */
5
10
  export declare function resolveParam(key: string, fixtureFile: string): string;
11
+ /**
12
+ * Resolves @alias references in a parameter value using runtime variables from page state.
13
+ * Call this after resolveParam() if you need @alias support.
14
+ * @param value - The value that may contain @alias references
15
+ * @param page - The Playwright page object
16
+ * @returns The value with @alias placeholders resolved
17
+ */
18
+ export declare function resolveAliasInParam(value: any, page: any): Promise<any>;
6
19
  //# sourceMappingURL=resolver.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"resolver.d.ts","sourceRoot":"","sources":["../../../src/backend/utils/resolver.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,MAAM,CASrE"}
1
+ {"version":3,"file":"resolver.d.ts","sourceRoot":"","sources":["../../../src/backend/utils/resolver.ts"],"names":[],"mappings":"AAEA;;;;;;;;GAQG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,MAAM,CAcrE;AAED;;;;;;GAMG;AACH,wBAAsB,mBAAmB,CAAC,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,CAG7E"}
@@ -1,19 +1,74 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
2
35
  Object.defineProperty(exports, "__esModule", { value: true });
3
36
  exports.resolveParam = resolveParam;
37
+ exports.resolveAliasInParam = resolveAliasInParam;
4
38
  const fixtures_1 = require("./fixtures");
5
39
  /**
6
40
  * Resolves a parameter by checking if it's a key in a fixture file.
7
41
  * If the fixture doesn't exist or the key isn't found, it returns the raw string.
42
+ * Also resolves environment variable placeholders {{VARIABLE_NAME}}.
43
+ * For @alias resolution, use resolveAliasInParam() instead.
44
+ * @param key - The key to resolve (can be a fixture key or {{ENV_VAR}})
45
+ * @param fixtureFile - The fixture file to load (e.g., "selectors.json")
46
+ * @returns The resolved value
8
47
  */
9
48
  function resolveParam(key, fixtureFile) {
10
49
  try {
11
50
  const fixture = (0, fixtures_1.loadFixture)(fixtureFile);
12
51
  // getFixtureValue handles the logic of returning the raw key if the value isn't found
52
+ // and resolves {{ENV_VAR}} placeholders
13
53
  return (0, fixtures_1.getFixtureValue)(fixture, key);
14
54
  }
15
55
  catch (_error) {
16
56
  // If fixture file is missing, fallback to the raw string
57
+ // But still resolve environment variables
58
+ if (key.includes('{{') && key.includes('}}')) {
59
+ return (0, fixtures_1.resolveEnvVariable)(key);
60
+ }
17
61
  return key;
18
62
  }
19
63
  }
64
+ /**
65
+ * Resolves @alias references in a parameter value using runtime variables from page state.
66
+ * Call this after resolveParam() if you need @alias support.
67
+ * @param value - The value that may contain @alias references
68
+ * @param page - The Playwright page object
69
+ * @returns The value with @alias placeholders resolved
70
+ */
71
+ async function resolveAliasInParam(value, page) {
72
+ const fixturesModule = await Promise.resolve().then(() => __importStar(require('./fixtures')));
73
+ return fixturesModule.resolveAliasInValue(value, page);
74
+ }
@@ -4,6 +4,7 @@ import "../backend/elements/index";
4
4
  import "../backend/api/index";
5
5
  import "../backend/auth/index";
6
6
  import "../backend/utils/state";
7
+ import "../backend/utils/faker";
7
8
  import "../backend/db/index";
8
9
  export interface RunnerOptions {
9
10
  tags?: string;
@@ -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;AAC/B,OAAO,wBAAwB,CAAC;AAChC,OAAO,qBAAqB,CAAC;AAG7B,MAAM,WAAW,aAAa;IAC5B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,GAAG,CAAC,CAAC;CAC3C;AA8FD,wBAAgB,QAAQ,CAAC,WAAW,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,aAAa,QA8LpE"}
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;AAC/B,OAAO,wBAAwB,CAAC;AAChC,OAAO,wBAAwB,CAAC;AAChC,OAAO,qBAAqB,CAAC;AAG7B,MAAM,WAAW,aAAa;IAC5B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,GAAG,CAAC,CAAC;CAC3C;AA8FD,wBAAgB,QAAQ,CAAC,WAAW,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,aAAa,QA8LpE"}
@@ -46,6 +46,7 @@ require("../backend/elements/index");
46
46
  require("../backend/api/index");
47
47
  require("../backend/auth/index");
48
48
  require("../backend/utils/state");
49
+ require("../backend/utils/faker");
49
50
  require("../backend/db/index");
50
51
  /**
51
52
  * Parses a block of Gherkin lines into structured steps.
package/dist/index.d.ts CHANGED
@@ -2,6 +2,7 @@ export { runTests } from "./core/runner";
2
2
  export { Step } from "./core/registry";
3
3
  export { getReporters } from "./reporting/index";
4
4
  export { runComponentTests } from "./component/index";
5
+ export { setFixtureConfig, resolveEnvVariable } from "./backend/utils/fixtures";
5
6
  export type { RunnerOptions } from "./core/runner";
6
7
  export type { ReportOptions } from "./reporting/index";
7
8
  export type { StepAction } from "./core/registry";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AACvC,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAGtD,YAAY,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AACnD,YAAY,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AACvD,YAAY,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAClD,YAAY,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AACvC,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAGhF,YAAY,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AACnD,YAAY,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AACvD,YAAY,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAClD,YAAY,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC"}
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.runComponentTests = exports.getReporters = exports.Step = exports.runTests = void 0;
3
+ exports.resolveEnvVariable = exports.setFixtureConfig = exports.runComponentTests = exports.getReporters = exports.Step = exports.runTests = void 0;
4
4
  var runner_1 = require("./core/runner");
5
5
  Object.defineProperty(exports, "runTests", { enumerable: true, get: function () { return runner_1.runTests; } });
6
6
  var registry_1 = require("./core/registry");
@@ -9,3 +9,6 @@ var index_1 = require("./reporting/index");
9
9
  Object.defineProperty(exports, "getReporters", { enumerable: true, get: function () { return index_1.getReporters; } });
10
10
  var index_2 = require("./component/index");
11
11
  Object.defineProperty(exports, "runComponentTests", { enumerable: true, get: function () { return index_2.runComponentTests; } });
12
+ var fixtures_1 = require("./backend/utils/fixtures");
13
+ Object.defineProperty(exports, "setFixtureConfig", { enumerable: true, get: function () { return fixtures_1.setFixtureConfig; } });
14
+ Object.defineProperty(exports, "resolveEnvVariable", { enumerable: true, get: function () { return fixtures_1.resolveEnvVariable; } });
@@ -472,17 +472,65 @@
472
472
  "type": "When"
473
473
  },
474
474
  {
475
- "pattern": "I pw expect the response status to be {int}",
475
+ "pattern": "I pw expect the response status to be {string}",
476
+ "type": "Then"
477
+ },
478
+ {
479
+ "pattern": "I pw expect the response status to be successful",
476
480
  "type": "Then"
477
481
  },
478
482
  {
479
483
  "pattern": "I pw expect the response body to contain {string}",
480
484
  "type": "Then"
481
485
  },
486
+ {
487
+ "pattern": "I pw expect the response body to not contain {string}",
488
+ "type": "Then"
489
+ },
490
+ {
491
+ "pattern": "I pw expect the response body to equal {string}",
492
+ "type": "Then"
493
+ },
482
494
  {
483
495
  "pattern": "I pw expect the response property {string} to be {string}",
484
496
  "type": "Then"
485
497
  },
498
+ {
499
+ "pattern": "I pw store response property {string} value as {string}",
500
+ "type": "When"
501
+ },
502
+ {
503
+ "pattern": "I pw expect response property {string} to exist",
504
+ "type": "Then"
505
+ },
506
+ {
507
+ "pattern": "I pw expect response property {string} to not exist",
508
+ "type": "Then"
509
+ },
510
+ {
511
+ "pattern": "I pw expect response property {string} to be null",
512
+ "type": "Then"
513
+ },
514
+ {
515
+ "pattern": "I pw expect response property {string} to not be null",
516
+ "type": "Then"
517
+ },
518
+ {
519
+ "pattern": "I pw expect response property {string} to contain {string}",
520
+ "type": "Then"
521
+ },
522
+ {
523
+ "pattern": "I pw expect response property {string} array length to be {int}",
524
+ "type": "Then"
525
+ },
526
+ {
527
+ "pattern": "I pw expect response property {string} array to not be empty",
528
+ "type": "Then"
529
+ },
530
+ {
531
+ "pattern": "I pw fill {string} with stored value {string}",
532
+ "type": "When"
533
+ },
486
534
  {
487
535
  "pattern": "I pw mock the API endpoint {string} with body {string}",
488
536
  "type": "When"
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.3.2",
4
+ "version": "1.3.4",
5
5
  "private": false,
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
@@ -100,6 +100,8 @@
100
100
  "@cucumber/cucumber-expressions": "^17.1.0",
101
101
  "@cucumber/gherkin": "^27.0.0",
102
102
  "@cucumber/messages": "^22.0.0",
103
+ "@faker-js/faker": "^10.3.0",
104
+ "dotenv": "^17.3.1",
103
105
  "glob": "^10.3.10"
104
106
  }
105
- }
107
+ }