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 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 [@LubaRaph on Twitter](https://twitter.com/lubaraph)), open a ticket or - even better - send me a pull request.
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/).
@@ -103,7 +103,11 @@ function Description() {
103
103
  this.useJsonForObjects = oldJsonFlag;
104
104
  }
105
105
  } else {
106
- this.append(value);
106
+ try {
107
+ this.append(value);
108
+ } catch (e) {
109
+ this.append('<' + e.stack + '>');
110
+ }
107
111
  }
108
112
  return this;
109
113
  },
package/lib/assertThat.js CHANGED
@@ -41,7 +41,7 @@ const assertThat = (...args) => {
41
41
  } else {
42
42
  if (global && global.expect) {
43
43
  const expectation = global.expect();
44
- if (expectation && expectation.nothing) {
44
+ if (expectation && 'nothing' in expectation) {
45
45
  expectation.nothing();
46
46
  }
47
47
  }
@@ -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(results, (__result, index) => {
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(actual[index], description));
37
+ return description.indented(() => matcher.describeMismatch(actualItem, description));
41
38
  });
42
39
  }
43
40
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hamjest",
3
- "version": "4.1.0",
3
+ "version": "4.1.1",
4
4
  "main": "index.js",
5
5
  "description": "A library of composable matchers for defining meaningful and readable assertions in JavaScript.",
6
6
  "homepage": "https://github.com/rluba/hamjest",
@@ -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
  });