cypress-playwright-data-gen 1.0.5 → 1.0.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/README.md +125 -11
- package/package.json +1 -1
package/README.md
CHANGED
@@ -1,9 +1,7 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
cypress-playwright-data-gen 🥰
|
3
2
|
A lightweight fake data generator for Cypress and Playwright tests — create realistic test data like users, cards, institutions, and more in seconds!
|
4
3
|
|
5
|
-
🚀 Installation
|
6
|
-
|
4
|
+
🚀 Installation steps:
|
7
5
|
Install using npm or yarn:
|
8
6
|
|
9
7
|
npm install cypress-playwright-data-gen
|
@@ -12,9 +10,9 @@ or
|
|
12
10
|
|
13
11
|
yarn add cypress-playwright-data-gen
|
14
12
|
|
13
|
+
##############################################################################
|
15
14
|
|
16
|
-
🧪 Usage
|
17
|
-
In Cypress
|
15
|
+
🧪 Usage In Cypress
|
18
16
|
|
19
17
|
Add the commands in your cypress/support/e2e.js (or commands.js):
|
20
18
|
|
@@ -23,12 +21,128 @@ import 'cypress-playwright-data-gen/cypress/commands';
|
|
23
21
|
|
24
22
|
Then you can use the custom commands anywhere in your tests:
|
25
23
|
|
26
|
-
|
27
|
-
|
28
|
-
|
24
|
+
describe('OrangeHRM Demo Login', () => {
|
25
|
+
beforeEach(() => {
|
26
|
+
cy.visit('https://opensource-demo.orangehrmlive.com/web/index.php/auth/login');
|
27
|
+
});
|
28
|
+
|
29
|
+
|
30
|
+
it('uses generated user data for a signup-style test', () => {
|
31
|
+
cy.generateUser().then((user) => {
|
32
|
+
/**
|
33
|
+
* Just an example — OrangeHRM doesn’t have public signup, so let’s imagine we were testing a form or registration flow:
|
34
|
+
*/
|
35
|
+
cy.visit('https://example.com/register');
|
36
|
+
cy.get('#firstName').type(user.firstName);
|
37
|
+
cy.get('#lastName').type(user.lastName);
|
38
|
+
cy.get('#email').type(user.email);
|
39
|
+
cy.get('#password').type(user.password);
|
40
|
+
cy.get('#submit').click();
|
41
|
+
cy.log(`Generated user: ${user.firstName} ${user.lastName}, email: ${user.email}`);
|
42
|
+
});
|
43
|
+
});
|
44
|
+
|
45
|
+
it('generates card data for payment-related tests', () => {
|
46
|
+
cy.generateCard().then((card) => {
|
47
|
+
cy.log(`Card Number: ${card.number}`);
|
48
|
+
cy.log(`Expiry: ${card.expiryMonth}/${card.expiryYear}`);
|
49
|
+
cy.log(`CVV: ${card.cvv}`);
|
50
|
+
});
|
51
|
+
});
|
52
|
+
});
|
53
|
+
|
54
|
+
|
55
|
+
##############################################################################
|
29
56
|
|
30
|
-
|
31
|
-
|
57
|
+
🧪 Usage In Playwright
|
58
|
+
|
59
|
+
Import the utility functions in your test file (or a setup file):
|
60
|
+
import { generateUser, generateCard, generateAddress, generateTransaction, generateInstitution } from 'cypress-playwright-data-gen/playwright/utils';
|
61
|
+
|
62
|
+
|
63
|
+
Then you can use them anywhere in your Playwright tests:
|
64
|
+
|
65
|
+
import { test, expect } from '@playwright/test';
|
66
|
+
import { generateUser, generateCard } from 'cypress-playwright-data-gen/playwright/utils';
|
67
|
+
|
68
|
+
test.describe('OrangeHRM Demo Login', () => {
|
69
|
+
test.beforeEach(async ({ page }) => {
|
70
|
+
await page.goto('https://opensource-demo.orangehrmlive.com/web/index.php/auth/login');
|
32
71
|
});
|
33
72
|
|
73
|
+
test('uses generated user data for a signup-style test', async ({ page }) => {
|
74
|
+
const user = generateUser();
|
75
|
+
|
76
|
+
/**
|
77
|
+
* Just an example — OrangeHRM doesn’t have public signup,
|
78
|
+
* so let’s imagine we were testing a form or registration flow:
|
79
|
+
*/
|
80
|
+
await page.goto('https://example.com/register');
|
81
|
+
await page.fill('#firstName', user.firstName);
|
82
|
+
await page.fill('#lastName', user.lastName);
|
83
|
+
await page.fill('#email', user.email);
|
84
|
+
await page.fill('#password', user.password);
|
85
|
+
await page.click('#submit');
|
86
|
+
|
87
|
+
console.log(`Generated user: ${user.firstName} ${user.lastName}, email: ${user.email}`);
|
88
|
+
});
|
89
|
+
|
90
|
+
test('generates card data for payment-related tests', async () => {
|
91
|
+
const card = generateCard();
|
92
|
+
console.log(`Card Number: ${card.number}`);
|
93
|
+
console.log(`Expiry: ${card.expiryMonth}/${card.expiryYear}`);
|
94
|
+
console.log(`CVV: ${card.cvv}`);
|
95
|
+
});
|
96
|
+
});
|
97
|
+
|
98
|
+
|
99
|
+
|
100
|
+
##############################################################################
|
101
|
+
|
102
|
+
|
103
|
+
🧩 Available Generators & Their Attributes:
|
104
|
+
|
105
|
+
🧍♂️generateUser()
|
106
|
+
fullName
|
107
|
+
firstName
|
108
|
+
lastName
|
109
|
+
username
|
110
|
+
password
|
111
|
+
userId
|
112
|
+
avatar
|
113
|
+
email
|
114
|
+
phone
|
115
|
+
address
|
116
|
+
|
117
|
+
💳 generateCard()
|
118
|
+
cardNumber
|
119
|
+
cvv
|
120
|
+
expiry
|
121
|
+
|
122
|
+
🏠 generateAddress()
|
123
|
+
street
|
124
|
+
city
|
125
|
+
state
|
126
|
+
postalCode
|
127
|
+
country
|
128
|
+
|
129
|
+
🏦 generateInstitution()
|
130
|
+
institutionId
|
131
|
+
name
|
132
|
+
type
|
133
|
+
country
|
134
|
+
branchCode
|
135
|
+
contactEmail
|
136
|
+
phone
|
137
|
+
|
138
|
+
💰 generateTransaction()
|
139
|
+
amount
|
140
|
+
currency
|
141
|
+
type
|
142
|
+
date
|
143
|
+
merchant
|
144
|
+
transactionId
|
145
|
+
status
|
146
|
+
|
147
|
+
|
34
148
|
|
package/package.json
CHANGED