cypress-localstorage-commands icon indicating copy to clipboard operation
cypress-localstorage-commands copied to clipboard

Got ReferenceError: require is not defined

Open daisypreeti opened this issue 1 year ago • 1 comments

Describe the bug Got ReferenceError: require is not defined

To Reproduce After installing run the test

Expected behavior instead of require what else we can use to configure in the cypress.config.ts

daisypreeti avatar May 24 '24 13:05 daisypreeti

Hi @daisypreeti ,

I suppose that you are referring to install the plugin node events in the Cypress configuration. And it seems that you are trying to install it in a TypeScript config by copying directly the installation example in the docs, am I right? (please, next time provide more context, details, code examples, etc.)

Anyway, note that the plugin is a CommonJS module, and, so, you should use the appropriated syntax when importing it in TypeScript

For example:

import plugin = require("cypress-localstorage-commands/plugin");

export default {
  e2e: {
    setupNodeEvents(on, config) {
      plugin(on, config);
    },
  },
}

I hope this helps. Please let me know.

javierbrea avatar May 27 '24 16:05 javierbrea