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

[Bug]: use node testEnvironment but load uuid dependency by default not node-require #13215

Closed
zyf0330 opened this issue Sep 5, 2022 · 7 comments

Comments

@zyf0330
Copy link

zyf0330 commented Sep 5, 2022

Version

29.0.2

Steps to reproduce

  1. I just want to know if it is expected like [Bug]: Jest resolves browser version of modules instead of node #12770, or not

Expected behavior

I see no error.

Actual behavior

I see

Details:

    /.../project/node_modules/@atinc/chaos/node_modules/uuid/dist/esm-browser/index.js:1
    ({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,jest){export { default as v1 } from './v1.js';
                                                                                      ^^^^^^

    SyntaxError: Unexpected token 'export'

      at Runtime.createScriptFromCode (../../node_modules/jest-runner/node_modules/jest-runtime/build/index.js:1678:14)
      at Object.<anonymous> (../../node_modules/src/utilities/utilities.ts:9:1)

Additional context

related to #12770

Environment

System:
    OS: Linux 5.15 Ubuntu 22.04.1 LTS 22.04.1 LTS (Jammy Jellyfish)
    CPU: (8) x64 11th Gen Intel(R) Core(TM) i7-1165G7 @ 2.80GHz
  Binaries:
    Node: 16.17.0 - ~/.nvm/versions/node/v16.17.0/bin/node
    Yarn: 3.2.0 - ~/.nvm/versions/node/v16.17.0/bin/yarn
    npm: 8.18.0 - ~/.nvm/versions/node/v16.17.0/bin/npm
  npmPackages:
    jest: ^29.0.2 => 29.0.2
@SimenB
Copy link
Member

SimenB commented Sep 5, 2022

See uuidjs/uuid#616.

Will be fixed in uuid@9 which is expected today

@SimenB SimenB closed this as not planned Won't fix, can't repro, duplicate, stale Sep 5, 2022
@zyf0330
Copy link
Author

zyf0330 commented Sep 6, 2022

Thanks.
Due to that issue just mentions jest-environment-jsdom, so I am not sure if testEnvironment: node is affected.

@SimenB
Copy link
Member

SimenB commented Sep 6, 2022

Oh, missed you're using node env. Feel free to open a new issue with a reproduction

@zyf0330
Copy link
Author

zyf0330 commented Sep 6, 2022

Oh, missed you're using node env. Feel free to open a new issue with a reproduction

Ok, I will.

@zyf0330
Copy link
Author

zyf0330 commented Sep 6, 2022

I know why.
It's bug of jest-environment-node@27 which doesn't support node key in exports.
Though I install jest@29 which installs node_modules/jest-runner/node_modules/jest-environment-node, I install @nrwl/jest too which install jest-environment-node@27 to node_modules/jest-environment-node, and jest-runner resolves testEnvironment module path to the latter.
I think jest-runner should find environment inside its self node_modules at first.

@SimenB
Copy link
Member

SimenB commented Sep 6, 2022

If you install jest-environment-node yourself it'll be hoisted to the top

@github-actions
Copy link

github-actions bot commented Oct 7, 2022

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 Oct 7, 2022
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

2 participants