Skip to content

Commit

Permalink
[7.x] Do not use the idx babel plugin in the test environment… (#48118)
Browse files Browse the repository at this point in the history
When running Jest with `--coverage`, modules using idx fail with the error shown in facebook/idx#19.

Change the babel configuration so that is `NODE_ENV=test`, the idx plugin is not loaded.
  • Loading branch information
smith committed Oct 14, 2019
1 parent 8a5ad6a commit 073c864
Showing 1 changed file with 20 additions and 12 deletions.
32 changes: 20 additions & 12 deletions packages/kbn-babel-preset/common_preset.js
Expand Up @@ -17,20 +17,28 @@
* under the License.
*/

const plugins = [
require.resolve('babel-plugin-add-module-exports'),

// The class properties proposal was merged with the private fields proposal
// into the "class fields" proposal. Babel doesn't support this combined
// proposal yet, which includes private field, so this transform is
// TECHNICALLY stage 2, but for all intents and purposes it's stage 3
//
// See https://github.com/babel/proposals/issues/12 for progress
require.resolve('@babel/plugin-proposal-class-properties'),
];

module.exports = {
presets: [require.resolve('@babel/preset-typescript'), require.resolve('@babel/preset-react')],
plugins: [
require.resolve('@kbn/elastic-idx/babel'),
require.resolve('babel-plugin-add-module-exports'),

// The class properties proposal was merged with the private fields proposal
// into the "class fields" proposal. Babel doesn't support this combined
// proposal yet, which includes private field, so this transform is
// TECHNICALLY stage 2, but for all intents and purposes it's stage 3
//
// See https://github.com/babel/proposals/issues/12 for progress
require.resolve('@babel/plugin-proposal-class-properties'),
],
plugins: plugins.concat(require.resolve('@kbn/elastic-idx/babel')),
// Do not use the idx plugin in the test environment because it causes
// causes conflicts with Jest's coverage mapping.
env: {
test: {
plugins,
},
},
overrides: [
{
// Babel 7 don't support the namespace feature on typescript code.
Expand Down

0 comments on commit 073c864

Please sign in to comment.