diff --git a/src/matcher.ts b/src/matcher.ts index 3ca9db4..b4ac171 100644 --- a/src/matcher.ts +++ b/src/matcher.ts @@ -41,21 +41,21 @@ export function toMatchError( if (got.class !== expected.class) { diff.push( "Error class is not the same:", - this.utils.diff(got.class, expected.class) as string + this.utils.diff(expected.class, got.class) as string ); } if (got.message !== expected.message) { diff.push( "Error message is not the same:", - this.utils.diff(got.message, expected.message) as string + this.utils.diff(expected.message, got.message) as string ); } - if (!this.equals(got.publicFields, expected.publicFields)) { + if (!this.equals(expected.publicFields, got.publicFields)) { diff.push( "Error public fields is not the same:", - this.utils.diff(got.publicFields, expected.publicFields) as string + this.utils.diff(expected.publicFields, got.publicFields) as string ); } } diff --git a/test/matcher.test.ts b/test/matcher.test.ts index d075cd9..c2bf8f0 100644 --- a/test/matcher.test.ts +++ b/test/matcher.test.ts @@ -36,8 +36,8 @@ describe("matcher", () => { - Expected + Received - - [Function SpecificError2] - + [Function SpecificError]" + - [Function SpecificError] + + [Function SpecificError2]" `); }); @@ -51,8 +51,8 @@ describe("matcher", () => { - Expected + Received - - test - + test2" + - test2 + + test" `); }); @@ -67,8 +67,8 @@ describe("matcher", () => { + Received Object { - - "other": Object {}, - + "other": false, + - "other": false, + + "other": Object {}, }" `); }); @@ -99,8 +99,8 @@ describe("matcher", () => { - Expected + Received - - [Function SpecificError] - + [Function SpecificError2]" + - [Function SpecificError2] + + [Function SpecificError]" `); }); });