The public NPM release of Nightwatch 2.0 is here and can be installed directly with:
npm i nightwatch --save-dev
Over the past few weeks we have worked tirelessly to finalise the apis, add a few more examples, and try and smooth over any rough edges.
Important Changes
- Added a new plugin API; check out the docs for how to create a Nightwatch plugin: nightwatchjs.org/guide/extending-nightwatch/plugin-api.html
- Added support for using
nightwatch.conf.cjs
as config file for projects that use ES Modules - Upgraded
chai expect
to version 5 and added support for using regular chaibrowser.expect()
assertions; this doesn't affect the existingexpect.element()
,expect.elements()
,expect.cookie()
,expect.title()
, andexpect.url()
.- Example:
See examples/tests/shadowRootExample.js for the complete example.const infoElement = element('.info'); expect(infoElement.property('innerHTML')) .to.be.a('string') .and.to.include('validation code');
Improvements
- Added several new assertions:
- titleEquals
- titleMatches
- urlMatches
- textMatches
- textEquals
- domPropertyMatches
- attributeMatches
- valueEquals
- hasClass
- hasAttribute
- elementsCount
- Added new element commands:
- getFirstElementChild
- getNextSibling
- getPreviousSibling
- hasDescendants
- isPresent
- Added new API mouse actions:
- clickAndHold
- rightClick
- releaseMouseButton
- Added new
--devtools
CLI flag to open the Chrome Devtools automatically