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

Error: Cannot resolve cypress-xray-plugin/plugin #136

Closed
caique-rd opened this issue Aug 2, 2023 · 2 comments
Closed

Error: Cannot resolve cypress-xray-plugin/plugin #136

caique-rd opened this issue Aug 2, 2023 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@caique-rd
Copy link

caique-rd commented Aug 2, 2023

When I run my tests in the CLI I get the follow error:

Error: Webpack Compilation Error
./cypress/support/e2e.js
Module not found: Error: Can't resolve 'cypress-xray-plugin/plugin' in '/Users/caiquecoelho/Documents/Projects/directory_ui_test_framework/cypress/support'
resolve 'cypress-xray-plugin/plugin' in '/Users/caiquecoelho/Documents/Projects/directory_ui_test_framework/cypress/support'
  Parsed request is a module
  using description file: /Users/caiquecoelho/Documents/Projects/directory_ui_test_framework/package.json (relative path: ./cypress/support)
    Field 'browser' doesn't contain a valid alias configuration
    Looked for and couldn't find the file at the following paths:

I'm using the 4.0.1 version and my configurations look like this:
e2e.js

import "cypress-xray-plugin/plugin";

cypress.config.js

const {addXrayResultUpload, configureXrayPlugin} = require("cypress-xray-plugin")
....
module.exports = async (on, config) => {
  await configureXrayPlugin(
    config,
    {
        jira: {
            projectKey: "MY_PROJECT_KEY",
            url: "MY_PROJECT_URL",
            testExecutionIssueKey: "MY_PROJECT_TEST_EXECUTION_ISSUE_KEY"
        },
    }
  );
  await addXrayResultUpload(on);

  return config
}

I'm running the test with:

cypress run --env JIRA_PROJECT_KEY='RPF',JIRA_USERNAME='<MY_EMAIL>',JIRA_API_TOKEN='<MY_API_TOKEN>',XRAY_CLIENT_ID='<MY_CLIENT_ID>',XRAY_CLIENT_SECRET='<MY_CLIENT_SECRET>''
@caique-rd
Copy link
Author

I was able to fix that importing in e2e.js this way:

import "cypress-xray-plugin/src/register";

@csvtuda csvtuda self-assigned this Aug 2, 2023
@csvtuda csvtuda added the bug Something isn't working label Aug 2, 2023
@csvtuda
Copy link
Contributor

csvtuda commented Aug 2, 2023

Yes, your e2e.js file should not import the event listeners like this:

import "cypress-xray-plugin/plugin" // no longer works in 4.0.1

but rather using:

import "cypress-xray-plugin/register"
// or
require("cypress-xray-plugin/register")

I know it doesn't work for you in 4.0.1 (#133), but as of now I cannot reproduce it. You can simply omit the /register import in e2e.js, it does not do anything. Everything in there is commented out and has been for a long time:

// Currently not in use.
// Cypress.on("test:after:run", (test: Cypress.ObjectLike, runnable: Mocha.Test) => {
// console.log("test:after:run", test, runnable);
// });

I think I will update the documentation accordingly.

@csvtuda csvtuda changed the title Error: Field 'browser' doesn't contain a valid alias configuration Error: Can't resolve cypress-xray-plugin/plugin Aug 2, 2023
@csvtuda csvtuda changed the title Error: Can't resolve cypress-xray-plugin/plugin Error: Can't resolve cypress-xray-plugin/plugin Nov 25, 2023
@csvtuda csvtuda changed the title Error: Can't resolve cypress-xray-plugin/plugin Error: Cannot resolve cypress-xray-plugin/plugin Nov 25, 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