Skip to content

Migrating to Nightwatch v3

Priyansh Garg edited this page Aug 24, 2023 · 2 revisions

To migrate your existing project to Nightwatch v3:

  • Install Nightwatch v3 from NPM: npm i -D nightwatch@3
  • Remove all webdriver packages: npm un -D chromedriver geckodriver (these are now automatically handled in Nightwatch)
  • Remove any imports of the above webdriver packages from nightwatch.conf.js file. See percy/percy-nightwatch#532 for reference.

Migrating TS project to Nightwatch v3

  • Follow the above steps.
  • Remove @types/nightwatch package: npm un -D @types/nightwatch (types are now natively shipped with Nightwatch)

Breaking Changes

  • browser.element() command is now replaced with the new element API.
    (To continue using the older version of browser.element() command, set backwards_compatibility_mode to true in Nightwatch config file.)

FAQs

Types not working properly?

After following the above steps, if your types are not working as they should with Nightwatch v3, it's possible that your IDE is picking up types from someplace else (some other project you might have in the same directory as your current project, or from some cache), or not picking up the types at all. You can verify this by doing cmd/ctrl + click on any Nightwatch type and then looking at the path of the opened type declaration file.

While this is mostly fixed automatically in IDEs after some time, another way to fix this is to make the following changes to your root tsconfig.json file:

{
  "compilerOptions": {
    // other configs
    "types": ["node", "nightwatch"],
  },
  "include": ["test"] // location where your Nightwatch tests are present (setting this may/may not be required)
}

If you still face issues, please feel free to reach out to us on the #typescript channel of our Discord server, and we'd be happy to help.

See also