Intro
Chester Rivas
Senior Front-End Developer
E: chester.rivas@gmail.com
GitHub: codebend3r

E2E Testing

E2E Testing
- Nightwatch.js
- environments (local, dev, prod)
- subset of tests (sanity tests)
- CI/CD
- Browserstack!
E2E Options
- Cucumber - https://cucumber.io/
- Cypress - https://www.cypress.io/
- WebDriver.io - https://webdriver.io/
- Nightwatch - http://nightwatchjs.org/
Why Nightwatch?
- CLI support
- tests are written in ES6
- Integrations supported for Jenkins/Circle CI/Slack
- Supports multiple browsers, not just Chrome
- Customizable assertions and PageObjects
- Supported by Browserstack (all the browsers and all the versions on multiple OSs)

Getting Setup
- Everything is installed through NPM (even the drivers)
"nightwatch": "1.0.19",
"chromedriver": "2.46.0",
"geckodriver": "1.16.2",
"selenium-server": "3.141.59",
"selenium-server-standalone-jar": "3.141.5",- Nightwatch config file
- specify test paths
- custom assertions path
- custom object aka page objects path
Examples and Running Tests
nightwatch -t $TESTS_PATH -c $CONFIG -e $BROWSER --tag $TAGInsanity Tests

Sanity Tests
- aka Smoke Screen Tests
- We define sanity tests as any feature which is mature enough to expect a constant result
- Page Objects - useful for repetitive actions:
- logging in
- clicking on a link
- redirecting to page
- liking a comment
- Slowly build up to larger more complicated tests
What is Not Sanity?
- Any tests that take you to a third-party website
- Tests which go through multiple steps and take a long time to complete
- Tests that are comprised of lots of other smaller tests
- Tests that effect production data
Page Objects and Custom Assertions
Continuous Integration

CI/CD Integration
- Jenkins
- How often do we want to test?
- What do we want to test?
- At least test on every merge into master
- Run nightly tests to ensure no third party has altered the behaviour of your website or web app
- Need to optimize build and deploy along with a short subset of E2E tests (sanity)
- As little dependencies as possible, use Browserstack

Browserstack
- Custom config file specifically for Browserstack
- Browserstack has support for all browsers on multiple versions
- You don't need to manage/update multiple drivers in your codebase if you don't want to
- Records each test so you can play it back
- Ideal for CI/CD
Best Practices
- For repetitive actions and assertions use Page Objects
- Break into small tests doing 1 or 2 actions, then chain them if needed
- Tackle low hanging fruit first
- Test on the fastest server first (PROD), then slower QA/Staging servers
- Structure all configurations based on ENV
- urls
- timeouts (tricky)
- For testing breakpoints make tests re-usable with only the window size changing

- Do not test features that are still in development
- Put yourself in the shoes of QA, what would they test and how?
- Tests should not depend on each other (put things back how you found them)
- Don't over-engineer tests, get them working first, optimize later
Outro

E2E Testing with Nightwatch
By Chester Rivas
E2E Testing with Nightwatch
- 609