Custom Nightwatch.js assertions for writing tests against mssql databases
Why write tests against the database during testing?
When running NightwatchJS or browser-based selenium tests it can be useful to verify that actions done by the user or your automation on the front end correctly update the backend. This assertion library allows you to connect to an MSSQL database and write tests or checks against the database tables.
In your Nightwatch test project
npm install nightwatch-mssql-assertions --save
In your Nightwatch.js nightwatch.json configuration add or append this entry
The package looks for the database configuration inside the test_settings section of the nightwatch.json file. Add a globals section if it doesn't already exist inside one of your nested test_settings such as default for example.
Writing Nightwatch tests with SQL assertions
This first publish adds the .recordCountIs(expectedCount, tableName, whereClause--or null to return count of entire table) assertion which allows you to verify a specified row/record count against a WHERE clause you specify.