Skip to content

Commit

Permalink
docs(testing): add assertExists example (denoland#9613)
Browse files Browse the repository at this point in the history
  • Loading branch information
getspooky committed Mar 2, 2021
1 parent 0762664 commit 79c198f
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions docs/testing/assertions.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand All @@ -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()`,
Expand Down

0 comments on commit 79c198f

Please sign in to comment.