hamjest 4.1.0 → 4.1.1
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/README.md +1 -1
- package/lib/Description.js +5 -1
- package/lib/assertThat.js +1 -1
- package/lib/matchers/IsArrayWithItem.js +2 -5
- package/package.json +1 -1
- package/test/node/assertThatSpec.js +14 -0
package/README.md
CHANGED
|
@@ -122,7 +122,7 @@ Expected: is animal with name length a number greater than <5>
|
|
|
122
122
|
## Suggestions
|
|
123
123
|
Do you have an idea how to make a matcher's error description even more readable? Does Hamjest lack a crucial matcher? (I'm sure it does...)
|
|
124
124
|
|
|
125
|
-
Just send me a message (I'm [@
|
|
125
|
+
Just send me a message (I'm [@LubaRaphael on X/Twitter](https://x.com/LubaRaphael)), open a ticket or - even better - send me a pull request.
|
|
126
126
|
|
|
127
127
|
# Browser support
|
|
128
128
|
Hamjest also runs in the browser - thanks to [browserify](http://browserify.org/).
|
package/lib/Description.js
CHANGED
package/lib/assertThat.js
CHANGED
|
@@ -27,17 +27,14 @@ function IsArrayWithItem(valueOrMatcher) {
|
|
|
27
27
|
description.append('was empty');
|
|
28
28
|
return;
|
|
29
29
|
}
|
|
30
|
-
const results = _map(actual, (value) => {
|
|
31
|
-
return matcher.matches(value);
|
|
32
|
-
});
|
|
33
30
|
|
|
34
|
-
return promiseAgnostic.describeMismatchAggregate(
|
|
31
|
+
return promiseAgnostic.describeMismatchAggregate(actual, (actualItem, index) => {
|
|
35
32
|
description.append('\n');
|
|
36
33
|
description
|
|
37
34
|
.append('item ')
|
|
38
35
|
.append(index)
|
|
39
36
|
.append(': ');
|
|
40
|
-
return description.indented(() => matcher.describeMismatch(
|
|
37
|
+
return description.indented(() => matcher.describeMismatch(actualItem, description));
|
|
41
38
|
});
|
|
42
39
|
}
|
|
43
40
|
});
|
package/package.json
CHANGED
|
@@ -114,4 +114,18 @@ describe('assertThat', () => {
|
|
|
114
114
|
|
|
115
115
|
assert.equal(expectNothingWasCalled, true);
|
|
116
116
|
});
|
|
117
|
+
|
|
118
|
+
it('should not throw when nothing is not available on expect (fix "Invalid Chai property" in vitest)', () => {
|
|
119
|
+
const chaiFake = {irrelevant: 'property'};
|
|
120
|
+
|
|
121
|
+
global.expect = () => new Proxy(chaiFake, {
|
|
122
|
+
get(target, property) {
|
|
123
|
+
if (!Object.keys(target).includes(property)) {
|
|
124
|
+
throw Error(`Invalid Chai property: ${property}`);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
__.assertThat(true, __.is(__.equalTo(true)));
|
|
130
|
+
});
|
|
117
131
|
});
|