Skip to content

Commit 849edbf

Browse files
authored
fix(tests): adjust functional test ran by addons-linter because require(esm) is now a thing in Node 20.19+ (#3516)
1 parent f22b34a commit 849edbf

File tree

1 file changed

+6
-14
lines changed

1 file changed

+6
-14
lines changed

tests/fixtures/webext-as-library/test-require.js

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,13 @@
1-
const assert = require('assert');
2-
31
const {testModuleExports, testModuleExportedUtils} = require('./helpers.js');
42

53

64
(async () => {
7-
// Trying to require web-ext as a CommonJS module is not supported anymore
8-
// and it should be throwing the expected ERR_REQUIRE_ESM error.
9-
assert.throws(
10-
() => require('web-ext'),
11-
{
12-
name: 'Error',
13-
code: 'ERR_REQUIRE_ESM',
14-
}
15-
);
16-
17-
// But it should still be possible to import it in a CommonJS module
18-
// using a dynamic import.
5+
// Prior to Node v20.19, it was not possible to load web-ext with `require()`
6+
// but that changed in Node v20.19 according to
7+
// https://nodejs.org/en/blog/release/v20.19.0#requireesm-is-now-enabled-by-default.
8+
//
9+
// We are not going to verify that. Instead, we only verify that we can
10+
// import web-ext using a dynamic import in a CommonJS module.
1911
const {cmd, main} = await import('web-ext'); // eslint-disable-line import/no-unresolved
2012

2113
await testModuleExports({cmd, main});

0 commit comments

Comments
 (0)