Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

428
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda