Skip to content

loadJSConfigFile test failures in Node 22 and 23 #3429

Open
@Rob--W

Description

@Rob--W
  • Node 21.7.3: All tests pass
  • Node 22.16.0: Test failures:
    • provides help message on load failure due to .js ESM config file and no package
    • provides help message on load failure due to .js ESM config file and type commonjs package
  • Node 23.11.1: Test failures from 22 plus the following.
    • parses successfully .js file as CommonJS config file
    • parses .cjs file as CommonJS config file when no package type

Output of test failures with Node.js 23 and the latest version of the code:

$ nvm use 23
Now using node v23.11.1 (npm v10.9.2)

$ git clone https://github.com/mozilla/web-ext

$ cd web-ext/

$ ./node_modules/.bin/mocha tests/unit/test.config.js --grep=loadJSConfigFile


  config
    loadJSConfigFile
WARNING: config file /tmp/tmp-web-ext--2471-0mSC4xRHq80h/non-existant-config.js should be renamed to ".cjs" or ".mjs" file extension to ensure its format is not ambiguous. Config files with the ".js" file extension are deprecated and will not be loaded anymore in a future web-ext major version.
      ✔ throws an error if the config file does not exist
WARNING: config file /tmp/tmp-web-ext--2471-YOIlLugC1QNq/config.js should be renamed to ".cjs" or ".mjs" file extension to ensure its format is not ambiguous. Config files with the ".js" file extension are deprecated and will not be loaded anymore in a future web-ext major version.
      ✔ throws an error if the config file has syntax errors
WARNING: config file /tmp/tmp-web-ext--2471-yv3qc0j5gZnf/config.js should be renamed to ".cjs" or ".mjs" file extension to ensure its format is not ambiguous. Config files with the ".js" file extension are deprecated and will not be loaded anymore in a future web-ext major version.
      1) provides help message on load failure due to .js ESM config file and no package
WARNING: config file /tmp/tmp-web-ext--2471-VcSUwqWb25tE/config.js should be renamed to ".cjs" or ".mjs" file extension to ensure its format is not ambiguous. Config files with the ".js" file extension are deprecated and will not be loaded anymore in a future web-ext major version.
      ✔ provides help message on load failure due to .js CJS config file and type module package
WARNING: config file /tmp/tmp-web-ext--2471-BYmV8y5AsRCK/config-with-export.js should be renamed to ".cjs" or ".mjs" file extension to ensure its format is not ambiguous. Config files with the ".js" file extension are deprecated and will not be loaded anymore in a future web-ext major version.
      2) provides help message on load failure due to .js ESM config file and type commonjs package
      3) parses successfully .js file as CommonJS config file
      ✔ parses successfully .mjs file as ESM config file when no package type
      4) parses .cjs file as CommonJS config file when no package type
      ✔ parses package.json file correctly
WARNING: config file /tmp/tmp-web-ext--2471-Q3LwQ65bOmT1/config.js should be renamed to ".cjs" or ".mjs" file extension to ensure its format is not ambiguous. Config files with the ".js" file extension are deprecated and will not be loaded anymore in a future web-ext major version.
      ✔ does not throw an error for an empty config
      ✔ returns an empty object when webExt key is not in package.json


  7 passing (32ms)
  4 failing

  1) config
       loadJSConfigFile
         provides help message on load failure due to .js ESM config file and no package:
     AssertionError: expected promise to be rejected with 'UsageError' but it was fulfilled with { sourceDir: 'fake/dir' }
  

  2) config
       loadJSConfigFile
         provides help message on load failure due to .js ESM config file and type commonjs package:
     AssertionError: expected promise to be rejected with 'UsageError' but it was fulfilled with { __esModule: true, default: {}, …(1) }
  

  3) config
       loadJSConfigFile
         parses successfully .js file as CommonJS config file:

      AssertionError: expected { sourceDir: 'fake/dir', …(1) } to deeply equal { sourceDir: 'fake/dir' }
      + expected - actual

       {
      -  "module.exports": {
      -    "sourceDir": "fake/dir"
      -  }
         "sourceDir": "fake/dir"
       }
      
      at file:///tmp/web-ext/node_modules/chai-as-promised/lib/chai-as-promised.js:405:36
      at async file:///tmp/web-ext/tests/unit/test.config.js:1003:9

  4) config
       loadJSConfigFile
         parses .cjs file as CommonJS config file when no package type:

      AssertionError: expected { sourceDir: 'fake/dir', …(1) } to deeply equal { sourceDir: 'fake/dir' }
      + expected - actual

       {
      -  "module.exports": {
      -    "sourceDir": "fake/dir"
      -  }
         "sourceDir": "fake/dir"
       }
      
      at file:///tmp/web-ext/node_modules/chai-as-promised/lib/chai-as-promised.js:405:36
      at async file:///tmp/web-ext/tests/unit/test.config.js:1027:9

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions