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

2.28.1 - cy.allure().writeEnvironmentInfo() no longer generates widgets/environment.json

Open monkpit opened this issue 2 years ago • 3 comments

When I upgrade to versions of cypress-allure-plugin higher than 2.28.0, my unit tests fail because widgets/environment.json has empty array as contents, instead of the expected contents. I am generating this using cy.allure().writeEnvironmentInfo().

Cypress version: 9.7.0 Node version: 16.17.1 cypress-allure-plugin version: >=2.28.1 all seem to have this issue OS: Mac 12.6 Monterey

To Reproduce Steps to reproduce the behavior:

  1. Install the above versions
  2. Write an environment file using cy.allure().writeEnvironmentInfo({ foo: 'bar' })
  3. Open the report - the environment area is blank.
  4. Open cypress/reports/widgets/environment.json - the contents are an empty array.

Expected behavior The Allure report should contain Environment info as it did before 2.28.1.

monkpit avatar Oct 07 '22 20:10 monkpit

Hi @monkpit Thank you for opening an issue.

Yeah, that part of plugin with environment.properties file was ambiguous so I have refactored writeEnvironmentInfo implementation and handling and for now I am sure it is writing env data properly.

However, you mention that problem started in v2.28.1. Only difference with v2.28.0 is with using cypress projectRoot to define allure-results path. The logic is simple - we take project root and concatenate it with allureResultsPath to get proper absolute path to this folder.

I am not able to reproduce it, was using:

  • cypress v9.7.0
  • node v16.14.2
  • cypress-allure-plugin v2.33.0
  • OS Macos v12.6

So I assume you may have some custom allureResultsPath or some different cypress project setup.

Shelex avatar Oct 08 '22 19:10 Shelex

I am using executing cypress/allure in a sub folder of the main project as a part of my unit tests (I test to make sure Cypress runs the way I expect it to within my test tools package).

So the project root contains testCypressApp, and within that it contains a fake Cypress project, we run and write allure-results inside and then test the expected output such as widget/environment.json.

On Sat, Oct 8, 2022 at 2:52 PM Oleksandr Shevtsov @.***> wrote:

Hi @monkpit https://github.com/monkpit Thank you for opening an issue.

Yeah, that part of plugin with environment.properties file was ambiguous so I have refactored writeEnvironmentInfo implementation and handling and for now I am sure it is writing env data properly.

However, you mention that problem started in v2.28.1. Only difference with v2.28.0 is with using cypress projectRoot to define allure-results path. The logic is simple - we take project root and concatenate it with allureResultsPath to get proper absolute path to this folder.

I am not able to reproduce it, was using:

  • cypress v9.7.0
  • node v16.14.2
  • cypress-allure-plugin v2.33.0
  • OS Macos v12.6

So I assume you may have some custom allureResultsPath or some different cypress project setup.

— Reply to this email directly, view it on GitHub https://github.com/Shelex/cypress-allure-plugin/issues/170#issuecomment-1272387304, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABINJDOB7RELVT2UNE3IAULWCHGIHANCNFSM6AAAAAAQ74YOHE . You are receiving this because you were mentioned.Message ID: @.***>

monkpit avatar Oct 08 '22 19:10 monkpit

So please correct me if I got it wrong:

Structure:

  • project
    • cypress
    • testCypressApp
      • cypress
      • allure-results
      • cypress.json
    • cypress.json

In such case, allureResultsPath is not needed as it will write to project/testCypressApp/allure-results, because:

  • previously it was saving allure-results to folder relative to cwd where you run it
  • now it saves it relative to projectRoot from Cypress (as it may differ from cwd)

Could you please provide some examples, at least some schematic details, because I am not sure I have understood that setup. Also, you can try DEBUG=allure-plugin* npx cypress run to check where it writes allure-results files.

Shelex avatar Oct 08 '22 20:10 Shelex

Cypress version: 10.9.0 @badeball/cypress-cucumber-preprocessor: 13.0.3 (latest) cypress-allure-plugin: 2.33.1 node: 14.17.3

Hi, I have upgraded to v2.33.1 but still the environment.json file returns as an empty array when report is prepared. I can see xxxx.results.json and yyyy.container.json files in the/allure-results path. However envorimnet.json is missing. I get error while writing allure results: ReferenceError: filePath is not defined error.

I have tried both wit and without defining the allureResultsPath configuration, both were unsuccessful. You can see Debug logs:

 allure-plugin:writer starting writing allure results to "/Users/xxxxx/WebstormProjects/yyyyy-ui/packages/zzzzz-ui/allure-results" +8s
  allure-plugin:writer write suite "Help Panel" to file "19455105-477c-463e-9b65-dba705c7a2b3-container.json" +1ms
  allure-plugin:writer write test "User navigates to Help panel" to file "756c7ff7-0f8f-455b-af04-dfe1b44d19d4-result.json" +1ms
  allure-plugin:writer removing empty step ""after each" hook" from test "756c7ff7-0f8f-455b-af04-dfe1b44d19d4" +1ms
  allure-plugin:writer write file "/Users/xxxxx/WebstormProjects/yyyyy-ui/packages/zzzzz-ui/allure-results/categories.json" +0ms
error while writing allure results: ReferenceError: filePath is not defined  allure-plugin:writer failed to write allure results: ReferenceError: filePath is not defined
  allure-plugin:writer     at writeInfoFile (/Users/xxxxx/WebstormProjects/zzzzz-ui/node_modules/@shelex/cypress-allure-plugin/writer/writeInfoFiles.js:10:20)
  allure-plugin:writer     at writeAllureResults (/Users/xxxxx/WebstormProjects/zzzzz-ui/node_modules/@shelex/cypress-allure-plugin/writer.js:227:17)
  allure-plugin:writer     at invoke (/Users/xxxxx/Library/Caches/Cypress/10.9.0/Cypress.app/Contents/Resources/app/packages/server/lib/plugins/child/run_plugins.js:256:16)
  allure-plugin:writer     at /Users/xxxxx/Library/Caches/Cypress/10.9.0/Cypress.app/Contents/Resources/app/packages/server/lib/plugins/util.js:59:14
  allure-plugin:writer     at tryCatcher (/Users/xxxxx/Library/Caches/Cypress/10.9.0/Cypress.app/Contents/Resources/app/packages/server/node_modules/bluebird/js/release/util.js:16:23)
  allure-plugin:writer     at Function.Promise.attempt.Promise.try (/Users/xxxxx/Library/Caches/Cypress/10.9.0/Cypress.app/Contents/Resources/app/packages/server/node_modules/bluebird/js/release/method.js:39:29)
  allure-plugin:writer     at Object.wrapChildPromise (/Users/xxxxxxx/Library/Caches/Cypress/10.9.0/Cypress.app/Contents/Resources/app/packages/server/lib/plugins/util.js:58:23)
  allure-plugin:writer     at RunPlugins.taskExecute (/Users/xxxxxx/Library/Caches/Cypress/10.9.0/Cypress.app/Contents/Resources/app/packages/server/lib/plugins/child/run_plugins.js:262:10)
  allure-plugin:writer     at RunPlugins.execute (/Users/xxxxxx/Library/Caches/Cypress/10.9.0/Cypress.app/Contents/Resources/app/packages/server/lib/plugins/child/run_plugins.js:182:21)
  allure-plugin:writer     at EventEmitter.<anonymous> (/Users/xxxxxx/Library/Caches/Cypress/10.9.0/Cypress.app/Contents/Resources/app/packages/server/lib/plugins/child/run_plugins.js:279:12)
  allure-plugin:writer     at EventEmitter.emit (events.js:375:28)
  allure-plugin:writer     at EventEmitter.emit (domain.js:470:12)
  allure-plugin:writer     at process.<anonymous> (/Users/xxxxxx/Library/Caches/Cypress/10.9.0/Cypress.app/Contents/Resources/app/packages/server/lib/plugins/util.js:33:22)
  allure-plugin:writer     at process.emit (events.js:387:35)
  allure-plugin:writer     at process.emit (domain.js:470:12)
  allure-plugin:writer     at process.emit.sharedData.processEmitHook.installedValue [as emit] (/Users/xxxxxx/Library/Caches/Cypress/10.9.0/Cypress.app/Contents/Resources/app/node_modules/@cspotcode/source-map-support/source-map-support.js:745:40)
  allure-plugin:writer     at emit (internal/child_process.js:910:12)
  allure-plugin:writer     at processTicksAndRejections (internal/process/task_queues.js:83:21) +0ms
  allure-plugin:writer got "after:spec" process message +7ms
  allure-plugin:writer processing "after:spec" results +1ms
  allure-plugin:writer going to check attachments for "756c7ff7-0f8f-455b-af04-dfe1b44d19d4" +0ms
  allure-plugin:writer video will not be attached +0ms

mysticdevx avatar Nov 02 '22 19:11 mysticdevx

:tada: This issue has been resolved in version 2.33.2 :tada:

The release is available on:

Your semantic-release bot :package::rocket:

github-actions[bot] avatar Nov 02 '22 21:11 github-actions[bot]