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

116
Visualizações
Jest is magically working with some wrong module import statement

I have some code that my linter thinks the import statement in it is wrong. And I think the linter is right but the problem is the code is working lol. I wonder how.

// some.test.js file   

// transactions/api not found in '../client'  eslint(import/named)
import { transactions, api } from '../client';

jest.mock('../client');

...

client.js:

// client.js

import Arweave from 'arweave';

const client = Arweave.init({
  host: 'localhost',
  port: 1984,
  protocol: 'http',
  timeout: 20000,
  logging: true,
});

// client type ==> {transactions: object, api: object, ...}

export default client;

I think jest.mock would automatically mock all the properties of a module but I'd never seen that properties of a default export be name-imported in JS. I even checked it in other files and it raised a run-time error but here it works.

Could you explain what's happening?

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