cypress-io / cypress

Fast, easy and reliable testing for anything that runs in a browser.
https://cypress.io
MIT License
47.09k stars 3.19k forks source link

breaking: remove support for create react app for component testing as it is no longer maintained #30558

Closed AtofStryker closed 2 weeks ago

AtofStryker commented 2 weeks ago

Additional details

Create React App is de-facto abandoned and unsupported. Because of this, Cypress has chosen to remove CRA support for Component Testing in Cypress 14. This means that create-react-app users will need to use either webpack or vite to bundler their component tests. webpack support is supported with create-react-app if a user choses to eject their app.

If starting cypress without doing any migration, this error will throw in the cypress config

Screenshot 2024-11-06 at 4 20 57 PM

However, users can migrate via npm run eject with create-react-app, which will generate a webpack config. If users change their config from:

const { defineConfig } = require('cypress')

module.exports = defineConfig({
  component: {
    devServer: {
      framework: 'create-react-app',
      bundler: 'webpack',
    },
  },
})

to

process.env.NODE_ENV = 'development'
const { defineConfig } = require('cypress')
const webpackConfig = require('./config/webpack.config.js')

module.exports = defineConfig({
  component: {
    devServer: {
      framework: 'react',
      bundler: 'webpack',
      webpackConfig: webpackConfig('development'),
    },
  },
})

this does work

Screenshot 2024-11-06 at 4 57 07 PM

It does work with new projects as react is selected and webpack is detected. However, a user will need to eject the application and point to the webpack config as shown above. Otherwise, the config will throw an error which is expected

Steps to test

Testing against prepublished binary to verify migration steps work as expected

How has the user experience changed?

PR Tasks

cypress[bot] commented 2 weeks ago

cypress    Run #58281

Run Properties:  status check passed Passed #58281  •  git commit b4aeb278b2: breaking: remove support for create react app for component testing as it is no ...
Project cypress
Branch Review breaking/remove_create_react_app
Run status status check passed Passed #58281
Run duration 09m 59s
Commit git commit b4aeb278b2: breaking: remove support for create react app for component testing as it is no ...
Committer AtofStryker
View all properties for this run ↗︎

Test results
Tests that failed  Failures 0
Tests that were flaky  Flaky 0
Tests that did not run due to a developer annotating a test with .skip  Pending 1
Tests that did not run due to a failure in a mocha hook  Skipped 0
Tests that passed  Passing 667
View all changes introduced in this branch ↗︎
UI Coverage  38.03%
  Untested elements 132  
  Tested elements 81  
Accessibility  92.06%
  Failed rules  3 critical   7 serious   1 moderate   1 minor
  Failed elements 540