Folders and files
| Name | Name | Last commit date | ||
|---|---|---|---|---|
Repository files navigation
FizzBuzz - Unit Testing Example in JavaScript 🚀 This project provides a practical example for learning unit testing in JavaScript using Jest. The popular FizzBuzz problem is used as a case study. The FizzBuzz problem involves printing a list of numbers from 1 to 100, but with certain conditions: for multiples of 3, "Fizz" is printed; for multiples of 5, "Buzz" is printed; and for multiples of both 3 and 5, "FizzBuzz" is printed. Project Objective 🎯 The main goal of this project is to offer a practical, hands-on introduction to unit testing in JavaScript. By addressing the simple yet classic FizzBuzz problem, developers can learn how to structure and execute unit tests, understanding their importance in the software development process. Project Structure 📂 The project structure follows common conventions for organizing JavaScript projects: -src/: Contains the project's source code. -fizzbuzz.js: Implementation of the FizzBuzz function. -tests/: Contains the project's unit tests. -fizzbuzz.test.js: Unit tests for the FizzBuzz function. -package.json: npm configuration file that includes dependencies and scripts for running tests. -README.md: Documentation providing a project description and instructions for use. -Setup and Execution 🛠 To use this project, follow these steps: -Clone the repository: Clone this repository to your local machine. -Copy code git clone https://github.com/qapacker/FizzBuzz-unit-Testing.git -cd FizzBuzz-unit-Testing ## Install dependencies: Install the necessary dependencies using npm. -npm install ## Install development dependencies: Install the following development dependencies by running this command in your terminal: ```bash npm install --save-dev jest @babel/core @babel/preset-env babel-jest ``` 4. **Configuración de Babel**: Crea un archivo de configuración de Babel llamado `.babelrc` en la raíz de tu proyecto. Asegúrate de que contenga lo siguiente: ```json { "presets": ["@babel/preset-env"] } ``` ## Jest Configuration: Add the following configuration in your package.json file to make Jest use Babel as a transformer: { "jest": { "transform": { "^.+\\.js$": "babel-jest" } } } ## Run the unit tests: Execute the unit tests with the following command: -npm test This will run Jest and display the test results in the console. Contributions 🙌 Contributions are welcome! If you have ideas to improve this project, please submit a pull request. Any enhancements or bug fixes are appreciated. License 📝 This project is licensed under the MIT License.