Skip to content

Use Babel 7 in nightwatch

David edited this page Aug 30, 2019 · 1 revision

Steps to configure Babel 7 in Nightwatch

  • Install babel packages.

npm i @babel/core @babel/plugin-transform-arrow-functions @babel/preset-env @babel/register babel-plugin-add-module-exports --save-dev

  • Create .babelrc file with this json.
{
    "presets": [
      [
        "@babel/preset-env",
        {
          "modules": "commonjs",
          "targets": {
            "node": "current"
          }
        }
      ]
    ],
    "plugins": [
      "add-module-exports",
      "@babel/plugin-transform-arrow-functions"
    ]
  }
  • Add require("@babel/register")() in the top of the main nightwatch config js file or some file that you use before all the other files.

And that's it!