Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Screenshots are not added to the Cucumber JSON #705

Closed
GRmeB opened this issue May 6, 2022 · 4 comments
Closed

Screenshots are not added to the Cucumber JSON #705

GRmeB opened this issue May 6, 2022 · 4 comments

Comments

@GRmeB
Copy link
Contributor

GRmeB commented May 6, 2022

Current behavior

With the new plugin version 9.1.3 the screenshots are not added to the Cucumber JSON if a test will fail. Of course the screenshotOnRunFailure is set to true.

The screenshots are correctly generated and located under cypress/screenshots/, as for me e.g. as cypress/screenshots/features/landingPage.feature/Landing Page -- Check landing page (example #1) (failed).png.

Desired behavior

If a screenshot is generated it should attached also to the Cucumber JSON report correctly.

Test code to reproduce

The generated Cucumber JSON looks like this at the end:

[
  {
    "description": "",
    "elements": [
      {
        "description": "",
        "id": "landing-page;check-landing-page;;2",
        "keyword": "Scenario Outline",
        "line": 11,
        "name": "Check landing page",
        "steps": [
          {
            "keyword": "Given ",
            "line": 5,
            "name": "the user opens the shop webpage",
            "result": {
              "duration": 7172000000,
              "status": "passed"
            },
            "match": {
              "location": "not available:0"
            }
          },
          {
            "keyword": "When ",
            "line": 6,
            "name": "the user changes the viewport to \"desktop\"",
            "result": {
              "duration": 763000000,
              "status": "passed"
            },
            "match": {
              "location": "not available:0"
            }
          },
          {
            "keyword": "Then ",
            "line": 7,
            "name": "the shop landing page is correctly visible",
            "result": {
              "status": "failed",
              "error_message": "Timed out retrying after 10000ms: Expected to find element: `asdasdasd`, but never found it."
            },
            "match": {
              "location": "not available:0"
            }
          }
        ],
        "type": "scenario",
        "tags": [
          {
            "line": 3,
            "name": "@landingPage"
          },
          {
            "line": 3,
            "name": "@smoke"
          }
        ]
      }
    ],
    "id": "landing-page",
    "keyword": "Feature",
    "line": 1,
    "name": "Landing Page",
    "uri": "cypress/integration/features/landingPage.feature"
  }
]

Versions

  • Cypress version: 9.6.0
  • Preprocessor version: 9.1.3
  • Node version: 16.13.1
@badeball
Copy link
Owner

badeball commented May 6, 2022

You have to provide me with a minimal example that let's me reproduce the behavior.

@GRmeB
Copy link
Contributor Author

GRmeB commented May 12, 2022

@badeball Sorry for the belated answer... Now, I've created a small example from our big project but reduced it, but not everywhere. So, please don't worry about it.

This is the repo: https://github.com/GRmeB/cypress-cucumber-preprocessor-example

You can find two Cucumber testcases, the first one should pass and the second one should fail. For the failed testcase no created screenshot will be attached to the cucumber.json file.

@badeball
Copy link
Owner

This preprocessor will attach a handler on after:screenshot and said handler won't be invoked when you also do that, ref. cypress-io/cypress#6648.

As explained by Chris (cypress-io/cypress#6648 (comment)), this might be considered bad behavior from the preprocessor and we should expose a method which you can call yourself instead (when needed).

Do you need a handler for after:screenshot yourself or is it just there incidentally?

@badeball
Copy link
Owner

I've released v9.2.0 where you can omit attaching event handlers at your own will, as seen here. 15ae6d0 is the relevant commit. As described in the changelog, this is undocumented, but I trust you'll infer how to make stuff work based on the patch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants