From aeba505f7e791eae57e80603ad3b4ab1ab764e96 Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Sat, 1 Jun 2024 00:06:58 -0300 Subject: test: extract STATIC_VERSION from affecting tests --- test/lib/content-function.js | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'test/lib') diff --git a/test/lib/content-function.js b/test/lib/content-function.js index be76c31d..a46d18c9 100644 --- a/test/lib/content-function.js +++ b/test/lib/content-function.js @@ -17,8 +17,23 @@ import mock from './generic-mock.js'; const __dirname = path.dirname(fileURLToPath(import.meta.url)); +function cleanURLSpec(reference) { + const prepared = structuredClone(reference); + + for (const spec of Object.values(prepared)) { + if (spec.prefix) { + // Strip out STATIC_VERSION. This updates fairly regularly and we + // don't want it to affect snapshot tests. + spec.prefix = spec.prefix + .replace(/static-\d+[a-z]\d+/i, 'static'); + } + } + + return prepared; +} + export function testContentFunctions(t, message, fn) { - const urls = generateURLs(urlSpec); + const urls = generateURLs(cleanURLSpec(urlSpec)); t.test(message, async t => { let loadedContentDependencies; -- cgit 1.3.0-6-gf8a5