cypress-playwright-data-gen 1.0.5 → 1.0.7

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 (2) hide show
  1. package/README.md +106 -12
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,9 +1,7 @@
1
- 🧠 cypress-playwright-data-gen
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,23 +10,119 @@ 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
-
21
18
  import 'cypress-playwright-data-gen/cypress/commands';
22
19
 
23
20
 
24
21
  Then you can use the custom commands anywhere in your tests:
25
22
 
26
- it('should create fake user and card data', () => {
27
- const user = cy.generateUser();
28
- const card = cy.generateCard();
23
+ it('uses generated user data for a signup-style test', () => {
24
+ cy.generateUser().then((user) => {
25
+ /** Just an example — OrangeHRM doesn’t have public signup, so let’s imagine we were testing a form or registration flow: **/
26
+ cy.visit('https://example.com/register');
27
+ cy.get('#firstName').type(user.firstName);
28
+ cy.get('#lastName').type(user.lastName);
29
+ cy.get('#email').type(user.email);
30
+ cy.get('#password').type(user.password);
31
+ cy.get('#submit').click();
32
+ cy.log(`Generated user: ${user.firstName} ${user.lastName}, email: ${user.email}`);
33
+ });
34
+ });
29
35
 
30
- cy.log(JSON.stringify(user));
31
- cy.log(JSON.stringify(card));
36
+ it('generates card data for payment-related tests', () => {
37
+ cy.generateCard().then((card) => {
38
+ cy.log(`Card Number: ${card.number}`);
39
+ cy.log(`Expiry: ${card.expiryMonth}/${card.expiryYear}`);
40
+ cy.log(`CVV: ${card.cvv}`);
41
+ });
32
42
  });
33
43
 
34
44
 
45
+ ##############################################################################
46
+
47
+ 🧪 Usage In Playwright
48
+
49
+ Import the utility functions in your test file (or a setup file):
50
+ import { generateUser, generateCard, generateAddress, generateTransaction, generateInstitution } from 'cypress-playwright-data-gen/playwright/utils';
51
+
52
+
53
+ Then you can use them anywhere in your Playwright tests:
54
+ import { test, expect } from '@playwright/test';
55
+ import { generateUser, generateCard } from 'cypress-playwright-data-gen/playwright/utils';
56
+ /** Just an example — OrangeHRM doesn’t have public signup, so let’s imagine we were testing a form or registration flow: **/
57
+ test('uses generated user data for a signup-style test', async ({ page }) => {
58
+ const user = generateUser();
59
+ await page.goto('https://example.com/register');
60
+ await page.fill('#firstName', user.firstName);
61
+ await page.fill('#lastName', user.lastName);
62
+ await page.fill('#email', user.email);
63
+ await page.fill('#password', user.password);
64
+ await page.click('#submit');
65
+ console.log(`Generated user: ${user.firstName} ${user.lastName}, email: ${user.email}`);
66
+ });
67
+
68
+ /**
69
+ * Just an example
70
+ */
71
+ test('generates card data for payment-related tests', async () => {
72
+ const card = generateCard();
73
+ console.log(`Card Number: ${card.number}`);
74
+ console.log(`Expiry: ${card.expiryMonth}/${card.expiryYear}`);
75
+ console.log(`CVV: ${card.cvv}`);
76
+ });
77
+
78
+
79
+
80
+ ##############################################################################
81
+
82
+
83
+ 🧩 Available Generators & Their Attributes:
84
+
85
+ 🧍‍♂️generateUser()
86
+ fullName
87
+ firstName
88
+ lastName
89
+ username
90
+ password
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
+
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cypress-playwright-data-gen",
3
- "version": "1.0.5",
3
+ "version": "1.0.7",
4
4
  "description": "A simple Cypress & Playwright plugin for generating realistic test data using Faker.js.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",