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

Getting -SyntaxError: 'import' and 'export' may appear only with 'sourceType: module' at EventEmitter.handler after adding import "cypress-ag-grid"; to the Index.js file #9

Closed
MonikaJaiswalMJ opened this issue Feb 3, 2022 · 20 comments

Comments

@MonikaJaiswalMJ
Copy link

No description provided.

@MonikaJaiswalMJ
Copy link
Author

@kpmck Can you please help me in this

@kpmck
Copy link
Owner

kpmck commented Feb 3, 2022

Hi @MonikaJaiswalMJ . This type of error typically stems from configuration in your project, rather than from a plugin. Without having details on how your Cypress project is configured, it would be difficult for me to help resolve this issue for you. However, here is a relevant StackOverflow answer that may help! https://stackoverflow.com/questions/53650208/cypress-parseerror-import-and-export-may-appear-only-with-sourcetype-modu

@MonikaJaiswalMJ
Copy link
Author

@kpmck Actually this specific error I am getting after adding the Import statement only, once I have removed this, my tests are working fine

@kpmck
Copy link
Owner

kpmck commented Feb 3, 2022

Are you importing other plugins in your support/index.js file, or is this the only plugin you're importing?

@MonikaJaiswalMJ
Copy link
Author

MonikaJaiswalMJ commented Feb 3, 2022

@kpmck
// ***********************************************************
// This example support/index.js is processed and
// loaded automatically before your test files.
//
// This is a great place to put global configuration and
// behavior that modifies Cypress.
//
// You can change the location of this file or turn off
// automatically serving support files with the
// 'supportFile' configuration option.
//
// You can read more here:
// https://on.cypress.io/configuration
// ***********************************************************

// Import commands.js using ES2015 syntax:
import './commands'
import 'cypress-ag-grid'
// Alternatively you can use CommonJS syntax:
// require('./commands')

It is the only plugin

@kpmck
Copy link
Owner

kpmck commented Feb 3, 2022

Would you be able to provide a reproducible solution? Are you using TypeScript elsewhere in your project, or is this pure JavaScript?

@MonikaJaiswalMJ
Copy link
Author

MonikaJaiswalMJ commented Feb 7, 2022

@kpmck Issue has been resolved, Thank You !!

@kpmck
Copy link
Owner

kpmck commented Feb 7, 2022

I’m glad to hear that! Would you mind sharing the resolution in case anyone else incurs this issue?

@MonikaJaiswalMJ
Copy link
Author

@kpmck Actually Cucumber plugin was causing that issue, I have just removed the Cucumber plugin and issue got resolved

@shalini1691
Copy link

Hi @kpmck , I am facing a similar issue in my project, but as many teams are using the same component, I cannot remove the cucumber plugin. Any workaround for this issue other than removing the cucumber plugin ?

@kpmck
Copy link
Owner

kpmck commented Apr 25, 2022

Would you be able to provide a reproducible solution? Are you using TypeScript elsewhere in your project, or is this pure JavaScript?

@shalini1691 would you mind answering the above questions please?

@shalini1691
Copy link

We are not using TypeScript @kpmck . Its pure Javascript.

@kpmck
Copy link
Owner

kpmck commented Apr 25, 2022 via email

@shalini1691
Copy link

shalini1691 commented Apr 25, 2022

Sure @kpmck ,

  1. You have to do npm install cypress-cucumber-preprocessor
  2. Add the below code in Plugin>index.js

// eslint-disable-next-line no-unused-vars
const cucumber = require('cypress-cucumber-preprocessor').default
module.exports = (on, config) => {
on('file:preprocessor', cucumber());
}
3) Do a npm run test - check if you are able to see the issue.
SyntaxError: 'import' and 'export' may appear only with 'sourceType: module' at EventEmitter.handler after adding import "cypress-ag-grid"; to the Index.js file

@kpmck
Copy link
Owner

kpmck commented Apr 29, 2022

@shalini1691 I have followed your instructions, but I am not able to reproduce your issue. If you are able to upload a reproducible solution to GitHub that I can pull down, that would be helpful.

@kpmck
Copy link
Owner

kpmck commented May 8, 2022

Hi @shalini1691, just wanted to follow up on if you were able to resolve your issue or create a reproducible solution?

@shalini1691
Copy link

Hi @kpmck , I still couldn't figure out a solution for this, I will do a detailed analysis on this and let you know the outcome.

@Pallabee94
Copy link

I am facing the same issue as well, and I cannot remove Cucumber plugin as it is used in our project. Please let me know if there is any workaround for this. @kpmck @shalini1691

@kpmck
Copy link
Owner

kpmck commented Aug 4, 2022

Hello @Pallabee94 , unfortunately I have not been able to reproduce this in my solutions that leverage cypress-cucumber-preprocessor, and won't be able to resolve without a reproducible solution.

@erpachecomo
Copy link

So this plugin needs webpack as the file preprocessor, and that's the reason when we try to use other preprocessors plugins.
There is a current thread on cypress: cypress-io/cypress#5832.

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

No branches or pull requests

5 participants