Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

440
Views
Why is a Node/Jest runtime syntax error thrown when performing a non-declarative destructing assignment to variable(s) with global scope?

Performing a destructuring assignment on global variables anywhere in an ES6 module results in the following error being thrown when running a Jest test configured with the '--experimental-vm-modules' CLI option in VSCode:

● Test suite failed to run

SyntaxError: Invalid destructuring assignment target

  at Runtime.loadEsmModule (node_modules/jest-runtime/build/index.js:551:22)

Adding the following line after initial declaration, or within function scope results in the error.

[globalOne, globalTwo] = ["", ""];

The code executes without issue in the browser (Chrome/Safari/Firefox).

Separately, are there any Node or Jest CLI configs that would help trace line numbers that throw this type of parsing error? Tracking down the culprit was a bit too manual.

Edit:

example_module.js

var globalOne, globalTwo;
[globalOne, globalTwo] = ["", ""];

example_module.test.js

import * as example_module from './example_module.js';

Visual Studio Code | .vscode/launch.json

{
"version": "0.2.0",
"configurations": [
    {
        "name": "Debug Example",
        "type": "node",
        "cwd": "${workspaceRoot}/PROJECT/",
        "request": "launch",
        "runtimeArgs": [
            "--experimental-vm-modules",
            "--inspect-brk",
            "${workspaceRoot}/PROJECT/node_modules/.bin/jest",
            "--runInBand",
            "--testPathPattern",
            "example_module.test.js"
        ],
        "console": "integratedTerminal",
        "internalConsoleOptions": "neverOpen",
        "port": 9229
    }
]
}

Both example_module.js and example_module.test.js in '${workspaceRoot}/PROJECT/'

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!