Skip to content

Commit

Permalink
update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
Roaders committed Jan 29, 2025
1 parent 11930db commit bc18da8
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Requires a minimum Typescript version of 5.0.

# Framework support

This library has been tested with and supports Jasmine versions 1 and 2 and Jest versions 26 and 27. The mocking functionality should work in any environment as it has no dependencies on any particular framework. The import replacement functionality uses the jasmine `beforeAll` / `afterAll` and `beforeEach` / `afterEach` so will not work in other environments.
This library has been tested with and supports Jasmine versions 2 - 5, Jest versions 26 - 29 and vitest version 3. The mocking functionality should work in any environment as it has no dependencies on any particular framework.

# Usage

Expand Down Expand Up @@ -79,9 +79,9 @@ const systemUnderTest = new ClassWithConstructorArgument(mockedService.mockConst
## Verify Calls
[Examples](https://github.com/morganstanley/ts-mocking-bird/tree/master/spec/examples/exampleTests.spec.ts)

### Jasmine / Jest Matchers
### Adding Custom Matchers

When a mock is created using `Mock.create()` the custom matchers that are used by `ts-mocking-bird` are automatically setup. However this can only be done if the creation occurs within a `before` function. If you need to manually setup the custom matchers please call `addMatchers()`:
When a mock is created using `Mock.create()` the custom matchers that are used by `ts-mocking-bird` are automatically setup in jest, jasmine or vitest - whichever framework you are using. However this can only be done if the creation occurs within a `before` function. If you need to manually setup the custom matchers please call `addMatchers()`:

```typescript
import { addMatchers } from '@morgan-stanley/ts-mocking-bird'
Expand All @@ -93,6 +93,8 @@ describe("my test", () => {
})
```

For jasmine this has to be done in a `beforeEach` or `beforeAll` function but for jest and vitest it can be done in the test setup file.

### Verify that a function was called a number of times without checking parameters
```typescript
const mockedService: IMocked<IMyService> = Mock.create<IMyService>().setup(setupFunction('functionOne'));
Expand All @@ -116,6 +118,8 @@ expect(
).wasCalledOnce();
```

**NOTE:** `.withParameters` doe a strict equality check on the value you give it. It you want to see if the values are equal (for example two identical objects that are different instances) use `.withParametersEqualTo`.

### Verify Constructor Parameters

```ts
Expand Down

0 comments on commit bc18da8

Please sign in to comment.