hein 1.2.3 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +11 -0
- package/README.md +76 -21
- package/dist/.tsbuildinfo +1 -1
- package/dist/assert/deep-has-property.d.ts +19 -1
- package/dist/assert/deep-has-property.d.ts.map +1 -1
- package/dist/assert/deep-has-property.js.map +1 -1
- package/dist/assert/ends-with.d.ts +5 -0
- package/dist/assert/ends-with.d.ts.map +1 -1
- package/dist/assert/ends-with.js +2 -2
- package/dist/assert/ends-with.js.map +1 -1
- package/dist/assert/equal.d.ts +1 -1
- package/dist/assert/has-members.d.ts +46 -0
- package/dist/assert/has-members.d.ts.map +1 -0
- package/dist/assert/has-members.js +52 -0
- package/dist/assert/has-members.js.map +1 -0
- package/dist/assert/has-members.test.d.ts +2 -0
- package/dist/assert/has-members.test.d.ts.map +1 -0
- package/dist/assert/has-members.test.js +85 -0
- package/dist/assert/has-members.test.js.map +1 -0
- package/dist/assert/has-property.d.ts +19 -1
- package/dist/assert/has-property.d.ts.map +1 -1
- package/dist/assert/has-property.js.map +1 -1
- package/dist/assert/has-size.d.ts +39 -1
- package/dist/assert/has-size.d.ts.map +1 -1
- package/dist/assert/has-size.js +4 -1
- package/dist/assert/has-size.js.map +1 -1
- package/dist/assert/has-size.test.js +10 -0
- package/dist/assert/has-size.test.js.map +1 -1
- package/dist/assert/in-ballpark.d.ts +13 -1
- package/dist/assert/in-ballpark.d.ts.map +1 -1
- package/dist/assert/in-ballpark.js +6 -1
- package/dist/assert/in-ballpark.js.map +1 -1
- package/dist/assert/in-ballpark.test.js +6 -0
- package/dist/assert/in-ballpark.test.js.map +1 -1
- package/dist/assert/includes.d.ts +15 -0
- package/dist/assert/includes.d.ts.map +1 -1
- package/dist/assert/includes.js +2 -2
- package/dist/assert/includes.js.map +1 -1
- package/dist/assert/instance-of.d.ts +10 -8
- package/dist/assert/instance-of.d.ts.map +1 -1
- package/dist/assert/instance-of.js.map +1 -1
- package/dist/assert/instance-of.test.js.map +1 -1
- package/dist/assert/is-between.d.ts.map +1 -1
- package/dist/assert/is-between.js +8 -7
- package/dist/assert/is-between.js.map +1 -1
- package/dist/assert/is-between.test.js +3 -0
- package/dist/assert/is-between.test.js.map +1 -1
- package/dist/assert/is-empty.d.ts +28 -1
- package/dist/assert/is-empty.d.ts.map +1 -1
- package/dist/assert/is-empty.js +4 -1
- package/dist/assert/is-empty.js.map +1 -1
- package/dist/assert/is-empty.test.js +4 -0
- package/dist/assert/is-empty.test.js.map +1 -1
- package/dist/assert/is-type.d.ts +92 -1
- package/dist/assert/is-type.d.ts.map +1 -1
- package/dist/assert/is-type.js.map +1 -1
- package/dist/assert/match.d.ts +12 -1
- package/dist/assert/match.d.ts.map +1 -1
- package/dist/assert/match.js.map +1 -1
- package/dist/assert/rejects.d.ts +32 -1
- package/dist/assert/rejects.d.ts.map +1 -1
- package/dist/assert/rejects.js +6 -3
- package/dist/assert/rejects.js.map +1 -1
- package/dist/assert/round-to.d.ts +12 -1
- package/dist/assert/round-to.d.ts.map +1 -1
- package/dist/assert/round-to.js.map +1 -1
- package/dist/assert/starts-with.d.ts +6 -0
- package/dist/assert/starts-with.d.ts.map +1 -1
- package/dist/assert/starts-with.js +2 -2
- package/dist/assert/starts-with.js.map +1 -1
- package/dist/assert/throws.d.ts +25 -1
- package/dist/assert/throws.d.ts.map +1 -1
- package/dist/assert/throws.js.map +1 -1
- package/dist/assert.d.ts +1 -0
- package/dist/assert.d.ts.map +1 -1
- package/dist/assert.js +4 -1
- package/dist/assert.js.map +1 -1
- package/dist/expect/after.d.ts +1 -2
- package/dist/expect/after.d.ts.map +1 -1
- package/dist/expect/after.js.map +1 -1
- package/dist/expect/ballpark.d.ts +1 -1
- package/dist/expect/before.d.ts +1 -2
- package/dist/expect/before.d.ts.map +1 -1
- package/dist/expect/before.js.map +1 -1
- package/dist/expect/end-with.d.ts +6 -1
- package/dist/expect/end-with.d.ts.map +1 -1
- package/dist/expect/end-with.js +3 -3
- package/dist/expect/end-with.js.map +1 -1
- package/dist/expect/eql.d.ts +1 -4
- package/dist/expect/eql.d.ts.map +1 -1
- package/dist/expect/eql.js.map +1 -1
- package/dist/expect/equal.d.ts +2 -2
- package/dist/expect/has-property.d.ts +28 -0
- package/dist/expect/has-property.d.ts.map +1 -1
- package/dist/expect/has-property.js.map +1 -1
- package/dist/expect/instance-of.d.ts +9 -1
- package/dist/expect/instance-of.d.ts.map +1 -1
- package/dist/expect/instance-of.js.map +1 -1
- package/dist/expect/members.d.ts +13 -0
- package/dist/expect/members.d.ts.map +1 -0
- package/dist/expect/members.js +32 -0
- package/dist/expect/members.js.map +1 -0
- package/dist/expect/members.test.d.ts +2 -0
- package/dist/expect/members.test.d.ts.map +1 -0
- package/dist/expect/members.test.js +52 -0
- package/dist/expect/members.test.js.map +1 -0
- package/dist/expect/reject.d.ts +4 -0
- package/dist/expect/reject.d.ts.map +1 -1
- package/dist/expect/reject.js.map +1 -1
- package/dist/expect/start-with.d.ts +5 -0
- package/dist/expect/start-with.d.ts.map +1 -1
- package/dist/expect/start-with.js.map +1 -1
- package/dist/expect/throw.d.ts +4 -0
- package/dist/expect/throw.d.ts.map +1 -1
- package/dist/expect/throw.js.map +1 -1
- package/dist/expect.d.ts +1 -0
- package/dist/expect.d.ts.map +1 -1
- package/dist/expect.js +3 -0
- package/dist/expect.js.map +1 -1
- package/dist/expect.types.d.ts +2 -0
- package/dist/expect.types.d.ts.map +1 -1
- package/dist/expect.types.js.map +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/mixins.d.ts +2 -0
- package/dist/mixins.d.ts.map +1 -1
- package/dist/mixins.js.map +1 -1
- package/dist/utils/fail.d.ts +5 -0
- package/dist/utils/fail.d.ts.map +1 -0
- package/dist/utils/fail.js +12 -0
- package/dist/utils/fail.js.map +1 -0
- package/dist/utils/fail.test.d.ts +2 -0
- package/dist/utils/fail.test.d.ts.map +1 -0
- package/dist/utils/fail.test.js +12 -0
- package/dist/utils/fail.test.js.map +1 -0
- package/dist/utils/types.d.ts +4 -0
- package/dist/utils/types.d.ts.map +1 -0
- package/dist/utils/types.js +3 -0
- package/dist/utils/types.js.map +1 -0
- package/package.json +6 -3
package/CHANGELOG.md
CHANGED
|
@@ -4,11 +4,22 @@ All notable changes to this project will be documented in this file. Dates are d
|
|
|
4
4
|
|
|
5
5
|
Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
6
6
|
|
|
7
|
+
#### [hein@1.3.0](https://github.com/KristjanTammekivi/hein/compare/hein@1.2.3...hein@1.3.0)
|
|
8
|
+
|
|
9
|
+
> 15 July 2023
|
|
10
|
+
|
|
11
|
+
- feat: add .fail [`#156`](https://github.com/KristjanTammekivi/hein/issues/156)
|
|
12
|
+
- feat: add .members [`#148`](https://github.com/KristjanTammekivi/hein/issues/148)
|
|
13
|
+
- docs: polish jsdocs [`50b738f`](https://github.com/KristjanTammekivi/hein/commit/50b738f80768df1ec47d347de114818426b10a81)
|
|
14
|
+
- docs: fix build badge [`f897239`](https://github.com/KristjanTammekivi/hein/commit/f897239806aad8f21cf0845a95e60c9c64e45892)
|
|
15
|
+
- docs: add homepage [`bd7917b`](https://github.com/KristjanTammekivi/hein/commit/bd7917b65bf68a71e73afe90e9ea855c2e1c0baf)
|
|
16
|
+
|
|
7
17
|
#### [hein@1.2.3](https://github.com/KristjanTammekivi/hein/compare/hein@1.2.2...hein@1.2.3)
|
|
8
18
|
|
|
9
19
|
> 5 July 2023
|
|
10
20
|
|
|
11
21
|
- feat: add roundTo [`f9bb073`](https://github.com/KristjanTammekivi/hein/commit/f9bb0739b798861e506311a3ba55eb4fd3ac5920)
|
|
22
|
+
- style: remove unused export [`256de45`](https://github.com/KristjanTammekivi/hein/commit/256de455ce7eeff35049d72bc80043db06a68f0c)
|
|
12
23
|
|
|
13
24
|
#### [hein@1.2.2](https://github.com/KristjanTammekivi/hein/compare/hein@1.2.1...hein@1.2.2)
|
|
14
25
|
|
package/README.md
CHANGED
|
@@ -3,35 +3,36 @@
|
|
|
3
3
|
[](https://www.npmjs.com/package/hein)
|
|
4
4
|
[](https://www.npmjs.com/package/hein)
|
|
5
5
|
[](https://www.npmjs.com/package/hein)
|
|
6
|
-
[](https://www.npmjs.com/package/hein)
|
|
7
7
|
|
|
8
8
|
Assertion library with focus on TypeScript
|
|
9
9
|
|
|
10
|
-
## Features
|
|
10
|
+
## Features
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
- Full TypeScript support
|
|
13
|
+
- Fuzzy matching for eql with hein.any
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
- [Differences between Chai and Hein](https://github.com/KristjanTammekivi/hein/blob/main/packages/hein/DIFFERENCES_WITH_CHAI.md)
|
|
16
16
|
|
|
17
17
|
## Plugins
|
|
18
18
|
|
|
19
19
|
[npm/hein-plugin-sinon](https://www.npmjs.com/package/hein-plugin-sinon) -
|
|
20
20
|
Provides assertions like to.have.been.calledOnce() and to.have.been.calledWith() for sinon spies.
|
|
21
21
|
|
|
22
|
-
|
|
23
22
|
## Usage
|
|
24
23
|
|
|
25
24
|
### Assert
|
|
25
|
+
|
|
26
26
|
```typescript
|
|
27
27
|
import { assert } from 'hein';
|
|
28
|
-
import {equal} from 'hein/assert';
|
|
28
|
+
import { equal } from 'hein/assert';
|
|
29
29
|
|
|
30
30
|
equal(1, 1);
|
|
31
31
|
assert.equal(1, 1);
|
|
32
32
|
```
|
|
33
33
|
|
|
34
34
|
### Expect
|
|
35
|
+
|
|
35
36
|
```typescript
|
|
36
37
|
import { expect } from 'hein';
|
|
37
38
|
expect(1).to.equal(1);
|
|
@@ -39,13 +40,13 @@ expect(1).to.equal(1);
|
|
|
39
40
|
|
|
40
41
|
#### Chainable properties
|
|
41
42
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
43
|
+
- a
|
|
44
|
+
- an
|
|
45
|
+
- and - used to chain multiple assertions, clears the state (so .not will be reset)
|
|
46
|
+
- be
|
|
47
|
+
- have
|
|
48
|
+
- not - inverts the expectation (ie `expect(5).to.not.equal(5)` will throw)
|
|
49
|
+
- to
|
|
49
50
|
|
|
50
51
|
#### Assertions
|
|
51
52
|
|
|
@@ -72,6 +73,7 @@ Alias for [lessThanOrEqual](#lessThanOrEqual)
|
|
|
72
73
|
##### ballpark
|
|
73
74
|
|
|
74
75
|
Assert that value is within a range of expectation (default is 0.1 - within 10%)
|
|
76
|
+
|
|
75
77
|
```typescript
|
|
76
78
|
expect(1.1).to.be.in.ballpark(1);
|
|
77
79
|
expect(120).to.be.in.ballpark(100, 0.2);
|
|
@@ -106,12 +108,13 @@ Alias for [include](#include)
|
|
|
106
108
|
Assert that value is an instance of Date
|
|
107
109
|
|
|
108
110
|
```typescript
|
|
109
|
-
expect(new Date).to.be.a.date();
|
|
111
|
+
expect(new Date()).to.be.a.date();
|
|
110
112
|
```
|
|
111
113
|
|
|
112
114
|
##### empty
|
|
113
115
|
|
|
114
116
|
Assert that array / object / Map / Set is empty
|
|
117
|
+
|
|
115
118
|
```typescript
|
|
116
119
|
expect([]).to.be.empty();
|
|
117
120
|
expect({}).to.be.empty();
|
|
@@ -122,6 +125,7 @@ expect(new Set()).to.be.empty();
|
|
|
122
125
|
##### endWith
|
|
123
126
|
|
|
124
127
|
Assert that string ends with argument
|
|
128
|
+
|
|
125
129
|
```typescript
|
|
126
130
|
expect('hein').to.endWith('in');
|
|
127
131
|
```
|
|
@@ -129,17 +133,17 @@ expect('hein').to.endWith('in');
|
|
|
129
133
|
##### eql
|
|
130
134
|
|
|
131
135
|
Assert that value deep equals the expectation. When combined with .partially expected may have missing properties
|
|
136
|
+
|
|
132
137
|
```typescript
|
|
133
138
|
expect({ a: 1 }).to.eql({ a: 1 });
|
|
134
|
-
expect({ a: 1, b: new Date()}).to.partially.eql({ a: 1 });
|
|
139
|
+
expect({ a: 1, b: new Date() }).to.partially.eql({ a: 1 });
|
|
135
140
|
|
|
136
141
|
import { any, createEvaluation } from 'hein';
|
|
137
142
|
expect({ a: 1, b: new Date(), c: Math.random() }).to.eql({
|
|
138
143
|
a: 1,
|
|
139
144
|
b: any,
|
|
140
|
-
c: createEvaluation(n => typeof n === 'number')
|
|
145
|
+
c: createEvaluation((n) => typeof n === 'number')
|
|
141
146
|
});
|
|
142
|
-
|
|
143
147
|
```
|
|
144
148
|
|
|
145
149
|
##### eq
|
|
@@ -150,15 +154,17 @@ Alias for [equal](#equal)
|
|
|
150
154
|
|
|
151
155
|
Assert that value strictly equals expectation. NaN is treated as a non-unique value.
|
|
152
156
|
Chaining with .deep is an alias for [#eql]
|
|
157
|
+
|
|
153
158
|
```typescript
|
|
154
159
|
expect('hein').to.equal('hein');
|
|
155
160
|
expect(NaN).to.equal(NaN);
|
|
156
|
-
expect({ a: 1 }).to.deep.equal({ a: 1 })
|
|
161
|
+
expect({ a: 1 }).to.deep.equal({ a: 1 });
|
|
157
162
|
```
|
|
158
163
|
|
|
159
164
|
##### false
|
|
160
165
|
|
|
161
166
|
Assert that value is false
|
|
167
|
+
|
|
162
168
|
```typescript
|
|
163
169
|
expect(false).to.be.false();
|
|
164
170
|
```
|
|
@@ -166,6 +172,7 @@ expect(false).to.be.false();
|
|
|
166
172
|
##### function
|
|
167
173
|
|
|
168
174
|
Assert that value is a function
|
|
175
|
+
|
|
169
176
|
```typescript
|
|
170
177
|
expect(() => {}).to.be.a.function();
|
|
171
178
|
```
|
|
@@ -173,6 +180,7 @@ expect(() => {}).to.be.a.function();
|
|
|
173
180
|
##### greaterThan
|
|
174
181
|
|
|
175
182
|
Assert that value is greater than expectation
|
|
183
|
+
|
|
176
184
|
```typescript
|
|
177
185
|
expect(5).to.be.greaterThan(4);
|
|
178
186
|
```
|
|
@@ -184,6 +192,7 @@ Alias for [greaterThan](#greaterThan)
|
|
|
184
192
|
##### greaterThanOrEqual
|
|
185
193
|
|
|
186
194
|
Assert that value is greater than or equal to argument
|
|
195
|
+
|
|
187
196
|
```typescript
|
|
188
197
|
expect(5).to.be.greaterThanOrEqual(5);
|
|
189
198
|
expect(5).to.be.greaterThanOrEqual(4);
|
|
@@ -196,6 +205,7 @@ Alias for [greaterThanOrEqual](#greaterThanOrEqual)
|
|
|
196
205
|
##### include
|
|
197
206
|
|
|
198
207
|
Assert that element / substring is present in array / string
|
|
208
|
+
|
|
199
209
|
```typescript
|
|
200
210
|
expect([1, 2, 3]).to.include(2);
|
|
201
211
|
expect('hein').to.include('ei');
|
|
@@ -204,6 +214,7 @@ expect('hein').to.include('ei');
|
|
|
204
214
|
##### instanceOf
|
|
205
215
|
|
|
206
216
|
Assert that value is an instance of provided constructor
|
|
217
|
+
|
|
207
218
|
```typescript
|
|
208
219
|
expect(new Error()).to.be.an.instanceOf(Error);
|
|
209
220
|
```
|
|
@@ -211,6 +222,7 @@ expect(new Error()).to.be.an.instanceOf(Error);
|
|
|
211
222
|
##### lengthOf
|
|
212
223
|
|
|
213
224
|
Assert that value has a length equal to argument
|
|
225
|
+
|
|
214
226
|
```typescript
|
|
215
227
|
expect([1]).to.have.a.lengthOf(1);
|
|
216
228
|
expect({ a: 1 }).to.have.a.lengthOf(1);
|
|
@@ -222,6 +234,7 @@ expect('hein').to.have.a.lengthOf(4);
|
|
|
222
234
|
##### isAfter
|
|
223
235
|
|
|
224
236
|
Assert that date is before argument
|
|
237
|
+
|
|
225
238
|
```typescript
|
|
226
239
|
expect(new Date(2020, 1, 2)).to.be.after(new Date(2020, 1, 1));
|
|
227
240
|
```
|
|
@@ -229,6 +242,7 @@ expect(new Date(2020, 1, 2)).to.be.after(new Date(2020, 1, 1));
|
|
|
229
242
|
##### isBefore
|
|
230
243
|
|
|
231
244
|
Assert that date is before argument
|
|
245
|
+
|
|
232
246
|
```typescript
|
|
233
247
|
expect(new Date(2020, 1, 1)).to.be.before(new Date(2020, 1, 2));
|
|
234
248
|
```
|
|
@@ -236,6 +250,7 @@ expect(new Date(2020, 1, 1)).to.be.before(new Date(2020, 1, 2));
|
|
|
236
250
|
##### isBetween
|
|
237
251
|
|
|
238
252
|
Assert that date or number is between arguments
|
|
253
|
+
|
|
239
254
|
```typescript
|
|
240
255
|
expect(new Date(2020, 1, 2)).to.be.between(new Date(2020, 1, 1), new Date(2020, 1, 3));
|
|
241
256
|
expect(2).to.be.between(1, 3);
|
|
@@ -244,9 +259,11 @@ expect(2).to.be.between(1, 3);
|
|
|
244
259
|
##### lessThan
|
|
245
260
|
|
|
246
261
|
Assert that value is less than expectation
|
|
262
|
+
|
|
247
263
|
```typescript
|
|
248
264
|
expect(5).to.be.lessThan(6);
|
|
249
265
|
```
|
|
266
|
+
|
|
250
267
|
##### lt
|
|
251
268
|
|
|
252
269
|
Alias for [lessThan](#lessThan)
|
|
@@ -254,6 +271,7 @@ Alias for [lessThan](#lessThan)
|
|
|
254
271
|
##### lessThanOrEqual
|
|
255
272
|
|
|
256
273
|
Assert that value is less than or equal to expectation
|
|
274
|
+
|
|
257
275
|
```typescript
|
|
258
276
|
expect(5).to.be.lessThanOrEqual(5);
|
|
259
277
|
expect(4).to.be.lessThanOrEqual(5);
|
|
@@ -266,13 +284,31 @@ Alias for [lessThanOrEqual](#lessThanOrEqual)
|
|
|
266
284
|
##### Map
|
|
267
285
|
|
|
268
286
|
Assert that value is an instance of Map
|
|
287
|
+
|
|
269
288
|
```typescript
|
|
270
289
|
expect(new Map()).to.be.a.Map();
|
|
271
290
|
```
|
|
272
291
|
|
|
292
|
+
##### members
|
|
293
|
+
|
|
294
|
+
Assert that array contains members of expectation
|
|
295
|
+
|
|
296
|
+
```typescript
|
|
297
|
+
expect([1, 2, 3]).to.have.members([1, 2]);
|
|
298
|
+
// check that the arrays have same length
|
|
299
|
+
expect([1, 2, 3]).to.have.same.members([1, 2, 3]);
|
|
300
|
+
// check that the members are found in the same order
|
|
301
|
+
expect([1, 2, 3]).to.have.ordered.members([1, 2, 3]);
|
|
302
|
+
// check for deep equality of members
|
|
303
|
+
expect([{ a: 1 }, { b: 2 }]).to.have.deep.members([{ a: 1 }]);
|
|
304
|
+
// check for members by partial equality
|
|
305
|
+
expect([{ a: 1 }, { b: 2 }]).to.have.partially.members([{ a: 1 }]);
|
|
306
|
+
```
|
|
307
|
+
|
|
273
308
|
##### NaN
|
|
274
309
|
|
|
275
310
|
Assert that value is NaN
|
|
311
|
+
|
|
276
312
|
```typescript
|
|
277
313
|
expect(NaN).to.be.NaN();
|
|
278
314
|
```
|
|
@@ -280,6 +316,7 @@ expect(NaN).to.be.NaN();
|
|
|
280
316
|
##### null
|
|
281
317
|
|
|
282
318
|
Assert that value is null
|
|
319
|
+
|
|
283
320
|
```typescript
|
|
284
321
|
expect(null).to.be.null();
|
|
285
322
|
```
|
|
@@ -287,6 +324,7 @@ expect(null).to.be.null();
|
|
|
287
324
|
##### number
|
|
288
325
|
|
|
289
326
|
Assert that value is a number
|
|
327
|
+
|
|
290
328
|
```typescript
|
|
291
329
|
expect(5).to.be.a.number();
|
|
292
330
|
```
|
|
@@ -294,6 +332,7 @@ expect(5).to.be.a.number();
|
|
|
294
332
|
##### object
|
|
295
333
|
|
|
296
334
|
Assert that value is an object. Null and instances of Array don't count
|
|
335
|
+
|
|
297
336
|
```typescript
|
|
298
337
|
expect({}).to.be.an.object();
|
|
299
338
|
```
|
|
@@ -301,6 +340,7 @@ expect({}).to.be.an.object();
|
|
|
301
340
|
##### property
|
|
302
341
|
|
|
303
342
|
Assert that actual has property. Optionally check that propery has value
|
|
343
|
+
|
|
304
344
|
```typescript
|
|
305
345
|
expect({ a: 1 }).to.have.property('a');
|
|
306
346
|
expect({ a: 1 }).to.have.property('a', 1);
|
|
@@ -309,6 +349,7 @@ expect({ a: 1 }).to.have.property('a', 1);
|
|
|
309
349
|
##### reject
|
|
310
350
|
|
|
311
351
|
Assert that provided Promise rejects. At the moment this is the only assertion that can't be chained, returns a promise
|
|
352
|
+
|
|
312
353
|
```typescript
|
|
313
354
|
await expect(Promise.reject()).to.reject();
|
|
314
355
|
```
|
|
@@ -316,6 +357,7 @@ await expect(Promise.reject()).to.reject();
|
|
|
316
357
|
##### roundTo
|
|
317
358
|
|
|
318
359
|
Assert that number can be rounded to target
|
|
360
|
+
|
|
319
361
|
```typescript
|
|
320
362
|
expect(5.5).to.be.roundTo(6);
|
|
321
363
|
expect(5.14).to.roundTo(5.1, 1);
|
|
@@ -325,17 +367,19 @@ expect(110).to.roundTo(100, -2);
|
|
|
325
367
|
##### Set
|
|
326
368
|
|
|
327
369
|
Assert that value is an instance of Set
|
|
370
|
+
|
|
328
371
|
```typescript
|
|
329
372
|
expect(new Set()).to.be.a.Set();
|
|
330
373
|
```
|
|
374
|
+
|
|
331
375
|
##### sizeOf
|
|
332
376
|
|
|
333
377
|
Alias of [lengthOf](#lengthOf)
|
|
334
378
|
|
|
335
|
-
|
|
336
379
|
##### startWith
|
|
337
380
|
|
|
338
381
|
Assert that string starts with argument
|
|
382
|
+
|
|
339
383
|
```typescript
|
|
340
384
|
expect('hein').to.startWith('he');
|
|
341
385
|
```
|
|
@@ -343,6 +387,7 @@ expect('hein').to.startWith('he');
|
|
|
343
387
|
##### string
|
|
344
388
|
|
|
345
389
|
Assert that value is a string
|
|
390
|
+
|
|
346
391
|
```typescript
|
|
347
392
|
expect('hein').to.be.a.string();
|
|
348
393
|
```
|
|
@@ -350,6 +395,7 @@ expect('hein').to.be.a.string();
|
|
|
350
395
|
##### symbol
|
|
351
396
|
|
|
352
397
|
Assert that value is a symbol
|
|
398
|
+
|
|
353
399
|
```typescript
|
|
354
400
|
expect(Symbol()).to.be.a.symbol();
|
|
355
401
|
```
|
|
@@ -357,12 +403,17 @@ expect(Symbol()).to.be.a.symbol();
|
|
|
357
403
|
##### throw
|
|
358
404
|
|
|
359
405
|
Assert that provided function throws
|
|
406
|
+
|
|
360
407
|
```typescript
|
|
361
|
-
expect(() => {
|
|
408
|
+
expect(() => {
|
|
409
|
+
throw new Error();
|
|
410
|
+
}).to.throw();
|
|
362
411
|
```
|
|
412
|
+
|
|
363
413
|
##### true
|
|
364
414
|
|
|
365
415
|
Assert that value is true
|
|
416
|
+
|
|
366
417
|
```typescript
|
|
367
418
|
expect(true).to.be.true;
|
|
368
419
|
```
|
|
@@ -370,6 +421,7 @@ expect(true).to.be.true;
|
|
|
370
421
|
##### undefined
|
|
371
422
|
|
|
372
423
|
Assert that value is undefined
|
|
424
|
+
|
|
373
425
|
```typescript
|
|
374
426
|
expect(undefined).to.be.undefined();
|
|
375
427
|
```
|
|
@@ -377,6 +429,7 @@ expect(undefined).to.be.undefined();
|
|
|
377
429
|
##### WeakMap
|
|
378
430
|
|
|
379
431
|
Assert that value is an instance of WeakMap
|
|
432
|
+
|
|
380
433
|
```typescript
|
|
381
434
|
expect(new WeakMap()).to.be.a.WeakMap();
|
|
382
435
|
```
|
|
@@ -384,6 +437,7 @@ expect(new WeakMap()).to.be.a.WeakMap();
|
|
|
384
437
|
##### WeakSet
|
|
385
438
|
|
|
386
439
|
Assert that value is an instance of WeakSet
|
|
440
|
+
|
|
387
441
|
```typescript
|
|
388
442
|
expect(new WeakSet()).to.be.a.WeakSet();
|
|
389
443
|
```
|
|
@@ -393,6 +447,7 @@ expect(new WeakSet()).to.be.a.WeakSet();
|
|
|
393
447
|
##### excluding
|
|
394
448
|
|
|
395
449
|
Exclude properties from assertion
|
|
450
|
+
|
|
396
451
|
```typescript
|
|
397
452
|
expect({ a: 1, b: 2 }).excluding('a').to.eql({ b: 2 });
|
|
398
453
|
```
|