1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-24 15:19:26 -05:00

docs(testing): add assertExists example (#9613)

This commit is contained in:
Yasser A.Idrissi 2021-03-02 15:08:54 +01:00 committed by GitHub
parent 07626645e7
commit 79c198f348
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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()`,