diff options
author | Yasser A.Idrissi <getspookydev@gmail.com> | 2021-03-02 15:05:38 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-02 23:05:38 +0900 |
commit | 07626645e784ebc7f7335e40c439a39f9ae13864 (patch) | |
tree | 371836febc815d85f124e37e26450b2f840556c2 /docs/testing | |
parent | faf2e802724be9d493dad232759b76e7253feab0 (diff) |
docs(testing): add assertObjectMatch example (#9645)
Diffstat (limited to 'docs/testing')
-rw-r--r-- | docs/testing/assertions.md | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/docs/testing/assertions.md b/docs/testing/assertions.md index e80e760fe..9de7d1f35 100644 --- a/docs/testing/assertions.md +++ b/docs/testing/assertions.md @@ -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>` @@ -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, |