Skip to content
This repository has been archived by the owner on Apr 27, 2021. It is now read-only.

Module tests don't make sense #21

Open
mgol opened this issue Jun 1, 2016 · 4 comments
Open

Module tests don't make sense #21

mgol opened this issue Jun 1, 2016 · 4 comments

Comments

@mgol
Copy link

mgol commented Jun 1, 2016

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.

@getify
Copy link
Owner

getify commented Jun 1, 2016

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

@getify
Copy link
Owner

getify commented Jun 1, 2016

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

@mgol
Copy link
Author

mgol commented Jun 1, 2016

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

@getify
Copy link
Owner

getify commented Jun 1, 2016

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants