ES-Feature-Tests icon indicating copy to clipboard operation
ES-Feature-Tests copied to clipboard

Module tests don't make sense

Open mgol opened this issue 8 years ago • 4 comments

The module tests don't make sense. They will always fail, even in environments supporting ES6 modules:

  1. import/export statements are allowed only in top-level scope so new Function('export var a = 1') will always fail.
  2. import/export are only allowed in modules, not scripts; in browsers JS code will be able to be loaded as a module via <script type="module" src="path.js"><script>, in Node it's not fully clear yet. In any case, those tests will need to be run in a different way then every other one.
  3. For import {a} from 'b' to not fail the environment needs to first be able to resolve the module 'b'.

To sum up, the tests in their current form don't really make any sense, they will always fail for multiple reasons so they should be removed.

mgol avatar Jun 01 '16 11:06 mgol

Yes I'm aware. I don't have any knowledge of how to actually test this.

getify avatar Jun 01 '16 14:06 getify

But no, I'm not going to remove them. Modules are far too important to be not tested.

getify avatar Jun 01 '16 14:06 getify

What I'm saying is that the current tests are only creating an illusion of testing; you might as well hardcode false in their results as that's what's effectively happening anyway.

Generic tests would require a standard way of loading JS code in module mode.

Michał Gołębiowski

mgol avatar Jun 01 '16 15:06 mgol

If it turns out there is no way to parse modules inside non-modules, we may load a module to set the test to true. But I think eventually the tests will probably just infer module support by checking for the system loader API. For now it's a known issue.

getify avatar Jun 01 '16 19:06 getify