Skip to content

Commit 16b3fa5

Browse files
committed
test: use relative require in SEA VFS test
Use require('./modules/math.js') instead of require('/sea/modules/math.js') in the main SEA script to verify that relative requires work from the entry point, since __filename is now set to a VFS path.
1 parent 7e5ab70 commit 16b3fa5

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

test/fixtures/sea/vfs/sea.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,15 @@ assert.ok(entries.includes('config.json'), 'Should include config.json');
3535
assert.ok(entries.includes('data'), 'Should include data directory');
3636
console.log('readdirSync tests passed, entries:', entries);
3737

38-
// Test requiring a module from SEA VFS using direct require()
39-
const mathModule = require('/sea/modules/math.js');
38+
// Test relative require from main script - __filename is /sea/sea.js so
39+
// relative paths resolve under /sea/ via module hooks
40+
const mathModule = require('./modules/math.js');
4041
assert.strictEqual(mathModule.add(2, 3), 5, 'math.add should work');
4142
assert.strictEqual(mathModule.multiply(4, 5), 20, 'math.multiply should work');
42-
console.log('direct require from VFS tests passed');
43+
console.log('relative require from main script passed');
4344

4445
// Test transitive requires: calculator.js requires ./math.js internally
45-
const calculator = require('/sea/modules/calculator.js');
46+
const calculator = require('./modules/calculator.js');
4647
assert.strictEqual(calculator.sum(10, 20), 30, 'calculator.sum should work');
4748
assert.strictEqual(calculator.product(3, 7), 21, 'calculator.product should work');
4849
console.log('transitive require from VFS tests passed');

0 commit comments

Comments
 (0)