Create-react-app is deprecated

Apparently, create-react-app was deprecated in 2023, but most of the projects and tutorials still involve using it. Are we allowed to use other methods of creating a react app (such as vite or next.js). Enzyme is also recommended for testing, but it has not been updated to work with react 18 which results in an error when trying to install it with create-react-app. The project I am currently working on (Reddit Project from the Redux Section) requires me to write tests with jest and enzyme but if enzyme is not currently updated to work with the latest react this doesn’t seem feasible, and I have not yet been given the knowledge to properly use tags like --force while understanding future problems that I may run into.

2 Likes

I took the risk of using the --force to install enzyme, and after playing with the package.json file for awhile I managed to get the test suite working.

“jest”: {
“snapshotSerializers”: [
“enzyme-to-json/serializer”
],
“moduleNameMapper”: {
“\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$”:
“/mocks/fileMock.js”,
“\.(css|less)$”: “/mocks/styleMock.js”
},
“setupFilesAfterEnv”: [“./src/setupTests.js”]
},
“devDependencies”: {
“enzyme-to-json”: “^3.6.2”
}
}

fileMock.js -
module.exports = ‘test-file-stub’;

styleMock.js -
module.exports = {};

With these changes I was able to get it functioning properly. I still hope that alternatives will start to appear in the lessons since the technology is not being updated any longer.

I too had this issue. So I looked for additional courses on Codecademy and found the course, ‘Learn React Testing’. After completing that course I began using RTL instead of Enzyme.

That course utilizes Jest and React Testing Library (RTL) for testing instead of Enzyme. I have seen a few sources online recommend RTL over Enzyme due to Enzyme’s depreciation and RTL being more ‘future-proof’ and compatible with newer versions of React. You can find more about how to migrate from Enzyme to RTL here. You can also check out the ‘Learn React Testing’ course for how to use it, it is a very short course that should get you started.

-Josh

1 Like