Skip to content

Commit

Permalink
docs(testing): add assertObjectMatch example (denoland#9645)
Browse files Browse the repository at this point in the history
  • Loading branch information
getspooky committed Mar 2, 2021
1 parent faf2e80 commit 0762664
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions docs/testing/assertions.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ The assertions module provides 10 assertions:
- `assertArrayIncludes(actual: unknown[], expected: unknown[], msg?: string): void`
- `assertMatch(actual: string, expected: RegExp, msg?: string): void`
- `assertNotMatch(actual: string, expected: RegExp, msg?: string): void`
- `assertObjectMatch( actual: Record<PropertyKey, unknown>, expected: Record<PropertyKey, unknown>): void`
- `assertThrows(fn: () => void, ErrorClass?: Constructor, msgIncludes = "", msg?: string): Error`
- `assertThrowsAsync(fn: () => Promise<void>, ErrorClass?: Constructor, msgIncludes = "", msg?: string): Promise<Error>`

Expand Down Expand Up @@ -136,6 +137,21 @@ Deno.test("Test Assert Not Match", () => {
});
```

### Object

Use `assertObjectMatch` to check that a JavaScript object matches a subset of
the properties of an object.

```js
// Simple subset
assertObjectMatch(
{ foo: true, bar: false },
{
foo: true,
},
);
```

### Throws

There are two ways to assert whether something throws an error in Deno,
Expand Down

0 comments on commit 0762664

Please sign in to comment.