lorenzofox3 / zora

Lightest, yet Fastest Javascript test runner for nodejs and browsers
MIT License
539 stars 93 forks source link

module-loader es is not treating my test files as es modules #118

Closed mellson closed 2 years ago

mellson commented 3 years ago

Is it correct that if I run pta with --module-loader es, it should treat the test files as es modules no matter the file name? My files have the .bs.js suffix because I need compatibility with other dependencies that only work with that suffix. If I manually rename the files to .mjs, it works. But it would be great if I could force pta to treat my files as es modules.

lorenzofox3 commented 3 years ago

Is it correct that if I run pta with --module-loader es, it should treat the test files as es modules no matter the file name?

Not really, it just tells pta which zora singleton it should use (cjs, esm). Your package.json should still reflect the repository set up. If your files are effectively written in ESM, you'll have then to add type=module in your package.json.

You can refer to the test/samples for more details.

mellson commented 3 years ago

Thanks for the info. My problem is that I'm using some dependencies which does not play nice with .mjs or type=module. So I "only" need a way to force the test runner to accept that my files are indeed es modules. Currently I got it working by using onchange to rename the files from .bs.js to .mjs but it feels a bit hacky.

lorenzofox3 commented 2 years ago

in favor of https://github.com/lorenzofox3/zora/issues/155