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

import.meta is not supported inside/outside of test file when using ES modules #9213

Closed
Userbit opened this issue Nov 20, 2019 · 5 comments
Closed

Comments

@Userbit
Copy link

Userbit commented Nov 20, 2019

🐛 Bug Report

When using ES Modules the import.meta variable is not supported correctly:

  • inside a test file;
  • inside an external files being imported into a test file.

Error occurs such as SyntaxError: Cannot use 'import.meta' outside a module.

To Reproduce

Steps to reproduce the behavior:

git clone https://github.com/Userbit/jest-import-meta
cd jest-import-meta/
npm install
npm test

Expected behavior

All tests should be passed successfully without any errors such as SyntaxError: Cannot use 'import.meta' outside a module

Link to repl or repo (highly encouraged)

Repo with all necessary source code and a screenshots about what happens.

envinfo

$ npx envinfo --preset jest
npx: installed 1 in 3.828s

  System:
    OS: Linux 4.15 Ubuntu 18.04.3 LTS (Bionic Beaver)
    CPU: (4) x64 Intel(R) Core(TM) i5-3210M CPU @ 2.50GHz
  Binaries:
    Node: 12.7.0 - /usr/local/bin/node
    npm: 6.10.0 - /usr/local/bin/npm
  npmPackages:
    jest: ^24.9.0 => 24.9.0
@Userbit
Copy link
Author

Userbit commented Nov 24, 2019

It seems my issue corresponds to long-lived issue #4842

@SimenB
Copy link
Member

SimenB commented Nov 24, 2019

Yeah, it'll need to wait for proper esm support

@rogeliog
Copy link
Contributor

rogeliog commented Dec 3, 2019

Should we close this in favor of #4842?

@SimenB
Copy link
Member

SimenB commented Jan 19, 2020

yeah

@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 11, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants