You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/03-assertions.md
+10-4Lines changed: 10 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -141,9 +141,9 @@ Assert that `actual` is not deeply equal to `expected`. The inverse of `.deepEqu
141
141
142
142
Assert that `actual` is like `selector`. This is a variant of `.deepEqual()`, however `selector` does not need to have the same enumerable properties as `actual` does.
143
143
144
-
Instead AVA derives a *comparable*object from `actual`, based on the deeply-nested properties of `selector`. This object is then compared to `selector` using `.deepEqual()`.
144
+
Instead AVA derives a *comparable*value from `actual`, recursively based on the shape of `selector`. This value is then compared to `selector` using `.deepEqual()`.
145
145
146
-
Any values in `selector` that are not regular objects should be deeply equal to the corresponding values in `actual`.
146
+
Any values in `selector` that are not arrays or regular objects should be deeply equal to the corresponding values in `actual`.
147
147
148
148
In the following example, the `map` property of `actual` must be deeply equal to that of `selector`. However `nested.qux` is ignored, because it's not in `selector`.
149
149
@@ -162,6 +162,12 @@ t.like({
162
162
})
163
163
```
164
164
165
+
You can also use arrays, but note that any indices in `actual` that are not in `selector` are ignored:
166
+
167
+
```js
168
+
t.like([1, 2, 3], [1, 2])
169
+
```
170
+
165
171
Finally, this returns a boolean indicating whether the assertion passed.
166
172
167
173
### `.throws(fn, expectation?, message?)`
@@ -172,7 +178,7 @@ Assert that an error is thrown. `fn` must be a function which should throw. The
172
178
173
179
*`instanceOf`: a constructor, the thrown error must be an instance of
174
180
*`is`: the thrown error must be strictly equal to `expectation.is`
175
-
*`message`: the following types are valid:
181
+
*`message`: the following types are valid:
176
182
**string* - it is compared against the thrown error's message
177
183
**regular expression* - it is matched against this message
178
184
**function* - it is passed the thrown error message and must return a boolean for whether the assertion passed
@@ -207,7 +213,7 @@ The thrown value *must* be an error. It is returned so you can run more assertio
207
213
208
214
*`instanceOf`: a constructor, the thrown error must be an instance of
209
215
*`is`: the thrown error must be strictly equal to `expectation.is`
210
-
*`message`: the following types are valid:
216
+
*`message`: the following types are valid:
211
217
**string* - it is compared against the thrown error's message
212
218
**regular expression* - it is matched against this message
213
219
**function* - it is passed the thrown error message and must return a boolean for whether the assertion passed
0 commit comments