@centreon/js-config 25.10.1 â 25.10.2
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.
|
@@ -6,6 +6,9 @@ const {
|
|
|
6
6
|
} = require('@simonsmith/cypress-image-snapshot/plugin');
|
|
7
7
|
const cypressCodeCoverageTask = require('@cypress/code-coverage/task');
|
|
8
8
|
|
|
9
|
+
const fs = require('fs');
|
|
10
|
+
const path = require('path');
|
|
11
|
+
|
|
9
12
|
module.exports = ({
|
|
10
13
|
rspackConfig,
|
|
11
14
|
cypressFolder,
|
|
@@ -41,6 +44,35 @@ module.exports = ({
|
|
|
41
44
|
|
|
42
45
|
return launchOptions;
|
|
43
46
|
});
|
|
47
|
+
|
|
48
|
+
on('after:run', (results) => {
|
|
49
|
+
const testRetries = {};
|
|
50
|
+
if ('runs' in results) {
|
|
51
|
+
results.runs.forEach((run) => {
|
|
52
|
+
run.tests.forEach((test) => {
|
|
53
|
+
if (test.attempts && test.attempts.length > 1 && test.state === 'passed') {
|
|
54
|
+
const testTitle = test.title.join(' > '); // Convert the array to a string
|
|
55
|
+
testRetries[testTitle] = test.attempts.length - 1;
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// Save the testRetries object to a file in the e2e/results directory
|
|
62
|
+
const resultFilePath = path.join(
|
|
63
|
+
mainCypressFolder,
|
|
64
|
+
'results',
|
|
65
|
+
'retries.json'
|
|
66
|
+
);
|
|
67
|
+
|
|
68
|
+
fs.writeFileSync(resultFilePath, JSON.stringify(testRetries, null, 2));
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
on('after:spec', () => {
|
|
72
|
+
if (global.__coverage__) {
|
|
73
|
+
delete global.__coverage__;
|
|
74
|
+
}
|
|
75
|
+
});
|
|
44
76
|
},
|
|
45
77
|
specPattern,
|
|
46
78
|
supportFile: `${mainCypressFolder}/support/component.tsx`
|
|
@@ -58,6 +90,7 @@ module.exports = ({
|
|
|
58
90
|
},
|
|
59
91
|
...env
|
|
60
92
|
},
|
|
93
|
+
numTestsKeptInMemory: 1,
|
|
61
94
|
reporter: 'mochawesome',
|
|
62
95
|
reporterOptions: {
|
|
63
96
|
html: false,
|
|
@@ -66,6 +99,10 @@ module.exports = ({
|
|
|
66
99
|
reportDir: `${mainCypressFolder}/results`,
|
|
67
100
|
reportFilename: '[name]-report.json'
|
|
68
101
|
},
|
|
102
|
+
retries: {
|
|
103
|
+
openMode: 0,
|
|
104
|
+
runMode: 2
|
|
105
|
+
},
|
|
69
106
|
video: true,
|
|
70
107
|
videosFolder: `${mainCypressFolder}/results/videos`,
|
|
71
108
|
viewportHeight: 590,
|
package/cypress/e2e/tasks.ts
CHANGED
|
@@ -19,13 +19,6 @@ interface Containers {
|
|
|
19
19
|
[key: string]: StartedTestContainer;
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
class NotFoundContainerError extends Error {
|
|
23
|
-
constructor(message) {
|
|
24
|
-
super(message);
|
|
25
|
-
this.name = 'NotFoundContainerError';
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
|
|
29
22
|
export default (on: Cypress.PluginEvents): void => {
|
|
30
23
|
let dockerEnvironment: StartedDockerComposeEnvironment | null = null;
|
|
31
24
|
const containers: Containers = {};
|
|
@@ -38,7 +31,7 @@ export default (on: Cypress.PluginEvents): void => {
|
|
|
38
31
|
} else if (containers[containerName]) {
|
|
39
32
|
container = containers[containerName];
|
|
40
33
|
} else {
|
|
41
|
-
throw new
|
|
34
|
+
throw new Error(`Cannot get container ${containerName}`);
|
|
42
35
|
}
|
|
43
36
|
|
|
44
37
|
return container;
|
|
@@ -61,6 +54,35 @@ export default (on: Cypress.PluginEvents): void => {
|
|
|
61
54
|
}
|
|
62
55
|
|
|
63
56
|
on("task", {
|
|
57
|
+
checkDockerImage: async (params: StartContainerProps) => {
|
|
58
|
+
const { image, name } = params;
|
|
59
|
+
console.log(`đ [checkDockerImage] Checking if image exists: ${image}`);
|
|
60
|
+
|
|
61
|
+
if (!image) {
|
|
62
|
+
console.error("â [checkDockerImage] No image name provided");
|
|
63
|
+
return { exists: false, error: "Image name is undefined" };
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
try {
|
|
67
|
+
execSync(`docker image inspect ${image}`, { stdio: "ignore" });
|
|
68
|
+
console.log(`â
[checkDockerImage] Image already exists locally: ${image}`);
|
|
69
|
+
return { exists: true, image };
|
|
70
|
+
} catch {
|
|
71
|
+
console.log(`âšī¸ [checkDockerImage] Image not found locally, trying to pull...`);
|
|
72
|
+
|
|
73
|
+
try {
|
|
74
|
+
execSync(`docker pull ${image}`, { stdio: "pipe" });
|
|
75
|
+
console.log(`â
[checkDockerImage] Image successfully pulled: ${image}`);
|
|
76
|
+
return { exists: true, image };
|
|
77
|
+
} catch (err: unknown) {
|
|
78
|
+
const errorMessage =
|
|
79
|
+
err instanceof Error ? err.message : JSON.stringify(err);
|
|
80
|
+
console.warn(`â ī¸ [checkDockerImage] Image not found or pull failed: ${errorMessage}`);
|
|
81
|
+
|
|
82
|
+
return { exists: false, error: errorMessage, image };
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
},
|
|
64
86
|
copyFromContainer: async ({ destination, serviceName, source }) => {
|
|
65
87
|
try {
|
|
66
88
|
const container = getContainer(serviceName);
|
|
@@ -75,11 +97,7 @@ export default (on: Cypress.PluginEvents): void => {
|
|
|
75
97
|
});
|
|
76
98
|
});
|
|
77
99
|
} catch (error) {
|
|
78
|
-
|
|
79
|
-
console.log(`Cannot get ${source} from container ${serviceName} because it doesn't exist.`);
|
|
80
|
-
} else {
|
|
81
|
-
console.error(error);
|
|
82
|
-
}
|
|
100
|
+
console.error(error);
|
|
83
101
|
}
|
|
84
102
|
|
|
85
103
|
return null;
|
package/package.json
CHANGED