From 21408ecb544c68dd2fc5f72e5dc7891fceab16a1 Mon Sep 17 00:00:00 2001 From: James Garbutt <43081j@users.noreply.github.com> Date: Wed, 14 May 2025 16:31:18 +0100 Subject: [PATCH] test: strip slashes in snapshots For windows, tests will fail since the output contains `$CWD\path` rather than `$CWD/path`. We can just replace all backslashes for now and make Windows happy. If we ever need to assert something contains a backslash, do a more complex solution here. --- test/utils.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/test/utils.js b/test/utils.js index bc150ef..1afa63c 100644 --- a/test/utils.js +++ b/test/utils.js @@ -106,6 +106,12 @@ function getNormalizedOutput(output, options) { // the cwd is replaced with $CWD for snapshotting purposes const { cwd } = options; output = output.replaceAll(cwd, "$CWD"); + // We do this because snapshots on windows will have backslashes, and on + // linux will have forward slashes. Since we don't care right now about + // slashes, we can replace them. + // If we ever need to assert that something contained a backslash, remove + // this and make it configurable or do it only for paths + output = output.replaceAll("\\", "/"); return output; }