lundi 4 juin 2018

Support for ES2018 in Cypress tests? (Object spread operator)

I'm trying to run a Cypress test with ES2018 syntax:

describe("Cypress test", () => {

  const objA = { a: 1, b: 2 };
  const objB = { ...objA };

  ...
}

But when executed, I'm getting:

SyntaxError: /....../cypress/loginTest.js: Unexpected token (29:17)
  27 | 
  28 |   const objA = { a: 1, b: 2 };
> 29 |   const objB = { ...objA };
     |                  ^

I also tried to check browserify presets with following plugin:

// plugins.js
const browserify = require("@cypress/browserify-preprocessor");

module.exports = (on) => {
  const options = browserify.defaultOptions;

  // Check presets
  console.log(options.browserifyOptions.transform[1][1].presets);

  on("file:preprocessor", browserify(options));
};

and it seems to already have babel-preset-env set-up.

Any ideas, please?

Aucun commentaire:

Enregistrer un commentaire