node/test/addons/hello-world-esm/test.js
Rich Trott 981595c316 test: fix test-esm-addons
Move test-esm-addons to test/addons/hello-world-esm.

Test should now work properly on CI machines where `addons` are not
always built at the expected relative path from the es-modules tests.

Test should now work in Debug builds.

PR-URL: https://github.com/nodejs/node/pull/16174
Fixes: https://github.com/nodejs/node/issues/16155
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
2017-10-13 10:50:02 -07:00

21 lines
719 B
JavaScript

'use strict';
const common = require('../../common');
const assert = require('assert');
const { spawnSync } = require('child_process');
const { copyFileSync } = require('fs');
const { join } = require('path');
const buildDir = join(__dirname, 'build');
copyFileSync(join(buildDir, common.buildType, 'binding.node'),
join(buildDir, 'binding.node'));
const result = spawnSync(process.execPath,
['--experimental-modules', `${__dirname}/test.mjs`]);
assert.ifError(result.error);
// TODO: Uncomment this once ESM is no longer experimental.
// assert.strictEqual(result.stderr.toString().trim(), '');
assert.strictEqual(result.stdout.toString().trim(), 'binding.hello() = world');