Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/mahammad-mostafa/unit-testing-exercise

This is the fifth project in the second module in the Microverse program. It is an exercise for practicing unit testing in JavaScript using Jest framework & Test Driven Development.
https://github.com/mahammad-mostafa/unit-testing-exercise

arrange-act-assert arrow-functions es6 javascript jest jest-matchers npm-scripts tdd-javascript test-automation test-driven-development testing testing-framework testing-tools

Last synced: 28 days ago
JSON representation

This is the fifth project in the second module in the Microverse program. It is an exercise for practicing unit testing in JavaScript using Jest framework & Test Driven Development.

Awesome Lists containing this project

README

        

# 🏷️ Unit Testing Exercise

This is the fifth project in the second module in the **Microverse** program.


Check the below contents for further details about this project.

# 📗 Contents

- [Description](#description)
- [Instructions](#instructions)
- [Authors](#authors)
- [Contributions](#contributions)
- [Support](#support)
- [Acknowledgements](#acknowledgements)
- [License](#license)

# 📖 Description

This project is an exercise for practicing unit testing using `Jest` framework with `TDD` (Test Driven Development).
It contains two directories `units` for functions & `testers` for testing functions.
It also includes config linters for `JavaScript` in the `.github` directory.

📌 **Tech Stack:**
- Logic & functionality built with `JavaScript`
- Unit testing done with `Jest` framework

📌 **Key Features:**
- Each task has its own unit & tester file
- All tasks are in separate test group with description text
- Function `stringLength` returns a number for the input string length
- Any string length outside the range of `(1 - 10)` throws an error `Value out of range!`
- Three test cases are implemented in `stringLength.test.js` for checking valid & invalid input
- Function `reverseString` returns the input string with characters in reverse order
- One test case was done for `reverseString` function in `reverseString.test.js`
- Object `calculator` contains four functions (`add` / `subtract` / `multiply` / `divide`)
- Each function inside the `calculator` object has three test cases grouped together
- Function `capitalize` takes a string input & returns it with first letter capitalized
- The test cases for `capitalize` function was created first in `capitalize.test.js`
- Any number input for `capitalize` function thriws an error `Invalid string!`

back to top

# 🛠️ Instructions

You can easily clone or fork this repository and work on it immadiately!

📌 **Prerequisites:**
- `NodeJS` for installing & running all packages
- `Jest` testing framework installed with:
```
npm i -D jest
```

📌 **Setup:**
- Install all dependencies with `npm`
- For running tests use:
```
npm run test
```

back to top

# 👥 Authors

📌 **Mahammad:**
- [GitHub](https://github.com/mahammad-mostafa)
- [Twitter](https://twitter.com/mahammad_mostfa)
- [LinkedIn](https://linkedin.com/in/mahammad-mostafa)

back to top

# 🤝🏻 Contributions

Wish to contribute to this project?


Contributions, issues, and feature requests are more than welcome!


Feel free to check the [issues](../../issues) page too.

back to top

# ⭐️ Support

Like this project? Show your support by starring!

back to top

# 🙏🏻 Acknowledgements

I thank everyone at **Microverse** for guiding me through this project.

back to top

# 📝 License

This project is [MIT](LICENSE.md) licensed.

back to top