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

Plugin not working with 4.0.0 #132

Closed
alexviz7 opened this issue Jul 31, 2023 · 13 comments
Closed

Plugin not working with 4.0.0 #132

alexviz7 opened this issue Jul 31, 2023 · 13 comments
Assignees
Labels
bug Something isn't working

Comments

@alexviz7
Copy link

Thank you first of all for the work you ve done to fix the issues I found.
I installed the latest cypress-xray-plugin version 4.0.0 and after that I had an Error on my cypress config file.

Screenshot 2023-07-31 114412

Running cypress with the Jira PAT created the following error:

Your configFile is invalid: C:\Projects\frontend\cypress.config.ts

It threw an error when required, check the stack trace below:

Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './plugin' is not defined by "exports" in C:\Projects\frontend\node_modules\cypress-xray-plugin\package.json
    at new NodeError (node:internal/errors:405:5)
    at exportsNotFound (node:internal/modules/esm/resolve:259:10)
    at packageExportsResolve (node:internal/modules/esm/resolve:589:9)
    at resolveExports (node:internal/modules/cjs/loader:571:36)
    at Function.Module._findPath (node:internal/modules/cjs/loader:645:31)
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:1058:27)
    at Function.Module._resolveFilename (C:\Users\AppData\Local\Cypress\Cache\12.8.1\Cypress\resources\app\node_modules\tsconfig-paths\lib\register.js:75:40)
    at Function.Module._resolveFilename.sharedData.moduleResolveFilenameHook.installedValue [as _resolveFilename] (C:\Users\AppData\Local\Cypress\Cache\12.8.1\Cypress\resources\app\node_modules\@cspotcode\source-map-support\source-map-support.js:811:30)
    at Function.Module._load (node:internal/modules/cjs/loader:925:27)
    at Module.require (node:internal/modules/cjs/loader:1139:19)
    at require (node:internal/modules/helpers:121:18)
    at Object.<anonymous> (C:\Projects\frontend\cypress.config.ts:3:1)
    at Module._compile (node:internal/modules/cjs/loader:1257:14)
    at Module.m._compile (C:\Users\AppData\Local\Cypress\Cache\12.8.1\Cypress\resources\app\node_modules\ts-node\dist\index.js:857:29)
    at Module._extensions..js (node:internal/modules/cjs/loader:1311:10)
    at Object.require.extensions.<computed> [as .ts] (C:\Users\AppData\Local\Cypress\Cache\12.8.1\Cypress\resources\app\node_modules\ts-node\dist\index.js:859:16)
    at Module.load (node:internal/modules/cjs/loader:1115:32)
    at Function.Module._load (node:internal/modules/cjs/loader:962:12)
    at Module.require (node:internal/modules/cjs/loader:1139:19)
    at require (node:internal/modules/helpers:121:18)
    at loadFile (C:\Users\AppData\Local\Cypress\Cache\12.8.1\Cypress\resources\app\node_modules\@packages\server\lib\plugins\child\run_require_async_child.js:89:14)
    at EventEmitter.<anonymous> (C:\Users\AppData\Local\Cypress\Cache\12.8.1\Cypress\resources\app\node_modules\@packages\server\lib\plugins\child\run_require_async_child.js:116:38)
@csvtuda
Copy link
Contributor

csvtuda commented Jul 31, 2023

Please make sure to update the import to:

import {
  addXrayResultUpload,
  configureXrayPlugin,
  syncFeatureFile
} from  "cypress-xray-plugin";

(see changelog)

@csvtuda csvtuda added bug Something isn't working under investigation The issue is being investigated labels Jul 31, 2023
@csvtuda csvtuda self-assigned this Jul 31, 2023
@alexviz7
Copy link
Author

Please make sure to update the import to:

import {
  addXrayResultUpload,
  configureXrayPlugin,
  syncFeatureFile
} from  "cypress-xray-plugin";

(see changelog)

I have tried that also and I had the following error:

Your configFile threw an error from: C:\Projects\frontend\cypress.config.ts

The error was thrown while executing your e2e.setupNodeEvents() function:

TypeError: Cannot use 'in' operator to search for 'JIRA_ATTACH_VIDEOS' in undefined
    at parse (C:\Projects\frontend\node_modules\cypress-xray-plugin\src\util\parsing.js:61:21)
    at initOptions (C:\Projects\frontend\node_modules\cypress-xray-plugin\src\context.js:21:47)
    at configureXrayPlugin (C:\Projects\frontend\node_modules\cypress-xray-plugin\src\plugin.js:12:45)
    at setupNodeEvents (C:\Projects\frontend\cypress.config.ts:33:28)

@csvtuda
Copy link
Contributor

csvtuda commented Jul 31, 2023

Have you updated configureXrayPlugin() as well? It now expects the config as first parameter:

async setupNodeEvents(on, config) {
    await configureXrayPlugin(
        config,
        {
            jira: {
                projectKey: "PRJ",         // placeholder value
                url: "https://example.org" // placeholder value
            }
        }
    );
    // ...
}

@alexviz7
Copy link
Author

alexviz7 commented Jul 31, 2023

I changed the code as you proposed and I have now the following error when running:

  Running:  language.feature                                                                (1 of 1)
X [ERROR] Could not resolve "cypress-xray-plugin/register"

    cypress/support/e2e.ts:20:7:
      20 │ import 'cypress-xray-plugin/register';
         ╵        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

  The path "./register" is not exported by package "cypress-xray-plugin":

    node_modules/cypress-xray-plugin/package.json:30:15:
      30 │     "exports": "./index.js",
         ╵                ~~~~~~~~~~~~

  You can mark the path "cypress-xray-plugin/register" as external to exclude it from the bundle, which will remove this error.


Oops...we found an error preparing this test file:

  > cypress\support\e2e.ts

The error was:

Error: Build failed with 1 error:
cypress/support/e2e.ts:20:7: ERROR: Could not resolve "cypress-xray-plugin/register"
    at failureErrorWithLog (C:\Projects\frontend\node_modules\esbuild\lib\main.js:1636:15)
    at C:\Projects\frontend\node_modules\esbuild\lib\main.js:1048:25
    at runOnEndCallbacks (C:\Projects\frontend\node_modules\esbuild\lib\main.js:1471:45)
    at buildResponseToResult (C:\Projects\frontend\node_modules\esbuild\lib\main.js:1046:7)
    at C:\Projects\frontend\node_modules\esbuild\lib\main.js:1075:16
    at responseCallbacks.<computed> (C:\Projects\frontend\node_modules\esbuild\lib\main.js:697:9)
    at handleIncomingPacket (C:\Projects\frontend\node_modules\esbuild\lib\main.js:752:9)
    at Socket.readFromStdout (C:\Projects\frontend\node_modules\esbuild\lib\main.js:673:7)
    at Socket.emit (node:events:511:28)
    at Socket.emit (node:domain:489:12)
    at addChunk (node:internal/streams/readable:332:12)
    at readableAddChunk (node:internal/streams/readable:305:9)

TypeError: Cannot read properties of null (reading 'some')
    at afterSpecHandler (C:\Projects\frontend\node_modules\@badeball\cypress-cucumber-preprocessor\lib\add-cucumber-preprocessor-plugin.js:166:47)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async Object.handler (C:\Projects\frontend\node_modules\cypress-on-fix\index.js:32:20)

@alexviz7
Copy link
Author

alexviz7 commented Jul 31, 2023

Further errors shown on cypress config file:
Screenshot 2023-07-31 155218
Screenshot 2023-07-31 155250
Screenshot 2023-07-31 155454

Screenshot 2023-07-31 155632

@alexviz7
Copy link
Author

I removed the register from the cypress-xray-plugin import and the run was successful. Errors on config file are still to be seen though.

@csvtuda
Copy link
Contributor

csvtuda commented Jul 31, 2023

Yes, these options don't exist anymore (see changelog):

  • Removed plugin.overwriteIssueSummary option

  • Removed xray.testType option

  • Removed jira.createTestIssues option

plugin.overwriteIssueSummary

The plugin now never overwrites issue summaries on its own (except for test execution summaries provided via jira.testExecutionIssueSummary). Even for imported feature files (as you correctly identified in #100). This was tricky because the import is non-configurable in this regard, which is why the plugin now automatically reverts the summary after each successful import with additional requests.

xray.testType

Test types are now automatically fetched from Jira for each issue. No need to specify them anymore.

jira.createTestIssues

The plugin has been modified to not create issues whatsoever anymore. The only exception are of course test execution issues. This option is therefore not needed anymore.

@alexviz7
Copy link
Author

So is this still possible to upload scenarios on Jira and have not created a test ticket previously?

@csvtuda
Copy link
Contributor

csvtuda commented Jul 31, 2023

No, this is not possible anymore. It was possible to configure such created issues (summary, ...) when using the normal upload, but it was not possible to configure them using the Cucumber upload. Xray (more or less) simply does what it wants in this case, unfortunately.

Keeping things as is for the normal upload would have meant adding a whole new set of options for Cucumber specifically and would have overcomplicated the configuration (for me as well as for the users).

The easier option was to simply not allow issue creation anymore. So you either link your tests/scenarios/backgrounds to existing issues, or they will be skipped during upload. Hopefully this is not too much of a bummer 😞 In the long term it's the better approach I think. The other version was capable of creating hundreds of issues out of nowhere (you've struggled with this too, I think). Now it's less dangerous.

@alexviz7
Copy link
Author

alexviz7 commented Jul 31, 2023

well for me its a relief not to have to delete the generated tickets after a test run. So this means if i don't have the merge background option then no background steps will be shown and no Background files are created either, right?

@csvtuda
Copy link
Contributor

csvtuda commented Jul 31, 2023

No, if you don't merge the backgrounds, your feature files will not be uploaded anymore, which means that no background issues will be created anymore either.

Regarding the results displayed in a test execution: I'm actually unsure. I think in the worst case you might see a warning like "executed steps don't match steps of test issue".

@alexviz7
Copy link
Author

Ok thanks again for your help. Just don't forget to document this on your plugin configuration documentation, for others to see.

@csvtuda
Copy link
Contributor

csvtuda commented Jul 31, 2023

Yes, I will make sure to add a note somewhere. I will try it out myself later, just to see what actually happens. Closing here, the /register issue will be tracked in #133.

@csvtuda csvtuda closed this as completed Jul 31, 2023
@csvtuda csvtuda removed the under investigation The issue is being investigated label Jul 31, 2023
@csvtuda csvtuda changed the title Cypress not working with v4.0.0 Plugin not working with 4.0.0 Jul 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants