End-to-end testing, the easy way.
Nightwatch.js is an integrated, easy to use End-to-End testing solution for web applications and websites, written in Node.js. It uses the W3C WebDriver API to drive browsers and perform commands and assertions on DOM elements.
Simple but powerful syntax which enables you to write tests very quickly, using Javascript (Node.js) and CSS or Xpath selectors. Typescript is supported as well.
Works with BrowserStack out of the box. Other cloud testing providers, such as SauceLabs or LambdaTest are easy to add.
Fluent and easy to work with Page Object Model support to better organise elements and sections, with support for both CSS or Xpath selectors.
Flexible command and assertion framework which makes it easy to implement your own plugins and extend the built-in commands and assertions APIs.
Built-in command-line test runner which runs the tests either sequentially or in parallel, with retries and implicit waits. Also supports grouping of test suites and tags.
Manages automatically Selenium or WebDriver services (ChromeDriver, GeckoDriver, Edge, Safari) in a separate child process.
JUnit XML reporting is built-in so you can integrate your tests in your build process with systems such as Teamcity, Jenkins, CircleCI etc.
The test below opens the search engine Ecosia.org and searches for "nightwatch", then verifies if the term first result is the Nightwatch.js website.
describe('Demo test Ecosia.org', function() {
test('search for nightwatch', function(browser) {
browser
.url('https://www.ecosia.org/')
.waitForElementVisible('body')
.assert.titleContains('Ecosia')
.assert.visible('input[type=search]')
.sendKeys('input[type=search]', 'nightwatch')
.assert.visible('button[type=submit]')
.click('button[type=submit]')
.assert.textContains('.layout__content', 'Nightwatch.js')
.end();
})
});
Follow this video and run your first Nightwatch test in your selected browsers within a minute (assuming Node.js and NPM are installed)
npm init nightwatch /path/to/new-project
Follow Nightwatch.js on Twitter to reach out and stay updated to new release updates, announcements, and tutorials from our community.