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?