From a39ba693aaf335235d15624cb85a175eef5959e7 Mon Sep 17 00:00:00 2001 From: Thomas Heartman Date: Wed, 4 Jan 2023 10:04:41 +0100 Subject: [PATCH] chore: add comprehensive logging for when test fails --- src/test/e2e/api/admin/playground.e2e.test.ts | 29 ++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/src/test/e2e/api/admin/playground.e2e.test.ts b/src/test/e2e/api/admin/playground.e2e.test.ts index 38fa0a5ac8..bbc56e1e04 100644 --- a/src/test/e2e/api/admin/playground.e2e.test.ts +++ b/src/test/e2e/api/admin/playground.e2e.test.ts @@ -254,8 +254,35 @@ describe('Playground API E2E', () => { const mappedToggles = createDict(body.features); if (features.length !== body.features.length) { + const [longer, shorter] = + features.length > body.features.length + ? [features, body.features] + : [body.features, features]; + + const extraFeatures = longer.filter( + (longerFeature) => + shorter.some( + (shorterFeature) => + longerFeature.name === + shorterFeature.name, + ), + ); + ctx.log( - `I expected the number of mapped toggles (${body.features.length}) to be the same as the number of created toggles (${features.length}), but that was not the case.`, + `I expected the number of mapped toggles (${ + body.features.length + }) to be the same as the number of generated toggles (${ + features.length + }), but that was not the case. + +The mapped toggles are ${JSON.stringify(body.features)}. + +The generated toggles are ${JSON.stringify(features)}. + +The following features are in the longer list, but not in the shorter: ${JSON.stringify( + extraFeatures, + )} +`, ); return false; }