Skip to content

Commit 3474523

Browse files
Bartek Wronaclaude
andcommitted
Fix test_environment assertion to handle ESM dynamic imports
In ESM mode (WASM_ESM_INTEGRATION), the runtime uses dynamic import() instead of require() for node modules. Update the test_environment assertion to check for 'import(' when in ESM mode, rather than always expecting 'require('. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 14fdc3b commit 3474523

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

test/test_core.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8662,7 +8662,12 @@ def test(assert_returncode=0):
86628662
js = read_file(self.output_name('test_hello_world.support'))
86638663
else:
86648664
js = read_file(self.output_name('test_hello_world'))
8665-
assert ('require(' in js) == ('node' in self.get_setting('ENVIRONMENT')), 'we should have require() calls only if node js specified'
8665+
# In ESM mode, we use dynamic import() instead of require() for node modules
8666+
if self.get_setting('WASM_ESM_INTEGRATION'):
8667+
has_node_imports = 'import(' in js
8668+
else:
8669+
has_node_imports = 'require(' in js
8670+
assert has_node_imports == ('node' in self.get_setting('ENVIRONMENT')), 'we should have node imports only if node js specified'
86668671

86678672
for engine in self.js_engines:
86688673
print(f'engine: {engine}')

0 commit comments

Comments
 (0)