Frontend testing

Test types

Unit. Testing of individual components (modules) of the application. 

Integration. Testing component interaction with outer world. I/O, side-effects,  UI.

E2E/functional/UI. Testing application from the user’s perspective.

What is what?

Terms

Test structure – test organisation and syntax, nowadays it's BDD as a rule.

Assertions (assertion functions) functions that make sure that tested variables contain the expected value.

Snapshot –  stringified "picture" of rendered component, used to compare with last taken snapshot.

Mocks, spies, stubs functions-helpers allowing to track and provide the desired behavior.

Browser (browser-like) enviroment – "live" enviroment to run tests:  browser emulation, headless browser, real browser.

    Tools

  1. Test structure (Jest, Mocha, Jasmine, Cucumber)
  2. Assertions (Jest, Chai, Jasmine, Unexpected)
  3. Generate, display, and watch test results (Jest, Mocha, Jasmine, Karma)
  4. Snapshots (Jest, Ava)
  5. Mocks, spies, stubs (Jest, Sinon, Jasmine, enzyme, testdouble)
  6. Generate code coverage reports (Jest, Istanbul, Blanket)
  7. Browser (browser-like) enviroment (JSDOM, Selenium, TestCafe, Cypress)

Testing process

e2e

Integration

Unit

  • run unit + integration before commit (use husky + lint-staged)
  • run e2e before merging your feature
  • e2e are slow
  • e2e are harder to write
  • Unit + integration tests make
    sure enough as a rule

How many tests

we need?

Tips

$$$

$

Thank you!

Made with Slides.com