title: Cypress for Components Tests React configuration problem absolute path
body: <p>the goal is to use Cypress for component testing and e2e testing mainly.
  Install and configure all Cypress correctly, configure Cypress in the 'cypress open' script to open E2E related tests and configure the 'cypress open-ct' script for component tests, all settings work very well.</p>
  <h3>Problem</h3>
  <p>The project is already ready and I have absolute folders configuration, when I import a component from '~/components' I am accessing 'src/components', I am not able to make the proper settings to be able to access the absolute folders because when I run the cypress open script -ct doesn't seem to run 'file:preprocessor', where you need to run it to run the webpack where you have the absolute folder settings.
  I tried several alternatives and this was the one that worked the best because when I run the 'cypress open' script cypress executes 'file:preprocessor' it applies the webpack settings and if I try to import a component using '~/component/InputDate' it works , however 'cypress open' is for E2E tests, I can't run unit tests through this script.<br />
  I can be wrong about the cypress open script not running component tests correctly but I'm looking for a solution to the big problem that is these absolute folders.</p>
  <h3>Attempts</h3>
  <p>I tried the tsconfig.json files configuration solution but I couldn't make it work because I use it in the jsconfig.json project, I tried to use tsconfig.json I used the 'tsconfig-paths' package and got no result.</p>
  <h3>cypress/plugins/index.js</h3>
  <pre><code>const webpack = require('@cypress/webpack-preprocessor')
  
  const injectDevServer = require('@cypress/react/plugins/react-scripts')
  
  module.exports = (on, config) =&gt; {
    const options = {
      webpackOptions: require('../../webpack.config.js'),
      watchOptions: {},
    }
    on('file:preprocessor', webpack(options))
  
    injectDevServer(on, config)
  
    return config
  }
  </code></pre>
  <h3>cypress.json</h3>
  <pre><code>{
    &quot;component&quot;: {
      &quot;componentFolder&quot;: &quot;src/tests/components&quot;
    },
    &quot;integrationFolder&quot;: &quot;src/tests/integration&quot;
  }
  
  </code></pre>
  <h3>webpackconfig.js</h3>
  <pre><code>var path = require('path')
  
  module.exports = {
    mode: 'development',
    module: {
      rules: [
        {
          test: /\.js$|jsx/,
          exclude: [/node_modules/],
          use: [
            {
              loader: 'babel-loader',
              options: {
                presets: ['@babel/preset-env', '@babel/preset-react'],
              },
            },
          ],
        },
      ],
    },
    resolve: {
      alias: {
        '~': path.resolve(__dirname, 'src'),
      },
    },
  }
  
  </code></pre>
  <h3>packjage.json</h3>
  <pre><code>&quot;devDependencies&quot;: {
      &quot;@cypress/react&quot;: &quot;5.12.4&quot;,
      &quot;@cypress/webpack-dev-server&quot;: &quot;1.8.3&quot;,
      &quot;@cypress/webpack-preprocessor&quot;: &quot;^5.11.1&quot;,
      &quot;@types/jwt-decode&quot;: &quot;^3.1.0&quot;,
      &quot;babel-loader&quot;: &quot;^8.2.3&quot;,
      &quot;cypress&quot;: &quot;9.5.2&quot;,
      &quot;webpack-dev-server&quot;: &quot;3.2.1&quot;
    }
  </code></pre>