diff --git a/src/jest.mock.js b/src/jest.mock.js index 4058f1c..07b2233 100644 --- a/src/jest.mock.js +++ b/src/jest.mock.js @@ -264,6 +264,11 @@ function jestmock(name, mocker, { override = false } = {}) { if (insideEsbuild) { // esbuild handles unwrapping just default exports for us assert(!likelyESM) // should not be reachable + const { default: defaultExport, __esModule, ...namedExports } = value // eslint-disable-line @typescript-eslint/no-unused-vars + // Don't override defaultExport, as that's processed with esbuild + // Add named exports though for further static named imports from that module + // type:module and esbuild can be combined e.g. when testing typescript packages + if (__esModule) obj.namedExports = namedExports } else if (likelyESM && isObject(value) && value.__esModule === true) { // eslint-disable-next-line @typescript-eslint/no-unused-vars const { default: defaultExport, __esModule, ...namedExports } = value