haven-cypress-integration 2.0.1 → 2.0.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.
- package/package.json +5 -1
- package/support.js +38 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "haven-cypress-integration",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.2",
|
|
4
4
|
"description": "Seamless Cypress integration with HAVEN test case management",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"bin": {
|
|
@@ -17,10 +17,14 @@
|
|
|
17
17
|
"license": "ISC",
|
|
18
18
|
"files": [
|
|
19
19
|
"index.js",
|
|
20
|
+
"support.js",
|
|
20
21
|
"bin/",
|
|
21
22
|
"templates/",
|
|
22
23
|
"README.md"
|
|
23
24
|
],
|
|
25
|
+
"peerDependencies": {
|
|
26
|
+
"mochawesome": ">=7.0.0"
|
|
27
|
+
},
|
|
24
28
|
"engines": {
|
|
25
29
|
"node": ">=16.0.0"
|
|
26
30
|
}
|
package/support.js
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Haven Cypress Support
|
|
3
|
+
*
|
|
4
|
+
* Import this file in your cypress/support/e2e.ts to enable:
|
|
5
|
+
* - Screenshot attachment to mochawesome HTML reports
|
|
6
|
+
*
|
|
7
|
+
* Usage:
|
|
8
|
+
* import 'haven-cypress-integration/support'
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
const addContext = require('mochawesome/addContext');
|
|
12
|
+
|
|
13
|
+
// Attach failed test screenshots to mochawesome report
|
|
14
|
+
// This enables screenshots to appear inline in the mochawesome HTML report
|
|
15
|
+
Cypress.on('test:after:run', (test, runnable) => {
|
|
16
|
+
if (test.state === 'failed') {
|
|
17
|
+
// Build the screenshot path that Cypress creates (must match Cypress naming exactly)
|
|
18
|
+
const specName = Cypress.spec.name;
|
|
19
|
+
|
|
20
|
+
// Walk up the parent chain to get ALL describe block titles (for nested describes)
|
|
21
|
+
const titleParts = [];
|
|
22
|
+
let parent = runnable.parent;
|
|
23
|
+
while (parent && parent.title) {
|
|
24
|
+
titleParts.unshift(parent.title);
|
|
25
|
+
parent = parent.parent;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// Cypress screenshot naming: {specName}/{all describes joined by ' -- '} -- {testTitle} (failed).png
|
|
29
|
+
const fullTitle = [...titleParts, test.title].join(' -- ');
|
|
30
|
+
const screenshotPath = `screenshots/${specName}/${fullTitle} (failed).png`;
|
|
31
|
+
|
|
32
|
+
// Add screenshot to mochawesome context (will appear in HTML report)
|
|
33
|
+
addContext({ test }, screenshotPath);
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
console.log('[Haven] Screenshot-to-mochawesome integration enabled');
|
|
38
|
+
|