Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
dane-harnett committed Jul 27, 2021
1 parent 3c9b295 commit 2fc914f
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
22 changes: 22 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
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 screenshotFileName = `${testState.feature.name} -- ${testState.currentScenario.name} (failed).png`;
cy.readFile(
`${screenshotsFolder}/${Cypress.spec.name}/${screenshotFileName}`,
"base64"
).then((imgData) => {
stepResult.attachment = {
data: imgData,
media: { type: "image/png" },
index: testState.currentStep,
testCase: testState.formatTestCase(testState.currentScenario),
};
});
}
}
});
18 changes: 18 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"name": "cypress-cucumber-attach-screenshots-to-failed-steps",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "git+https://github.com/dane-harnett/cypress-cucumber-attach-screenshots-to-failed-steps.git"
},
"author": "",
"bugs": {
"url": "https://github.com/dane-harnett/cypress-cucumber-attach-screenshots-to-failed-steps/issues"
},
"homepage": "https://github.com/dane-harnett/cypress-cucumber-attach-screenshots-to-failed-steps#readme"
}

0 comments on commit 2fc914f

Please sign in to comment.