deno.land / std@0.224.0 / expect / _to_be_defined_test.ts

_to_be_defined_test.ts
View Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.// deno-lint-ignore-file no-explicit-any
import { expect } from "./expect.ts";import { AssertionError, assertThrows } from "../assert/mod.ts";
Deno.test("expect().toBeDefined()", () => { expect(1).toBeDefined(); expect("a").toBeDefined();
expect(undefined).not.toBeDefined(); expect(({} as any).foo).not.toBeDefined();
assertThrows(() => { expect(undefined).toBeDefined(); }, AssertionError); assertThrows(() => { expect(({} as any).foo).toBeDefined(); }, AssertionError);
assertThrows(() => { expect(1).not.toBeDefined(); }, AssertionError); assertThrows(() => { expect("a").not.toBeDefined(); }, AssertionError);});
std

Version Info

Tagged at
6 months ago