question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

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

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).

Issue Analytics

  • State:open
  • Created a year ago
  • Reactions:1
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
DenFincommented, 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

0reactions
DenFincommented, Oct 20, 2022

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

Read more comments on GitHub >

github_iconTop Results From Across the Web

node.js - Migrating cypress test from old version to latest ...
Migrating cypress test from old version to latest version throws error ... Expected to find a global registry (this usually means you are ......
Read more >
Migration Guide | Cypress Documentation
This guide details the changes and how to change your code to migrate to Cypress version 11.0. See the full changelog for version...
Read more >
Migrating Test Automation Suite To Cypress 10 - LambdaTest
P.S.: When writing this blog, the latest version of Cypress is 11.2.0. ... When a test fails, an error message is thrown.
Read more >
Cypress 10 Upgrade - TestersDock
As you can see above in the After section the file names are not shown as cy.js because the migration helper is not...
Read more >
Mocha - the fun, simple, flexible JavaScript test framework
If you use callback-based async tests, Mocha will throw an error if done() is ... In versions older than v3.0.0, the call to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found