Guest User

Untitled

a guest
Oct 18th, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1. # HOW TO CREATE A WEB PROJECT
  2.  
  3. ## BABEL + JEST
  4.  
  5. Guide working at Mac OS with npm 6.4.1.
  6.  
  7. #### Installation
  8.  
  9. ```shell
  10. npm init -y
  11. ```
  12.  
  13. Install JEST.
  14.  
  15. ```shell
  16. npm init -y
  17. npm install --save-dev jest
  18. npx jest --init
  19. ```
  20.  
  21. Install Babel.
  22.  
  23. ```shell
  24. npm install --save-dev @babel/core @babel/cli @babel/preset-env
  25. npm install --save @babel/polyfill
  26. npm install --save-dev babel-jest
  27. ```
  28.  
  29. **IMPORTANT**
  30.  
  31. if u have problems with babel/core version...Do this and be happy. 😍
  32.  
  33. ```shell
  34. npx babel-upgrade --write --install
  35. ```
  36.  
  37. #### Configuration
  38.  
  39. In your `package.json` file make the following changes:
  40.  
  41. ```json
  42. {
  43. "scripts": {
  44. "test": "jest --watch"
  45. },
  46. "jest": {
  47. "transform": {
  48. "^.+\\.jsx?$": "babel-jest"
  49. }
  50. }
  51. }
  52. ```
  53.  
  54. Creating a config file named `.babelrc` in the root of your project with this content:
  55.  
  56. ```shell
  57. {
  58. "presets": ["@babel/preset-env"]
  59. }
  60. ```
  61.  
  62. Create the following structure:
  63.  
  64. - Node_modules
  65. - src
  66. - index.js
  67. - test
  68. - index.test.js
  69. - .babelrc
  70. - .gitignore
  71. - Jest.config.js
  72. - Package-lock.json
  73. - Package.json
  74.  
  75. NOW YOU CAN DANCE
  76. πŸ•ΊπŸ•ΊπŸ•ΊπŸ•ΊπŸ•ΊπŸ•ΊπŸ•ΊπŸ•Ί
Add Comment
Please, Sign In to add comment