Setting up the environment - danberkeland/personalReddit GitHub Wiki
We're gonna set this up with React, React-Router, and Redux. For testing, we will use Jest and Enzyme.
To create the initial structure for the environment:
npx create-react-app personalreddit
After entering new directory - personalreddit (Gotta remember that on the git push, need to move back up to personalReddit one level up.):
npm install react-router-dom
Then add redux:
npm install redux react-redux
Now to set up Jest. FIrst we'll install it:
npm install --save-dev jest
To use it together with Babel, we'll install:
npm install --save-dev babel-jest
Create a file named .babelrc and paste this code:
{
"presets": ["@babel/preset-env"]
}
Then add this to scripts in package.json:
{
...
"scripts": {
...
"test": "jest",
"test:watch": "npm test -- --watch"
},
...
}
Need to add Enzyme. I'll update this when the time comes.
Upon attempting to start the script, I ran into a problem with the Jest dependency. Here's the fix:
1. Delete package-lock.json (not package.json!) and/or yarn.lock in your project folder.
2. Delete node_modules in your project folder.
3. Remove "jest" from dependencies and/or devDependencies in the package.json file in your project folder.
4. Run npm install or yarn, depending on the package manager you use.