score:13

Accepted answer

babel bridge is meant to cover any issues between 6 and 7

That is 100% not what the bridge package does. All it does is allow tools that use babel-core to pass through to @babel/core. The entire package is this single line of code.

If you are using @babel/core, you need to use plugins that work on Babel 7. That means babel-preset-react should be changed to @babel/preset-react and same for @babel/preset-env and your .babelrc should be:

{
  "presets": [
    "@babel/env",
    "@babel/react",
  ]
}

Similarly, babel-polyfill should be @babel/polyfill.

None of this is well documented yet because Babel 7 is still an unstable beta.

score:3

I met the same challenge while configuring jest to work with babel-6.

See complete explanation here

But in summary, this combination of --devDependencies worked for me, and i set-up babel-jest to transform my **.js files:

// package.json

  "devDependencies": {
    "babel-core": "6.26.0",
    "babel-jest": "21.2.0",
    "babel-loader": "7.1.2",
    "babel-preset-env": "1.6.0",
    "babel-preset-react": "6.24.1",
    "babel-preset-stage-0": "6.24.1",
    "jest": "21.2.1",
    "webpack": "3.6.0"
  },
  "jest": {
    "transform": {
      "^.+\\.jsx?$": "babel-jest"
    }
  }

// .babelrc

{
  "presets": [
    "env",
    "stage-0",
    "react"
  ]
}

score:65

{
    "presets": [
        "env",
        "react"
    ],
    "test": [
        "jest"
    ]
}

Add the last block of code for "test" to you babel.rc Here is my .babelrc code for reference

   {
    "presets": [
        "env",
        "react"
    ],
    "plugins": [
        "transform-class-properties",
        "transform-object-rest-spread"
    ],
    "test": [
        "jest"
    ]
}

Here is my output from the command-line

Test Suites: 1 passed, 1 total
Tests:       1 passed, 1 total
Snapshots:   0 total
Time:        9.264s
Ran all test suites.
Done in 12.99s.

Related Query

More Query from same tag