2. < >About me…</ >
@Salva_bg
● PHP Programmer.
● Creator and maintainer of multiple modules in
Drupal.org (entityreference_autocomplete, viewport,
nodejs_chat…).
● Working as Freelance:
○ Drupal and Symfony.
○ Security Audits.
○ A bit of devops.
6. ● Good documentation.
● Built-in test runner for parallel or sequentially execution.
● Built-in JUnit XML reporting.
● Very intuitive to understand and extend.
● Cloud Testing provides supported.
Features
Nightwatch.js - Overview
7. ● Built-in Unit testing support, with Mocha-compatible interface.
● Node.js assertion framework used by default in nightwatch unit
tests.
● BDD-Style expect() assertions.
● Freedom to choose assertion framework of choice.
● Headless Chrome? Got that too.
● Hooks: before, beforeEach, after, afterEach, etc.
More...
Nightwatch.js - Overview
9. ● Commands.
● Page objects.
● Tests.
● Data.
● Assertions.
Core Features
Nightwatch.js - Core Features
10. ● Generic actions used across the site. Nightwatch comes with several by default:
○ .closeWindow().
○ .getCookie().
○ .getValue().
○ .useXpath().
● Custom commands can be created, too. There are 2 Types:
○ Function-style commands.
○ Class-style commands.
Commands
Nightwatch.js - Core Features
11. Function-style (commands/myCommand.js)
Nightwatch.js - Core Features
exports.command = function (someParameter, someOtherParam) {
/** .execute() allows to run App-specific JS in our test. **/
this.execute(
function(someParameter) {
return MyApplication.doSomething().result();
},
[someParameter, someOtherParam],
function(result) {
/** Optional callback to receive the result from the JS. **/
}
);
return this;
};
14. Page objects are a classic example of encapsulation - they hide the details of
the UI structure and widgetry from other components (the tests).
Martin Fowler.
Page Objects
Nightwatch.js - Core Features
28. Summary
Nightwatch.js - Advanced
● Simple CI integration (Jenkins, CircleCI, etc…).
● Clear guidelines for a clean and simple test set up.
● Flexibility to extend core artifacts with a custom library tailored for
our projects.
● Ability to talk directly to browsers. Bye bye Selenium!