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

Migrating Cypress test from old version to latest version throws error Expected to find a global registry #860

Closed
3 tasks done
scrumvisualize opened this issue Oct 14, 2022 · 8 comments

Comments

@scrumvisualize
Copy link

scrumvisualize commented Oct 14, 2022

Current behavior

I am trying to migrate my existing Cypress BDD tests from 8.7.0 version to latest version 10.10.0. I have installed the required libraries and amended the settings. I was having an old node version 12 + version, now updated to node v18.4.0 and tried again. Couldn't find any pointers to resolve similar issue, so any advise would be really helpful.

Following is my automation folder structure:

  • ** feature file location**

tests/cypress/e2e/ login/login.feature

  • ** Step definition location**
    Imported in the step definition file
    import { Given, When, Then, Before, After} from "@badeball/cypress-cucumber-preprocessor";

tests/cypress/stepDefinitions/login.cy.js

Added e2e.js file under tests/cypress/support folder:

// Import commands.js using ES2015 syntax:
import './commands'
Cypress.on('uncaught:exception', (err, runnable) => {
    // returning false here prevents Cypress from
    // failing the test
    return false
})

Added .cypress-cucumber-preprocessorrc.jsonfile in to the test root folder


{
  "stepDefinitions": [
    "[filepath].{js,ts}",
    "tests/cypress/stepDefinitions/**/*.{js,ts}",
    "tests/cypress/e2e/[filepath]/**/*.{js,ts}",
    "tests/cypress/e2e/[filepath].{js,ts}",
    "tests/cypress/support/step_definitions/**/*.{js,ts}"
  ]
}

Below is my cypress.config.js file:

const { defineConfig } = require("cypress");
const webpackPreprocessor = require('@cypress/webpack-preprocessor');
const addCucumberPreprocessorPlugin = require("@badeball/cypress-cucumber-preprocessor");
const dotenvPlugin = require("cypress-dotenv");

async function setupNodeEvents(on, config) {
    await addCucumberPreprocessorPlugin.addCucumberPreprocessorPlugin(on, config);

    const options = {
        webpackOptions: {
            module: {
                rules: [
                    {
                        test: /\.feature$/,
                        use: [
                            {
                                loader: '@badeball/cypress-cucumber-preprocessor/webpack',
                                options: config,
                            },
                        ],
                    },
                ],
            },
        },

    };

    on('file:preprocessor', webpackPreprocessor(options));

    return config;
}

module.exports = {
    default: defineConfig({
        e2e: {
            baseUrl: "https://book.test.co",
            specPattern: "tests/cypress/e2e/**/*.feature",
            supportFile: false,
            setupNodeEvents,
        },
    }),
    setupNodeEvents,
};

Error Details
image

Desired behavior

Hope to run the BDD feature file without errors

Test code to reproduce

Removed following items from the automation framework

  • **plugin/index.js ** file
  • **cypress.json ** file
    uninstalled old cypress-cucumber-preprocessor from the project

Versions

  • Cypress version: Cypress 10.10.0
  • Preprocessor version: @badeball/cypress-cucumber-preprocessor 11.4.0
  • Node version: v18.4.0
  • cypress/webpack-preprocessor: 5.14.0
  • OS: Ubuntu 20.04.3 LTS

Checklist

  • I've read the FAQ.
  • I've read Instructions for logging issues.
  • I'm not using cypress-cucumber-preprocessor@4.3.1 (package name has changed and it is no longer the most recent version, see #689).
@badeball
Copy link
Owner

You need to provide me with a complete, but minimal and runnable example.

@DenFin
Copy link

DenFin commented Oct 14, 2022

I'm having the same issue with the 'Expected to find a global registry' error. I created a minimal setup with cypress and cucumber. Maybe this might help: https://github.com/DenFin/minimal-cypress-cucumber-setup

@badeball
Copy link
Owner

@DenFin, in your case you can remove js from specPattern. You're now trying to run step definitions as if they're the test (they're not).

@scrumvisualize
Copy link
Author

scrumvisualize commented Oct 16, 2022

@badeball In my case , I didn't have js in my specPattern. Don't know if that is helpful in case. This is my settings: specPattern: "tests/cypress/e2e/**/*.feature",

@scrumvisualize
Copy link
Author

scrumvisualize commented Oct 19, 2022

I'm having the same issue with the 'Expected to find a global registry' error. I created a minimal setup with cypress and cucumber. Maybe this might help: https://github.com/DenFin/minimal-cypress-cucumber-setup
@DenFin Have you got an idea or work around on how to handle this issue ? I did one one more thing, I have downgraded node version to v14.16.1 and update to the latest version of "@badeball/cypress-cucumber-preprocessor": "^13.0.2", then clear the app data and tried again, but still the same error. I am kind of stuck at the moment.

@DenFin
Copy link

DenFin commented Oct 20, 2022

@scrumvisualize actually removing js from the specPattern solved the problem for me

@smorstabilini
Copy link

@scrumvisualize have you found any solution?

@badeball
Copy link
Owner

Closing due to lack of reproducible example. Feel free to open up another issue if anything changes in this regard.

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

4 participants