deno.land / std@0.139.0 / testing / chai_example.ts

chai_example.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
29
30
31
32
33
34
35
36
37
38
39
// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license./** * Run this example with: * * deno test ./testing/chai_example.ts */import chai from "https://cdn.skypack.dev/chai@4.3.4?dts";
const foo = "bar";const beverages = { tea: ["chai", "matcha", "oolong"] };
Deno.test("we can make chai assertions", () => { const assert = chai.assert;
assert.typeOf(foo, "string"); // without optional message assert.typeOf(foo, "string", "foo is a string"); // with optional message assert.equal(foo, "bar", "foo equal `bar`"); assert.lengthOf(foo, 3, "foo`s value has a length of 3"); assert.lengthOf(beverages.tea, 3, "beverages has 3 types of tea");});
Deno.test("we can make chai expectations", () => { const expect = chai.expect;
expect(foo).to.be.a("string"); expect(foo).to.equal("bar"); expect(foo).to.have.lengthOf(3); expect(beverages).to.have.property("tea").with.lengthOf(3);});
Deno.test("we can use chai should style", () => { chai.should();
foo.should.be.a("string"); foo.should.equal("bar"); foo.should.have.lengthOf(3); beverages.should.have.property("tea").with.lengthOf(3);});
std
Deno standard library
GitHub Repositorydenoland/deno_std
GitHub Stars
2121

Version Info

Tagged at
a week ago