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 import path in ES6 module syntax #295

Open
anselmbradford opened this issue Dec 19, 2023 · 3 comments
Open

Plugin import path in ES6 module syntax #295

anselmbradford opened this issue Dec 19, 2023 · 3 comments
Assignees
Labels
documentation Improvements or additions to documentation enhancement New feature or request

Comments

@anselmbradford
Copy link

Describe the bug

Start a new Cypress project from Cypress 13.x and the config will look like:

import { defineConfig } from "cypress";

export default defineConfig({
  e2e: {
    setupNodeEvents(on, config) {
      // implement node event listeners here
    },
  },
});

If you add require('cypress-fail-fast/plugin')(on, config); to this, per the readme, you'll get the error ReferenceError: require is not defined when attempting to run cypress.

To Reproduce
Try adding this plugin to a Cypress ES6 module config file and try running Cypress.

Expected behavior
Plugin should be updated to ES6 module syntax.ontext about the problem here.

@javierbrea
Copy link
Owner

Hi @anselmbradford , have you tried to change the import to ES6 import module syntax?

import cypressFailFast from "cypress-fail-fast/plugin";

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

I have tried it in a cypress.config.ts file, and it works properly. I also have tried in a cypress.config.mjs file, and, in that case, you should change the import to import cypressFailFast from "cypress-fail-fast/src/plugin.js";

@javierbrea javierbrea self-assigned this Dec 20, 2023
@javierbrea javierbrea added documentation Improvements or additions to documentation stage: awaiting response Potential solution was proposed; awaiting response labels Dec 20, 2023
@anselmbradford
Copy link
Author

Hi @javierbrea, ahh I tried it with import cypressFailFast from "cypress-fail-fast/plugin"; and it didn't work, but import cypressFailFast from "cypress-fail-fast/src/plugin.js" does! I guess I should have scrutinized the source closer. Thanks! Maybe update the readme for this scenario? Cheers!

@javierbrea
Copy link
Owner

Thank you @anselmbradford. I will try to use subpaths exports in the exports field in the package.json file in order to avoid this problem, and, in case I can't make it work, I will update the readme.

@javierbrea javierbrea changed the title Default generated cypress.config.js is an ES6 module. This plugin is not compatible. Plugin import path in ES6 module syntax Jan 8, 2024
@javierbrea javierbrea added enhancement New feature or request and removed stage: awaiting response Potential solution was proposed; awaiting response labels Jan 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants