From 693705ae6258a4d3376c2ac3981d972e172ece3c Mon Sep 17 00:00:00 2001 From: Andras Schmelczer Date: Tue, 8 Jul 2025 21:21:16 +0100 Subject: [PATCH] Fix tests with sync WASM loading --- reconcile-js/__mocks__/wasm.js | 9 +++++++++ reconcile-js/jest.config.js | 5 ++++- 2 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 reconcile-js/__mocks__/wasm.js diff --git a/reconcile-js/__mocks__/wasm.js b/reconcile-js/__mocks__/wasm.js new file mode 100644 index 0000000..e67f920 --- /dev/null +++ b/reconcile-js/__mocks__/wasm.js @@ -0,0 +1,9 @@ +const fs = require('fs'); +const path = require('path'); + +// Read the actual WASM file and convert to base64 for testing +const wasmPath = path.join(__dirname, '../../pkg/reconcile_bg.wasm'); +const wasmBuffer = fs.readFileSync(wasmPath); +const wasmBase64 = wasmBuffer.toString('base64'); + +module.exports = wasmBase64; diff --git a/reconcile-js/jest.config.js b/reconcile-js/jest.config.js index 8c1027e..d8542ff 100644 --- a/reconcile-js/jest.config.js +++ b/reconcile-js/jest.config.js @@ -1,3 +1,6 @@ module.exports = { - preset: "ts-jest/presets/js-with-babel-esm" + preset: 'ts-jest/presets/js-with-babel-esm', + moduleNameMapper: { + '^reconcile/reconcile_bg\\.wasm$': `/__mocks__/wasm.js`, + }, };