testdouble / quibble

Makes it easy to replace require'd dependencies.
93 stars 26 forks source link

fix esm mocks on windows #71

Closed connorjclark closed 1 year ago

connorjclark commented 2 years ago

ref https://github.com/testdouble/testdouble.js/issues/491

Note: I am away from my windows machine so this is not yet verified. How can I configure the travis yml to run the tests on windows?

connorjclark commented 2 years ago

@searls I tried testing on windows but ran into too many issues.

TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension "" for C:\Users\cjamc\code\quibble\node_modules\teenytest\bin\teenytest
    at new NodeError (internal/errors.js:322:7)
    at defaultGetFormat (internal/modules/esm/get_format.js:71:15)
    at getFormat (file:///C:/Users/cjamc/code/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'
}

So I can't actually run the tests. Any advice on how to?

I gave it a spin with large number of tests that use testdouble, and do see some bugs still present so not ready to merge yet.


Some resources perhaps needed to reference for a proper fix.

connorjclark commented 2 years ago

Managed to get the tests to run on windows. Added a script win:test:esm. But does require one small change in a dep:

image

searls commented 2 years ago

Thanks for continuing to work on this, I appreciate it. I won't be able to review for four or five days so feel free to keep pulling at this and polishing it

searls commented 2 years ago

Hey @connorjclark, is there anything you need from me for next steps here? I'm back in town and technically own a Windows machine so I could try setting it up for win32 development if need be to verify manually

connorjclark commented 2 years ago

My plan at the moment is to first try it out on our Lighthouse unit tests on Window, but I've got a few more things to do first before I'll be able to try that. I'll comment here when I've verified it works on a big set of tests, so I'd hold off on your own verification until then.

searls commented 1 year ago

Hi @connorjclark, this was fixed in v0.6.16 thanks to @webstech's help! https://github.com/testdouble/quibble/pull/89#issuecomment-1427049176