Skip to content

Commit c69011e

Browse files
author
jared
committed
Improved error messages
1 parent e917194 commit c69011e

File tree

1 file changed

+17
-11
lines changed
  • testsuites/lbt-prelude/lbt-prelude-typescript/src

1 file changed

+17
-11
lines changed

testsuites/lbt-prelude/lbt-prelude-typescript/src/Json-test.ts

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -51,20 +51,26 @@ export async function fromToGoldenTest<A>(
5151
for (const [filepath, index] of foundGoldens) {
5252
const contents = await Fs.readFile(filepath, { encoding: "utf8" });
5353

54-
const fromToJson = PreludeJson.stringify(
55-
jsonDict.toJson(
56-
jsonDict.fromJson(
57-
PreludeJson.parseJson(contents),
54+
try {
55+
const fromToJson = PreludeJson.stringify(
56+
jsonDict.toJson(
57+
jsonDict.fromJson(
58+
PreludeJson.parseJson(contents),
59+
),
5860
),
59-
),
60-
);
61+
);
6162

62-
// TODO(jaredponn). This fails on the _first_ test instead of
63-
// accumulating all of them.. Perhaps we want to accumulate all of
64-
// them by e.g. wrapping this with `it`.
65-
if (contents !== fromToJson) {
63+
// TODO(jaredponn). This fails on the _first_ test instead of
64+
// accumulating all of them.. Perhaps we want to accumulate all of
65+
// them by e.g. wrapping this with `it`.
66+
if (contents !== fromToJson) {
67+
assert.fail(
68+
`Golden test failed for ${index}. Expected:\n\`${contents}\`\nbut got\n\`${fromToJson}\``,
69+
);
70+
}
71+
} catch (err) {
6672
assert.fail(
67-
`Golden test failed for ${index}. Expected:\n\`${contents}\`\nbut got\n\`${fromToJson}\``,
73+
`Golden test failed for ${index} since an error was thrown: \`${err}\`.`,
6874
);
6975
}
7076
}

0 commit comments

Comments
 (0)