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/react regression in 5.9.0 from 5.8.0: findReactScriptsWebpackConfig returns undefined #16751

Closed
yann-combarnous opened this issue May 31, 2021 · 5 comments
Assignees
Labels
npm: @cypress/react @cypress/react package issues

Comments

@yann-combarnous
Copy link

yann-combarnous commented May 31, 2021

Current behavior

findReactScriptsWebpackConfig is returning "undefined" for react-script webpack configuration in version 5.9.0.

Desired behavior

findReactScriptsWebpackConfig was returning react-scripts webpack configuration in version 5.8.0, both with cypress-run and cypress run-ct.

Test code to reproduce

In plugin/index.js, we setup the following for unit/component testing code coverage:

import injectDevServer from '@cypress/react/plugins/react-scripts';
import findReactScriptsWebpackConfig from '@cypress/react/plugins/react-scripts/findReactScriptsWebpackConfig';
import { startDevServer } from '@cypress/webpack-dev-server';
// Code coverage
import codeCoverageTask from '@cypress/code-coverage/task';

// This function is called when a project is opened or re-opened (e.g. due to
// the project's config changing)
/**
 * @type {Cypress.PluginConfig}
 */
module.exports = (on, config) => {
  // `on` is used to hook into various events Cypress emits
  // `config` is the resolved Cypress config
  codeCoverageTask(on, config);

  // Component testing web dev server setup for code coverage
  injectDevServer(on, config);
  const webpackConfig = findReactScriptsWebpackConfig(config);
  const rules = webpackConfig.module.rules.find((rule) => !!rule.oneOf).oneOf;
  const babelRule = rules.find((rule) => /babel-loader/.test(rule.loader));
  babelRule.options.plugins.push(require.resolve('babel-plugin-istanbul'));

Versions

Create-React-App 4.0.3
@cypress/react: 5.9.0

@yann-combarnous
Copy link
Author

@jennifer-shehane , found the issue: findReactScriptsWebpackConfig now requires webpack config path to be set explicitely.

This is a breaking change, would have been nice to have default set to former 5.8.0 value if not provided.

@jennifer-shehane
Copy link
Member

Perhaps introduced in #16644

@yann-combarnous
Copy link
Author

yann-combarnous commented Jun 4, 2021

@jennifer-shehane , correct, the default CRA path was replaced by a variable, would have been nice to substitute CRA value if no value provided, for backward-compatibility.

@lmiller1990
Copy link
Contributor

lmiller1990 commented Jun 4, 2021

#16813 should fix it. We should definitely have the default webpack config path as the fallback.

@elevatebart
Copy link
Contributor

Delivered in 5.9.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
npm: @cypress/react @cypress/react package issues
Projects
None yet
Development

No branches or pull requests

4 participants