-1

Hey I have a JS expression that I don't know name of does somone know how is this called in theory?

return defaultScreenshotOptions?.errorThreshold || 0;

Full error message

 Error: Webpack Compilation Error
./node_modules/cypress-visual-regression/src/command.js 14:34
Module parse failed: Unexpected token (14:34)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
|   }
|
>   return defaultScreenshotOptions?.errorThreshold || 0;
| }
|

My other question is about the webpack loaders that are needed to parse this module.

1 Answers1

0

Reason to this error is return defaultScreenshotOptions?.errorThreshold || 0; a optional chaining operator expression is ES2020 feature thus is not supported by default file:preprocessor. Pass default options listed in package documentation.

module.exports = (on) => {
  const options = {
    // options here
  }

  on('file:preprocessor', browserify(options))
}

The solution to this error is to configure browserify-preprocessor for cypress. The default options for browserify are applaying ES2020 features.

npm package @cypress/browserify-preprocessor