Skip to content

Releases: rluba/hamjest

v4.1.0

08 Sep 10:34
Compare
Choose a tag to compare

Added two new matchers:

  • startsWithItems(…)
  • endsWithItems(…)

Example:

__.assertThat([1, 2, 3, 4], __.startsWithItems(1, 2));
__.assertThat([1, 2, 3, 4], __.endsWithItems(4));

v4.0.1

18 Apr 09:29
Compare
Choose a tag to compare

Same as 4.0.0 but without accidentally packaging the vim tags file. 🤦‍♂️

v4.0.0: Removal of Bluebird

18 Apr 09:10
Compare
Choose a tag to compare

This release removes Bluebird as a dependency.

This is a breaking change because all promise-returning functions (like promiseThat) now return native Promise instances instead of Bluebird instances. The former lack some utility functions like .finally(), .spread(), and .nodeify().

v3.5.0: Type fixes & simpler TypeSafeMatcher / Matcher generation

05 May 11:42
Compare
Choose a tag to compare
  • Fixed a few minor errors in yesterday’s TypeScript type definitions.
  • Added constructors to Matcher and TypeSafeMatcher that allow you to specify the functions that you need to override. This lets you create custom matchers with stronger typing:
    return new __.TypeSafeMatcher({
        isExpectedType(value) {
            return _.isString(value);
        },
        matchesSafely(value: string) {
            return value === 'something';
        },
        describeTo(description: __.Description) {
            description.append('a very special string');
        },
        describeMismatchSafely(value: string, description: __.Description) {
            description.append('was ').appendValue(value).append(' instead of "something");
        },
    });

v3.4.0: Typescript type definitions

04 May 15:29
Compare
Choose a tag to compare

This release contains Typescript type definitions thanks to @webpapaya’s pull request. Much appreciated! 🙇‍♂️

v3.2.5

30 Sep 06:32
Compare
Choose a tag to compare
  • #27: "Render NaN as 'NaN'
  • lodash upgrades to fix security vulnerabilities.

v3.2.0

30 Sep 06:30
Compare
Choose a tag to compare

New matcher containsStrings(…): similar to __.allOf(__.containsString(a), __.containsString(b), …), but with simpler syntax and much better error description.

v3.1.0

21 Aug 18:25
Compare
Choose a tag to compare

v3.0.0

29 May 08:02
Compare
Choose a tag to compare

Hamjest 3.0 brings several minor breaking changes compared to Hamjest 2.x – see the list in the readme for details.

Improvements

  • Much better mismatch descriptions!
    • Support for indentation when building nested messages. Many matchers use this to better format their sub-matcher’s error descriptions.
    • Custom formatting for DOM nodes (and DOM-like objects) in mismatch descriptions to make assertion errors involving the DOM easier to read and understand.
    • hasProperty and hasProperties now have a verbose mode – enabled with __.hasProperties({…}).verbose() – that appends a description of the whole object after the mismatch description. Useful for debugging failing tests that receive totally unexpected object types.
  • New matchers
    • inRange
    • hasExactlyOneItem
  • New alias empty for isEmpty to improve grammar in some use cases:
    __.promiseThat(promisedArray, __.willBe(__.empty()))
  • Switched from Q to Bluebird for faster tests and better sugar methods.

v2.13.0

28 Oct 15:07
Compare
Choose a tag to compare

New matchers

  • returns(matcherOrValue) can be used to test the return value of getter-style functions (#10)

  • typedError(type, messageMatcherOrValue) simplifies testing that your functions throw the right errors (#14):

    __.assertThat(myFunction, __.throws(__.typedError(RangeError, 'value out of range')));

New meta-matchers

matches(value), failsToMatch(value, mismatchDescriptionMatcherOrValue) and
hasDescription(matcherOrValue) simplify testing your matchers:

__. assertThat(__.containsString('value'), __.matches('some value'));
__. assertThat(__.containsString('value'), __.hasDescription('a string containing "value"'));
__. assertThat(__.containsString('value'), __.failsToMatch('something else', 'was "something else"'));

Misc

  • Description#appendDescriptionOf(…) now supports simple values
  • TypeSafeMatcher describes type mismatches slightly differently to be consistent with instanceOf