@jahia/cypress 8.2.0 → 8.3.0
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/CHANGELOG.md +14 -0
- package/README.md +1 -4
- package/dist/support/jahiaLog.d.ts +3 -0
- package/dist/support/jahiaLog.js +40 -0
- package/dist/support/jfaker.d.ts +0 -1
- package/dist/support/jfaker.js +2 -5
- package/dist/support/registerSupport.js +2 -0
- package/dist/utils/UsersHelper.d.ts +56 -1
- package/dist/utils/UsersHelper.js +73 -9
- package/fixtures/groovy/admin/addUserToGroup.groovy +4 -3
- package/fixtures/groovy/admin/createUser.groovy +5 -3
- package/fixtures/groovy/admin/deleteUser.groovy +3 -3
- package/fixtures/groovy/logger.groovy +6 -0
- package/package.json +17 -4
- package/src/support/jahiaLog.ts +45 -0
- package/src/support/jfaker.ts +2 -5
- package/src/support/registerSupport.ts +2 -0
- package/src/utils/UsersHelper.ts +72 -13
- package/dist/injections/bash-data.d.ts +0 -1
- package/dist/injections/bash-data.js +0 -57
- package/docs/browser-helper.md +0 -158
- package/docs/context-reporter.md +0 -104
- package/docs/extended-logger.md +0 -403
- package/docs/jfaker.md +0 -450
- package/docs/js-errors-logger.md +0 -210
- package/schema.graphql +0 -4569
- package/src/injections/bash-data.ts +0 -54
- package/tests/cypress/e2e/jfaker.spec.ts +0 -411
- package/tests/cypress/e2e/modSince.spec.ts +0 -334
- package/tests/cypress.config.ts +0 -23
- package/tests/package.json +0 -41
- package/tests/reporter-config.json +0 -13
- package/tests/yarn.lock +0 -8578
- package/tsconfig.json +0 -23
package/docs/extended-logger.md
DELETED
|
@@ -1,403 +0,0 @@
|
|
|
1
|
-
# Cypress Logger Module
|
|
2
|
-
|
|
3
|
-
## Overview
|
|
4
|
-
|
|
5
|
-
The Logger module is a helper utility designed to enhance Cypress test logging capabilities by providing structured log levels and decorating log messages with appropriate severity indicators. It enables developers to create more organized and filterable test output by categorizing log messages into different levels.
|
|
6
|
-
|
|
7
|
-
This documentation also covers the testStep custom action, which provides structured test organization through foldable log groups.
|
|
8
|
-
|
|
9
|
-
## Features
|
|
10
|
-
|
|
11
|
-
- **Multiple Log Levels**: Support for DEBUG and INFO logging levels, can easily be extended if required.
|
|
12
|
-
- **Level-based Filtering**: Configure minimum log level to control output verbosity
|
|
13
|
-
- **JSON Object Logging**: Specialized method for logging JSON objects
|
|
14
|
-
- **Cypress Integration**: Seamless integration with Cypress logging system
|
|
15
|
-
- **Chainable Interface**: Returns Cypress chainable objects for fluent test writing
|
|
16
|
-
- **Environment Variable Control**: Persistent log level configuration across test runs
|
|
17
|
-
- **Test Step Organization**: Foldable test steps for better test structure and readability.
|
|
18
|
-
|
|
19
|
-
## Log Levels and Test Steps
|
|
20
|
-
|
|
21
|
-
The module supports two distinct logging levels with hierarchical filtering:
|
|
22
|
-
|
|
23
|
-
### Log.debug()
|
|
24
|
-
- **Purpose**: Detailed diagnostic information for debugging and development
|
|
25
|
-
- **Visibility**: Only shown when log level is set to DEBUG
|
|
26
|
-
- **Use Case**: Verbose logging for troubleshooting complex test scenarios
|
|
27
|
-
|
|
28
|
-
### Log.info()
|
|
29
|
-
- **Purpose**: General informational messages about test execution
|
|
30
|
-
- **Visibility**: Shown when log level is set to INFO or DEBUG
|
|
31
|
-
- **Use Case**: Standard test progress and status information
|
|
32
|
-
|
|
33
|
-
### cy.step()
|
|
34
|
-
- **Purpose**: Group related test actions under foldable and self-descriptive step names
|
|
35
|
-
- **Visibility**: Shown always
|
|
36
|
-
- **Use Case**: Organize complex test scenarios and have self-documenting code
|
|
37
|
-
|
|
38
|
-
## Configuration
|
|
39
|
-
|
|
40
|
-
### Setting Log Level
|
|
41
|
-
|
|
42
|
-
```typescript
|
|
43
|
-
import { Log } from '@jahia/cypress';
|
|
44
|
-
|
|
45
|
-
// Set visibility to DEBUG level for verbose output
|
|
46
|
-
Log.setLevel(Log.LEVEL.DEBUG);
|
|
47
|
-
|
|
48
|
-
// Set visibility to INFO level for standard output (default configuration)
|
|
49
|
-
Log.setLevel(Log.LEVEL.INFO);
|
|
50
|
-
```
|
|
51
|
-
|
|
52
|
-
## Usage
|
|
53
|
-
|
|
54
|
-
### Basic Logging
|
|
55
|
-
|
|
56
|
-
```typescript
|
|
57
|
-
import { Log } from '@jahia/cypress';
|
|
58
|
-
|
|
59
|
-
describe('Test Suite', () => {
|
|
60
|
-
it('should demonstrate logging capabilities', () => {
|
|
61
|
-
// Info level logging (always visible)
|
|
62
|
-
Log.info('Starting test execution');
|
|
63
|
-
|
|
64
|
-
// Debug level logging (only visible when DEBUG level is set)
|
|
65
|
-
Log.debug('Detailed diagnostic information');
|
|
66
|
-
|
|
67
|
-
// Chainable usage
|
|
68
|
-
Log.info('Processing user data')
|
|
69
|
-
.then(() => {
|
|
70
|
-
// Continue with test logic
|
|
71
|
-
cy.visit('/login');
|
|
72
|
-
});
|
|
73
|
-
});
|
|
74
|
-
});
|
|
75
|
-
```
|
|
76
|
-
|
|
77
|
-
### JSON Object Logging
|
|
78
|
-
|
|
79
|
-
```typescript
|
|
80
|
-
import { Log } from '@jahia/cypress';
|
|
81
|
-
|
|
82
|
-
describe('API Tests', () => {
|
|
83
|
-
it('should log API responses', () => {
|
|
84
|
-
cy.request('/api/users').then((response) => {
|
|
85
|
-
// Log response data at DEBUG level
|
|
86
|
-
Log.json(Log.LEVEL.DEBUG, response.body);
|
|
87
|
-
|
|
88
|
-
// Log summary at INFO level
|
|
89
|
-
const summary = { status: response.status, count: response.body.length };
|
|
90
|
-
Log.json(Log.LEVEL.INFO, summary);
|
|
91
|
-
});
|
|
92
|
-
});
|
|
93
|
-
});
|
|
94
|
-
```
|
|
95
|
-
|
|
96
|
-
### Test Step Organization
|
|
97
|
-
|
|
98
|
-
The test step action creates foldable, hierarchical log groups to organize complex test scenarios:
|
|
99
|
-
|
|
100
|
-
```typescript
|
|
101
|
-
describe('User Registration Flow', () => {
|
|
102
|
-
it('should register a new user successfully', () => {
|
|
103
|
-
cy.step('Navigate to registration page', () => {
|
|
104
|
-
cy.visit('/register');
|
|
105
|
-
cy.url().should('include', '/register');
|
|
106
|
-
});
|
|
107
|
-
|
|
108
|
-
cy.step('Fill out registration form', () => {
|
|
109
|
-
cy.get('[data-testid="first-name"]').type('John');
|
|
110
|
-
cy.get('[data-testid="last-name"]').type('Doe');
|
|
111
|
-
cy.get('[data-testid="email"]').type('john.doe@example.com');
|
|
112
|
-
cy.get('[data-testid="password"]').type('SecurePassword123!');
|
|
113
|
-
cy.get('[data-testid="confirm-password"]').type('SecurePassword123!');
|
|
114
|
-
});
|
|
115
|
-
|
|
116
|
-
cy.step('Submit registration and verify success', () => {
|
|
117
|
-
cy.get('[data-testid="register-button"]').click();
|
|
118
|
-
cy.get('[data-testid="success-message"]').should('be.visible');
|
|
119
|
-
cy.url().should('include', '/welcome');
|
|
120
|
-
});
|
|
121
|
-
});
|
|
122
|
-
});
|
|
123
|
-
```
|
|
124
|
-
|
|
125
|
-
#### Test Step Features
|
|
126
|
-
|
|
127
|
-
- **Hierarchical Organization**: Group related test actions under descriptive step names
|
|
128
|
-
- **Foldable Interface**: Steps can be collapsed/expanded in Cypress Test Runner
|
|
129
|
-
- **Clean Log Output**: Reduces clutter by organizing actions into logical groups
|
|
130
|
-
- **Better Debugging**: Easier to identify which step failed during test execution
|
|
131
|
-
- **Documentation**: Steps serve as living documentation of test flow
|
|
132
|
-
|
|
133
|
-
## Output Format
|
|
134
|
-
|
|
135
|
-
### Console Display
|
|
136
|
-
|
|
137
|
-
The logger decorates messages with level indicators in the Cypress runner:
|
|
138
|
-
|
|
139
|
-
```
|
|
140
|
-
[ INFO ] Starting test execution
|
|
141
|
-
[ DEBUG ] Detailed diagnostic information
|
|
142
|
-
[ INFO ] {
|
|
143
|
-
"status": 200,
|
|
144
|
-
"data": {
|
|
145
|
-
"users": 5
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
```
|
|
149
|
-
|
|
150
|
-
### Level Filtering Behavior
|
|
151
|
-
|
|
152
|
-
| Set Level | INFO Messages | DEBUG Messages |
|
|
153
|
-
|-----------|---------------|----------------|
|
|
154
|
-
| INFO | ✅ Visible | ❌ Hidden |
|
|
155
|
-
| DEBUG | ✅ Visible | ✅ Visible |
|
|
156
|
-
|
|
157
|
-
## Best Practices
|
|
158
|
-
|
|
159
|
-
### Development Environment
|
|
160
|
-
- Use `DEBUG` level during active development for maximum visibility
|
|
161
|
-
- Log detailed state information and intermediate values
|
|
162
|
-
- Include context-rich debug messages for complex operations
|
|
163
|
-
|
|
164
|
-
```typescript
|
|
165
|
-
// Good: Detailed development logging
|
|
166
|
-
Log.debug('User authentication state: authenticated=true, role=admin');
|
|
167
|
-
Log.debug('Form validation results', validationResults);
|
|
168
|
-
```
|
|
169
|
-
|
|
170
|
-
### CI/CD Environment
|
|
171
|
-
- Use `INFO` level for cleaner output in automated environments
|
|
172
|
-
- Focus on test milestones and important status updates
|
|
173
|
-
- Avoid excessive logging that could impact performance
|
|
174
|
-
|
|
175
|
-
```typescript
|
|
176
|
-
// Good: Concise CI/CD logging
|
|
177
|
-
Log.info('Test suite: User Management - Started');
|
|
178
|
-
Log.info('Authentication tests completed successfully');
|
|
179
|
-
```
|
|
180
|
-
|
|
181
|
-
### Test Organization with Steps
|
|
182
|
-
- Use meaningful step descriptions that explain the intent
|
|
183
|
-
- Group related actions within logical steps
|
|
184
|
-
- Keep steps focused on a single responsibility
|
|
185
|
-
- Combine with logging for comprehensive test documentation
|
|
186
|
-
|
|
187
|
-
```typescript
|
|
188
|
-
// Good: Well-organized test with steps and logging
|
|
189
|
-
describe('E-commerce Checkout', () => {
|
|
190
|
-
it('should complete purchase flow', () => {
|
|
191
|
-
cy.step('Add products to cart', () => {
|
|
192
|
-
Log.info('Starting product selection');
|
|
193
|
-
cy.visit('/products');
|
|
194
|
-
cy.get('[data-testid="product-1"]').click();
|
|
195
|
-
cy.get('[data-testid="add-to-cart"]').click();
|
|
196
|
-
Log.debug('Product added to cart successfully');
|
|
197
|
-
});
|
|
198
|
-
|
|
199
|
-
cy.step('Proceed to checkout', () => {
|
|
200
|
-
Log.info('Initiating checkout process');
|
|
201
|
-
cy.get('[data-testid="cart-icon"]').click();
|
|
202
|
-
cy.get('[data-testid="checkout-button"]').click();
|
|
203
|
-
Log.debug('Navigated to checkout page');
|
|
204
|
-
});
|
|
205
|
-
|
|
206
|
-
cy.step('Complete payment', () => {
|
|
207
|
-
Log.info('Processing payment information');
|
|
208
|
-
// Payment form interactions
|
|
209
|
-
Log.info('Payment completed successfully');
|
|
210
|
-
});
|
|
211
|
-
});
|
|
212
|
-
});
|
|
213
|
-
```
|
|
214
|
-
|
|
215
|
-
## Integration Examples
|
|
216
|
-
|
|
217
|
-
### Page Object Pattern
|
|
218
|
-
|
|
219
|
-
```typescript
|
|
220
|
-
class LoginPage {
|
|
221
|
-
visit() {
|
|
222
|
-
Log.info('Navigating to login page');
|
|
223
|
-
return cy.visit('/login');
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
login(username: string, password: string) {
|
|
227
|
-
Log.debug(`Attempting login for user: ${username}`);
|
|
228
|
-
cy.get('[data-testid="username"]').type(username);
|
|
229
|
-
cy.get('[data-testid="password"]').type(password);
|
|
230
|
-
cy.get('[data-testid="login-button"]').click();
|
|
231
|
-
Log.info('Login form submitted');
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
```
|
|
235
|
-
|
|
236
|
-
### Complex Workflows with Nested Steps
|
|
237
|
-
|
|
238
|
-
```typescript
|
|
239
|
-
describe('Multi-step Workflow', () => {
|
|
240
|
-
it('should handle complex user journey', () => {
|
|
241
|
-
cy.step('User Authentication', () => {
|
|
242
|
-
cy.step('Navigate to login', () => {
|
|
243
|
-
cy.visit('/login');
|
|
244
|
-
Log.debug('Login page loaded');
|
|
245
|
-
});
|
|
246
|
-
|
|
247
|
-
cy.step('Enter credentials', () => {
|
|
248
|
-
cy.get('[data-testid="username"]').type('testuser');
|
|
249
|
-
cy.get('[data-testid="password"]').type('password');
|
|
250
|
-
Log.debug('Credentials entered');
|
|
251
|
-
});
|
|
252
|
-
|
|
253
|
-
cy.step('Submit login form', () => {
|
|
254
|
-
cy.get('[data-testid="login-button"]').click();
|
|
255
|
-
Log.info('User logged in successfully');
|
|
256
|
-
});
|
|
257
|
-
});
|
|
258
|
-
|
|
259
|
-
cy.step('Product Selection', () => {
|
|
260
|
-
// Product selection steps
|
|
261
|
-
Log.info('Product selection completed');
|
|
262
|
-
});
|
|
263
|
-
|
|
264
|
-
cy.step('Checkout Process', () => {
|
|
265
|
-
// Checkout steps
|
|
266
|
-
Log.info('Checkout process completed');
|
|
267
|
-
});
|
|
268
|
-
});
|
|
269
|
-
});
|
|
270
|
-
```
|
|
271
|
-
|
|
272
|
-
### Test Hooks
|
|
273
|
-
|
|
274
|
-
```typescript
|
|
275
|
-
describe('Feature Tests', () => {
|
|
276
|
-
beforeEach(() => {
|
|
277
|
-
cy.step('Test Environment Setup', () => {
|
|
278
|
-
Log.debug('Setting up test environment');
|
|
279
|
-
// Setup code
|
|
280
|
-
});
|
|
281
|
-
});
|
|
282
|
-
|
|
283
|
-
afterEach(() => {
|
|
284
|
-
cy.step('Test Environment Cleanup', () => {
|
|
285
|
-
Log.debug('Cleaning up test environment');
|
|
286
|
-
// Cleanup code
|
|
287
|
-
});
|
|
288
|
-
});
|
|
289
|
-
});
|
|
290
|
-
```
|
|
291
|
-
|
|
292
|
-
## Performance Considerations
|
|
293
|
-
|
|
294
|
-
### Log Level Impact
|
|
295
|
-
|
|
296
|
-
- **DEBUG Level**: Higher overhead due to increased log volume
|
|
297
|
-
- **INFO Level**: Minimal overhead with essential information only
|
|
298
|
-
- **JSON Logging**: Additional serialization overhead for large objects
|
|
299
|
-
|
|
300
|
-
### Optimization Tips
|
|
301
|
-
|
|
302
|
-
1. Use appropriate log levels for different environments
|
|
303
|
-
2. Avoid logging large objects in production environments
|
|
304
|
-
3. Consider conditional logging for performance-critical tests
|
|
305
|
-
4. Use test steps judiciously - too many nested steps can impact readability
|
|
306
|
-
|
|
307
|
-
## API Reference
|
|
308
|
-
|
|
309
|
-
### Logger Methods
|
|
310
|
-
|
|
311
|
-
| Method | Parameters | Return Type | Description |
|
|
312
|
-
|--------|------------|-------------|-------------|
|
|
313
|
-
| `info(message)` | `string` | `Cypress.Chainable` | Logs INFO level message |
|
|
314
|
-
| `debug(message)` | `string` | `Cypress.Chainable` | Logs DEBUG level message |
|
|
315
|
-
| `json(level, object)` | `LEVEL`, `string` | `Cypress.Chainable` | Logs formatted JSON object |
|
|
316
|
-
| `setVerbosity(level)` | `LEVEL` | `void` | Sets minimum visible log level |
|
|
317
|
-
|
|
318
|
-
### Test Step Methods
|
|
319
|
-
|
|
320
|
-
| Method | Parameters | Return Type | Description |
|
|
321
|
-
|--------|------------|-------------|-------------|
|
|
322
|
-
| `cy.step(message, func)` | `string`, `() => void` | `void` | Creates foldable test step group |
|
|
323
|
-
|
|
324
|
-
### Enums
|
|
325
|
-
|
|
326
|
-
| Enum | Values | Description |
|
|
327
|
-
|------|--------|-------------|
|
|
328
|
-
| `LEVEL` | `DEBUG (0)`, `INFO (1)` | Available logging levels |
|
|
329
|
-
|
|
330
|
-
### TypeScript Declarations
|
|
331
|
-
|
|
332
|
-
The testStep module extends the global Cypress interface:
|
|
333
|
-
|
|
334
|
-
```typescript
|
|
335
|
-
declare global {
|
|
336
|
-
namespace Cypress {
|
|
337
|
-
interface Chainable<Subject> {
|
|
338
|
-
step(message: string, func: () => void): void;
|
|
339
|
-
}
|
|
340
|
-
}
|
|
341
|
-
}
|
|
342
|
-
```
|
|
343
|
-
|
|
344
|
-
## Migration Guide
|
|
345
|
-
|
|
346
|
-
### From Console Logging
|
|
347
|
-
|
|
348
|
-
**Before:**
|
|
349
|
-
```typescript
|
|
350
|
-
console.log('Test started');
|
|
351
|
-
console.debug('Detailed information');
|
|
352
|
-
```
|
|
353
|
-
|
|
354
|
-
**After:**
|
|
355
|
-
```typescript
|
|
356
|
-
Log.info('Test started');
|
|
357
|
-
Log.debug('Detailed information');
|
|
358
|
-
```
|
|
359
|
-
|
|
360
|
-
### From Cypress.log()
|
|
361
|
-
|
|
362
|
-
**Before:**
|
|
363
|
-
```typescript
|
|
364
|
-
Cypress.log({ message: 'Custom message' });
|
|
365
|
-
```
|
|
366
|
-
|
|
367
|
-
**After:**
|
|
368
|
-
```typescript
|
|
369
|
-
Log.info('Custom message');
|
|
370
|
-
```
|
|
371
|
-
|
|
372
|
-
### From Unstructured Tests to Steps
|
|
373
|
-
|
|
374
|
-
**Before:**
|
|
375
|
-
```typescript
|
|
376
|
-
it('should complete user flow', () => {
|
|
377
|
-
cy.visit('/login');
|
|
378
|
-
cy.get('[data-testid="username"]').type('user');
|
|
379
|
-
cy.get('[data-testid="password"]').type('pass');
|
|
380
|
-
cy.get('[data-testid="login-button"]').click();
|
|
381
|
-
cy.visit('/products');
|
|
382
|
-
cy.get('[data-testid="product-1"]').click();
|
|
383
|
-
cy.get('[data-testid="add-to-cart"]').click();
|
|
384
|
-
});
|
|
385
|
-
```
|
|
386
|
-
|
|
387
|
-
**After:**
|
|
388
|
-
```typescript
|
|
389
|
-
it('should complete user flow', () => {
|
|
390
|
-
cy.step('Login to application', () => {
|
|
391
|
-
cy.visit('/login');
|
|
392
|
-
cy.get('[data-testid="username"]').type('user');
|
|
393
|
-
cy.get('[data-testid="password"]').type('pass');
|
|
394
|
-
cy.get('[data-testid="login-button"]').click();
|
|
395
|
-
});
|
|
396
|
-
|
|
397
|
-
cy.step('Add product to cart', () => {
|
|
398
|
-
cy.visit('/products');
|
|
399
|
-
cy.get('[data-testid="product-1"]').click();
|
|
400
|
-
cy.get('[data-testid="add-to-cart"]').click();
|
|
401
|
-
});
|
|
402
|
-
});
|
|
403
|
-
```
|