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

119
Vistas
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 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