cypress-fail-fast
cypress-fail-fast copied to clipboard
Plugin import path in ES6 module syntax
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.
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";
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!
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.
I have already changed the README file examples to ES6 syntax, and I have added a note about defining the file extension explicitly. Anyway, I'll leave this issue open in order to investigate about adding the subpath exports.