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

120
Views
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
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!