@jahia/cypress 5.2.0 → 6.1.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.
Files changed (36) hide show
  1. package/dist/support/index.d.ts +2 -0
  2. package/dist/support/index.js +2 -0
  3. package/dist/support/jsErrorsLogger.d.ts +45 -0
  4. package/dist/support/jsErrorsLogger.js +280 -0
  5. package/dist/support/provisioning/executeGroovy.js +2 -1
  6. package/dist/support/provisioning/index.d.ts +2 -2
  7. package/dist/support/provisioning/index.js +2 -2
  8. package/dist/support/provisioning/installModule.d.ts +11 -0
  9. package/dist/support/provisioning/installModule.js +25 -0
  10. package/dist/support/provisioning/runProvisioningScript.js +8 -0
  11. package/dist/support/provisioning/{uninstallBundle.d.ts → uninstallModule.d.ts} +2 -2
  12. package/dist/support/provisioning/{uninstallBundle.js → uninstallModule.js} +4 -4
  13. package/dist/support/registerSupport.js +11 -1
  14. package/dist/support/testStep.d.ts +27 -0
  15. package/dist/support/testStep.js +15 -0
  16. package/dist/utils/Logger.d.ts +54 -0
  17. package/dist/utils/Logger.js +105 -0
  18. package/dist/utils/index.d.ts +1 -0
  19. package/dist/utils/index.js +1 -0
  20. package/docs/extended-logger.md +403 -0
  21. package/docs/js-errors-logger.md +152 -0
  22. package/package.json +1 -1
  23. package/src/support/index.ts +2 -0
  24. package/src/support/jsErrorsLogger.ts +281 -0
  25. package/src/support/provisioning/executeGroovy.ts +2 -1
  26. package/src/support/provisioning/index.ts +2 -2
  27. package/src/support/provisioning/installModule.ts +34 -0
  28. package/src/support/provisioning/runProvisioningScript.ts +9 -0
  29. package/src/support/provisioning/{uninstallBundle.ts → uninstallModule.ts} +3 -3
  30. package/src/support/registerSupport.ts +14 -2
  31. package/src/support/testStep.ts +41 -0
  32. package/src/utils/Logger.ts +108 -0
  33. package/src/utils/index.ts +1 -0
  34. package/dist/support/provisioning/installBundle.d.ts +0 -9
  35. package/dist/support/provisioning/installBundle.js +0 -15
  36. package/src/support/provisioning/installBundle.ts +0 -23
@@ -3,3 +3,5 @@ export * from './provisioning';
3
3
  export * from './login';
4
4
  export * from './logout';
5
5
  export * from './repeatUntil';
6
+ export * from './testStep';
7
+ export * from './jsErrorsLogger';
@@ -15,3 +15,5 @@ __exportStar(require("./provisioning"), exports);
15
15
  __exportStar(require("./login"), exports);
16
16
  __exportStar(require("./logout"), exports);
17
17
  __exportStar(require("./repeatUntil"), exports);
18
+ __exportStar(require("./testStep"), exports);
19
+ __exportStar(require("./jsErrorsLogger"), exports);
@@ -0,0 +1,45 @@
1
+ /**
2
+ * Module for monitoring and reporting JavaScript errors and warnings in Cypress tests.
3
+ * Provides methods to enable, disable, and check logger status.
4
+ */
5
+ /**
6
+ * Strategy for handling JavaScript errors and warnings in Cypress tests.
7
+ * - failFast: Fail *immediately* when an error is detected.
8
+ * - failAfterEach: Collect all errors and warnings *during test* execution and fail if any issues are found.
9
+ * - failAfterAll: Collect all errors and warnings *after all tests* and fail at the end of the test suite.
10
+ */
11
+ declare enum STRATEGY {
12
+ failFast = 0,
13
+ failAfterAll = 1,
14
+ failAfterEach = 2
15
+ }
16
+ /**
17
+ * Sets the strategy for handling JavaScript errors and warnings in Cypress tests.
18
+ * @param {STRATEGY} strategy - Strategy for handling JavaScript errors and warnings.
19
+ * @throws {Error} If an invalid strategy is provided.
20
+ * @returns {void}
21
+ */
22
+ declare function setStrategy(strategy: STRATEGY): void;
23
+ /**
24
+ * Sets the list of allowed warnings that will not be reported by the logger.
25
+ * @param warnings {string[]} - Array of warning messages to be allowed.
26
+ * @return {void}
27
+ */
28
+ declare function setAllowedJsWarnings(warnings: string[]): void;
29
+ /**
30
+ * Attaches custom hooks to Cypress events to monitor and report JavaScript errors and warnings.
31
+ * This method is called automatically in registerSupport.ts#registerSupport
32
+ * It sets up listeners for console errors and warnings, collects them after each test,
33
+ * and throws an error if any issues are found after all tests are executed.
34
+ */
35
+ declare function attachHooks(): void;
36
+ /**
37
+ * Exports the jsLogger module with methods to attach hooks, enable/disable logging, and set allowed warnings.
38
+ */
39
+ export declare const jsErrorsLogger: {
40
+ attachHooks: typeof attachHooks;
41
+ setAllowedJsWarnings: typeof setAllowedJsWarnings;
42
+ setStrategy: typeof setStrategy;
43
+ STRATEGY: typeof STRATEGY;
44
+ };
45
+ export {};
@@ -0,0 +1,280 @@
1
+ "use strict";
2
+ /* eslint-disable brace-style */
3
+ /* eslint-disable max-statements-per-line */
4
+ /**
5
+ * Module for monitoring and reporting JavaScript errors and warnings in Cypress tests.
6
+ * Provides methods to enable, disable, and check logger status.
7
+ */
8
+ var __spreadArray = (this && this.__spreadArray) || function (to, from) {
9
+ for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
10
+ to[j] = from[i];
11
+ return to;
12
+ };
13
+ exports.__esModule = true;
14
+ exports.jsErrorsLogger = void 0;
15
+ var envVarDisabled = 'JS_LOGGER_DISABLED';
16
+ var envVarCollector = '__JS_LOGGER_FAILURES__';
17
+ var envVarAllowedWarnings = '__JS_LOGGER_ALLOWED_WARNINGS__';
18
+ var envVarStrategy = '__JS_LOGGER_STRATEGY__';
19
+ /**
20
+ * Strategy for handling JavaScript errors and warnings in Cypress tests.
21
+ * - failFast: Fail *immediately* when an error is detected.
22
+ * - failAfterEach: Collect all errors and warnings *during test* execution and fail if any issues are found.
23
+ * - failAfterAll: Collect all errors and warnings *after all tests* and fail at the end of the test suite.
24
+ */
25
+ var STRATEGY;
26
+ (function (STRATEGY) {
27
+ STRATEGY[STRATEGY["failFast"] = 0] = "failFast";
28
+ STRATEGY[STRATEGY["failAfterAll"] = 1] = "failAfterAll";
29
+ STRATEGY[STRATEGY["failAfterEach"] = 2] = "failAfterEach";
30
+ })(STRATEGY || (STRATEGY = {}));
31
+ /**
32
+ * Returns the current strategy for handling JavaScript errors and warnings in Cypress tests.
33
+ * @returns {STRATEGY} - The current strategy for handling JavaScript errors and warnings.
34
+ * @note be careful with Cypress.env(envVarStrategy), since it might return `0` for `failFast` strategy,
35
+ * which is falsy in JavaScript, so we need to check if the variable is undefined.
36
+ */
37
+ function getStrategy() {
38
+ return typeof Cypress.env(envVarStrategy) === 'undefined' ? STRATEGY.failFast : Cypress.env(envVarStrategy);
39
+ }
40
+ /**
41
+ * Sets the strategy for handling JavaScript errors and warnings in Cypress tests.
42
+ * @param {STRATEGY} strategy - Strategy for handling JavaScript errors and warnings.
43
+ * @throws {Error} If an invalid strategy is provided.
44
+ * @returns {void}
45
+ */
46
+ function setStrategy(strategy) { Cypress.env(envVarStrategy, strategy); }
47
+ /**
48
+ * Checks if the js errors and warnings logger is disabled.
49
+ * @returns {boolean} - true if the logger is disabled, false otherwise.
50
+ */
51
+ function isDisabled() { return Cypress.env(envVarDisabled) === true; }
52
+ /**
53
+ * Sets the list of allowed warnings that will not be reported by the logger.
54
+ * @param warnings {string[]} - Array of warning messages to be allowed.
55
+ * @return {void}
56
+ */
57
+ function setAllowedJsWarnings(warnings) { Cypress.env(envVarAllowedWarnings, warnings); }
58
+ /**
59
+ * Attaches custom hooks to Cypress events to monitor and report JavaScript errors and warnings.
60
+ * This method is called automatically in registerSupport.ts#registerSupport
61
+ * It sets up listeners for console errors and warnings, collects them after each test,
62
+ * and throws an error if any issues are found after all tests are executed.
63
+ */
64
+ function attachHooks() {
65
+ // Skip hook attachment if the logger is disabled (e.g. from CI/CD pipeline)
66
+ if (isDisabled()) {
67
+ return;
68
+ }
69
+ switch (getStrategy()) {
70
+ case STRATEGY.failAfterAll:
71
+ attachFailAfterAll();
72
+ break;
73
+ case STRATEGY.failAfterEach:
74
+ attachFailAfterEach();
75
+ break;
76
+ default:
77
+ attachFailFast();
78
+ }
79
+ }
80
+ /**
81
+ * Custom hook implementation which fails the test after all tests are executed if any JavaScript errors or warnings are found.
82
+ *
83
+ * Proc: Allows all tests to run, collects console errors and warnings, and fails the test suite at the end if any issues are found.
84
+ * This is useful for reporting all issues at once after all tests are executed, rather than failing immediately on the first issue.
85
+ * Cons: Reporting might be confusing, e.g. - cypress will report the very last test as failed, while many tests might have issues.
86
+ * This is because the hook is executed after all tests are completed, so the last test is reported as failed.
87
+ */
88
+ function attachFailAfterAll() {
89
+ /**
90
+ * Custom 'window:before:load' hook to spy on console errors and warnings
91
+ * This hook is executed before the page is loaded, allowing us to capture console messages.
92
+ */
93
+ Cypress.on('window:before:load', function (window) {
94
+ // Skip 'window:before:load' hook if the logger is not enabled
95
+ // Double-check in case if functionality was disabled within the test-case code
96
+ // to skip js validations for some particular test and enable it afterward
97
+ if (isDisabled()) {
98
+ return;
99
+ }
100
+ cy.spy(window.console, 'error').as('errors');
101
+ cy.spy(window.console, 'warn').as('warnings');
102
+ });
103
+ /**
104
+ * Custom 'afterEach' hook to collect console errors and warnings
105
+ */
106
+ afterEach(function () {
107
+ // Skip 'afterEach' hook if the logger is not enabled
108
+ // Double-check in case if functionality was disabled within the test-case code
109
+ // to skip js validations for some particular test and enable it afterward
110
+ if (isDisabled()) {
111
+ return;
112
+ }
113
+ var consoleIssues = [];
114
+ var allowedWarnings = Cypress.env(envVarAllowedWarnings) || [];
115
+ // All errors should be collected
116
+ cy.get('@errors')
117
+ .invoke('getCalls')
118
+ .then(function (calls) { consoleIssues = calls; });
119
+ // Only warnings not in the allowed list should be collected
120
+ cy.get('@warnings')
121
+ .invoke('getCalls')
122
+ .each(function (call) {
123
+ call.args.forEach(function (arg) {
124
+ if (!allowedWarnings.some(function (item) { return arg.includes(item); })) {
125
+ consoleIssues.push(arg);
126
+ }
127
+ });
128
+ });
129
+ // Collect all issues and store them in the Cypress environment variable for later usage
130
+ cy.then(function () {
131
+ if (consoleIssues.length > 0) {
132
+ Cypress.env(envVarCollector, __spreadArray(__spreadArray([], (Cypress.env(envVarCollector) || [])), [{
133
+ test: Cypress.currentTest.title,
134
+ errors: consoleIssues
135
+ }]));
136
+ }
137
+ });
138
+ });
139
+ /**
140
+ * Custom 'after' hook to analyze collected errors and warnings after all tests are executed.
141
+ */
142
+ after(function () {
143
+ // Skip 'after' hook if the logger is not enabled
144
+ // Double-check in case if functionality was disabled within the test-case code
145
+ // to skip js validations for some particular test and enable it afterward
146
+ if (isDisabled()) {
147
+ return;
148
+ }
149
+ // Analyze collected errors and warnings
150
+ var failures = Cypress.env(envVarCollector) || [];
151
+ cy.log('[JS ERRORS LOGGER] Analyze collected issues').then(function () {
152
+ if (failures.length > 0) {
153
+ // Format the error message for each test
154
+ var errorMessage = failures.map(function (failure) {
155
+ return "TEST: " + failure.test + "\nISSUES:\n" + failure.errors.map(function (e) { return "- " + e; }).join('\n');
156
+ }).join('\n\n');
157
+ // Throw an error with the collected issues
158
+ throw new Error('CONSOLE ERRORS and WARNINGS FOUND:\n\n' + errorMessage);
159
+ }
160
+ else {
161
+ cy.log('[JS ERRORS LOGGER] No console errors or warnings found.');
162
+ }
163
+ });
164
+ });
165
+ }
166
+ /**
167
+ * Custom hook implementation which fails the test after each test execution if any JavaScript errors or warnings are found.
168
+ *
169
+ * Proc: Allows each test to run, collects console errors and warnings, and fails the particular test by the end of it's execution
170
+ * if any issues are found.
171
+ * Cons: If errors or warnings were found during beforeEach or afterEach hook(s), the rest of spec will be ignored.
172
+ */
173
+ function attachFailAfterEach() {
174
+ // Double-check in case if functionality was disabled within the test-case code
175
+ // to skip js validations for some particular test and enable it afterward
176
+ if (isDisabled()) {
177
+ return;
178
+ }
179
+ /**
180
+ * Custom 'window:before:load' hook to spy on console errors and warnings
181
+ * This hook is executed before the page is loaded, allowing us to capture console messages.
182
+ */
183
+ Cypress.on('window:before:load', function (window) {
184
+ cy.spy(window.console, 'error').as('errors');
185
+ cy.spy(window.console, 'warn').as('warnings');
186
+ });
187
+ /**
188
+ * Custom 'afterEach' hook to collect console errors and warnings
189
+ */
190
+ afterEach(function () {
191
+ var consoleIssues = [];
192
+ var allowedWarnings = Cypress.env(envVarAllowedWarnings) || [];
193
+ // All errors should be collected
194
+ cy.get('@errors')
195
+ .invoke('getCalls')
196
+ .then(function (calls) { consoleIssues = calls; });
197
+ // Only warnings not in the allowed list should be collected
198
+ cy.get('@warnings')
199
+ .invoke('getCalls')
200
+ .each(function (call) {
201
+ call.args.forEach(function (arg) {
202
+ if (!allowedWarnings.some(function (item) { return arg.includes(item); })) {
203
+ consoleIssues.push(arg);
204
+ }
205
+ });
206
+ });
207
+ // Analyze collected errors and warnings
208
+ cy.log('[JS ERRORS LOGGER] Analyze collected issues').then(function () {
209
+ if (consoleIssues.length > 0) {
210
+ // Format the error message for each test
211
+ var errorMessage = consoleIssues.map(function (e) { return "- " + e; }).join('\n');
212
+ // Throw an error with the collected issues
213
+ throw new Error('CONSOLE ERRORS and WARNINGS FOUND:\n\n' + errorMessage);
214
+ }
215
+ else {
216
+ cy.log('[JS ERRORS LOGGER] No console errors or warnings found.');
217
+ }
218
+ });
219
+ });
220
+ }
221
+ /**
222
+ * Custom hook implementation which fails the test immediately when a JavaScript error or warning is detected.
223
+ *
224
+ * Proc: Allows each test to run, looks for console errors and warnings, and fails the particular test IMMEDIATELLY
225
+ * if any issues are found.
226
+ * Cons: If errors or warnings were found during beforeEach or afterEach hook(s), the rest of spec will be ignored.
227
+ */
228
+ function attachFailFast() {
229
+ // Double-check in case if functionality was disabled within the test-case code
230
+ // to skip js validations for some particular test and enable it afterward
231
+ if (isDisabled()) {
232
+ return;
233
+ }
234
+ /**
235
+ * Custom 'window:before:load' hook to spy on console errors and warnings
236
+ * This hook is executed before the page is loaded, allowing us to capture console messages.
237
+ */
238
+ Cypress.on('window:before:load', function (window) {
239
+ cy.spy(window.console, 'error').as('errors');
240
+ cy.spy(window.console, 'warn').as('warnings');
241
+ });
242
+ Cypress.on('window:load', function () {
243
+ // DOM should be loaded and parsed by now, so we can check for console errors and warnings
244
+ var consoleIssues = [];
245
+ var allowedWarnings = Cypress.env(envVarAllowedWarnings) || [];
246
+ // All errors should be collected
247
+ cy.get('@errors')
248
+ .invoke('getCalls')
249
+ .then(function (calls) { consoleIssues = calls; });
250
+ // Only warnings not in the allowed list should be collected
251
+ cy.get('@warnings')
252
+ .invoke('getCalls')
253
+ .each(function (call) {
254
+ call.args.forEach(function (arg) {
255
+ if (!allowedWarnings.some(function (item) { return arg.includes(item); })) {
256
+ consoleIssues.push(arg);
257
+ }
258
+ });
259
+ }).then(function () {
260
+ if (consoleIssues.length > 0) {
261
+ // Format the error message for each test
262
+ var errorMessage = consoleIssues.map(function (e) { return "- " + e; }).join('\n');
263
+ // Throw an error with the collected issues
264
+ throw new Error('CONSOLE ERRORS and WARNINGS FOUND:\n' + errorMessage);
265
+ }
266
+ else {
267
+ cy.log('[JS ERRORS LOGGER] No console errors or warnings found.');
268
+ }
269
+ });
270
+ });
271
+ }
272
+ /**
273
+ * Exports the jsLogger module with methods to attach hooks, enable/disable logging, and set allowed warnings.
274
+ */
275
+ exports.jsErrorsLogger = {
276
+ attachHooks: attachHooks,
277
+ setAllowedJsWarnings: setAllowedJsWarnings,
278
+ setStrategy: setStrategy,
279
+ STRATEGY: STRATEGY
280
+ };
@@ -18,7 +18,8 @@ var executeGroovy = function (scriptFile, replacements, jahiaServer) {
18
18
  files: [{
19
19
  fileName: scriptFile,
20
20
  replacements: replacements,
21
- type: 'text/plain'
21
+ type: 'text/plain',
22
+ encoding: 'utf-8'
22
23
  }],
23
24
  jahiaServer: jahiaServer
24
25
  }).then(function (r) { return r[0]; });
@@ -1,4 +1,4 @@
1
1
  export * from './executeGroovy';
2
2
  export * from './runProvisioningScript';
3
- export * from './installBundle';
4
- export * from './uninstallBundle';
3
+ export * from './installModule';
4
+ export * from './uninstallModule';
@@ -12,5 +12,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
12
12
  exports.__esModule = true;
13
13
  __exportStar(require("./executeGroovy"), exports);
14
14
  __exportStar(require("./runProvisioningScript"), exports);
15
- __exportStar(require("./installBundle"), exports);
16
- __exportStar(require("./uninstallBundle"), exports);
15
+ __exportStar(require("./installModule"), exports);
16
+ __exportStar(require("./uninstallModule"), exports);
@@ -0,0 +1,11 @@
1
+ /// <reference types="cypress" />
2
+ declare global {
3
+ namespace Cypress {
4
+ interface Chainable<Subject> {
5
+ installModule(moduleFile: string): Chainable<Cypress.Response<any>>;
6
+ installAndStartModule(moduleFile: string): Chainable<Cypress.Response<any>>;
7
+ }
8
+ }
9
+ }
10
+ export declare const installModule: (moduleFile: string) => void;
11
+ export declare const installAndStartModule: (moduleFile: string) => void;
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ /* eslint-disable @typescript-eslint/no-explicit-any, @typescript-eslint/no-namespace */
3
+ exports.__esModule = true;
4
+ exports.installAndStartModule = exports.installModule = void 0;
5
+ /// <reference types="cypress" />
6
+ var installModule = function (moduleFile) {
7
+ cy.runProvisioningScript({
8
+ script: [{ installModule: moduleFile }],
9
+ files: [{
10
+ fileName: moduleFile,
11
+ type: 'text/plain'
12
+ }]
13
+ });
14
+ };
15
+ exports.installModule = installModule;
16
+ var installAndStartModule = function (moduleFile) {
17
+ cy.runProvisioningScript({
18
+ script: [{ installAndStartModule: moduleFile }],
19
+ files: [{
20
+ fileName: moduleFile,
21
+ type: 'text/plain'
22
+ }]
23
+ });
24
+ };
25
+ exports.installAndStartModule = installAndStartModule;
@@ -20,6 +20,14 @@ function processContent(formFile) {
20
20
  });
21
21
  }
22
22
  formFile.fileContent = content;
23
+ // If the file has an encoding, create a Blob with the new Blob constructor. It handle correctly the encoding
24
+ // for the groovy scripts
25
+ // Did not change for all files because jar files can be added as well, which are binary files
26
+ // In that case the function binaryStringToBlob will be used
27
+ if (formFile.encoding) {
28
+ return new Blob([content], { type: formFile.type });
29
+ }
30
+ // Default to binary string to blob conversion
23
31
  return Cypress.Blob.binaryStringToBlob(content, formFile.type);
24
32
  }
25
33
  function append(formFile, formData, key) {
@@ -2,8 +2,8 @@
2
2
  declare global {
3
3
  namespace Cypress {
4
4
  interface Chainable<Subject> {
5
- uninstallBundle(bundleSymbolicName: string): Chainable<Cypress.Response<any>>;
5
+ uninstallModule(moduleSymbolicName: string): Chainable<Cypress.Response<any>>;
6
6
  }
7
7
  }
8
8
  }
9
- export declare const uninstallBundle: (bundleSymbolicName: string) => void;
9
+ export declare const uninstallModule: (moduleSymbolicName: string) => void;
@@ -1,14 +1,14 @@
1
1
  "use strict";
2
2
  /* eslint-disable @typescript-eslint/no-explicit-any, @typescript-eslint/no-namespace */
3
3
  exports.__esModule = true;
4
- exports.uninstallBundle = void 0;
4
+ exports.uninstallModule = void 0;
5
5
  /// <reference types="cypress" />
6
- var uninstallBundle = function (bundleSymbolicName) {
6
+ var uninstallModule = function (moduleSymbolicName) {
7
7
  cy.runProvisioningScript({
8
8
  script: {
9
- fileContent: '- uninstallBundle: "' + bundleSymbolicName + '"\n',
9
+ fileContent: '- uninstallModule: "' + moduleSymbolicName + '"\n',
10
10
  type: 'application/yaml'
11
11
  }
12
12
  });
13
13
  };
14
- exports.uninstallBundle = uninstallBundle;
14
+ exports.uninstallModule = uninstallModule;
@@ -7,16 +7,26 @@ var login_1 = require("./login");
7
7
  var logout_1 = require("./logout");
8
8
  var fixture_1 = require("./fixture");
9
9
  var repeatUntil_1 = require("./repeatUntil");
10
+ var testStep_1 = require("./testStep");
11
+ var jsErrorsLogger_1 = require("./jsErrorsLogger");
10
12
  var registerSupport = function () {
11
13
  Cypress.Commands.add('apolloClient', apollo_1.apolloClient);
12
14
  Cypress.Commands.add('apollo', { prevSubject: 'optional' }, apollo_1.apollo);
13
15
  Cypress.Commands.add('runProvisioningScript', provisioning_1.runProvisioningScript);
14
16
  Cypress.Commands.add('executeGroovy', provisioning_1.executeGroovy);
15
- Cypress.Commands.add('installBundle', provisioning_1.installBundle);
17
+ Cypress.Commands.add('installModule', provisioning_1.installModule);
18
+ Cypress.Commands.add('installAndStartModule', provisioning_1.installAndStartModule);
19
+ Cypress.Commands.add('uninstallModule', provisioning_1.uninstallModule);
16
20
  Cypress.Commands.add('login', login_1.login);
17
21
  Cypress.Commands.add('loginAndStoreSession', login_1.loginAndStoreSession);
18
22
  Cypress.Commands.add('logout', logout_1.logout);
19
23
  Cypress.Commands.add('repeatUntil', repeatUntil_1.repeatUntil);
20
24
  Cypress.Commands.overwrite('fixture', fixture_1.fixture);
25
+ Cypress.Commands.add('step', testStep_1.step);
26
+ // Since registerSupport() function is called in each repo from e2e.js,
27
+ // attaching the JavaScript errors logger hooks here ensures that logger is initialized automatically
28
+ // for all tests without needing to call it explicitly in each test file.
29
+ // This is useful for capturing and logging JavaScript errors across all tests.
30
+ jsErrorsLogger_1.jsErrorsLogger.attachHooks();
21
31
  };
22
32
  exports.registerSupport = registerSupport;
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Extends global Cypress Chainable interface with custom commands from 'commands.js' to avoid TypeScript errors when using them.
3
+ */
4
+ declare global {
5
+ namespace Cypress {
6
+ interface Chainable<Subject> {
7
+ /**
8
+ * Creates a foldable test-case step with corresponding message in Cypress log
9
+ * @param {string} message - folder's message
10
+ * @param {() => void} func - function to be executed and wrapped into the folder
11
+ * @returns void
12
+ * @example
13
+ * cy.step('Navigate to the destination point', () => {
14
+ * cy.get('selector').click();
15
+ * ...
16
+ * });
17
+ *
18
+ * cy.step('Do something', () => {
19
+ * cy.get('element').click();
20
+ * ...
21
+ * });
22
+ */
23
+ step(message: string, func: () => void): void;
24
+ }
25
+ }
26
+ }
27
+ export declare const step: (message: string, func: () => void) => void;
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ exports.__esModule = true;
3
+ exports.step = void 0;
4
+ var step = function (message, func) {
5
+ cy.then(function () {
6
+ // @ts-ignore
7
+ Cypress.log({ groupStart: true, displayName: '[ STEP ]', message: "" + message });
8
+ }).then(function () {
9
+ func();
10
+ }).then(function () {
11
+ // @ts-ignore
12
+ Cypress.log({ groupEnd: true, emitOnly: true });
13
+ });
14
+ };
15
+ exports.step = step;
@@ -0,0 +1,54 @@
1
+ /**
2
+ * Helper module to decorate Cypress log messages with different log levels (INFO and DEBUG at the moment).
3
+ * @example
4
+ * // Switch default logging verbosity to DEBUG
5
+ * Log.setVerbosity(Log.LEVELS.DEBUG);
6
+ *
7
+ * Log.info('This is an info message');
8
+ * Log.debug('This is a debug message');
9
+ * Log.json(Log.LEVELS.DEBUG, myJSON);
10
+ * Log.info('My info message').then(() => { ... });
11
+ *
12
+ * @note The log verbosity can be set by calling `Log.setVerbosity(Log.LEVELS.DEBUG)` in the code (default is `INFO`).
13
+ * It tells the logger to log only messages with the given level and above.
14
+ */
15
+ /**
16
+ * Logging levels enumerator.
17
+ */
18
+ declare enum LEVEL {
19
+ DEBUG = 0,
20
+ INFO = 1
21
+ }
22
+ /**
23
+ * Sets the logging verbosity level for the logger. Messages with a level lower than the set level will not be logged.
24
+ * @param {LEVEL} level - log level to be set (e.g. 'DEBUG', 'INFO')
25
+ * @return {void}
26
+ */
27
+ declare function setVerbosity(level: LEVEL): void;
28
+ /**
29
+ * Logs INFO message
30
+ * @param {string} message - log message
31
+ * @returns {Cypress.Chainable} - Cypress chainable object
32
+ */
33
+ declare function info(message: string): Cypress.Chainable;
34
+ /**
35
+ * Logs DEBUG message
36
+ * @param {string} message - log message
37
+ * @returns {Cypress.Chainable} - Cypress chainable object
38
+ */
39
+ declare function debug(message: string): Cypress.Chainable;
40
+ /**
41
+ * Logs JSON object with logging level given
42
+ * @param {LEVEL} level - log level (e.g. 'INFO', 'DEBUG')
43
+ * @param {string} text - json object to be logged
44
+ * @returns {Cypress.Chainable} - Cypress chainable object
45
+ */
46
+ declare function json(level: LEVEL, text: string): Cypress.Chainable;
47
+ export declare const Log: {
48
+ info: typeof info;
49
+ debug: typeof debug;
50
+ json: typeof json;
51
+ setVerbosity: typeof setVerbosity;
52
+ LEVEL: typeof LEVEL;
53
+ };
54
+ export {};