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

Support nodejs experimental-modules #1651

Closed
jehon opened this issue Feb 12, 2019 · 7 comments
Closed

Support nodejs experimental-modules #1651

jehon opened this issue Feb 12, 2019 · 7 comments
Labels

Comments

@jehon
Copy link

jehon commented Feb 12, 2019

Are you creating an issue in the correct repository?

The "bug" (unwanted feature) is at jasmine.js#89.5

Expected Behavior

We should be able to use the "ecmascript" experimental modules of nodejs (https://nodejs.org/dist/latest-v11.x/docs/api/esm.html),

Current Behavior

we receive an error:

Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: /mnt/c/Users/jhn/src/kiosk/tests/server/basic-test.mjs
at Object.Module._extensions..mjs (internal/modules/cjs/loader.js:724:11)
at Module.load (internal/modules/cjs/loader.js:599:32)
at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
at Function.Module._load (internal/modules/cjs/loader.js:530:3)
at Module.require (internal/modules/cjs/loader.js:637:17)
at require (internal/modules/cjs/helpers.js:22:18)
at /mnt/c/Users/jhn/src/kiosk/node_modules/jasmine/lib/jasmine.js:89:5
at Array.forEach ()
at Jasmine.loadSpecs (/mnt/c/Users/jhn/src/kiosk/node_modules/jasmine/lib/jasmine.js:88:18)
at Jasmine.execute (/mnt/c/Users/jhn/src/kiosk/node_modules/jasmine/lib/jasmine.js:257:8)

Possible Solution

Jasmine should use "import" instead of "require" when loading esm modules. But that is not that easy, since "import" is asynchronous, while require is synchronous.

Suite that reproduces the behavior (for bugs)

  • Create a .jsm file (can be any test, even a simple one)
    launch nearly as usual:
node --experimental-modules node_modules/.bin/jasmine

Context

This is blocking to use jasmine in this new (experimental) context.

Your Environment

  • Version used: 3.3.1
  • Environment name and version (e.g. Chrome 39, node.js 5.4): nodejs v10.15.1
  • Operating System and version (desktop or mobile): ubuntu
  • Link to your project:
@jehon
Copy link
Author

jehon commented Feb 12, 2019

After looking, I think it is part of the jasmine-npm package. I opened a bug there:
jasmine/jasmine-npm#150

@jehon jehon closed this as completed Feb 13, 2019
@jehon
Copy link
Author

jehon commented Mar 8, 2019

Reopened to include the management of the stacktrace in core

@jehon jehon reopened this Mar 8, 2019
@frank-dspeed
Copy link

where is the pr?

@frank-dspeed
Copy link

#1662

@damianobarbati
Copy link

Is there any workaround actually to use jasmine with node v14.3 and ESM imports?

@drzraf
Copy link

drzraf commented Sep 15, 2020

jasmine/jasmine-npm#150 (comment) :

jasmine --require=esm

or

  "requires": [
    "esm"
  ],

@slackersoft
Copy link
Member

Closing this issues as the relevant issue on jasmine-npm has been resolved and merged into main there to be included in the next release.

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

No branches or pull requests

5 participants