playwright-cucumber-ts-steps 1.3.3 → 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.
- package/dist/backend/api/assertions.d.ts +61 -1
- package/dist/backend/api/assertions.d.ts.map +1 -1
- package/dist/backend/api/assertions.js +202 -2
- package/dist/backend/utils/faker.d.ts +2 -0
- package/dist/backend/utils/faker.d.ts.map +1 -0
- package/dist/backend/utils/faker.js +510 -0
- package/dist/backend/utils/fixtures.d.ts +22 -2
- package/dist/backend/utils/fixtures.d.ts.map +1 -1
- package/dist/backend/utils/fixtures.js +247 -5
- package/dist/backend/utils/resolver.d.ts +13 -0
- package/dist/backend/utils/resolver.d.ts.map +1 -1
- package/dist/backend/utils/resolver.js +55 -0
- package/dist/core/runner.d.ts +1 -0
- package/dist/core/runner.d.ts.map +1 -1
- package/dist/core/runner.js +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/metadata.json +49 -1
- package/package.json +4 -2
|
@@ -0,0 +1,510 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
//src/backend/utils/faker.ts
|
|
4
|
+
const faker_1 = require("@faker-js/faker");
|
|
5
|
+
const registry_1 = require("../../core/registry");
|
|
6
|
+
const state_1 = require("./state");
|
|
7
|
+
// ==================================================
|
|
8
|
+
// HELPER FUNCTIONS
|
|
9
|
+
// ==================================================
|
|
10
|
+
/**
|
|
11
|
+
* Stores a generated value in the page state and logs it.
|
|
12
|
+
* @param page - The Playwright page object
|
|
13
|
+
* @param alias - The alias to store the value under
|
|
14
|
+
* @param value - The generated value
|
|
15
|
+
* @param label - A descriptive label for logging
|
|
16
|
+
*/
|
|
17
|
+
function storeGeneratedValue(page, alias, value, label) {
|
|
18
|
+
(0, state_1.setVariable)(page, alias, value);
|
|
19
|
+
console.log(`🎭 Generated ${label}: "${value}" (stored as @${alias})`);
|
|
20
|
+
}
|
|
21
|
+
// ==================================================
|
|
22
|
+
// NAME GENERATORS
|
|
23
|
+
// ==================================================
|
|
24
|
+
/**
|
|
25
|
+
* Generates a random first name.
|
|
26
|
+
* @example When I pw generate first name as "firstName"
|
|
27
|
+
*/
|
|
28
|
+
(0, registry_1.Step)("I pw generate first name as {string}", async (page, alias) => {
|
|
29
|
+
const value = faker_1.faker.person.firstName();
|
|
30
|
+
storeGeneratedValue(page, alias, value, "first name");
|
|
31
|
+
});
|
|
32
|
+
/**
|
|
33
|
+
* Generates a random last name.
|
|
34
|
+
* @example When I pw generate last name as "lastName"
|
|
35
|
+
*/
|
|
36
|
+
(0, registry_1.Step)("I pw generate last name as {string}", async (page, alias) => {
|
|
37
|
+
const value = faker_1.faker.person.lastName();
|
|
38
|
+
storeGeneratedValue(page, alias, value, "last name");
|
|
39
|
+
});
|
|
40
|
+
/**
|
|
41
|
+
* Generates a random full name.
|
|
42
|
+
* @example When I pw generate full name as "fullName"
|
|
43
|
+
*/
|
|
44
|
+
(0, registry_1.Step)("I pw generate full name as {string}", async (page, alias) => {
|
|
45
|
+
const value = faker_1.faker.person.fullName();
|
|
46
|
+
storeGeneratedValue(page, alias, value, "full name");
|
|
47
|
+
});
|
|
48
|
+
/**
|
|
49
|
+
* Generates a random job title.
|
|
50
|
+
* @example When I pw generate job title as "jobTitle"
|
|
51
|
+
*/
|
|
52
|
+
(0, registry_1.Step)("I pw generate job title as {string}", async (page, alias) => {
|
|
53
|
+
const value = faker_1.faker.person.jobTitle();
|
|
54
|
+
storeGeneratedValue(page, alias, value, "job title");
|
|
55
|
+
});
|
|
56
|
+
// ==================================================
|
|
57
|
+
// TEXT GENERATORS
|
|
58
|
+
// ==================================================
|
|
59
|
+
/**
|
|
60
|
+
* Generates a random word.
|
|
61
|
+
* @example When I pw generate word as "word"
|
|
62
|
+
*/
|
|
63
|
+
(0, registry_1.Step)("I pw generate word as {string}", async (page, alias) => {
|
|
64
|
+
const value = faker_1.faker.lorem.word();
|
|
65
|
+
storeGeneratedValue(page, alias, value, "word");
|
|
66
|
+
});
|
|
67
|
+
/**
|
|
68
|
+
* Generates random words (default: 3).
|
|
69
|
+
* @example When I pw generate {int} words as "words"
|
|
70
|
+
*/
|
|
71
|
+
(0, registry_1.Step)("I pw generate {int} words as {string}", async (page, count, alias) => {
|
|
72
|
+
const value = faker_1.faker.lorem.words(count);
|
|
73
|
+
storeGeneratedValue(page, alias, value, `${count} words`);
|
|
74
|
+
});
|
|
75
|
+
/**
|
|
76
|
+
* Generates a random sentence.
|
|
77
|
+
* @example When I pw generate sentence as "sentence"
|
|
78
|
+
*/
|
|
79
|
+
(0, registry_1.Step)("I pw generate sentence as {string}", async (page, alias) => {
|
|
80
|
+
const value = faker_1.faker.lorem.sentence();
|
|
81
|
+
storeGeneratedValue(page, alias, value, "sentence");
|
|
82
|
+
});
|
|
83
|
+
/**
|
|
84
|
+
* Generates random sentences (default: 2).
|
|
85
|
+
* @example When I pw generate {int} sentences as "sentences"
|
|
86
|
+
*/
|
|
87
|
+
(0, registry_1.Step)("I pw generate {int} sentences as {string}", async (page, count, alias) => {
|
|
88
|
+
const value = faker_1.faker.lorem.sentences(count);
|
|
89
|
+
storeGeneratedValue(page, alias, value, `${count} sentences`);
|
|
90
|
+
});
|
|
91
|
+
/**
|
|
92
|
+
* Generates a short paragraph (1-3 sentences).
|
|
93
|
+
* @example When I pw generate short paragraph as "shortParagraph"
|
|
94
|
+
*/
|
|
95
|
+
(0, registry_1.Step)("I pw generate short paragraph as {string}", async (page, alias) => {
|
|
96
|
+
const value = faker_1.faker.lorem.paragraph({ min: 1, max: 3 });
|
|
97
|
+
storeGeneratedValue(page, alias, value, "short paragraph");
|
|
98
|
+
});
|
|
99
|
+
/**
|
|
100
|
+
* Generates a long paragraph (5-10 sentences).
|
|
101
|
+
* @example When I pw generate long paragraph as "longParagraph"
|
|
102
|
+
*/
|
|
103
|
+
(0, registry_1.Step)("I pw generate long paragraph as {string}", async (page, alias) => {
|
|
104
|
+
const value = faker_1.faker.lorem.paragraph({ min: 5, max: 10 });
|
|
105
|
+
storeGeneratedValue(page, alias, value, "long paragraph");
|
|
106
|
+
});
|
|
107
|
+
/**
|
|
108
|
+
* Generates multiple paragraphs.
|
|
109
|
+
* @example When I pw generate {int} paragraphs as "paragraphs"
|
|
110
|
+
*/
|
|
111
|
+
(0, registry_1.Step)("I pw generate {int} paragraphs as {string}", async (page, count, alias) => {
|
|
112
|
+
const value = faker_1.faker.lorem.paragraphs(count, '\n\n');
|
|
113
|
+
storeGeneratedValue(page, alias, value, `${count} paragraphs`);
|
|
114
|
+
});
|
|
115
|
+
/**
|
|
116
|
+
* Generates random text (lorem ipsum) with specified length in characters.
|
|
117
|
+
* @example When I pw generate text with {int} characters as "loremText"
|
|
118
|
+
*/
|
|
119
|
+
(0, registry_1.Step)("I pw generate text with {int} characters as {string}", async (page, length, alias) => {
|
|
120
|
+
let value = '';
|
|
121
|
+
while (value.length < length) {
|
|
122
|
+
value += faker_1.faker.lorem.word() + ' ';
|
|
123
|
+
}
|
|
124
|
+
value = value.trim().substring(0, length);
|
|
125
|
+
// Ensure exact length by padding if needed
|
|
126
|
+
while (value.length < length) {
|
|
127
|
+
value += 'x';
|
|
128
|
+
}
|
|
129
|
+
storeGeneratedValue(page, alias, value, `text (${length} chars)`);
|
|
130
|
+
});
|
|
131
|
+
// ==================================================
|
|
132
|
+
// NUMBER GENERATORS
|
|
133
|
+
// ==================================================
|
|
134
|
+
/**
|
|
135
|
+
* Generates a random number.
|
|
136
|
+
* @example When I pw generate number as "number"
|
|
137
|
+
*/
|
|
138
|
+
(0, registry_1.Step)("I pw generate number as {string}", async (page, alias) => {
|
|
139
|
+
const value = faker_1.faker.number.int({ min: 0, max: 999999 }).toString();
|
|
140
|
+
storeGeneratedValue(page, alias, value, "number");
|
|
141
|
+
});
|
|
142
|
+
/**
|
|
143
|
+
* Generates a random number between min and max.
|
|
144
|
+
* @example When I pw generate number between {int} and {int} as "randomNumber"
|
|
145
|
+
*/
|
|
146
|
+
(0, registry_1.Step)("I pw generate number between {int} and {int} as {string}", async (page, min, max, alias) => {
|
|
147
|
+
const value = faker_1.faker.number.int({ min, max }).toString();
|
|
148
|
+
storeGeneratedValue(page, alias, value, `number (${min}-${max})`);
|
|
149
|
+
});
|
|
150
|
+
/**
|
|
151
|
+
* Generates a random number with specified digit count.
|
|
152
|
+
* @example When I pw generate 5 digit number as "fiveDigitNumber"
|
|
153
|
+
*/
|
|
154
|
+
(0, registry_1.Step)("I pw generate {int} digit number as {string}", async (page, digitCount, alias) => {
|
|
155
|
+
const min = Math.pow(10, digitCount - 1);
|
|
156
|
+
const max = Math.pow(10, digitCount) - 1;
|
|
157
|
+
const value = faker_1.faker.number.int({ min, max }).toString();
|
|
158
|
+
storeGeneratedValue(page, alias, value, `${digitCount} digit number`);
|
|
159
|
+
});
|
|
160
|
+
/**
|
|
161
|
+
* Generates multiple random numbers.
|
|
162
|
+
* @example When I pw generate {int} numbers as "randomNumbers"
|
|
163
|
+
*/
|
|
164
|
+
(0, registry_1.Step)("I pw generate {int} numbers as {string}", async (page, count, alias) => {
|
|
165
|
+
const numbers = [];
|
|
166
|
+
for (let i = 0; i < count; i++) {
|
|
167
|
+
numbers.push(faker_1.faker.number.int({ min: 0, max: 999999 }));
|
|
168
|
+
}
|
|
169
|
+
const value = numbers.join(',');
|
|
170
|
+
storeGeneratedValue(page, alias, value, `${count} numbers`);
|
|
171
|
+
});
|
|
172
|
+
/**
|
|
173
|
+
* Generates a random digit (0-9).
|
|
174
|
+
* @example When I pw generate digit as "digit"
|
|
175
|
+
*/
|
|
176
|
+
(0, registry_1.Step)("I pw generate digit as {string}", async (page, alias) => {
|
|
177
|
+
const value = faker_1.faker.number.int({ min: 0, max: 9 }).toString();
|
|
178
|
+
storeGeneratedValue(page, alias, value, "digit");
|
|
179
|
+
});
|
|
180
|
+
/**
|
|
181
|
+
* Generates multiple random digits.
|
|
182
|
+
* @example When I pw generate {int} digits as "digits"
|
|
183
|
+
*/
|
|
184
|
+
(0, registry_1.Step)("I pw generate {int} digits as {string}", async (page, count, alias) => {
|
|
185
|
+
let value = '';
|
|
186
|
+
for (let i = 0; i < count; i++) {
|
|
187
|
+
value += faker_1.faker.number.int({ min: 0, max: 9 });
|
|
188
|
+
}
|
|
189
|
+
storeGeneratedValue(page, alias, value, `${count} digits`);
|
|
190
|
+
});
|
|
191
|
+
/**
|
|
192
|
+
* Generates a random float/decimal number.
|
|
193
|
+
* @example When I pw generate float as "floatNumber"
|
|
194
|
+
*/
|
|
195
|
+
(0, registry_1.Step)("I pw generate float as {string}", async (page, alias) => {
|
|
196
|
+
const value = faker_1.faker.number.float({ min: 0, max: 100, fractionDigits: 2 }).toString();
|
|
197
|
+
storeGeneratedValue(page, alias, value, "float");
|
|
198
|
+
});
|
|
199
|
+
// ==================================================
|
|
200
|
+
// STRING GENERATORS
|
|
201
|
+
// ==================================================
|
|
202
|
+
/**
|
|
203
|
+
* Generates a random alphanumeric string.
|
|
204
|
+
* @example When I pw generate alphanumeric as "alphanumeric"
|
|
205
|
+
*/
|
|
206
|
+
(0, registry_1.Step)("I pw generate alphanumeric as {string}", async (page, alias) => {
|
|
207
|
+
const value = faker_1.faker.string.alphanumeric();
|
|
208
|
+
storeGeneratedValue(page, alias, value, "alphanumeric");
|
|
209
|
+
});
|
|
210
|
+
/**
|
|
211
|
+
* Generates an alphanumeric string of specified length.
|
|
212
|
+
* @example When I pw generate alphanumeric with {int} characters as "alphanumeric10"
|
|
213
|
+
*/
|
|
214
|
+
(0, registry_1.Step)("I pw generate alphanumeric with {int} characters as {string}", async (page, length, alias) => {
|
|
215
|
+
const value = faker_1.faker.string.alphanumeric({ length });
|
|
216
|
+
storeGeneratedValue(page, alias, value, `alphanumeric (${length} chars)`);
|
|
217
|
+
});
|
|
218
|
+
/**
|
|
219
|
+
* Generates a random alphabetic string (letters only).
|
|
220
|
+
* @example When I pw generate alpha as "alpha"
|
|
221
|
+
*/
|
|
222
|
+
(0, registry_1.Step)("I pw generate alpha as {string}", async (page, alias) => {
|
|
223
|
+
const value = faker_1.faker.string.alpha();
|
|
224
|
+
storeGeneratedValue(page, alias, value, "alpha");
|
|
225
|
+
});
|
|
226
|
+
/**
|
|
227
|
+
* Generates an alphabetic string of specified length.
|
|
228
|
+
* @example When I pw generate alpha with {int} characters as "alpha10"
|
|
229
|
+
*/
|
|
230
|
+
(0, registry_1.Step)("I pw generate alpha with {int} characters as {string}", async (page, length, alias) => {
|
|
231
|
+
const value = faker_1.faker.string.alpha({ length });
|
|
232
|
+
storeGeneratedValue(page, alias, value, `alpha (${length} chars)`);
|
|
233
|
+
});
|
|
234
|
+
/**
|
|
235
|
+
* Generates a random numeric string (digits only).
|
|
236
|
+
* @example When I pw generate numeric as "numeric"
|
|
237
|
+
*/
|
|
238
|
+
(0, registry_1.Step)("I pw generate numeric as {string}", async (page, alias) => {
|
|
239
|
+
const value = faker_1.faker.string.numeric();
|
|
240
|
+
storeGeneratedValue(page, alias, value, "numeric");
|
|
241
|
+
});
|
|
242
|
+
/**
|
|
243
|
+
* Generates a numeric string of specified length.
|
|
244
|
+
* @example When I pw generate numeric with {int} digits as "numeric10"
|
|
245
|
+
*/
|
|
246
|
+
(0, registry_1.Step)("I pw generate numeric with {int} digits as {string}", async (page, length, alias) => {
|
|
247
|
+
const value = faker_1.faker.string.numeric({ length });
|
|
248
|
+
storeGeneratedValue(page, alias, value, `numeric (${length} digits)`);
|
|
249
|
+
});
|
|
250
|
+
/**
|
|
251
|
+
* Generates a random UUID.
|
|
252
|
+
* @example When I pw generate uuid as "uuid"
|
|
253
|
+
*/
|
|
254
|
+
(0, registry_1.Step)("I pw generate uuid as {string}", async (page, alias) => {
|
|
255
|
+
const value = faker_1.faker.string.uuid();
|
|
256
|
+
storeGeneratedValue(page, alias, value, "UUID");
|
|
257
|
+
});
|
|
258
|
+
/**
|
|
259
|
+
* Generates a random nanoid.
|
|
260
|
+
* @example When I pw generate nanoid as "nanoid"
|
|
261
|
+
*/
|
|
262
|
+
(0, registry_1.Step)("I pw generate nanoid as {string}", async (page, alias) => {
|
|
263
|
+
const value = faker_1.faker.string.nanoid();
|
|
264
|
+
storeGeneratedValue(page, alias, value, "nanoid");
|
|
265
|
+
});
|
|
266
|
+
// ==================================================
|
|
267
|
+
// USER GENERATORS
|
|
268
|
+
// ==================================================
|
|
269
|
+
/**
|
|
270
|
+
* Generates a random username.
|
|
271
|
+
* @example When I pw generate username as "username"
|
|
272
|
+
*/
|
|
273
|
+
(0, registry_1.Step)("I pw generate username as {string}", async (page, alias) => {
|
|
274
|
+
const value = faker_1.faker.internet.username();
|
|
275
|
+
storeGeneratedValue(page, alias, value, "username");
|
|
276
|
+
});
|
|
277
|
+
/**
|
|
278
|
+
* Generates a random email address.
|
|
279
|
+
* @example When I pw generate email as "email"
|
|
280
|
+
*/
|
|
281
|
+
(0, registry_1.Step)("I pw generate email as {string}", async (page, alias) => {
|
|
282
|
+
const value = faker_1.faker.internet.email();
|
|
283
|
+
storeGeneratedValue(page, alias, value, "email");
|
|
284
|
+
});
|
|
285
|
+
/**
|
|
286
|
+
* Generates a random password.
|
|
287
|
+
* @example When I pw generate password as "password"
|
|
288
|
+
*/
|
|
289
|
+
(0, registry_1.Step)("I pw generate password as {string}", async (page, alias) => {
|
|
290
|
+
const value = faker_1.faker.internet.password();
|
|
291
|
+
storeGeneratedValue(page, alias, value, "password");
|
|
292
|
+
});
|
|
293
|
+
/**
|
|
294
|
+
* Generates a password with specified length.
|
|
295
|
+
* @example When I pw generate password with {int} characters as "password12"
|
|
296
|
+
*/
|
|
297
|
+
(0, registry_1.Step)("I pw generate password with {int} characters as {string}", async (page, length, alias) => {
|
|
298
|
+
const value = faker_1.faker.internet.password({ length });
|
|
299
|
+
storeGeneratedValue(page, alias, value, `password (${length} chars)`);
|
|
300
|
+
});
|
|
301
|
+
/**
|
|
302
|
+
* Generates a random phone number.
|
|
303
|
+
* @example When I pw generate phone number as "phoneNumber"
|
|
304
|
+
*/
|
|
305
|
+
(0, registry_1.Step)("I pw generate phone number as {string}", async (page, alias) => {
|
|
306
|
+
const value = faker_1.faker.phone.number();
|
|
307
|
+
storeGeneratedValue(page, alias, value, "phone number");
|
|
308
|
+
});
|
|
309
|
+
/**
|
|
310
|
+
* Generates a phone number with country code and specified digit count.
|
|
311
|
+
* @example When I pw generate country code "+1" with random 10 digits as "randomPhoneNumber"
|
|
312
|
+
*/
|
|
313
|
+
(0, registry_1.Step)("I pw generate country code {string} with random {int} digits as {string}", async (page, countryCode, digitCount, alias) => {
|
|
314
|
+
let phoneNumber = countryCode + ' ';
|
|
315
|
+
for (let i = 0; i < digitCount; i++) {
|
|
316
|
+
phoneNumber += faker_1.faker.number.int({ min: 0, max: 9 });
|
|
317
|
+
}
|
|
318
|
+
storeGeneratedValue(page, alias, phoneNumber, `phone number (${countryCode})`);
|
|
319
|
+
});
|
|
320
|
+
// ==================================================
|
|
321
|
+
// ADDRESS GENERATORS
|
|
322
|
+
// ==================================================
|
|
323
|
+
/**
|
|
324
|
+
* Generates a random street address.
|
|
325
|
+
* @example When I pw generate street address as "streetAddress"
|
|
326
|
+
*/
|
|
327
|
+
(0, registry_1.Step)("I pw generate street address as {string}", async (page, alias) => {
|
|
328
|
+
const value = faker_1.faker.location.streetAddress();
|
|
329
|
+
storeGeneratedValue(page, alias, value, "street address");
|
|
330
|
+
});
|
|
331
|
+
/**
|
|
332
|
+
* Generates a random city name.
|
|
333
|
+
* @example When I pw generate city as "city"
|
|
334
|
+
*/
|
|
335
|
+
(0, registry_1.Step)("I pw generate city as {string}", async (page, alias) => {
|
|
336
|
+
const value = faker_1.faker.location.city();
|
|
337
|
+
storeGeneratedValue(page, alias, value, "city");
|
|
338
|
+
});
|
|
339
|
+
/**
|
|
340
|
+
* Generates a random state/province.
|
|
341
|
+
* @example When I pw generate state as "state"
|
|
342
|
+
*/
|
|
343
|
+
(0, registry_1.Step)("I pw generate state as {string}", async (page, alias) => {
|
|
344
|
+
const value = faker_1.faker.location.state();
|
|
345
|
+
storeGeneratedValue(page, alias, value, "state");
|
|
346
|
+
});
|
|
347
|
+
/**
|
|
348
|
+
* Generates a random country.
|
|
349
|
+
* @example When I pw generate country as "country"
|
|
350
|
+
*/
|
|
351
|
+
(0, registry_1.Step)("I pw generate country as {string}", async (page, alias) => {
|
|
352
|
+
const value = faker_1.faker.location.country();
|
|
353
|
+
storeGeneratedValue(page, alias, value, "country");
|
|
354
|
+
});
|
|
355
|
+
/**
|
|
356
|
+
* Generates a random zip/postal code.
|
|
357
|
+
* @example When I pw generate zip code as "zipCode"
|
|
358
|
+
*/
|
|
359
|
+
(0, registry_1.Step)("I pw generate zip code as {string}", async (page, alias) => {
|
|
360
|
+
const value = faker_1.faker.location.zipCode();
|
|
361
|
+
storeGeneratedValue(page, alias, value, "zip code");
|
|
362
|
+
});
|
|
363
|
+
// ==================================================
|
|
364
|
+
// COMPANY GENERATORS
|
|
365
|
+
// ==================================================
|
|
366
|
+
/**
|
|
367
|
+
* Generates a random company name.
|
|
368
|
+
* @example When I pw generate company name as "companyName"
|
|
369
|
+
*/
|
|
370
|
+
(0, registry_1.Step)("I pw generate company name as {string}", async (page, alias) => {
|
|
371
|
+
const value = faker_1.faker.company.name();
|
|
372
|
+
storeGeneratedValue(page, alias, value, "company name");
|
|
373
|
+
});
|
|
374
|
+
/**
|
|
375
|
+
* Generates a random catch phrase.
|
|
376
|
+
* @example When I pw generate catch phrase as "catchPhrase"
|
|
377
|
+
*/
|
|
378
|
+
(0, registry_1.Step)("I pw generate catch phrase as {string}", async (page, alias) => {
|
|
379
|
+
const value = faker_1.faker.company.catchPhrase();
|
|
380
|
+
storeGeneratedValue(page, alias, value, "catch phrase");
|
|
381
|
+
});
|
|
382
|
+
/**
|
|
383
|
+
* Generates random buzzwords.
|
|
384
|
+
* @example When I pw generate buzzwords as "buzzwords"
|
|
385
|
+
*/
|
|
386
|
+
(0, registry_1.Step)("I pw generate buzzwords as {string}", async (page, alias) => {
|
|
387
|
+
const value = faker_1.faker.company.buzzPhrase();
|
|
388
|
+
storeGeneratedValue(page, alias, value, "buzzwords");
|
|
389
|
+
});
|
|
390
|
+
// ==================================================
|
|
391
|
+
// FINANCE GENERATORS
|
|
392
|
+
// ==================================================
|
|
393
|
+
/**
|
|
394
|
+
* Generates a random amount (currency value).
|
|
395
|
+
* @example When I pw generate amount as "amount"
|
|
396
|
+
*/
|
|
397
|
+
(0, registry_1.Step)("I pw generate amount as {string}", async (page, alias) => {
|
|
398
|
+
const value = faker_1.faker.finance.amount();
|
|
399
|
+
storeGeneratedValue(page, alias, value, "amount");
|
|
400
|
+
});
|
|
401
|
+
/**
|
|
402
|
+
* Generates a random amount with min/max.
|
|
403
|
+
* @example When I pw generate amount between {int} and {int} as "randomAmount"
|
|
404
|
+
*/
|
|
405
|
+
(0, registry_1.Step)("I pw generate amount between {int} and {int} as {string}", async (page, min, max, alias) => {
|
|
406
|
+
const value = faker_1.faker.finance.amount({ min, max });
|
|
407
|
+
storeGeneratedValue(page, alias, value, `amount (${min}-${max})`);
|
|
408
|
+
});
|
|
409
|
+
/**
|
|
410
|
+
* Generates a random IBAN.
|
|
411
|
+
* @example When I pw generate iban as "iban"
|
|
412
|
+
*/
|
|
413
|
+
(0, registry_1.Step)("I pw generate iban as {string}", async (page, alias) => {
|
|
414
|
+
const value = faker_1.faker.finance.iban();
|
|
415
|
+
storeGeneratedValue(page, alias, value, "IBAN");
|
|
416
|
+
});
|
|
417
|
+
/**
|
|
418
|
+
* Generates a random credit card number.
|
|
419
|
+
* @example When I pw generate credit card number as "creditCard"
|
|
420
|
+
*/
|
|
421
|
+
(0, registry_1.Step)("I pw generate credit card number as {string}", async (page, alias) => {
|
|
422
|
+
const value = faker_1.faker.finance.creditCardNumber();
|
|
423
|
+
storeGeneratedValue(page, alias, value, "credit card number");
|
|
424
|
+
});
|
|
425
|
+
// ==================================================
|
|
426
|
+
// DATE/TIME GENERATORS
|
|
427
|
+
// ==================================================
|
|
428
|
+
/**
|
|
429
|
+
* Generates a random past date.
|
|
430
|
+
* @example When I pw generate past date as "pastDate"
|
|
431
|
+
*/
|
|
432
|
+
(0, registry_1.Step)("I pw generate past date as {string}", async (page, alias) => {
|
|
433
|
+
const value = faker_1.faker.date.past().toISOString();
|
|
434
|
+
storeGeneratedValue(page, alias, value, "past date");
|
|
435
|
+
});
|
|
436
|
+
/**
|
|
437
|
+
* Generates a random future date.
|
|
438
|
+
* @example When I pw generate future date as "futureDate"
|
|
439
|
+
*/
|
|
440
|
+
(0, registry_1.Step)("I pw generate future date as {string}", async (page, alias) => {
|
|
441
|
+
const value = faker_1.faker.date.future().toISOString();
|
|
442
|
+
storeGeneratedValue(page, alias, value, "future date");
|
|
443
|
+
});
|
|
444
|
+
/**
|
|
445
|
+
* Generates a random recent date.
|
|
446
|
+
* @example When I pw generate recent date as "recentDate"
|
|
447
|
+
*/
|
|
448
|
+
(0, registry_1.Step)("I pw generate recent date as {string}", async (page, alias) => {
|
|
449
|
+
const value = faker_1.faker.date.recent().toISOString();
|
|
450
|
+
storeGeneratedValue(page, alias, value, "recent date");
|
|
451
|
+
});
|
|
452
|
+
/**
|
|
453
|
+
* Generates a random birthdate.
|
|
454
|
+
* @example When I pw generate birthdate as "birthdate"
|
|
455
|
+
*/
|
|
456
|
+
(0, registry_1.Step)("I pw generate birthdate as {string}", async (page, alias) => {
|
|
457
|
+
const value = faker_1.faker.date.birthdate().toISOString();
|
|
458
|
+
storeGeneratedValue(page, alias, value, "birthdate");
|
|
459
|
+
});
|
|
460
|
+
// ==================================================
|
|
461
|
+
// COLOR GENERATORS
|
|
462
|
+
// ==================================================
|
|
463
|
+
/**
|
|
464
|
+
* Generates a random color name.
|
|
465
|
+
* @example When I pw generate color as "color"
|
|
466
|
+
*/
|
|
467
|
+
(0, registry_1.Step)("I pw generate color as {string}", async (page, alias) => {
|
|
468
|
+
const value = faker_1.faker.color.human();
|
|
469
|
+
storeGeneratedValue(page, alias, value, "color");
|
|
470
|
+
});
|
|
471
|
+
/**
|
|
472
|
+
* Generates a random RGB color.
|
|
473
|
+
* @example When I pw generate rgb color as "rgbColor"
|
|
474
|
+
*/
|
|
475
|
+
(0, registry_1.Step)("I pw generate rgb color as {string}", async (page, alias) => {
|
|
476
|
+
const value = faker_1.faker.color.rgb();
|
|
477
|
+
storeGeneratedValue(page, alias, value, "RGB color");
|
|
478
|
+
});
|
|
479
|
+
// ==================================================
|
|
480
|
+
// LENGTH UTILITY
|
|
481
|
+
// ==================================================
|
|
482
|
+
/**
|
|
483
|
+
* Stores the length of a previously generated value.
|
|
484
|
+
* @example When I pw get length of "username" as "usernameLength"
|
|
485
|
+
*/
|
|
486
|
+
(0, registry_1.Step)("I pw get length of {string} as {string}", async (page, sourceAlias, targetAlias) => {
|
|
487
|
+
const value = (0, state_1.getVariable)(page, sourceAlias);
|
|
488
|
+
if (value === undefined) {
|
|
489
|
+
throw new Error(`❌ No value found for alias "@${sourceAlias}"`);
|
|
490
|
+
}
|
|
491
|
+
const length = String(value).length;
|
|
492
|
+
(0, state_1.setVariable)(page, targetAlias, length);
|
|
493
|
+
console.log(`📏 Length of "@${sourceAlias}": ${length} (stored as @${targetAlias})`);
|
|
494
|
+
});
|
|
495
|
+
/**
|
|
496
|
+
* Asserts that a generated value has a specific length.
|
|
497
|
+
* @example Then I pw expect "@username" to have length {int}
|
|
498
|
+
*/
|
|
499
|
+
(0, registry_1.Step)("I pw expect {string} to have length {int}", async (page, alias, expectedLength) => {
|
|
500
|
+
const cleanAlias = alias.startsWith('@') ? alias.slice(1) : alias;
|
|
501
|
+
const value = (0, state_1.getVariable)(page, cleanAlias);
|
|
502
|
+
if (value === undefined) {
|
|
503
|
+
throw new Error(`❌ No value found for alias "${alias}"`);
|
|
504
|
+
}
|
|
505
|
+
const actualLength = String(value).length;
|
|
506
|
+
if (actualLength !== expectedLength) {
|
|
507
|
+
throw new Error(`Expected length ${expectedLength}, but got ${actualLength}`);
|
|
508
|
+
}
|
|
509
|
+
console.log(`✅ "@${cleanAlias}" has length ${expectedLength}`);
|
|
510
|
+
});
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
* @param config - The fixture configuration object
|
|
4
4
|
*/
|
|
5
5
|
export declare function setFixtureConfig(config: {
|
|
6
|
+
projectRoot?: string;
|
|
6
7
|
fixturesDir?: string;
|
|
7
8
|
selectorsFile?: string;
|
|
8
9
|
textsFile?: string;
|
|
@@ -19,10 +20,19 @@ export declare function setFixtureConfig(config: {
|
|
|
19
20
|
urlsFile?: string;
|
|
20
21
|
attributesFile?: string;
|
|
21
22
|
promptsFile?: string;
|
|
23
|
+
envFile?: string;
|
|
22
24
|
}): void;
|
|
25
|
+
/**
|
|
26
|
+
* Resolves environment variable placeholders in a string.
|
|
27
|
+
* Supports {{VARIABLE_NAME}} syntax for environment variables.
|
|
28
|
+
* Also supports @alias syntax for runtime variables stored in page state.
|
|
29
|
+
* @param value - The value that may contain placeholders
|
|
30
|
+
* @returns The resolved value with placeholders replaced
|
|
31
|
+
*/
|
|
32
|
+
export declare function resolveEnvVariable(value: string): string;
|
|
23
33
|
/**
|
|
24
34
|
* Loads a JSON fixture file from the test project's fixtures directory.
|
|
25
|
-
* Looks in the current working directory (test project root).
|
|
35
|
+
* Looks in the current working directory (test project root) or custom projectRoot if configured.
|
|
26
36
|
* @param fileName - Name of the fixture file (e.g., "selectors.json").
|
|
27
37
|
* @returns Parsed JSON object.
|
|
28
38
|
*/
|
|
@@ -30,9 +40,19 @@ export declare function loadFixture(fileName: string): Record<string, any>;
|
|
|
30
40
|
/**
|
|
31
41
|
* Retrieves a specific value from a loaded fixture.
|
|
32
42
|
* Returns the raw key if fixture or key is not found (fallback to raw selector).
|
|
43
|
+
* Also resolves environment variable placeholders {{VARIABLE_NAME}} in the returned value.
|
|
44
|
+
* For @alias resolution, use resolveAliasInValue() after getting the value.
|
|
33
45
|
* @param fixture - The loaded fixture object.
|
|
34
46
|
* @param keyPath - Dot-separated path to the desired value (e.g., "login.usernameField").
|
|
35
|
-
* @returns The value at the specified key path, or the keyPath itself if not found.
|
|
47
|
+
* @returns The value at the specified key path with env vars resolved, or the keyPath itself if not found.
|
|
36
48
|
*/
|
|
37
49
|
export declare function getFixtureValue(fixture: Record<string, any>, keyPath: string): any;
|
|
50
|
+
/**
|
|
51
|
+
* Resolves @alias references in a string value using runtime variables from page state.
|
|
52
|
+
* This should be called after getFixtureValue() when you need @alias support.
|
|
53
|
+
* @param value - The value that may contain @alias references
|
|
54
|
+
* @param page - The Playwright page object
|
|
55
|
+
* @returns The value with @alias placeholders resolved
|
|
56
|
+
*/
|
|
57
|
+
export declare function resolveAliasInValue(value: any, page: any): Promise<any>;
|
|
38
58
|
//# sourceMappingURL=fixtures.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fixtures.d.ts","sourceRoot":"","sources":["../../../src/backend/utils/fixtures.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"fixtures.d.ts","sourceRoot":"","sources":["../../../src/backend/utils/fixtures.ts"],"names":[],"mappings":"AAsCA;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE;IACrC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,CAAC;CACpB,GAAG,IAAI,CAqHP;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAmBxD;AAcD;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAcjE;AACD;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,OAAO,EAAE,MAAM,GAAG,GAAG,CA6BlF;AA+BD;;;;;;GAMG;AACH,wBAAsB,mBAAmB,CAAC,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,CA+D7E"}
|