Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

429
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda