From 11d35bd0650f800d56852396abba8090b9bd1db6 Mon Sep 17 00:00:00 2001 From: Domagoj Kriskovic Date: Wed, 6 May 2026 12:48:29 +0200 Subject: [PATCH] Test that pyodide package.json version matches fetch script GitOrigin-RevId: e04ae191d2b1e5a08ba2e27518e61899d0e2d490 --- .../src/Scripts/FetchPyodidePackages.test.mjs | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 services/web/test/unit/src/Scripts/FetchPyodidePackages.test.mjs diff --git a/services/web/test/unit/src/Scripts/FetchPyodidePackages.test.mjs b/services/web/test/unit/src/Scripts/FetchPyodidePackages.test.mjs new file mode 100644 index 0000000000..d2c0fd48ae --- /dev/null +++ b/services/web/test/unit/src/Scripts/FetchPyodidePackages.test.mjs @@ -0,0 +1,32 @@ +import { readFile } from 'node:fs/promises' +import path from 'node:path' +import { fileURLToPath } from 'node:url' + +const SERVICE_WEB_DIR = path.resolve( + path.dirname(fileURLToPath(import.meta.url)), + '../../../..' +) + +describe('fetch-pyodide-packages.mjs', function () { + it('PYODIDE_VERSION matches the pyodide dependency in package.json', async function () { + const packageJson = JSON.parse( + await readFile(path.join(SERVICE_WEB_DIR, 'package.json'), 'utf8') + ) + const scriptSource = await readFile( + path.join(SERVICE_WEB_DIR, 'scripts/fetch-pyodide-packages.mjs'), + 'utf8' + ) + + const match = scriptSource.match(/PYODIDE_VERSION\s*=\s*'([^']+)'/) + expect(match, 'PYODIDE_VERSION constant not found in fetch script').to.not + .be.null + const scriptVersion = match[1] + const packageVersion = + packageJson.dependencies?.pyodide ?? packageJson.devDependencies?.pyodide + + expect(scriptVersion).to.equal( + packageVersion, + 'PYODIDE_VERSION in scripts/fetch-pyodide-packages.mjs must match the pyodide version in package.json; bump both together.' + ) + }) +})