Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
  • Loading branch information
Gabriel Schulhof
Gabriel Schulhof committed Apr 8, 2018
commit 5fd931f4000eba8fd6082ee46d554c3ff14b2480
9 changes: 8 additions & 1 deletion test/addons/hello-world/test.js
Original file line number Diff line number Diff line change
@@ -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);