Ts-jest: Bug: updating from 20.0.4 to 20.0.6 fails tests w/ "babelHelpers is not defined"

Created on 18 Jun 2017  ·  8Comments  ·  Source: kulshekhar/ts-jest

Upgrading ts-jest from 20.0.4 to 20.0.6 ends up failing the compilation with "babelHelpers is not defined".

Links:

What happens is this:

 FAIL  test/core/either.test.ts
  ● Test suite failed to run

    ReferenceError: babelHelpers is not defined

      at src/core/errors.ts:24:37
      at Object.<anonymous> (src/core/errors.ts:47:114)
      at Object.<anonymous> (src/core/index.ts:25:10)
      at Object.<anonymous> (src/funfix.ts:24:10)
      at Object.<anonymous> (test/core/either.test.ts:20:16)
      at handle (node_modules/worker-farm/lib/child/index.js:41:8)
      at process.<anonymous> (node_modules/worker-farm/lib/child/index.js:47:3)
      at emitTwo (events.js:106:13)
      at process.emit (events.js:194:7)
      at process.nextTick (internal/child_process.js:766:12)
      at _combinedTickCallback (internal/process/next_tick.js:73:7)
      at process._tickCallback (internal/process/next_tick.js:104:9)

That error usually happens when Babel is configured to generate code with externalHelpers: true, which are then missing.

If this error happens due to Jest itself or to Babel, let me know so I can report it where it needs to be reported, however I upgraded those independently and the only upgrade that breaks my tests is ts-jest.

Thanks,

All 8 comments

I assume this is because we pick up on your external babelrc file. Can you try to remove it and see what happens?

I think someone else facing this issue was able to solve it by using --no-cache once

~@GeeWee deleting my .babelrc file did nothing, same result.~~

@kulshekhar indeed, it works with --no-cache.

Any ideas why this happens?

Actually what made it work is both deleting my .babelrc file and executing jest with --no-cache.

I must mention that it is working perfectly fine with 20.0.4, so something changed between that and 20.0.6 that breaks my build.

My .babelrc is this:

{
  "presets": [
    ["es2015-rollup"],
    ["env", {
      "targets": {
        "browsers": ["last 2 versions", "safari >= 7"],
        "node": true
      },
      "modules": false
    }]
  ],
  "comments": false
}

We started using babel by default to hoist jest.mock() calls. It seems to pick up on your .babelrc however. This is the same issue as #242
For now if you want you can use the skipBabel flag. @kulshekhar I propose we stop picking up external third party .babelrc files, I'm a little scared if this will break React Native compat however, which currently in our readme relies on a third party .babelrc

Add an ignoreBabelRC flag?

Thanks, I've added these configuration lines and it now seems to work:

"jest": {
    "globals": {
      "ts-jest": {
        "skipBabel": true
      }
    },
   // ...
}

@kulshekhar @GeeWee my vote would be to add another flag to ignore "upstream" .babelrc files. This way we don't break anyone that's working but it's a fix for cases like this. It's a short term fix and the approach should be reevaluated before v21.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

remcohaszing picture remcohaszing  ·  4Comments

GeeWee picture GeeWee  ·  4Comments

artola picture artola  ·  3Comments

AlexGellert picture AlexGellert  ·  4Comments

ahnpnl picture ahnpnl  ·  3Comments