Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

--loader=testdouble causes ERR_UNKNOWN_FILE_EXTENSION #477

Closed
6 tasks done
didiercolens opened this issue Dec 20, 2021 · 2 comments
Closed
6 tasks done

--loader=testdouble causes ERR_UNKNOWN_FILE_EXTENSION #477

didiercolens opened this issue Dec 20, 2021 · 2 comments

Comments

@didiercolens
Copy link

didiercolens commented Dec 20, 2021

Description

If I use the --loader=testdouble with mocha, I get an ERR_UNKNOWN_FILE_EXTENSION as described in nodejs/node#34049. I guess because mocha does not have an extension and testdouble tries to load it somehow?

Issue

Using any of:

  • node --loader=testdouble ./node_modules/.bin/mocha
  • NODE_OPTIONS='--loader=testdouble' ./node_modules/.bin/mocha
  • NODE_OPTIONS='--loader=testdouble' npx mocha

yields the following error:

TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension "" for /app/node_modules/mocha/bin/mocha
    at new NodeError (internal/errors.js:322:7)
    at defaultGetFormat (internal/modules/esm/get_format.js:71:15)
    at getFormat (file:///app/node_modules/quibble/lib/quibble.mjs:65:12)
    at Loader.getFormat (internal/modules/esm/loader.js:105:42)
    at Loader.getModuleJob (internal/modules/esm/loader.js:243:31)
    at async Loader.import (internal/modules/esm/loader.js:177:17)
    at async Object.loadESM (internal/process/esm_loader.js:68:5) {
  code: 'ERR_UNKNOWN_FILE_EXTENSION'
}

Environment

  • node -v output: v14.18.2
  • npm -v (or yarn --version) output: 6.14.15
  • npm ls testdouble (or yarn list testdouble) version: testdouble@3.16.3

Also tested with:

  • node -v output: v17.2.0
  • npm -v (or yarn --version) output: 8.1.4
  • npm ls testdouble (or yarn list testdouble) version: testdouble@3.16.3

Failing Test

  • cd empty folder
  • npm init
  • npm install mocha testdouble -D
  • node --loader=testdouble ./node_modules/.bin/mocha
@searls
Copy link
Member

searls commented Dec 20, 2021

Hey @giltayar is this related to your work? (I see "loader" and think of you)

@giltayar
Copy link
Collaborator

Yup, you linked to the right issue. This is a problem in Node.js, and not in testdouble. I've never had a problem because I use mocha --loader=testdouble , and that works well.

I actually did have a problem, when working on testdouble itself, because the tests there run with another testrunner that is run with just node and has no extension, and so I created a "proxy" file with a .js which does a require("./node_modules/.bin/mocha") and ran that instead of mocha: https://github.com/testdouble/quibble/blob/dd2b78f21d0aac3ccaada6f8971cf283dbd25f79/package.json#L17

@searls searls closed this as completed Dec 31, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants