September 2018
Intermediate to advanced
328 pages
9h 10m
English
Let's walk through the test file, located at /src/__tests__/main.test.js, and review the purpose of each section of code. The first section of the test file instantiates the main.wasm file and assigns the result to the local wasmInstance variable:
const fs = require('fs');const path = require('path');describe('main.wasm Tests', () => { let wasmInstance; beforeAll(async () => { const wasmPath = path.resolve(__dirname, '..', 'main.wasm'); const buffer = fs.readFileSync(wasmPath); const results = await WebAssembly.instantiate(buffer, { env: { memoryBase: 0, tableBase: 0, memory: new WebAssembly.Memory({ initial: 1024 }), table: new WebAssembly.Table({ initial: 16, element: 'anyfunc' }), abort: console.log } }); wasmInstance ...Read now
Unlock full access