diff options
author | Yasser A.Idrissi <getspookydev@gmail.com> | 2021-03-02 15:08:54 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-02 23:08:54 +0900 |
commit | 79c198f3488a4faaab2076aec751e29f4363001a (patch) | |
tree | f0de3ba2b0e32927830ab59d186f9937402b078d | |
parent | 07626645e784ebc7f7335e40c439a39f9ae13864 (diff) |
docs(testing): add assertExists example (#9613)
-rw-r--r-- | docs/testing/assertions.md | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/docs/testing/assertions.md b/docs/testing/assertions.md index 9de7d1f35..7d7bc69b3 100644 --- a/docs/testing/assertions.md +++ b/docs/testing/assertions.md @@ -16,6 +16,7 @@ The assertions module provides 10 assertions: - `assert(expr: unknown, msg = ""): asserts expr` - `assertEquals(actual: unknown, expected: unknown, msg?: string): void` +- `assertExists(actual: unknown,msg?: string): void` - `assertNotEquals(actual: unknown, expected: unknown, msg?: string): void` - `assertStrictEquals(actual: unknown, expected: unknown, msg?: string): void` - `assertStringIncludes(actual: string, expected: string, msg?: string): void` @@ -39,6 +40,19 @@ Deno.test("Test Assert", () => { }); ``` +### Exists + +The `assertExists` can be used to check if a value is not `null` or `undefined`. + +```js +assertExists("Denosaurus"); +Deno.test("Test Assert Exists", () => { + assertExists("Denosaurus"); + assertExists(false); + assertExists(0); +}); +``` + ### Equality There are three equality assertions available, `assertEquals()`, |