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

esm causes an error in cypress runner in windows 7/10 but works ok in linux #3678

Closed
janusqa opened this issue Mar 9, 2019 · 6 comments
Closed

Comments

@janusqa
Copy link

janusqa commented Mar 9, 2019

Current behavior:

Using esm in windows 7/10 causes cypress test runner to throw an error about the plugin file
When using command

node_modules/.bin/cypress open

error:

 Can't start server

The plugins file is missing or invalid.

Your pluginsFile is set to ....\cypress\plugins\index.js, but either the file is missing, it contains a syntax error, or threw an error when required. The pluginsFile must be a .js or .coffee file.

Please fix this, or set pluginsFile to false if a plugins file is not necessary for your project.

Error [ERR_UNKNOWN_STDIN_TYPE]: Unknown stdin file type

node_modules/.bin/cypress run however works successfully across linux/windows7/windows10

node_modules/.bin/cypress open works successfully in linux

Desired behavior:

node_modules/.bin/cypress open

should also work successfully on windows 7/10

Steps to reproduce: (app code and test code)

https://github.com/janusqa/janusqa-cypress-test-tiny-plugin3-esm
Run on windows using

node_modules/.bin/cypress open

Versions

Windows: 7/10
Cypress package version: 3.1.5
Cypress binary version: 3.1.5

@jennifer-shehane
Copy link
Member

The default plugins import must export the config like below in order to be properly read by Cypress:

export default (on, config) => {}

Since the pluginsFile is set to cypress\plugins\index.js and the config for Cypress is not imported there, it is throwing this error.

If you want to update the default imported file, you can add pluginsFile to your cypress.json specifying the cypress\plugins\main.index.js file and I believe this should work.

@cypress-bot cypress-bot bot added the stage: awaiting response Potential fix was proposed; awaiting response label Mar 10, 2019
@janusqa
Copy link
Author

janusqa commented Mar 10, 2019

@jennifer-shehane
It does not work.
I am actually trying to do this, but with esm module
https://github.com/cypress-io/cypress-example-recipes/tree/master/examples/server-communication__seeding-database-in-node

Using ES modules import/export syntax in your plugins

adding "pluginsFile": "cypress/plugins/main.index.js" to cypress.json takes me back to original issue of import/export not supported across linux/windows. It gives error about using imports.

I can't pick up on anything special you would have done there.
https://github.com/cypress-io/cypress-example-recipes/tree/master/examples/server-communication__seeding-database-in-node

@chrisbreiding
Copy link
Contributor

We'll have investigate this to figure out what's wrong. We'd like to support esm as a way to make import/export work.

Looks like this error is being thrown when the pluginsFile gets loaded:

Error [ERR_UNKNOWN_STDIN_TYPE]: Unknown stdin file type

A very quick investigation shows that it's probably related to the combination of Electron + Windows + esm.

@cypress-bot cypress-bot bot added stage: needs investigating Someone from Cypress needs to look at this and removed stage: awaiting response Potential fix was proposed; awaiting response labels Mar 11, 2019
@chrisbreiding chrisbreiding self-assigned this Mar 11, 2019
@axcosta
Copy link

axcosta commented Nov 17, 2019

I use elementary OS 5.0 Juno (built on Ubuntu 18.04.2 LTS / Linux 4.15.0-70-generic / GTK 3.22.30) and also getting the same error:

"Can't start server
The plugins file is missing or invalid.
Your pluginsFile is set to <project_folder_removed>/tests/e2e/plugins, but either the file is missing, it contains a syntax error, or threw an error when required. The pluginsFile must be a .js or .coffee file.
Please fix this, or set pluginsFile to false if a plugins file is not necessary for your project."

@jennifer-shehane
Copy link
Member

Since this issue hasn't had activity in a while, we'll close the issue until we can confirm this is still happening. Please comment if there is new information to provide concerning the original issue and we'd be happy to reopen.

@jennifer-shehane jennifer-shehane removed the stage: needs investigating Someone from Cypress needs to look at this label Feb 3, 2021
@marlonmarcello
Copy link

marlonmarcello commented Dec 7, 2021

@jennifer-shehane this is till an issue and it's not related to Windows. Can we reopen it?
I am on a

  • Mac
  • Cypress 9.1.1
  • Node v16.7.0

When trying to use ESM inside my plugins file I get this error:
Screen Shot 2021-12-06 at 5 04 57 PM

Even the simplest of the setups still errors:
Screen Shot 2021-12-06 at 5 10 49 PM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants