node/test/es-module/test-esm-wasm.mjs
Geoffrey Booth a9adbb680b
doc: fix spelling of 'WebAssembly'
PR-URL: https://github.com/nodejs/node/pull/40785
Backport-PR-URL: https://github.com/nodejs/node/pull/41776
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Bradley Farias <bradley.meck@gmail.com>
Reviewed-By: Myles Borins <myles.borins@gmail.com>
Reviewed-By: Guy Bedford <guybedford@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
2022-01-31 21:46:04 -05:00

37 lines
1 KiB
JavaScript

// Flags: --experimental-wasm-modules
import '../common/index.mjs';
import { path } from '../common/fixtures.mjs';
import { add, addImported } from '../fixtures/es-modules/simple.wasm';
import { state } from '../fixtures/es-modules/wasm-dep.mjs';
import { strictEqual, ok } from 'assert';
import { spawn } from 'child_process';
strictEqual(state, 'WASM Start Executed');
strictEqual(add(10, 20), 30);
strictEqual(addImported(0), 42);
strictEqual(state, 'WASM JS Function Executed');
strictEqual(addImported(1), 43);
// Test warning message
const child = spawn(process.execPath, [
'--experimental-wasm-modules',
path('/es-modules/wasm-modules.mjs'),
]);
let stderr = '';
child.stderr.setEncoding('utf8');
child.stderr.on('data', (data) => {
stderr += data;
});
child.on('close', (code, signal) => {
strictEqual(code, 0);
strictEqual(signal, null);
ok(stderr.toString().includes(
'ExperimentalWarning: Importing WebAssembly modules is ' +
'an experimental feature. This feature could change at any time'
));
});