SlideShare a Scribd company logo
Cross browser testing with Nightwatch,
Travis and Saucelabs
Tudor Barbu
@motanelu
github.com/motanelu
http://tudorbarbu.ninja
Frontend engineer*
*The views and opinions expressed in this presentation are my own
Everybody has a testing environment. Some people are
lucky enough to have a totally separate environment to
run production in.
Unknown author
Sample app - plug and play news widget!
Fully working demo at https://github.com/motanelu/bcn-
js-news-widget
new NewsWidget({
'selector': '#widget',
'api': 'some.url',
'userId': 1
})
// news items are
// populated correctly
[
{
"id": 1,
"title": "Everybody's rich",
"url": "http://fake.news/item/1",
"excerpt": "description",
"image": "url",
"timestamp": "1492375010933"
}
…
]
Current tab is selected
Dates are formatted
Missing images are
handled
Changing the category
works
// categories are populated
// correctly
[
{
"id": 1,
"name": "Financial"
},
{
"id": 2,
"name": "Sports"
}
]
Smoke test (Wikipedia)
When the testing
environment is just right
● Popular Javascript testing framework
● Wraps around Selenium (W3C Webdriver compatible)
● Supports BDD style expectations and assertions
● Extensible via plugins
http://nightwatchjs.org
http://expressjs.com http://restify.com
● more popular
● robust
● lots of extras (not always useful)
● aimed at RESTful APIs
● less popular
● Cross-browser testing platform
● Over 800 platform / browser combinations
● Free for open source projects
● Automated testing
● Manual testing
https://saucelabs.com
$ brew cask install sauce-connect
$ export SAUCE_USERNAME="..."
$ export SAUCE_ACCESS_KEY="..."
$ sc
sauce-connect tunnel
Browser running on Saucelabs VM
GET http://127.0.0.1:9000/
Local server listening on 9000
https://travis-ci.com
● Integration server
● Out of the box support for nodejs
● Integration with Saucelabs (sauce-connect)
● Free for open source (https://travis-ci.org)
Anatomy of a test
Load the page
Load the script
Point the API to
a mocked URL
Run assertions
/^dist/.+/ - express.static
/^static/.+/ - express.static
/^mock/.+/
/mock/{test} => fixtures/{test}
Default configuration for Saucelabs
Each such object represents a platform (browser + OS) in
Saucelabs
Nightwatch configuration (paths, ...)
$ npm run test
Run a build
Configure Nightwatch
Start Express
Run the tests
Send status to Saucelabs
package.json
runner.js
express.conf.js
nightwatch.conf.js
Stop Express
nightwatch.globals.conf.js
Example test for the
header of the widget
Demo time
...what could possibly go wrong?
Testing frontends with nightwatch & saucelabs
$ npm run test:debug
$ gem install travis
$ travis encrypt SAUCE_USERNAME=... --add
$ travis encrypt SAUCE_ACCESS_KEY=... --add
language: node_js
node_js:
- '7.4'
addons:
apt:
packages:
- oracle-java8-set-default
sauce_connect: true
before_install:
- export TZ=Europe/Madrid
script:
- npm run test
env:
global:
- secure: ki4GZ/fXn...
- secure: toxLrMviA9...
.travis.yml
Caveats
● Latency between Travis / localhost and Saucelabs can lead
to false negatives
● Difference in timezone (ex: 5 minutes ago messages)
● Booting VMs can be slow - try to group your tests and
optimize the testing schedule
jobs.schibsted.com
@Schibsted_Eng
bytes.schibsted.com
We’re hiring!
Thank you
@motanelu
github.com/motanelu
http://tudorbarbu.ninja

More Related Content

PDF
Building a js widget
PDF
20160905 - BrisJS - nightwatch testing
PDF
Vuejs testing
PDF
Modern frontend development with VueJs
PPTX
Browser Automated Testing Frameworks - Nightwatch.js
PDF
Night Watch with QA
PDF
Javascript Test Automation Workshop (21.08.2014)
PDF
Nightwatch at Tilt
Building a js widget
20160905 - BrisJS - nightwatch testing
Vuejs testing
Modern frontend development with VueJs
Browser Automated Testing Frameworks - Nightwatch.js
Night Watch with QA
Javascript Test Automation Workshop (21.08.2014)
Nightwatch at Tilt

What's hot (20)

PDF
Join the darkside: Selenium testing with Nightwatch.js
PDF
Backbone.js
PPTX
How to Build SPA with Vue Router 2.0
PDF
Packing it all: JavaScript module bundling from 2000 to now
PPTX
Backbone.js
PDF
Developing large scale JavaScript applications
PDF
Instant and offline apps with Service Worker
PDF
Building and deploying React applications
PDF
Building a Startup Stack with AngularJS
PDF
Webdriver.io
PDF
Enjoy the vue.js
PDF
DrupalCon Dublin 2016 - Automated browser testing with Nightwatch.js
PPTX
Vue business first
PPT
Js unit testing
PDF
From Hacker to Programmer (w/ Webpack, Babel and React)
PDF
Service worker - Offline Web
PDF
One step in the future: CSS variables
PDF
An introduction to Vue.js
PDF
Node.js & Twitter Bootstrap Crash Course
PDF
Building scalable applications with angular js
Join the darkside: Selenium testing with Nightwatch.js
Backbone.js
How to Build SPA with Vue Router 2.0
Packing it all: JavaScript module bundling from 2000 to now
Backbone.js
Developing large scale JavaScript applications
Instant and offline apps with Service Worker
Building and deploying React applications
Building a Startup Stack with AngularJS
Webdriver.io
Enjoy the vue.js
DrupalCon Dublin 2016 - Automated browser testing with Nightwatch.js
Vue business first
Js unit testing
From Hacker to Programmer (w/ Webpack, Babel and React)
Service worker - Offline Web
One step in the future: CSS variables
An introduction to Vue.js
Node.js & Twitter Bootstrap Crash Course
Building scalable applications with angular js
Ad

Similar to Testing frontends with nightwatch & saucelabs (20)

ODP
Selenium cloud
PPTX
Testing Testing everywhere
PPTX
Selenium practical
PPTX
QA Lab in the Cloud
PDF
Cross Browser Testing using Selenium GRID
PDF
PPTX
Continuous Testing in the Cloud
PPTX
One to rule them all
PPTX
Slow, Flaky and Legacy Tests: FTFY - Our New Testing Strategy at Net-A-Porter...
PPTX
Real-Time Communication Testing Evolution with WebRTC
PPTX
Continuous Testing and New Tools for Automation - Presentation from StarWest ...
PDF
KrishnaToolComparisionPPT.pdf
PDF
Testing nightwatch, by David Torroija
PPTX
How to Perform Test Automation With Gauge & Selenium Framework
PDF
Cypress vs Selenium WebDriver: Better, Or Just Different? -- by Gil Tayar
PDF
Cross Browser Testing using Selenium GRID.pdf
PPTX
Building reliable web applications using Cypress
ODP
Mastering selenium for automated acceptance tests
PDF
Cypress vs Selenium Choosing the Best Tool for Your Automation Needs.pdf
PDF
11 Top Cross Browser Testing Tools to Know About.pdf
Selenium cloud
Testing Testing everywhere
Selenium practical
QA Lab in the Cloud
Cross Browser Testing using Selenium GRID
Continuous Testing in the Cloud
One to rule them all
Slow, Flaky and Legacy Tests: FTFY - Our New Testing Strategy at Net-A-Porter...
Real-Time Communication Testing Evolution with WebRTC
Continuous Testing and New Tools for Automation - Presentation from StarWest ...
KrishnaToolComparisionPPT.pdf
Testing nightwatch, by David Torroija
How to Perform Test Automation With Gauge & Selenium Framework
Cypress vs Selenium WebDriver: Better, Or Just Different? -- by Gil Tayar
Cross Browser Testing using Selenium GRID.pdf
Building reliable web applications using Cypress
Mastering selenium for automated acceptance tests
Cypress vs Selenium Choosing the Best Tool for Your Automation Needs.pdf
11 Top Cross Browser Testing Tools to Know About.pdf
Ad

Recently uploaded (20)

PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
PDF
iTop VPN Free 5.6.0.5262 Crack latest version 2025
PPTX
history of c programming in notes for students .pptx
PPTX
Why Generative AI is the Future of Content, Code & Creativity?
PPTX
Operating system designcfffgfgggggggvggggggggg
PPTX
Reimagine Home Health with the Power of Agentic AI​
PDF
wealthsignaloriginal-com-DS-text-... (1).pdf
PDF
Tally Prime Crack Download New Version 5.1 [2025] (License Key Free
PDF
iTop VPN 6.5.0 Crack + License Key 2025 (Premium Version)
PDF
How to Choose the Right IT Partner for Your Business in Malaysia
PDF
Nekopoi APK 2025 free lastest update
PDF
Autodesk AutoCAD Crack Free Download 2025
PDF
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
PDF
Download FL Studio Crack Latest version 2025 ?
PPTX
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
PPTX
L1 - Introduction to python Backend.pptx
PDF
Design an Analysis of Algorithms II-SECS-1021-03
PDF
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 41
PDF
Adobe Illustrator 28.6 Crack My Vision of Vector Design
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
iTop VPN Free 5.6.0.5262 Crack latest version 2025
history of c programming in notes for students .pptx
Why Generative AI is the Future of Content, Code & Creativity?
Operating system designcfffgfgggggggvggggggggg
Reimagine Home Health with the Power of Agentic AI​
wealthsignaloriginal-com-DS-text-... (1).pdf
Tally Prime Crack Download New Version 5.1 [2025] (License Key Free
iTop VPN 6.5.0 Crack + License Key 2025 (Premium Version)
How to Choose the Right IT Partner for Your Business in Malaysia
Nekopoi APK 2025 free lastest update
Autodesk AutoCAD Crack Free Download 2025
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
Download FL Studio Crack Latest version 2025 ?
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
L1 - Introduction to python Backend.pptx
Design an Analysis of Algorithms II-SECS-1021-03
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
Internet Downloader Manager (IDM) Crack 6.42 Build 41
Adobe Illustrator 28.6 Crack My Vision of Vector Design

Testing frontends with nightwatch & saucelabs

  • 1. Cross browser testing with Nightwatch, Travis and Saucelabs Tudor Barbu @motanelu github.com/motanelu http://tudorbarbu.ninja Frontend engineer* *The views and opinions expressed in this presentation are my own
  • 2. Everybody has a testing environment. Some people are lucky enough to have a totally separate environment to run production in. Unknown author
  • 3. Sample app - plug and play news widget! Fully working demo at https://github.com/motanelu/bcn- js-news-widget new NewsWidget({ 'selector': '#widget', 'api': 'some.url', 'userId': 1 })
  • 4. // news items are // populated correctly [ { "id": 1, "title": "Everybody's rich", "url": "http://fake.news/item/1", "excerpt": "description", "image": "url", "timestamp": "1492375010933" } … ] Current tab is selected Dates are formatted Missing images are handled Changing the category works // categories are populated // correctly [ { "id": 1, "name": "Financial" }, { "id": 2, "name": "Sports" } ] Smoke test (Wikipedia)
  • 6. ● Popular Javascript testing framework ● Wraps around Selenium (W3C Webdriver compatible) ● Supports BDD style expectations and assertions ● Extensible via plugins http://nightwatchjs.org
  • 7. http://expressjs.com http://restify.com ● more popular ● robust ● lots of extras (not always useful) ● aimed at RESTful APIs ● less popular
  • 8. ● Cross-browser testing platform ● Over 800 platform / browser combinations ● Free for open source projects ● Automated testing ● Manual testing https://saucelabs.com
  • 9. $ brew cask install sauce-connect $ export SAUCE_USERNAME="..." $ export SAUCE_ACCESS_KEY="..." $ sc sauce-connect tunnel Browser running on Saucelabs VM GET http://127.0.0.1:9000/ Local server listening on 9000
  • 10. https://travis-ci.com ● Integration server ● Out of the box support for nodejs ● Integration with Saucelabs (sauce-connect) ● Free for open source (https://travis-ci.org)
  • 11. Anatomy of a test
  • 12. Load the page Load the script Point the API to a mocked URL Run assertions
  • 13. /^dist/.+/ - express.static /^static/.+/ - express.static /^mock/.+/ /mock/{test} => fixtures/{test}
  • 14. Default configuration for Saucelabs Each such object represents a platform (browser + OS) in Saucelabs Nightwatch configuration (paths, ...)
  • 15. $ npm run test Run a build Configure Nightwatch Start Express Run the tests Send status to Saucelabs package.json runner.js express.conf.js nightwatch.conf.js Stop Express nightwatch.globals.conf.js
  • 16. Example test for the header of the widget
  • 17. Demo time ...what could possibly go wrong?
  • 19. $ npm run test:debug
  • 20. $ gem install travis $ travis encrypt SAUCE_USERNAME=... --add $ travis encrypt SAUCE_ACCESS_KEY=... --add language: node_js node_js: - '7.4' addons: apt: packages: - oracle-java8-set-default sauce_connect: true before_install: - export TZ=Europe/Madrid script: - npm run test env: global: - secure: ki4GZ/fXn... - secure: toxLrMviA9... .travis.yml
  • 21. Caveats ● Latency between Travis / localhost and Saucelabs can lead to false negatives ● Difference in timezone (ex: 5 minutes ago messages) ● Booting VMs can be slow - try to group your tests and optimize the testing schedule