Skip to content

Commit 244af7a

Browse files
author
Gabriel Schulhof
committed
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>
1 parent 0bd3da1 commit 244af7a

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

test/addons/hello-world/test.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
'use strict';
22
const common = require('../../common');
33
const assert = require('assert');
4-
const binding = require(`./build/${common.buildType}/binding`);
4+
const bindingPath = require.resolve(`./build/${common.buildType}/binding`);
5+
const binding = require(bindingPath);
56
assert.strictEqual(binding.hello(), 'world');
67
console.log('binding.hello() =', binding.hello());
8+
9+
// Test multiple loading of the same module.
10+
delete require.cache[bindingPath];
11+
const rebinding = require(bindingPath);
12+
assert.strictEqual(rebinding.hello(), 'world');
13+
assert.notStrictEqual(binding.hello, rebinding.hello);

0 commit comments

Comments
 (0)