cypress-playwright-data-gen 1.0.9 → 1.0.11
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 +37 -25
- package/package.json +4 -2
package/README.md
CHANGED
@@ -1,29 +1,39 @@
|
|
1
|
-
cypress-playwright-data-gen
|
1
|
+
# cypress-playwright-data-gen
|
2
|
+
|
2
3
|
A lightweight fake data generator for Cypress and Playwright tests — create realistic test data like users, cards, institutions, and more in seconds!
|
3
4
|
|
4
|
-
|
5
|
+
|
6
|
+
[](https://nodei.co/npm/cypress-playwright-data-gen/)
|
7
|
+
|
8
|
+
|
9
|
+
## Installation steps:
|
5
10
|
Install using npm or yarn:
|
6
11
|
|
12
|
+
```bash
|
7
13
|
npm install cypress-playwright-data-gen
|
14
|
+
```
|
8
15
|
|
9
|
-
or
|
10
16
|
|
17
|
+
```bash
|
11
18
|
yarn add cypress-playwright-data-gen
|
19
|
+
```
|
20
|
+
|
12
21
|
|
13
|
-
|
22
|
+
## Usage In Cypress
|
14
23
|
|
15
|
-
|
24
|
+
- Importing - Add the commands in your cypress/support/e2e.js (or commands.js):
|
16
25
|
|
17
|
-
|
26
|
+
```javascript
|
18
27
|
import 'cypress-playwright-data-gen/cypress/commands';
|
28
|
+
```
|
19
29
|
|
20
30
|
|
21
|
-
Then you can use the custom commands anywhere in your tests:
|
31
|
+
### Then you can use the custom commands anywhere in your tests:
|
22
32
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
33
|
+
Just an example — OrangeHRM doesn’t have public signup, so let’s imagine we were testing a form or registration flow:
|
34
|
+
|
35
|
+
```javascript
|
36
|
+
//Generate user data (Firstname, Lastname, Email, etc)
|
27
37
|
it('uses generated user data for a signup-style test', () => {
|
28
38
|
cy.generateUser().then((user) => {
|
29
39
|
cy.visit('https://example.com/register');
|
@@ -36,9 +46,7 @@ it('uses generated user data for a signup-style test', () => {
|
|
36
46
|
});
|
37
47
|
});
|
38
48
|
|
39
|
-
|
40
|
-
* Just an example
|
41
|
-
*/
|
49
|
+
//Generate card data (Card number, Cvv, Expiry date)
|
42
50
|
it('generates card data for payment-related tests', () => {
|
43
51
|
cy.generateCard().then((card) => {
|
44
52
|
cy.log(`Card Number: ${card.number}`);
|
@@ -47,24 +55,29 @@ it('generates card data for payment-related tests', () => {
|
|
47
55
|
});
|
48
56
|
});
|
49
57
|
|
58
|
+
```
|
59
|
+
|
60
|
+
|
50
61
|
|
51
|
-
|
62
|
+
## Usage In Playwright
|
52
63
|
|
53
|
-
|
64
|
+
- Importing - Import the generators directly and use them in your Playwright tests:
|
54
65
|
|
66
|
+
```javascript
|
55
67
|
import { generateUser, generateCard, generateAddress, generateTransaction, generateInstitution }
|
56
68
|
from 'cypress-playwright-data-gen/playwright/utils';
|
69
|
+
```
|
57
70
|
|
58
71
|
|
59
|
-
Then you can use them anywhere in your Playwright tests:
|
72
|
+
### Then you can use them anywhere in your Playwright tests:
|
60
73
|
|
74
|
+
Just an example — OrangeHRM doesn’t have public signup, so let’s imagine we were testing a form or registration flow:
|
75
|
+
|
76
|
+
```javascript
|
61
77
|
import { test, expect } from '@playwright/test';
|
62
78
|
import { generateUser, generateCard } from 'cypress-playwright-data-gen/playwright/utils';
|
63
79
|
|
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
|
-
*/
|
80
|
+
//Generate user data (Firstname, Lastname, Email, etc)
|
68
81
|
test('uses generated user data for a signup-style test', async ({ page }) => {
|
69
82
|
const user = generateUser();
|
70
83
|
await page.goto('https://example.com/register');
|
@@ -76,9 +89,8 @@ test('uses generated user data for a signup-style test', async ({ page }) => {
|
|
76
89
|
console.log(`Generated user: ${user.firstName} ${user.lastName}, email: ${user.email}`);
|
77
90
|
});
|
78
91
|
|
79
|
-
|
80
|
-
|
81
|
-
*/
|
92
|
+
|
93
|
+
//Generate card data (Card number, Cvv, Expiry date)
|
82
94
|
test('generates card data for payment-related tests', async () => {
|
83
95
|
const card = generateCard();
|
84
96
|
console.log(`Card Number: ${card.number}`);
|
@@ -86,9 +98,9 @@ test('generates card data for payment-related tests', async () => {
|
|
86
98
|
console.log(`CVV: ${card.cvv}`);
|
87
99
|
});
|
88
100
|
|
101
|
+
```
|
89
102
|
|
90
103
|
|
91
|
-
##############################################################################
|
92
104
|
|
93
105
|
|
94
106
|
## 🧩 Available Generators
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "cypress-playwright-data-gen",
|
3
|
-
"version": "1.0.
|
3
|
+
"version": "1.0.11",
|
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",
|
@@ -36,7 +36,9 @@
|
|
36
36
|
"faker",
|
37
37
|
"test-data",
|
38
38
|
"automation",
|
39
|
-
"qa"
|
39
|
+
"qa",
|
40
|
+
"software testing",
|
41
|
+
"generator"
|
40
42
|
],
|
41
43
|
"author": "Goodness Okoye",
|
42
44
|
"license": "MIT",
|