Vagyasri / Jest-Setup

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Jest-Setup

Setting up the Jest-pack for the future Projects

Built With

  • HTML
  • CSS
  • JavaScipt
  • Webpack
  • ES6
  • Jest

Author

👤 Bhagyashree Patra

Getting Started

Prerequisites:

  • Web browser
  • Code Editor (VS Code)
  • Live Server Extension

Cloning the repo to your local system (If you already have git, installed in your system):

  • Copy this link
  • Open your terminal or command line
  • Run "git clone Paste this link"
  • Open the folder with your code editor
  • Now You can edit the code and check the changes in the browser using Live Server

Steps:

Basic Setup:

  • Install Jest using NPM: npm install --save-dev jest

  • Add the following section to your package.json:

        "scripts": {
    -       "test": "echo \"Error: no test specified\" && exit 1",
    +       "test": "jest",
            "start": "webpack serve --open",
            "build": "webpack"
            },
  • babel-jest is automatically installed when installing Jest and will automatically transform files if a babel configuration exists in your project. To avoid this behavior, you can explicitly reset the transform configuration option: (Create a file named jest.config.js)

// jest.config.js
module.exports = {
  transform: {},
};

Using Babel:

  • Install by Running: npm install --save-dev @babel/plugin-transform-modules-commonjs

  • Configure Babel to target your current version of Node by creating a babel.config.js file in the root of your project:

module.exports = {
  presets: [['@babel/preset-env', {targets: {node: 'current'}}]],
};

Using TypeScript:

// babel.config.js
module.exports = {
  presets: [
    ['@babel/preset-env', {targets: {node: 'current'}}],
+   '@babel/preset-typescript',
  ],
};

For Running Jest:

  • Run: npm run test or npm test

Get Live View in Localhost:

  • Run: npm start

Check linter errors:

  • Install npm
  • For HTML: Run npx hint .
  • For CSS: Run npx stylelint "**/*.{css,scss}"
  • For JS: Run npx eslint .

🤝 Contributing

Contributions, issues, and feature requests are welcome!

Start by:

  • Forking the project
  • Cloning the project to your local machine
  • cd into the Youtube-Replica project directory
  • Run git checkout -b your-branch-name
  • Make your contributions
  • Push your branch up to your forked repository
  • Open a Pull Request with a detailed description to the development branch of the original project for a review

Feel free to check the issues page, contribute to the Project by creating an issue.

Show your support

Give a ⭐️ if you like this project!

About

License:MIT License


Languages

Language:JavaScript 81.8%Language:HTML 16.4%Language:CSS 1.7%