Skip to content

[Bug]: ECMAScript Modules with multi spec can not debug #12075

@wszgrcy

Description

@wszgrcy

Version

27.3.1

Steps to reproduce

npm script: {"test": "NODE_OPTIONS="--experimental-vm-modules --inspect-brk" jest"}
launch.json

    {
      "name": "test",
      "type": "node",
      "request": "launch",
      "cwd": "${workspaceRoot}",
      "runtimeExecutable": "npm",
      "runtimeArgs": ["run-script", "test"],
      "port": 9229
    },

when spec pattern match only one(not xdescribe,is one file one describe)
I can debug one spec
when spec pattern match multi will throw error and can't debug

(node:85313) UnhandledPromiseRejectionWarning: Error: You need to run with a version of node that supports ES Modules in the VM API. See https://jestjs.io/docs/ecmascript-modules
    at invariant (/Users/chen/my-project/angular-miniprogram/node_modules/jest-runtime/build/index.js:2423:11)
    at importModuleDynamically (/Users/chen/my-project/angular-miniprogram/node_modules/jest-runtime/build/index.js:1735:11)
    at importModuleDynamicallyWrapper (internal/vm/module.js:451:21)
    at exports.importModuleDynamicallyCallback (internal/process/esm_loader.js:30:14)
    at eval (eval at <anonymous> (/Users/chen/my-project/angular-miniprogram/src/builder/util/load_esm.ts:2:33), <anonymous>:3:1)
    at /Users/chen/my-project/angular-miniprogram/src/builder/util/load_esm.ts:5:4
    at Generator.next (<anonymous>)
    at /Users/chen/my-project/angular-miniprogram/src/builder/util/load_esm.ts:8:71
    at new Promise (<anonymous>)
    at Object.<anonymous>.__awaiter (/Users/chen/my-project/angular-miniprogram/src/builder/util/load_esm.ts:4:12)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:85313) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 6)
(node:85313) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

but I add --experimental-vm-modules flag and run success on one spec one describe.

Expected behavior

multi spec file also run success

Actual behavior

only match one spec can run success

Additional context

No response

Environment

System:
    OS: macOS 11.1
    CPU: (8) x64 Intel(R) Core(TM) i5-1038NG7 CPU @ 2.00GHz
  Binaries:
    Node: 14.17.1 - ~/.nvm/versions/node/v14.17.1/bin/node
    Yarn: 1.22.10 - /usr/local/bin/yarn
    npm: 6.14.13 - ~/.nvm/versions/node/v14.17.1/bin/npm
  npmPackages:
    jest: ^27.3.1 => 27.3.1

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions