Skip to content

Commit

Permalink
docs(jest): update readme file and repo url [skip ci]
Browse files Browse the repository at this point in the history
  • Loading branch information
omermorad committed Jul 29, 2023
1 parent dc894cf commit 53dc0de
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 713 deletions.
58 changes: 16 additions & 42 deletions packages/testbeds/jest/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@ dependencies, allowing you to focus on writing test cases instead of mock setup.

<br>

Automock specially designed for Inversion of Control (IoC) and Dependency Injection (DI) scenarios, seamlessly
integrating automatic mocking into your framework of choice. With Automock, you can effortlessly isolate and test
Specially designed for Inversion of Control (IoC) and Dependency Injection (DI) scenarios, Automock seamlessly
integrates automatic mocking into your (DI) framework of choice. With Automock, you can effortlessly isolate and test
individual components, improving the efficiency and reliability of your unit testing process.


## :package: Installation

```bash
Expand All @@ -23,8 +24,7 @@ npm i -D @automock/jest

## :computer: Usage Example

With Automock, you can streamline the test creation process and eliminate the need for manual mock setup. Take a look at
the following example:
Take a look at the following example:

```typescript
import { TestBed } from '@automock/jest';
Expand All @@ -45,13 +45,13 @@ describe('User Service Unit Spec', () => {
let userService: UserService;
let database: jest.Mocked<Database>;

beforeEach(() => {
beforeAll(() => {
const { unit, unitRef } = TestBed.create(UserService).compile();
userService = unit;
database = unitRef.get(Database);
});

test('getAllUsers should retrieve users from the database', async () => {
test('should return users from the database', async () => {
database.getUsers.mockResolvedValue([{ id: 1, name: 'John' }, { id: 2, name: 'Jane' }]);

const users = await userService.getAllUsers();
Expand All @@ -60,48 +60,22 @@ describe('User Service Unit Spec', () => {
});
```

Automock streamlines the test creation process by automating the creation of mock objects and stubs, reducing
boilerplate code and eliminating the manual setup effort. This allows you to focus on writing meaningful test cases and
validating the behavior of your code without getting bogged down in repetitive mock object creation.

Automock specially designed for Inversion of Control (IoC) and Dependency Injection (DI) scenarios, seamlessly
integrating automatic mocking into your framework of choice.
**Both property injection and constructor injection are supported.** Whether your classes rely on dependencies injected
through properties or constructor parameters, Automock handles both scenarios seamlessly. This flexibility allows you to
write unit tests for a wide range of classes, ensuring that all dependencies are effectively mocked and isolated during
testing, regardless of the injection method used.

**[:books: For more examples and for API reference visit our docs page](https://github.com/automock/automock/blob/master/docs/automock.md)**

## :bulb: Philosophy

**We think that creating high-quality unit tests ought to be a breeze. We created Automock to remove the human element
from the otherwise tedious and error-prone process of creating mock objects manually. The following tenets form the
basis of our philosophy:**

**Productivity** \
Automock aims to save developers valuable time and effort by automating the process of creating mock objects. It
eliminates the need for manual mock setup and reduces boilerplate code, enabling you to focus on writing meaningful test
cases and improving code quality.

:rocket: **Simplicity** \
The library provides an intuitive and easy-to-use API, making it accessible to developers of all skill levels. By
automating mock object creation, Automock simplifies the testing process, reducing complexity and making unit testing
more approachable.

🔧 **Maintainability** \
By generating mock objects that closely resemble the original dependencies, Automock promotes code maintainability. The
generated mocks retain the same type information as the real objects, ensuring type safety and allowing you to leverage
TypeScript's powerful static type checking capabilities. This approach enhances code readability, reduces the risk of
errors, and makes it easier to refactor and maintain tests over time.

📐 **Consistent Syntax and Test Structure.** \
Automock promotes a uniform test syntax and test structure, ensuring consistency and coherence across your unit tests.
By adhering to established conventions and guidelines, you can establish a standardized approach to writing tests.

## :bookmark_tabs: Acknowledgments

Automock is influenced by the principles and concepts discussed in Martin Fowler's blog post on "Unit Tests". He
discusses the idea of creating "solitary" unit tests, which focus on testing a single unit of code in isolation,
independent of its dependencies.
Automock is built upon the fundamentals and principles of unit tests, particularly inspired by Martin Fowler's blog
posts on unit tests. Fowler advocates for creating "solitary" unit tests that concentrate on testing a single unit of
code in isolation, independently of its dependencies. This approach aligns with Automock's objective of providing a
simple and effective solution for automatically mocking class dependencies during unit testing.

https://martinfowler.com/bliki/UnitTest.html
If you're interested in learning more about unit tests, we encourage you to explore Martin Fowler's blog post on the
topic: https://martinfowler.com/bliki/UnitTest.html

## :scroll: License

Expand Down
4 changes: 2 additions & 2 deletions packages/testbeds/jest/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
],
"repository": {
"type": "git",
"url": "https://github.com/omermorad/automock.git"
"url": "https://github.com/automock/automock.git"
},
"bugs": {
"url": "https://github.com/omermorad/automock/issues"
"url": "https://github.com/automock/automock/issues"
},
"contributors": [
{
Expand Down
Loading

0 comments on commit 53dc0de

Please sign in to comment.