Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cypress setup default path aliases

All my Imports use a webpack/rollup default path to import my .js files is under src/.

My project is:

project-name/
    node_modules/
    cypress/
    src/
    ...

Then, when I run test into Cypress I wouldn't have error to import dependencies.

How can I setup a default project forlder for src

Thanks!

like image 878
Ivan Sanchez Avatar asked Sep 14 '25 19:09

Ivan Sanchez


1 Answers

Solution:

cypress/plugins/index.js

If you are using webpack, add you webpack config into this file.

const webpack = require('@cypress/webpack-preprocessor');


module.exports = (on) => {
  const options = {

      webpackOptions: require('../../build/webpack.config'),
      watchOptions: {},
  };

  on('file:preprocessor', webpack(options));
};

// send in the options from your webpack.config.js, so it works the same
// as your app's code
like image 133
Ivan Sanchez Avatar answered Sep 16 '25 09:09

Ivan Sanchez