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

`Cypress: SyntaxError: 'import' and 'export' may appear only with 'sourceType: module' at EventEmitter.handler #667

Closed
mireyam2x opened this issue Jan 26, 2022 · 1 comment

Comments

@mireyam2x
Copy link

mireyam2x commented Jan 26, 2022

@lgandecki Hi :)

Getting following error when trying to configure cucumber with cypress-firebase in cypress.
SyntaxError: 'import' and 'export' may appear only with 'sourceType: module' at EventEmitter.handler (/Users/.../Library/Caches/Cypress/7.0.0/Cypress.app/Contents/Resources/app/packages/server/lib/plugins/util.js:69:27) at EventEmitter.emit (events.js:315:20) at ChildProcess.<anonymous> (/Users/.../Library/Caches/Cypress/7.0.0/Cypress.app/Contents/Resources/app/packages/server/lib/plugins/util.js:19:22) at ChildProcess.emit (events.js:315:20) at emit (internal/child_process.js:903:12) at processTicksAndRejections (internal/process/task_queues.js:81:21)

cypress/plugins/index.js

/// <reference types="cypress" />
const cucumber = require("cypress-cucumber-preprocessor").default;
const browserify = require("@cypress/browserify-preprocessor");


const admin = require("firebase-admin");
const cypressFirebasePlugin = require("cypress-firebase").plugin;

/**
* @type {Cypress.PluginConfig}
*/

module.exports = (on, config) => {

const configJson = require(`../testConfigs/testConfigInfo.json`);
config.baseUrl = configJson[config.env.testbed]["baseUrl"];
const options = browserify.defaultOptions;
options.browserifyOptions.transform[1][1].babelrc = true;


on('file:preprocessor', cucumber(options));

on("before:browser:launch", (browser = {}, launchOptions) => {
 if (browser.name === "chrome") {
   launchOptions.args.push("--disable-extensions"); 
   launchOptions.args.push("--window-size=1920,1080"); 
   return launchOptions;
 }
 return launchOptions;
});

const extendedConfig = cypressFirebasePlugin(on, config, admin);


 return extendedConfig;
};

/Users/..../git/cypress-e2e-test/cypress/support/commands/loginBackground.js

  
   /// <reference types="cypress" />

import firebase from 'firebase/compat/app'
import 'firebase/compat/auth'
import 'firebase/compat/database';
import 'firebase/compat/firestore';


// const admin = require("firebase-admin");

import { attachCustomCommands } from 'cypress-firebase';


// Your web app's Firebase configuration
// For Firebase JS SDK v7.20.0 and later, measurementId is optional
const fbConfig = {
   apiKey: "xxxxxxxxxxxx",
   authDomain: "xxxxxx-test.firebaseapp.com",
   databaseURL: "https://xxxxxxxxx",
   projectId: "xxxxxxxx-test",
   storageBucket: "xxxxxxxx-test.appspot.com",
   messagingSenderId: "xxxxxxxxxx",
   appId: "xxxxxxxxxxxxxx",
   measurementId: "xxxxxxxxxx"
 };


 firebase.initializeApp(fbConfig);
 attachCustomCommands({ Cypress, cy, firebase });

Cypress.Commands.add("loginBackground", (uid, baseUrl) => {

 cy.login(uid);
 cy.visit(baseUrl);

 });

tsconfig.json

{
    "compilerOptions": {
      "strict": true,
      "baseUrl": "../node_modules",
      "target": "es5",
      "lib": ["es5", "dom"],
      "types": ["cypress"]
    },
    "include": [
      "**/*.ts"
    ]
  }

/Users/.../git/cypress-e2e-test/cypress/support/commands/index.js

import '../commands/loginBackground';

Any idea please why still getting this, I tried theses steps already :
https://stackoverflow.com/a/60017105

@badeball
Copy link
Owner

Due to personal reasons, the previous maintainers of this package are stepping down and handing the reigns over to me, a long-time contributor to the project and a user of it myself. This is a responsibility I'm very excited about. Furthermore, I'd like to thank @lgandecki ++ for all the work that they've done so far.

Read more about the transfer of ownership here.

The repository has however moved and all outstanding issues are being closed. This is not a reflection of the perceived importance of your reported issue. However, if after upgrading to the new version, you still find there to be an issue, feel free to open up another ticket or comment below. Please make sure to read CONTRIBUTING.md before doing so.

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

2 participants