Skip to content
Permalink
Browse files

test: verify multiple init via well-known symbol

Re-`require()` the addon after clearing its cache to ensure that it is
re-initialized via the well-known symbol.

PR-URL: #19875
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
  • Loading branch information...
gabrielschulhof committed Apr 8, 2018
1 parent 0bd3da1 commit 244af7a9d528b105b3e84db2c7d1a05fa295b334
Showing with 8 additions and 1 deletion.
  1. +8 −1 test/addons/hello-world/test.js
@@ -1,6 +1,13 @@
'use strict';
const common = require('../../common');
const assert = require('assert');
const binding = require(`./build/${common.buildType}/binding`);
const bindingPath = require.resolve(`./build/${common.buildType}/binding`);
const binding = require(bindingPath);
assert.strictEqual(binding.hello(), 'world');
console.log('binding.hello() =', binding.hello());

// Test multiple loading of the same module.
delete require.cache[bindingPath];
const rebinding = require(bindingPath);
assert.strictEqual(rebinding.hello(), 'world');
assert.notStrictEqual(binding.hello, rebinding.hello);

0 comments on commit 244af7a

Please sign in to comment.
You can’t perform that action at this time.