-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.js
29 lines (27 loc) · 1.03 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
afterEach(() => {
const screenshotsFolder = Cypress.config("screenshotsFolder");
if (window.cucumberJson?.generate) {
const testState = window.testState;
const stepResult =
testState.runTests[testState.currentScenario.name][testState.currentStep];
if (stepResult?.status === "failed") {
const scenarioName = testState.currentScenario.name.endsWith('.') ?
testState.currentScenario.name.substring(0, testState.currentScenario.name.length - 1) :
testState.currentScenario.name;
const screenshotFileName = `${testState.feature.name} -- ${scenarioName} (failed).png`;
cy.readFile(
`${screenshotsFolder}/${Cypress.spec.name}/${screenshotFileName}`,
"base64"
).then((imgData) => {
if(imgData) {
stepResult.attachment = {
data: imgData,
media: { type: "image/png" },
index: testState.currentStep,
testCase: testState.formatTestCase(testState.currentScenario),
};
}
});
}
}
});