Skip to content

Commit caa534d

Browse files
committed
Fixed assertEqual
1 parent fcb4c6a commit caa534d

File tree

2 files changed

+34
-28
lines changed

2 files changed

+34
-28
lines changed

src/package-lock.json

+25-25
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/packages/emmett/src/testing/assertions.ts

+9-3
Original file line numberDiff line numberDiff line change
@@ -90,16 +90,22 @@ export function assertEqual<T>(
9090
other: T | null | undefined,
9191
message?: string,
9292
): void {
93-
if (!obj || !other || obj != other)
94-
throw new AssertionError(message ?? `Objects are not equal`);
93+
if (obj !== other)
94+
throw new AssertionError(
95+
message ??
96+
`Objects are not equal:\n ${JSON.stringify(obj)}\ncompared:\n${JSON.stringify(other)}`,
97+
);
9598
}
9699

97100
export function assertNotEqual<T>(
98101
obj: T | null | undefined,
99102
other: T | null | undefined,
100103
message?: string,
101104
): void {
102-
if (obj === other) throw new AssertionError(message ?? `Objects are equal`);
105+
if (obj === other)
106+
throw new AssertionError(
107+
message ?? `Objects are equal: ${JSON.stringify(obj)}`,
108+
);
103109
}
104110

105111
export function assertIsNotNull<T extends object>(

0 commit comments

Comments
 (0)