cypress-playwright-data-gen 1.0.7 → 1.0.9
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 +54 -81
- package/package.json +1 -1
package/README.md
CHANGED
@@ -20,109 +20,82 @@ import 'cypress-playwright-data-gen/cypress/commands';
|
|
20
20
|
|
21
21
|
Then you can use the custom commands anywhere in your tests:
|
22
22
|
|
23
|
+
/**
|
24
|
+
* Just an example — OrangeHRM doesn’t have public signup,
|
25
|
+
* so let’s imagine we were testing a form or registration flow:
|
26
|
+
*/
|
23
27
|
it('uses generated user data for a signup-style test', () => {
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
cy.log(`Generated user: ${user.firstName} ${user.lastName}, email: ${user.email}`);
|
33
|
-
});
|
28
|
+
cy.generateUser().then((user) => {
|
29
|
+
cy.visit('https://example.com/register');
|
30
|
+
cy.get('#firstName').type(user.firstName);
|
31
|
+
cy.get('#lastName').type(user.lastName);
|
32
|
+
cy.get('#email').type(user.email);
|
33
|
+
cy.get('#password').type(user.password);
|
34
|
+
cy.get('#submit').click();
|
35
|
+
cy.log(`Generated user: ${user.firstName} ${user.lastName}, email: ${user.email}`);
|
34
36
|
});
|
37
|
+
});
|
35
38
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
});
|
39
|
+
/**
|
40
|
+
* Just an example
|
41
|
+
*/
|
42
|
+
it('generates card data for payment-related tests', () => {
|
43
|
+
cy.generateCard().then((card) => {
|
44
|
+
cy.log(`Card Number: ${card.number}`);
|
45
|
+
cy.log(`Expiry: ${card.expiryMonth}/${card.expiryYear}`);
|
46
|
+
cy.log(`CVV: ${card.cvv}`);
|
42
47
|
});
|
48
|
+
});
|
43
49
|
|
44
50
|
|
45
51
|
##############################################################################
|
46
52
|
|
47
53
|
🧪 Usage In Playwright
|
48
54
|
|
49
|
-
|
50
|
-
|
55
|
+
import { generateUser, generateCard, generateAddress, generateTransaction, generateInstitution }
|
56
|
+
from 'cypress-playwright-data-gen/playwright/utils';
|
51
57
|
|
52
58
|
|
53
59
|
Then you can use them anywhere in your Playwright tests:
|
60
|
+
|
54
61
|
import { test, expect } from '@playwright/test';
|
55
62
|
import { generateUser, generateCard } from 'cypress-playwright-data-gen/playwright/utils';
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
63
|
+
|
64
|
+
/**
|
65
|
+
* Just an example — OrangeHRM doesn’t have public signup,
|
66
|
+
* so let’s imagine we were testing a form or registration flow:
|
67
|
+
*/
|
68
|
+
test('uses generated user data for a signup-style test', async ({ page }) => {
|
69
|
+
const user = generateUser();
|
70
|
+
await page.goto('https://example.com/register');
|
71
|
+
await page.fill('#firstName', user.firstName);
|
72
|
+
await page.fill('#lastName', user.lastName);
|
73
|
+
await page.fill('#email', user.email);
|
74
|
+
await page.fill('#password', user.password);
|
75
|
+
await page.click('#submit');
|
76
|
+
console.log(`Generated user: ${user.firstName} ${user.lastName}, email: ${user.email}`);
|
77
|
+
});
|
67
78
|
|
68
79
|
/**
|
69
80
|
* Just an example
|
70
81
|
*/
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
82
|
+
test('generates card data for payment-related tests', async () => {
|
83
|
+
const card = generateCard();
|
84
|
+
console.log(`Card Number: ${card.number}`);
|
85
|
+
console.log(`Expiry: ${card.expiryMonth}/${card.expiryYear}`);
|
86
|
+
console.log(`CVV: ${card.cvv}`);
|
87
|
+
});
|
77
88
|
|
78
89
|
|
79
90
|
|
80
91
|
##############################################################################
|
81
92
|
|
82
93
|
|
83
|
-
🧩 Available Generators
|
84
|
-
|
85
|
-
|
86
|
-
fullName
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
userId
|
92
|
-
avatar
|
93
|
-
email
|
94
|
-
phone
|
95
|
-
address
|
96
|
-
|
97
|
-
💳 generateCard()
|
98
|
-
cardNumber
|
99
|
-
cvv
|
100
|
-
expiry
|
101
|
-
|
102
|
-
🏠 generateAddress()
|
103
|
-
street
|
104
|
-
city
|
105
|
-
state
|
106
|
-
postalCode
|
107
|
-
country
|
108
|
-
|
109
|
-
🏦 generateInstitution()
|
110
|
-
institutionId
|
111
|
-
name
|
112
|
-
type
|
113
|
-
country
|
114
|
-
branchCode
|
115
|
-
contactEmail
|
116
|
-
phone
|
117
|
-
|
118
|
-
💰 generateTransaction()
|
119
|
-
amount
|
120
|
-
currency
|
121
|
-
type
|
122
|
-
date
|
123
|
-
merchant
|
124
|
-
transactionId
|
125
|
-
status
|
126
|
-
|
127
|
-
|
128
|
-
|
94
|
+
## 🧩 Available Generators
|
95
|
+
| Generator | Attributes |
|
96
|
+
|------------|-------------|
|
97
|
+
| 👤 **generateUser()** | fullName, firstName, lastName, username, password, userId, avatar, email, phone, address |
|
98
|
+
| 💳 **generateCard()** | cardNumber, cvv, expiry |
|
99
|
+
| 🏠 **generateAddress()** | street, city, state, postalCode, country |
|
100
|
+
| 🏦 **generateInstitution()** | institutionId, name, type, country, branchCode, contactEmail, phone |
|
101
|
+
| 💰 **generateTransaction()** | amount, currency, type, date, merchant, transactionId, status |
|
package/package.json
CHANGED