cypress-xray-plugin icon indicating copy to clipboard operation
cypress-xray-plugin copied to clipboard

Failed to import execution: Request failed with status code 400

Open emsalmengus opened this issue 1 year ago • 1 comments

Description

Hello all,

we have successfully integrated the cypress-xray-plugin with version 7.1.0 and Cypress 13.13.1 according to the documentation. However, new cypress tests are not uploaded into Xray. This is true for both when test issue key is included in the title or not. Only by naming test issue keys that already exist in Xray, cypress test results are uploaded.

The authentication works:


Jira PAT found. Setting up Jira server PAT credentials.
Jira PAT found. Setting up Xray server PAT credentials.

But when uploading the results, we get the error message:

Importing Cypress execution...
Failed to import execution: Request failed with status code 400
Complete error logs have been written to: C:\Users\...
Encountered problems during plugin execution! C:/Users/...
Skipping result upload.
......
.....
No test results were uploaded
Failed to upload Cypress execution results.
Caused by: Failed to convert Cypress tests into Xray tests: No Cypress tests to upload

We want to upload new Cypress tests that are not existing in Xray yet. Could you please check this issue out?

Thank you very much.

Best wishes, Emsal

Cypress version

13.13.1

Plugin version

7.1.0

Jira/Xray type

Server

Configuration

const { defineConfig } = require("cypress");
const { configureXrayPlugin } = require ("cypress-xray-plugin");


module.exports = defineConfig({
  e2e: {
    async setupNodeEvents(on, config) {
      await configureXrayPlugin(
        on,
        config,
        {
          jira: {
            projectKey: "***",
            url: "https://****************************(this is our internal jira base url)",
            /*testExecutionIssueKey: "***",*/
            attachVideos: true
          },
          xray: {
            uploadResults: true,
            uploadScreenshots: true,
            uploadRequests: true
          }
        }
      );
    }
  }
});

Acknowledgements

  • [X] I have made sure not to include any sensitive data in screenshots or obfuscated all occurrences.
  • [X] I have made sure not to include any sensitive data in descriptions or replaced all values with placeholders.
  • [X] I have made sure not to include any sensitive data in code snippets or replaced all values with placeholders.

emsalmengus avatar Aug 01 '24 14:08 emsalmengus

Hey @emsalmengus,

thanks for raising this issue.

Only by naming test issue keys that already exist in Xray, cypress test results are uploaded.

To me, it sounds like there are two things going on that are causing you trouble, both of which are actually intended by design.

  • No Xray tests created for untagged Cypress tests: The plugin refuses to upload results for tests that don't exist in Jira (i.e. tests without issue keys in the title). You should hopefully see warnings for these.

    • Why is this not possible? It was possible in the past and it caused a lot of difficult to solve problems (#47, #83, #84), which is why I decided to remove this feature in 4.0.0. The plugin will only work properly/as intended if you treat Xray as the source of truth for test issues.
    • What can you do about this? Unfortunately, for new tests, you will have to manually create the test in Xray and then copy the test issue key to the Cypress test.
  • No results uploaded even though you've tagged everything: Based on the Failed to import execution: Request failed with status code 400 line in your logs, I assume you have tagged every test but the upload still failed. One way to end up with 400 Bad Request is to link Cypress results to non-existent Xray test issues. Xray will then be unable to match the uploaded results and will return a corresponding 400 Bad Request.

    • If this is not what you were trying to do, please enable debug mode and look into the returned response, it usually contains a more detailed explanation as to why the 400 Bad Request occurred.

csvtuda avatar Aug 04 '24 09:08 csvtuda

This issue is stale because it has been open for 30 days with no activity.

github-actions[bot] avatar Sep 04 '24 01:09 github-actions[bot]

This issue was closed because it has been inactive for 14 days since being marked as stale.

github-actions[bot] avatar Sep 18 '24 01:09 github-actions[bot]