SyntaxError: Unexpected token export when testing typescript code with ES2015 module imports with jest

Im struggeling to get some code I work with tested.

In all my projects I use jest for testing. it works fine as long as I have javascript files but I do work with some packages containing typescript code. The code contains dependencies with ES2015 module imports and exports and when built its bundled with webpack where the target code still contain ES2015 module exports and imports

Jest runs on node and canĀ“t handle ES2015 modules (yet) and I can not figure out how to configure either typescript babel or jest to transpile the dependency code into commonjs modules when I want to run my tests

I have spent an insane amount of time trying to figure this out so I appreciate all help I can get.

in this example I have cloned the jest example project for Typescript and modified it to contain a dependency containing ES2015 modules to illustrate the problem


  "compilerOptions": {
    "allowJs": true,
    "module": "commonjs"


    "devDependencies": {
        "@types/jest": "^23.1.1",
        "@types/node": "^10.12.3",
        "jest": "*",
        "typescript": "*",
        "ts-jest": "*"

        "dependencies": {
            "lodash-es": "^4.17.11" //has es2015 exports
          "jest": {
            "moduleFileExtensions": [
            "transform": {
              "^.+\\.(ts|tsx)$": "ts-jest"
            "globals": {
              "ts-jest": {
                "tsConfigFile": "tsconfig.json"
            "testMatch": [


import {map} from "lodash-es";
export function wrap(a: number, b: number): number {
  return map([a,b],i=>({i}));


import {wrap} from "../sum"
it('wrap ', ()=> {
  expect(wrap(1, 2)).toBe([{i:1},{i:1}]);

when running jest i get

 export { default as add } from './add.js';

SyntaxError: Unexpected token export

from a file in the dependency

any ideas on how to solve this?