diff --git a/Readme.md b/Readme.md index 107890e..1092693 100644 --- a/Readme.md +++ b/Readme.md @@ -8,6 +8,8 @@ A [Jest matcher](https://facebook.github.io/jest/docs/en/using-matchers.html) to verify the structure of an object, particularly useful for api integration tests +![example-gif](./example/huge-demo-gif.gif) + ## Installation ```bash diff --git a/example/huge-demo-gif.gif b/example/huge-demo-gif.gif new file mode 100644 index 0000000..19d5b3e Binary files /dev/null and b/example/huge-demo-gif.gif differ diff --git a/src/toBeTypeOf.ts b/src/toBeTypeOf.ts index 61efa4f..d6fc9cb 100644 --- a/src/toBeTypeOf.ts +++ b/src/toBeTypeOf.ts @@ -1,6 +1,5 @@ -import * as util from 'jest-matcher-utils' import * as getType from 'jest-get-type' -import { printExpected, printReceived } from 'jest-matcher-utils' +import { matcherHint, printExpected, printReceived } from 'jest-matcher-utils' import { JestResult } from './common-types' import MatcherUtils = jest.MatcherUtils @@ -17,8 +16,8 @@ export function toBeTypeOf (this: MatcherUtils, actual: T, expected: T): Jest return { message: () => pass ? '' : - util.matcherHint('.toBeTypeOf') + - '\n\n' + + `${matcherHint('.toBeTypeOf')}\n` + + `\n` + `Received:\n` + ` ${printReceived(getType(actual))}\n` + `Expected:\n` + diff --git a/src/toMatchOneOf.test.ts b/src/toMatchOneOf.test.ts index b68b9e5..eaaea92 100644 --- a/src/toMatchOneOf.test.ts +++ b/src/toMatchOneOf.test.ts @@ -1,4 +1,3 @@ -// tslint:disable:no-any import { toMatchOneOf } from './toMatchOneOf' describe('toMatchOneOf', () => { diff --git a/src/toMatchOneOf.ts b/src/toMatchOneOf.ts index 5f67abd..0b7b490 100644 --- a/src/toMatchOneOf.ts +++ b/src/toMatchOneOf.ts @@ -20,13 +20,13 @@ const successResult = { // tslint:disable-next-line:no-any export const formatError = (received: any, expectedTypes: Array, keys: Array): string => ( - util.matcherHint('.toMatchShapeOf') + - '\n\n' + + `${util.matcherHint('.toMatchShapeOf')}\n` + + `\n` + `For${(keys.length === 0) ? '' : ' received' + keys.join('')}:\n` + - ` type: ${util.printReceived(getType(received))}\n` + + ` type: ${util.RECEIVED_COLOR(getType(received))}\n` + ` value: ${util.printReceived(received)}\n` + `Expected type to be one of\n` + - ` ${util.printExpected(`[${expectedTypes.join(', ')}]`)}\n` + ` ${util.EXPECTED_COLOR(`${expectedTypes.join(', ')}`)}\n` ) export function toMatchOneOf(