@centreon/js-config 24.10.5 → 24.10.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.
@@ -1,76 +1,116 @@
1
- /* eslint-disable @typescript-eslint/no-var-requires */
2
- const { devServer } = require('cypress-rspack-dev-server');
3
- const { defineConfig } = require('cypress');
4
- const {
5
- addMatchImageSnapshotPlugin
6
- } = require('@simonsmith/cypress-image-snapshot/plugin');
7
- const cypressCodeCoverageTask = require('@cypress/code-coverage/task');
8
-
9
- module.exports = ({
10
- rspackConfig,
11
- cypressFolder,
12
- specPattern,
13
- env,
14
- excludeSpecPattern
15
- }) => {
16
- const mainCypressFolder = cypressFolder || 'cypress';
17
-
18
- return defineConfig({
19
- component: {
20
- devServer: (devServerConfig) =>
21
- devServer({
22
- ...devServerConfig,
23
- framework: 'react',
24
- rspackConfig
25
- }),
26
- excludeSpecPattern,
27
- setupNodeEvents: (on, config) => {
28
- addMatchImageSnapshotPlugin(on, config);
29
-
30
- cypressCodeCoverageTask(on, config);
31
- on('task', {
32
- coverageReport: () => {
33
- return null;
34
- }
35
- });
36
-
37
- on('before:browser:launch', (browser, launchOptions) => {
38
- if (browser.name === 'chrome' && browser.isHeadless) {
39
- launchOptions.args.push('--headless=new');
40
- launchOptions.args.push('--force-color-profile=srgb');
41
- launchOptions.args.push('--window-size=1400,1200');
42
- }
43
-
44
- return launchOptions;
45
- });
46
- },
47
- specPattern,
48
- supportFile: `${mainCypressFolder}/support/component.tsx`
49
- },
50
- env: {
51
- baseUrl: 'http://localhost:9092',
52
- codeCoverage: {
53
- exclude: [
54
- 'cypress/**/*.*',
55
- 'packages/**',
56
- 'node_modules',
57
- '**/*.js',
58
- '**/*.spec.tsx'
59
- ]
60
- },
61
- ...env
62
- },
63
- reporter: 'mochawesome',
64
- reporterOptions: {
65
- html: false,
66
- json: true,
67
- overwrite: true,
68
- reportDir: `${mainCypressFolder}/results`,
69
- reportFilename: '[name]-report.json'
70
- },
71
- video: true,
72
- videosFolder: `${mainCypressFolder}/results/videos`,
73
- viewportHeight: 590,
74
- viewportWidth: 1280
75
- });
76
- };
1
+ /* eslint-disable @typescript-eslint/no-var-requires */
2
+ const { devServer } = require('cypress-rspack-dev-server');
3
+ const { defineConfig } = require('cypress');
4
+ const {
5
+ addMatchImageSnapshotPlugin
6
+ } = require('@simonsmith/cypress-image-snapshot/plugin');
7
+ const cypressCodeCoverageTask = require('@cypress/code-coverage/task');
8
+
9
+ const fs = require('fs');
10
+ const path = require('path');
11
+
12
+ module.exports = ({
13
+ rspackConfig,
14
+ cypressFolder,
15
+ specPattern,
16
+ env,
17
+ excludeSpecPattern
18
+ }) => {
19
+ const mainCypressFolder = cypressFolder || 'cypress';
20
+
21
+ return defineConfig({
22
+ component: {
23
+ devServer: (devServerConfig) =>
24
+ devServer({
25
+ ...devServerConfig,
26
+ framework: 'react',
27
+ rspackConfig
28
+ }),
29
+ excludeSpecPattern,
30
+ setupNodeEvents: (on, config) => {
31
+ addMatchImageSnapshotPlugin(on, config);
32
+
33
+ cypressCodeCoverageTask(on, config);
34
+ on('task', {
35
+ coverageReport: () => {
36
+ return null;
37
+ }
38
+ });
39
+
40
+ on('before:browser:launch', (browser, launchOptions) => {
41
+ if (browser.name === 'chrome' && browser.isHeadless) {
42
+ launchOptions.args.push('--headless=new');
43
+ launchOptions.args.push('--force-color-profile=srgb');
44
+ launchOptions.args.push('--window-size=1400,1200');
45
+ launchOptions.args.push('--max-old-space-size=4096');
46
+ launchOptions.args.push('--disable-dev-shm-usage');
47
+ launchOptions.args.push('--disable-gpu');
48
+ launchOptions.args.push('--no-sandbox');
49
+ }
50
+
51
+ return launchOptions;
52
+ });
53
+
54
+ on('after:run', (results) => {
55
+ const testRetries = {};
56
+ if ('runs' in results) {
57
+ results.runs.forEach((run) => {
58
+ run.tests.forEach((test) => {
59
+ if (test.attempts && test.attempts.length > 1 && test.state === 'passed') {
60
+ const testTitle = test.title.join(' > '); // Convert the array to a string
61
+ testRetries[testTitle] = test.attempts.length - 1;
62
+ }
63
+ });
64
+ });
65
+ }
66
+
67
+ // Save the testRetries object to a file in the e2e/results directory
68
+ const resultFilePath = path.join(
69
+ mainCypressFolder,
70
+ 'results',
71
+ 'retries.json'
72
+ );
73
+
74
+ fs.writeFileSync(resultFilePath, JSON.stringify(testRetries, null, 2));
75
+ });
76
+
77
+ on('after:spec', () => {
78
+ if (global.__coverage__) {
79
+ delete global.__coverage__;
80
+ }
81
+ });
82
+ },
83
+ specPattern,
84
+ supportFile: `${mainCypressFolder}/support/component.tsx`
85
+ },
86
+ env: {
87
+ baseUrl: 'http://localhost:9092',
88
+ codeCoverage: {
89
+ exclude: [
90
+ 'cypress/**/*.*',
91
+ 'packages/**',
92
+ 'node_modules',
93
+ '**/*.js',
94
+ '**/*.spec.tsx'
95
+ ]
96
+ },
97
+ ...env
98
+ },
99
+ reporter: 'mochawesome',
100
+ reporterOptions: {
101
+ html: false,
102
+ json: true,
103
+ overwrite: true,
104
+ reportDir: `${mainCypressFolder}/results`,
105
+ reportFilename: '[name]-report.json'
106
+ },
107
+ retries: {
108
+ openMode: 0,
109
+ runMode: 2
110
+ },
111
+ video: true,
112
+ videosFolder: `${mainCypressFolder}/results/videos`,
113
+ viewportHeight: 590,
114
+ viewportWidth: 1280
115
+ });
116
+ };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@centreon/js-config",
3
3
  "description": "Centreon Frontend shared build configuration",
4
- "version": "24.10.5",
4
+ "version": "24.10.7",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git+https://github.com/centreon/centreon-frontend.git"