When comparing Nightwatch.js vs Cypress, the Slant community recommends Cypress for most people. In the question“What are the best Javascript end-to-end testing tools?” Cypress is ranked 1st while Nightwatch.js is ranked 2nd. The most important reason people chose Cypress is:
You can edit your test code in the browser and instantly see it run as you change the code.
Ranked in these QuestionsQuestion Ranking
Pros
Pro You don't have to choose a testing framework
Nightwatch solves the Paradox of Choice among testing frameworks such as Jasmine, Cucumber or Mocha+Chai, by including its own BDD-style assertion library, based on Chai.
Pro Includes its own testing framework / assertions library
Pro Test organization is out of the box
Supports page object model, custom commands, custom assertions, and globals.js.
Pro 3rd party integration with Cucumber
Though Cucumber is not officially supported, Nightwatch can be used with Cucumber.
Pro Web UI to develop tests quickly
You can edit your test code in the browser and instantly see it run as you change the code.
Pro Easy to record a video
It can easily record a video so you can understand what happened when a test failed in your CI.
Pro Amazing dashboard to view reports and recordings
The Cypress dashboard allows you to see every run on a great UI linked to commits and gitflow.
Pro Cross Browser testing
https://docs.cypress.io/guides/guides/cross-browser-testing.html
Chrome
Firefox
Edge
Electron
Brave
Cons
Con No official BDD-style syntax support
Con Includes its own testing framework / assertions library
Unlike WebdriverIO, which lets you use various test frameworks and assertion libraries (e.g. Jasmine, Cucumber, Mocha + Chai), Nightwatch comes with its own BDD-style interface for performing assertions, based on Chai.
Here's a simple test example:
module.exports = {
'Demo test Google' : function (browser) {
browser
.url('http://www.google.com')
.waitForElementVisible('body', 1000)
.setValue('input[type=text]', 'nightwatch')
.waitForElementVisible('button[name=btnG]', 1000)
.click('button[name=btnG]')
.pause(1000)
.assert.containsText('#main', 'Night Watch')
.end();
}
};
Con Doesn't support Safari
Con Single tab only
Does not and will not support multiple tabs or multiple simultaneous browsers.
See https://docs.cypress.io/guides/references/trade-offs.html#Permanent-trade-offs-1
Con Heavy in setup
Do not add Cypress in the main repo. Have a specific test repo for it or you will be sorry when the CI/CD flow takes 5-6 min longer every build due to installation time of Cypress.