Nightwatch Testing Library
nightwatch-testing-library allows the use of dom-testing-library queries
in Nightwatch for end-to-end web testing.
Install
Be sure to follow the Nightwatch install & config instructions first
then just
READ THIS FIRST
At it's core, nightwatch-testing-library translates between
dom-testing-library queries and css selectors. This is due to the fact that
Nightwatch adheres to the WebDriver standards for
locator strategies. For
now, this means that the logging will have some very detailed css paths. PRs
welcome for a
custom reporter
to solve this problem 🤗.
So remember, the results from NWTL queries are WebDriver locators, not DOM nodes.
Note, in NWTL, all queries must be
awaited.
Usage
AllBy queries
The results of AllBy queries have an additional function added to them: nth
which can be used in nightwatch functions as well as in the within function of
NWTL.
Configure
You can customize the testIdAttribute using the configure function just like
dom-testing-library:
Containers
By default the queries come pre-bound to document.body, so no need to provide
a container. However, if you want to restrict your query using a container, you
can use within.